Improve BDATA already exists error messages
Add two different error messages for BDATA already exists error.
@@ -269,11 +269,19 @@ public class BusinessObjectDataDaoHelper
request.getBusinessObjectFormatFileType(), request.getBusinessObjectFormatVersion(), request.getPartitionValue(),
request.getSubPartitionValues(), null));
- // Throw an error if this business object data already exists and createNewVersion flag is not set.
- if (existingBusinessObjectDataEntity != null && (!Boolean.TRUE.equals(request.isCreateNewVersion()) ||
- Boolean.TRUE.equals(existingBusinessObjectDataEntity.getStatus().getPreRegistrationStatus())))
+ if (existingBusinessObjectDataEntity != null)
+ {
+ if (!Boolean.TRUE.equals(request.isCreateNewVersion()))
{
- throw new AlreadyExistsException("Unable to create business object data because it already exists.");
+ throw new AlreadyExistsException("Unable to create business object data because it already exists and a new version is not allowed.");
+ }
+ else if (Boolean.TRUE.equals(existingBusinessObjectDataEntity.getStatus().getPreRegistrationStatus()))
+ {
+ throw new AlreadyExistsException(String
+ .format("Unable to create business object data because it already exists and is still in \"%s\", which is a pre-registration status.",
+ existingBusinessObjectDataEntity.getStatus().getDescription()));
+
+ }
}
// Create a business object data entity from the request information.
@@ -449,8 +457,8 @@ public class BusinessObjectDataDaoHelper
// Make sure that business object data exists.
if (businessObjectDataEntity == null)
{
- throw new ObjectNotFoundException(
- String.format("Business object data {namespace: \"%s\", businessObjectDefinitionName: \"%s\", businessObjectFormatUsage: \"%s\", " +
+ throw new ObjectNotFoundException(String.format(
+ "Business object data {namespace: \"%s\", businessObjectDefinitionName: \"%s\", businessObjectFormatUsage: \"%s\", " +
"businessObjectFormatFileType: \"%s\", businessObjectFormatVersion: %d, businessObjectDataPartitionValue: \"%s\", " +
"businessObjectDataSubPartitionValues: \"%s\", businessObjectDataVersion: %d, businessObjectDataStatus: \"%s\"} doesn't exist.",
businessObjectDataKey.getNamespace(), businessObjectDataKey.getBusinessObjectDefinitionName(),
