edited after first UI impl
diff --git a/api/src/main/java/io/mifos/deposit/api/v1/client/DepositAccountManager.java b/api/src/main/java/io/mifos/deposit/api/v1/client/DepositAccountManager.java
index 516e4e2..2cc93d4 100644
--- a/api/src/main/java/io/mifos/deposit/api/v1/client/DepositAccountManager.java
+++ b/api/src/main/java/io/mifos/deposit/api/v1/client/DepositAccountManager.java
@@ -15,12 +15,17 @@
  */
 package io.mifos.deposit.api.v1.client;
 
+import io.mifos.core.api.annotation.ThrowsException;
+import io.mifos.core.api.annotation.ThrowsExceptions;
 import io.mifos.core.api.util.CustomFeignClientsConfiguration;
+import io.mifos.deposit.api.v1.definition.ActionAlreadyExistsException;
+import io.mifos.deposit.api.v1.definition.ProductDefinitionAlreadyExistsException;
 import io.mifos.deposit.api.v1.definition.domain.Action;
 import io.mifos.deposit.api.v1.definition.domain.ProductDefinition;
 import io.mifos.deposit.api.v1.definition.domain.ProductDefinitionCommand;
 import io.mifos.deposit.api.v1.instance.domain.ProductInstance;
 import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -41,6 +46,9 @@
       consumes = MediaType.APPLICATION_JSON_VALUE,
       produces = MediaType.APPLICATION_JSON_VALUE
   )
+  @ThrowsExceptions(
+      @ThrowsException(status = HttpStatus.CONFLICT, exception = ActionAlreadyExistsException.class)
+  )
   void create(@RequestBody @Valid final Action action);
 
   @RequestMapping(
@@ -57,6 +65,9 @@
       consumes = MediaType.APPLICATION_JSON_VALUE,
       produces = MediaType.APPLICATION_JSON_VALUE
   )
+  @ThrowsExceptions(
+      @ThrowsException(status = HttpStatus.CONFLICT, exception = ProductDefinitionAlreadyExistsException.class)
+  )
   void create(@RequestBody @Valid final ProductDefinition productDefinition);
 
   @RequestMapping(
diff --git a/api/src/main/java/io/mifos/deposit/api/v1/definition/ActionAlreadyExistsException.java b/api/src/main/java/io/mifos/deposit/api/v1/definition/ActionAlreadyExistsException.java
new file mode 100644
index 0000000..8d9277b
--- /dev/null
+++ b/api/src/main/java/io/mifos/deposit/api/v1/definition/ActionAlreadyExistsException.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.mifos.deposit.api.v1.definition;
+
+public class ActionAlreadyExistsException extends RuntimeException {
+}
diff --git a/api/src/main/java/io/mifos/deposit/api/v1/definition/ProductDefinitionAlreadyExistsException.java b/api/src/main/java/io/mifos/deposit/api/v1/definition/ProductDefinitionAlreadyExistsException.java
new file mode 100644
index 0000000..08f429e
--- /dev/null
+++ b/api/src/main/java/io/mifos/deposit/api/v1/definition/ProductDefinitionAlreadyExistsException.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.mifos.deposit.api.v1.definition;
+
+public class ProductDefinitionAlreadyExistsException extends RuntimeException {
+}
diff --git a/component-test/src/main/java/io/mifos/deposit/AbstractDepositAccountManagementTest.java b/component-test/src/main/java/io/mifos/deposit/AbstractDepositAccountManagementTest.java
index fa16c72..3dad546 100644
--- a/component-test/src/main/java/io/mifos/deposit/AbstractDepositAccountManagementTest.java
+++ b/component-test/src/main/java/io/mifos/deposit/AbstractDepositAccountManagementTest.java
@@ -50,7 +50,8 @@
 @RunWith(SpringRunner.class)
 @SpringBootTest(
     webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
-    classes = {AbstractDepositAccountManagementTest.TestConfiguration.class})
+    classes = {AbstractDepositAccountManagementTest.TestConfiguration.class}
+)
 public abstract class AbstractDepositAccountManagementTest {
 
   private static final String APP_NAME = "deposit-v1";
diff --git a/component-test/src/main/java/io/mifos/deposit/Fixture.java b/component-test/src/main/java/io/mifos/deposit/Fixture.java
index 21cee88..5e08d7b 100644
--- a/component-test/src/main/java/io/mifos/deposit/Fixture.java
+++ b/component-test/src/main/java/io/mifos/deposit/Fixture.java
@@ -15,6 +15,7 @@
  */
 package io.mifos.deposit;
 
+import io.mifos.deposit.api.v1.definition.domain.Action;
 import io.mifos.deposit.api.v1.definition.domain.Charge;
 import io.mifos.deposit.api.v1.definition.domain.Currency;
 import io.mifos.deposit.api.v1.definition.domain.ProductDefinition;
@@ -75,4 +76,13 @@
     return productDefinition;
   }
 
+  public static Action action() {
+    final Action action = new Action();
+    action.setIdentifier(RandomStringUtils.randomAlphanumeric(32));
+    action.setName(RandomStringUtils.randomAlphanumeric(256));
+    action.setDescription(RandomStringUtils.randomAlphanumeric(2048));
+    action.setTransactionType("ACCO");
+
+    return action;
+  }
 }
diff --git a/component-test/src/main/java/io/mifos/deposit/TestActions.java b/component-test/src/main/java/io/mifos/deposit/TestActions.java
index 4d34f83..fe3b79f 100644
--- a/component-test/src/main/java/io/mifos/deposit/TestActions.java
+++ b/component-test/src/main/java/io/mifos/deposit/TestActions.java
@@ -15,6 +15,8 @@
  */
 package io.mifos.deposit;
 
+import io.mifos.deposit.api.v1.EventConstants;
+import io.mifos.deposit.api.v1.definition.ActionAlreadyExistsException;
 import io.mifos.deposit.api.v1.definition.domain.Action;
 import org.junit.Assert;
 import org.junit.Test;
@@ -31,6 +33,25 @@
   public void shouldFetchDefaultActions() {
     final List<Action> actions = super.depositAccountManager.fetchActions();
 
-    Assert.assertEquals(5, actions.size());
+    Assert.assertTrue(actions.size() >= 5);
+  }
+
+  @Test
+  public void shouldCreateAction() throws Exception {
+    final Action action = Fixture.action();
+
+    super.depositAccountManager.create(action);
+
+    super.eventRecorder.wait(EventConstants.POST_PRODUCT_ACTION, action.getIdentifier());
+  }
+
+  @Test(expected = ActionAlreadyExistsException.class)
+  public void shouldNoCreateActionAlreadyExists() throws Exception {
+    final Action action = Fixture.action();
+    super.depositAccountManager.create(action);
+
+    super.eventRecorder.wait(EventConstants.POST_PRODUCT_ACTION, action.getIdentifier());
+
+    super.depositAccountManager.create(action);
   }
 }
diff --git a/component-test/src/main/java/io/mifos/deposit/TestProductDefinition.java b/component-test/src/main/java/io/mifos/deposit/TestProductDefinition.java
index f7011a9..b48c67b 100644
--- a/component-test/src/main/java/io/mifos/deposit/TestProductDefinition.java
+++ b/component-test/src/main/java/io/mifos/deposit/TestProductDefinition.java
@@ -16,6 +16,7 @@
 package io.mifos.deposit;
 
 import io.mifos.deposit.api.v1.EventConstants;
+import io.mifos.deposit.api.v1.definition.ProductDefinitionAlreadyExistsException;
 import io.mifos.deposit.api.v1.definition.domain.ProductDefinition;
 import io.mifos.deposit.api.v1.definition.domain.ProductDefinitionCommand;
 import org.apache.commons.lang3.RandomStringUtils;
@@ -37,6 +38,18 @@
     super.eventRecorder.wait(EventConstants.POST_PRODUCT_DEFINITION, productDefinition.getIdentifier());
   }
 
+
+  @Test(expected = ProductDefinitionAlreadyExistsException.class)
+  public void shouldNotCreateProductDefinitionAlreadyExists() throws Exception {
+    final ProductDefinition productDefinition = Fixture.productDefinition();
+
+    super.depositAccountManager.create(productDefinition);
+
+    super.eventRecorder.wait(EventConstants.POST_PRODUCT_DEFINITION, productDefinition.getIdentifier());
+
+    super.depositAccountManager.create(productDefinition);
+  }
+
   @Test
   public void shouldFindProductDefinition() throws Exception {
     final ProductDefinition productDefinition = Fixture.productDefinition();
@@ -96,4 +109,24 @@
 
     Assert.assertFalse(fetchProductDefinition.getActive());
   }
+
+  @Test
+  public void shouldAllowCommandWithNullNote() throws Exception {
+    final ProductDefinition productDefinition = Fixture.productDefinition();
+
+    super.depositAccountManager.create(productDefinition);
+
+    super.eventRecorder.wait(EventConstants.POST_PRODUCT_DEFINITION, productDefinition.getIdentifier());
+
+    final ProductDefinitionCommand productDefinitionCommand = new ProductDefinitionCommand();
+    productDefinitionCommand.setAction(ProductDefinitionCommand.Action.DEACTIVATE.name());
+
+    super.depositAccountManager.process(productDefinition.getIdentifier(), productDefinitionCommand);
+
+    super.eventRecorder.wait(EventConstants.POST_PRODUCT_DEFINITION_COMMAND, productDefinition.getIdentifier());
+
+    final ProductDefinition fetchProductDefinition = super.depositAccountManager.findProductDefinition(productDefinition.getIdentifier());
+
+    Assert.assertFalse(fetchProductDefinition.getActive());
+  }
 }
diff --git a/component-test/src/main/java/io/mifos/deposit/TestProductInstance.java b/component-test/src/main/java/io/mifos/deposit/TestProductInstance.java
index f6c6224..59454b3 100644
--- a/component-test/src/main/java/io/mifos/deposit/TestProductInstance.java
+++ b/component-test/src/main/java/io/mifos/deposit/TestProductInstance.java
@@ -41,7 +41,6 @@
     final ProductInstance productInstance = new ProductInstance();
     productInstance.setProductIdentifier(productDefinition.getIdentifier());
     productInstance.setCustomerIdentifier(customerIdentifier);
-    productInstance.setAccountIdentifier("60606");
 
     super.depositAccountManager.create(productInstance);
 
diff --git a/component-test/src/main/java/io/mifos/deposit/listener/ActionEventListener.java b/component-test/src/main/java/io/mifos/deposit/listener/ActionEventListener.java
new file mode 100644
index 0000000..20409b6
--- /dev/null
+++ b/component-test/src/main/java/io/mifos/deposit/listener/ActionEventListener.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.mifos.deposit.listener;
+
+import io.mifos.core.lang.config.TenantHeaderFilter;
+import io.mifos.core.test.listener.EventRecorder;
+import io.mifos.deposit.AbstractDepositAccountManagementTest;
+import io.mifos.deposit.api.v1.EventConstants;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.jms.annotation.JmsListener;
+import org.springframework.messaging.handler.annotation.Header;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ActionEventListener {
+
+  private final Logger logger;
+  private final EventRecorder eventRecorder;
+
+  @Autowired
+  public ActionEventListener(@Qualifier(AbstractDepositAccountManagementTest.TEST_LOGGER) final Logger logger,
+                             final EventRecorder eventRecorder) {
+    super();
+    this.logger = logger;
+    this.eventRecorder = eventRecorder;
+  }
+
+  @JmsListener(
+      destination = EventConstants.DESTINATION,
+      selector = EventConstants.SELECTOR_POST_PRODUCT_ACTION,
+      subscription = EventConstants.DESTINATION
+  )
+  public void onCreateAction(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant,
+                             final String payload) {
+    this.logger.debug("Action created.");
+    this.eventRecorder.event(tenant, EventConstants.POST_PRODUCT_ACTION, payload, String.class);
+  }
+}
diff --git a/service/src/main/java/io/mifos/deposit/service/internal/command/handler/ActionAggregate.java b/service/src/main/java/io/mifos/deposit/service/internal/command/handler/ActionAggregate.java
index 8dcde7c..f2d9dbd 100644
--- a/service/src/main/java/io/mifos/deposit/service/internal/command/handler/ActionAggregate.java
+++ b/service/src/main/java/io/mifos/deposit/service/internal/command/handler/ActionAggregate.java
@@ -48,6 +48,7 @@
   public String createAction(final CreateActionCommand createActionCommand) {
     final Action action = createActionCommand.action();
     this.actionRepository.save(ActionMapper.map(action));
+    this.logger.debug("Action {} created.", action.getIdentifier());
     return action.getIdentifier();
   }
 }
diff --git a/service/src/main/java/io/mifos/deposit/service/internal/command/handler/ProductInstanceAggregate.java b/service/src/main/java/io/mifos/deposit/service/internal/command/handler/ProductInstanceAggregate.java
index edcfbba..33743d1 100644
--- a/service/src/main/java/io/mifos/deposit/service/internal/command/handler/ProductInstanceAggregate.java
+++ b/service/src/main/java/io/mifos/deposit/service/internal/command/handler/ProductInstanceAggregate.java
@@ -27,6 +27,7 @@
 import io.mifos.deposit.service.internal.repository.ProductDefinitionRepository;
 import io.mifos.deposit.service.internal.repository.ProductInstanceEntity;
 import io.mifos.deposit.service.internal.repository.ProductInstanceRepository;
+import org.apache.commons.lang.RandomStringUtils;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -60,6 +61,10 @@
     final ProductInstanceEntity productInstanceEntity =
         ProductInstanceMapper.map(productInstance, this.productDefinitionRepository);
 
+    if (productInstance.getAccountIdentifier() == null) {
+      productInstanceEntity.setAccountIdentifier(RandomStringUtils.randomNumeric(32));
+    }
+
     productInstanceEntity.setCreatedBy(UserContextHolder.checkedGetUser());
     productInstanceEntity.setCreatedOn(LocalDateTime.now(Clock.systemUTC()));
     productInstanceEntity.setState("PENDING");
diff --git a/service/src/main/java/io/mifos/deposit/service/rest/ProductDefinitionRestController.java b/service/src/main/java/io/mifos/deposit/service/rest/ProductDefinitionRestController.java
index 3a828d8..785d4ee 100644
--- a/service/src/main/java/io/mifos/deposit/service/rest/ProductDefinitionRestController.java
+++ b/service/src/main/java/io/mifos/deposit/service/rest/ProductDefinitionRestController.java
@@ -75,8 +75,12 @@
   )
   @ResponseBody
   public ResponseEntity<Void> create(@RequestBody @Valid final ProductDefinition productDefinition) {
-    this.commandGateway.process(new CreateProductDefinitionCommand(productDefinition));
-    return ResponseEntity.accepted().build();
+    if (this.productDefinitionService.findProductDefinition(productDefinition.getIdentifier()).isPresent()) {
+      throw ServiceException.conflict("Product definition{0} already exists.", productDefinition.getIdentifier());
+    } else {
+      this.commandGateway.process(new CreateProductDefinitionCommand(productDefinition));
+      return ResponseEntity.accepted().build();
+    }
   }
 
   @Permittable(value = AcceptedTokenType.TENANT, groupId = PermittableGroupIds.DEFINITION_MANAGEMENT)
diff --git a/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql b/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
index c7ac510..530c179 100644
--- a/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
+++ b/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
@@ -108,7 +108,7 @@
   id                    BIGINT        NOT NULL AUTO_INCREMENT,
   product_definition_id BIGINT        NOT NULL,
   a_action              VARCHAR(256)  NOT NULL,
-  note                  VARCHAR(2048) NOT NULL,
+  note                  VARCHAR(2048) NULL,
   created_on            TIMESTAMP(3)  NOT NULL,
   created_by            VARCHAR(32)   NOT NULL,
   CONSTRAINT shed_commands PRIMARY KEY (id),