use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiEntityTypeInterface method getEntityType.
public JAXBEntityType getEntityType(Properties properties) throws Throwable {
JAXBEntityType jaxbEntityType = null;
try {
IEntityManager manager = this.getEntityManager();
String typeCode = properties.getProperty(this.getTypeCodeParamName());
IApsEntity masterEntityType = manager.getEntityPrototype(typeCode);
if (null == masterEntityType) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, this.getTypeLabel() + " with code '" + typeCode + "' does not exist");
}
jaxbEntityType = this.createJAXBEntityType(masterEntityType);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("Error extracting entity type", t);
// ApsSystemUtils.logThrowable(t, this, "getEntityType");
throw new ApsSystemException("Error extracting entity type", t);
}
return jaxbEntityType;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiEntityTypeInterface method updateEntityType.
public StringApiResponse updateEntityType(JAXBEntityType jaxbEntityType) throws Throwable {
StringApiResponse response = new StringApiResponse();
try {
String typeCode = jaxbEntityType.getTypeCode();
IApsEntity masterUserProfileType = this.getEntityManager().getEntityPrototype(typeCode);
if (null == masterUserProfileType) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, this.getTypeLabel() + " with code '" + typeCode + "' doesn't exist");
}
Map<String, AttributeInterface> attributes = this.getEntityManager().getEntityAttributePrototypes();
IApsEntity entityTypeToUpdate = jaxbEntityType.buildEntityType(this.getEntityManager().getEntityClass(), attributes);
this.checkEntityTypeToUpdate(jaxbEntityType, entityTypeToUpdate, response);
((IEntityTypesConfigurer) this.getEntityManager()).updateEntityPrototype(entityTypeToUpdate);
response.setResult(IResponseBuilder.SUCCESS, null);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);
} catch (Throwable t) {
_logger.error("Error updating entity type", t);
// ApsSystemUtils.logThrowable(t, this, "updateEntityType");
throw new ApsSystemException("Error updating entity type", t);
}
return response;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiEntityTypeInterface method getEntityTypes.
public StringListApiResponse getEntityTypes(Properties properties) throws Throwable {
StringListApiResponse response = new StringListApiResponse();
try {
IEntityManager manager = this.getEntityManager();
Map<String, IApsEntity> prototypes = manager.getEntityPrototypes();
List<String> codes = new ArrayList<String>();
codes.addAll(prototypes.keySet());
Collections.sort(codes);
response.setResult(codes, null);
} catch (Throwable t) {
_logger.error("Error extracting entity type codes", t);
// ApsSystemUtils.logThrowable(t, this, "getEntityTypes");
throw new ApsSystemException("Error extracting entity type codes", t);
}
return response;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class AbstractDatabaseUtils method getType.
protected IDatabaseManager.DatabaseType getType(DataSource dataSource) throws ApsSystemException {
String typeString = null;
try {
String driverClassName = this.invokeGetMethod("getDriverClassName", dataSource);
Iterator<Object> typesIter = this.getDatabaseTypeDrivers().keySet().iterator();
while (typesIter.hasNext()) {
String typeCode = (String) typesIter.next();
List<String> driverClassNames = (List<String>) this.getDatabaseTypeDrivers().get(typeCode);
if (null != driverClassNames && driverClassNames.contains(driverClassName)) {
typeString = typeCode;
break;
}
}
if (null == typeString) {
_logger.error("Type not recognized for Driver '{}' - Recognized types '{}'", driverClassName, IDatabaseManager.DatabaseType.values());
return IDatabaseManager.DatabaseType.UNKNOWN;
}
return Enum.valueOf(IDatabaseManager.DatabaseType.class, typeString.toUpperCase());
} catch (Throwable t) {
_logger.error("Invalid type for db - '{}' - ", typeString, t);
throw new ApsSystemException("Invalid type for db - '" + typeString + "'", t);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ComponentManager method loadComponents.
protected void loadComponents() throws ApsSystemException {
try {
ComponentLoader loader = new ComponentLoader(this.getLocationPatterns(), this.getPostProcessClasses());
Map<String, Component> componentMap = loader.getComponents();
List<Component> components = new ArrayList<Component>();
components.addAll(componentMap.values());
List<Component> orderedComponents = this.getOrderedComponents(components);
this.setComponents(orderedComponents);
} catch (Throwable t) {
_logger.error("Error loading components definitions", t);
throw new ApsSystemException("Error loading components definitions", t);
}
}
Aggregations