use of org.entando.entando.aps.system.services.api.model.ApiService in project entando-core by entando.
the class ApiCatalogManager method updateService.
@Override
public void updateService(ApiService service) throws ApsSystemException {
try {
if (null == service) {
throw new ApsSystemException("Null api service to update");
}
ApiService masterService = this.getServiceCacheWrapper().getMasterServices().get(service.getKey());
if (null == masterService) {
throw new ApsSystemException("Api service '" + service.getKey() + "' does not exist");
}
masterService.setActive(service.isActive());
masterService.setHidden(service.isHidden());
this.getApiCatalogDAO().updateService(masterService);
this.getServiceCacheWrapper().updateService(service);
} catch (Throwable t) {
logger.error("Error updating api service with key '{}'", service.getKey(), t);
throw new ApsSystemException("Error updating service '" + service.getKey() + "'", t);
}
}
use of org.entando.entando.aps.system.services.api.model.ApiService 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;
}
use of org.entando.entando.aps.system.services.api.model.ApiService in project entando-core by entando.
the class ApiServiceCacheWrapper method removeService.
@Override
public void removeService(String key) {
ApiService apiService = this.get(this.getCacheKeyPrefix() + key, ApiService.class);
this.manage(key, apiService, Action.DELETE);
}
use of org.entando.entando.aps.system.services.api.model.ApiService in project entando-core by entando.
the class ApiServiceCacheWrapper method initCache.
@Override
public void initCache(Map<String, ApiResource> resources, IApiCatalogDAO apiCatalogDAO) throws ApsSystemException {
try {
Cache cache = this.getCache();
this.releaseCachedObjects(cache);
List<ApiMethod> apiGETMethods = buildApiGetMethods(resources);
Map<String, ApiService> services = apiCatalogDAO.loadServices(apiGETMethods);
this.insertObjectsOnCache(cache, services);
} catch (Throwable t) {
logger.error("Error bootstrapping ApiCatalog cache", t);
throw new ApsSystemException("Error bootstrapping ApiCatalog cache", t);
}
}
use of org.entando.entando.aps.system.services.api.model.ApiService in project entando-core by entando.
the class ApiServiceFinderAction method updateAllStatusOfGroup.
public String updateAllStatusOfGroup() {
try {
if (this.getServiceGroup() == null) {
this.addActionMessage(this.getText("error.service.group.required"));
return INPUT;
}
Map<String, List<ApiSelectItem>> groups = this.getServiceFlavours();
List<ApiSelectItem> group = groups.get(this.getServiceGroup());
if (group == null) {
this.addActionMessage(this.getText("error.service.group.invalid"));
return INPUT;
}
for (int i = 0; i < group.size(); i++) {
ApiSelectItem serviceItem = group.get(i);
ApiService service = this.getApiCatalogManager().getApiService(serviceItem.getKey());
boolean activeService = (this.getRequest().getParameter(service.getKey() + "_active") != null);
boolean publicService = (this.getRequest().getParameter(service.getKey() + "_public") != null);
if (activeService != service.isActive() || publicService != !service.isHidden()) {
service.setActive(activeService);
service.setHidden(!publicService);
this.getApiCatalogManager().updateService(service);
this.addActionMessage(this.getText("message.service.status.updated", new String[] { serviceItem.getKey(), serviceItem.getValue() }));
_logger.info("Updated api service status - Service Key '{}'", serviceItem.getKey());
}
}
} catch (Throwable t) {
_logger.error("error in updateAllStatusOfGroup", t);
// ApsSystemUtils.logThrowable(t, this, "updateAllStatusOfGroup");
return FAILURE;
}
return SUCCESS;
}
Aggregations