use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class EntandoOauth2Interceptor method extractOAuthParameters.
protected void extractOAuthParameters(HttpServletRequest request, String permission) {
try {
logger.info("Permission required: {}", permission);
OAuthAccessResourceRequest requestMessage = new OAuthAccessResourceRequest(request, ParameterStyle.HEADER);
String accessToken = requestMessage.getAccessToken();
if (StringUtils.isBlank(accessToken)) {
throw new EntandoTokenException("no access token found", request, null);
}
final OAuth2Token token = oAuth2TokenManager.getApiOAuth2Token(accessToken);
this.validateToken(request, accessToken, token);
String username = token.getClientId();
this.checkAuthorization(username, permission, request);
} catch (OAuthSystemException | ApsSystemException | OAuthProblemException ex) {
logger.error("System exception {}", ex.getMessage());
throw new EntandoTokenException("error parsing OAuth parameters", request, "guest");
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ResourceManager method fillEmptyResourceFromXml.
/**
* Valorizza una risorsa prototipo con gli elementi
* dell'xml che rappresenta una risorsa specifica.
* @param resource Il prototipo di risorsa da specializzare con gli attributi dell'xml.
* @param xml L'xml della risorsa specifica.
* @throws ApsSystemException
*/
protected void fillEmptyResourceFromXml(ResourceInterface resource, String xml) throws ApsSystemException {
try {
SAXParserFactory parseFactory = SAXParserFactory.newInstance();
SAXParser parser = parseFactory.newSAXParser();
InputSource is = new InputSource(new StringReader(xml));
ResourceHandler handler = new ResourceHandler(resource, this.getCategoryManager());
parser.parse(is, handler);
} catch (Throwable t) {
logger.error("Error loading resource", t);
throw new ApsSystemException("Error loading resource", t);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ResourceManager method getGroupUtilizers.
@Override
public List<String> getGroupUtilizers(String groupName) throws ApsSystemException {
List<String> resourcesId = null;
try {
List<String> allowedGroups = new ArrayList<String>(1);
allowedGroups.add(groupName);
resourcesId = this.getResourceDAO().searchResourcesId(null, null, null, null, allowedGroups);
} catch (Throwable t) {
logger.error("Error searching group utilizers : group '{}'", groupName, t);
throw new ApsSystemException("Error searching group utilizers : group '" + groupName + "'", t);
}
return resourcesId;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ResourceManager method updateResource.
@Override
public void updateResource(ResourceDataBean bean) throws ApsSystemException {
ResourceInterface oldResource = this.loadResource(bean.getResourceId());
try {
if (null == bean.getInputStream()) {
oldResource.setDescription(bean.getDescr());
oldResource.setCategories(bean.getCategories());
this.getResourceDAO().updateResource(oldResource);
this.notifyResourceChanging(oldResource);
} else {
// this.saveResource(bean);
ResourceInterface updatedResource = this.createResource(bean);
updatedResource.saveResourceInstances(bean);
this.getResourceDAO().updateResource(updatedResource);
if (!updatedResource.getMasterFileName().equals(oldResource.getMasterFileName())) {
oldResource.deleteResourceInstances();
}
this.notifyResourceChanging(updatedResource);
}
} catch (Throwable t) {
logger.error("Error updating resource", t);
throw new ApsSystemException("Error updating resource", t);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ResourceManager method loadResource.
/**
* Restituisce la risorsa con l'id specificato.
* @param id L'identificativo della risorsa da caricare.
* @return La risorsa cercata. null se non vi รจ nessuna risorsa con l'identificativo immesso.
* @throws ApsSystemException in caso di errore.
*/
@Override
public ResourceInterface loadResource(String id) throws ApsSystemException {
ResourceInterface resource = null;
try {
ResourceRecordVO resourceVo = this.getResourceDAO().loadResourceVo(id);
if (null != resourceVo) {
resource = this.createResource(resourceVo);
resource.setMasterFileName(resourceVo.getMasterFileName());
}
} catch (Throwable t) {
logger.error("Error loading resource : id {}", id, t);
throw new ApsSystemException("Error loading resource : id " + id, t);
}
return resource;
}
Aggregations