Search in sources :

Example 16 with ApsSystemException

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");
    }
}
Also used : OAuthProblemException(org.apache.oltu.oauth2.common.exception.OAuthProblemException) EntandoTokenException(org.entando.entando.web.common.exceptions.EntandoTokenException) OAuthAccessResourceRequest(org.apache.oltu.oauth2.rs.request.OAuthAccessResourceRequest) OAuthSystemException(org.apache.oltu.oauth2.common.exception.OAuthSystemException) OAuth2Token(org.entando.entando.aps.system.services.oauth2.model.OAuth2Token) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 17 with ApsSystemException

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);
    }
}
Also used : InputSource(org.xml.sax.InputSource) StringReader(java.io.StringReader) SAXParser(javax.xml.parsers.SAXParser) ResourceHandler(com.agiletec.plugins.jacms.aps.system.services.resource.parse.ResourceHandler) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 18 with ApsSystemException

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;
}
Also used : ArrayList(java.util.ArrayList) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 19 with ApsSystemException

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);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Example 20 with ApsSystemException

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;
}
Also used : ResourceRecordVO(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceRecordVO) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Aggregations

ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)452 ArrayList (java.util.ArrayList)53 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)48 RestServerError (org.entando.entando.aps.system.exception.RestServerError)39 ApsProperties (com.agiletec.aps.util.ApsProperties)26 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)23 HashMap (java.util.HashMap)23 UserDetails (com.agiletec.aps.system.services.user.UserDetails)21 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)21 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)20 Date (java.util.Date)20 StringReader (java.io.StringReader)18 IPage (com.agiletec.aps.system.services.page.IPage)17 List (java.util.List)17 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)16 File (java.io.File)16 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)16 Widget (com.agiletec.aps.system.services.page.Widget)15 IOException (java.io.IOException)15 Cache (org.springframework.cache.Cache)15