Search in sources :

Example 1 with ServiceParameterInfo

use of org.entando.entando.aps.system.services.api.model.ServiceParameterInfo 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;
}
Also used : ServiceInfo(org.entando.entando.aps.system.services.api.model.ServiceInfo) ApiMethodParameter(org.entando.entando.aps.system.services.api.model.ApiMethodParameter) ServiceParameterInfo(org.entando.entando.aps.system.services.api.model.ServiceParameterInfo) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

ApsProperties (com.agiletec.aps.util.ApsProperties)1 ApiMethodParameter (org.entando.entando.aps.system.services.api.model.ApiMethodParameter)1 ServiceInfo (org.entando.entando.aps.system.services.api.model.ServiceInfo)1 ServiceParameterInfo (org.entando.entando.aps.system.services.api.model.ServiceParameterInfo)1