use of org.entando.entando.plugins.jacms.aps.system.services.api.model.JAXBResource in project entando-core by entando.
the class ApiResourceInterface method getResource.
public JAXBResource getResource(Properties properties) throws Throwable {
JAXBResource jaxbResource = null;
String id = properties.getProperty("id");
String resourceTypeCode = properties.getProperty(RESOURCE_TYPE_CODE_PARAM);
try {
ResourceInterface resource = this.getResourceManager().loadResource(id);
if (null == resource || !resource.getType().equalsIgnoreCase(resourceTypeCode)) {
throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Null resource by id '" + id + "'", Response.Status.CONFLICT);
}
UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
if (null == user) {
user = this.getUserManager().getGuestUser();
}
String groupName = resource.getMainGroup();
if (!Group.FREE_GROUP_NAME.equals(groupName) && !this.getAuthorizationManager().isAuthOnGroup(user, groupName)) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Required resource '" + id + "' does not allowed", Response.Status.FORBIDDEN);
}
jaxbResource = new JAXBResource(resource);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("error in getResource", t);
throw new ApsSystemException("Error into API method", t);
}
return jaxbResource;
}
Aggregations