use of org.entando.entando.aps.system.services.api.model.ServiceInfo in project entando-core by entando.
the class ApiServiceInterface method createServiceInfo.
protected ServiceInfo createServiceInfo(ApiService service, String langCode, String defaultLangCode) {
String description = service.getDescription().getProperty(langCode);
if (null == description || description.trim().length() == 0) {
description = service.getDescription().getProperty(defaultLangCode);
}
ServiceInfo smallService = new ServiceInfo(service.getKey(), description, service.getTag());
String[] freeParameters = service.getFreeParameters();
if (null != freeParameters && freeParameters.length > 0) {
for (int i = 0; i < freeParameters.length; i++) {
String freeParameter = freeParameters[i];
ApiMethodParameter apiParameter = service.getMaster().getParameter(freeParameter);
if (null != apiParameter) {
ServiceParameterInfo spi = new ServiceParameterInfo(apiParameter);
ApsProperties serviceParameters = service.getParameters();
String defaultValue = (null != serviceParameters) ? serviceParameters.getProperty(freeParameter) : null;
if (null != defaultValue) {
spi.setDefaultValue(defaultValue);
spi.setRequired(false);
}
smallService.addParameter(spi);
}
}
}
return smallService;
}
use of org.entando.entando.aps.system.services.api.model.ServiceInfo in project entando-core by entando.
the class ServicesResponseResult method getResult.
@XmlElement(name = "services", required = false)
public ListResponse getResult() {
if (this.getMainResult() instanceof Collection) {
List<ServiceInfo> services = new ArrayList<ServiceInfo>();
services.addAll((Collection<ServiceInfo>) this.getMainResult());
ListResponse listResponse = new ListResponse(services) {
};
return listResponse;
}
return null;
}
use of org.entando.entando.aps.system.services.api.model.ServiceInfo in project entando-core by entando.
the class ApiServiceInterface method getServices.
public ArrayList<ServiceInfo> getServices(Properties properties) throws ApiException {
ArrayList<ServiceInfo> services = new ArrayList<ServiceInfo>();
try {
String defaultLangCode = this.getLangManager().getDefaultLang().getCode();
String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
String tagParamValue = properties.getProperty("tag");
// String myentandoParamValue = properties.getProperty("myentando");
// Boolean myentando = (null != myentandoParamValue && myentandoParamValue.trim().length() > 0) ? Boolean.valueOf(myentandoParamValue) : null;
langCode = (null != langCode && null != this.getLangManager().getLang(langCode)) ? langCode : defaultLangCode;
Map<String, ApiService> masterServices = this.getApiCatalogManager().getServices(tagParamValue);
Iterator<ApiService> iter = masterServices.values().iterator();
while (iter.hasNext()) {
ApiService service = (ApiService) iter.next();
if (service.isActive() && !service.isHidden() && this.checkServiceAuthorization(service, properties, false)) {
ServiceInfo smallService = this.createServiceInfo(service, langCode, defaultLangCode);
services.add(smallService);
}
}
BeanComparator comparator = new BeanComparator("description");
Collections.sort(services, comparator);
} catch (Throwable t) {
_logger.error("Error extracting services", t);
throw new ApiException(IApiErrorCodes.SERVER_ERROR, "Internal error");
}
return services;
}
Aggregations