public StringApiResponse addMessageType(JAXBMessageType jaxbMessageType) throws Throwable {
StringApiResponse response = new StringApiResponse();
try {
String typeCode = jaxbMessageType.getTypeCode();
IApsEntity masterMessageType = this.getMessageManager().getEntityPrototype(typeCode);
if (null != masterMessageType) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
"Message type with code '" + typeCode + "' already exists", Response.Status.CONFLICT);
}
if (typeCode == null || typeCode.length() != 3) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
"Invalid type code - '" + typeCode + "'", Response.Status.CONFLICT);
}
Map<String, AttributeInterface> attributes = this.getMessageManager().getEntityAttributePrototypes();
IApsEntity messageType = jaxbMessageType.buildEntityType(this.getMessageManager().getEntityClass(), attributes);
((IEntityTypesConfigurer) this.getMessageManager()).addEntityPrototype(messageType);
response.setResult(IResponseBuilder.SUCCESS, null);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);