use of org.entando.entando.aps.system.services.api.model.StringListApiResponse in project entando-core by entando.
the class ApiDataObjectModelInterface method getModels.
public StringListApiResponse getModels(Properties properties) throws ApiException, Throwable {
StringListApiResponse response = new StringListApiResponse();
try {
List<DataObjectModel> models = null;
String dataTypeParam = properties.getProperty("dataType");
String dataType = (null != dataTypeParam && dataTypeParam.trim().length() > 0) ? dataTypeParam.trim() : null;
if (null != dataType && null == this.getDataObjectManager().getSmallDataTypesMap().get(dataType)) {
ApiError error = new ApiError(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Content Type " + dataType + " does not exist", Response.Status.CONFLICT);
response.addError(error);
dataType = null;
}
if (null != dataType) {
models = this.getDataObjectModelManager().getModelsForDataObjectType(dataType);
} else {
models = this.getDataObjectModelManager().getDataObjectModels();
}
List<String> list = new ArrayList<String>();
if (null != models) {
for (int i = 0; i < models.size(); i++) {
DataObjectModel model = models.get(i);
list.add(String.valueOf(model.getId()));
}
}
response.setResult(list, null);
} catch (Throwable t) {
_logger.error("Error loading models", t);
throw new ApsSystemException("Error loading models", t);
}
return response;
}
use of org.entando.entando.aps.system.services.api.model.StringListApiResponse 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 org.entando.entando.aps.system.services.api.model.StringListApiResponse in project entando-core by entando.
the class ApiContentModelInterface method getModels.
public StringListApiResponse getModels(Properties properties) throws ApiException, Throwable {
StringListApiResponse response = new StringListApiResponse();
try {
List<ContentModel> models = null;
String contentTypeParam = properties.getProperty("contentType");
String contentType = (null != contentTypeParam && contentTypeParam.trim().length() > 0) ? contentTypeParam.trim() : null;
if (null != contentType && null == this.getContentManager().getSmallContentTypesMap().get(contentType)) {
ApiError error = new ApiError(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Content Type " + contentType + " does not exist", Response.Status.CONFLICT);
response.addError(error);
contentType = null;
}
if (null != contentType) {
models = this.getContentModelManager().getModelsForContentType(contentType);
} else {
models = this.getContentModelManager().getContentModels();
}
List<String> list = new ArrayList<String>();
if (null != models) {
for (int i = 0; i < models.size(); i++) {
ContentModel model = models.get(i);
list.add(String.valueOf(model.getId()));
}
}
response.setResult(list, null);
} catch (Throwable t) {
_logger.error("Error loading models", t);
// ApsSystemUtils.logThrowable(t, this, "getModels");
throw new ApsSystemException("Error loading models", t);
}
return response;
}
Aggregations