Search in sources :

Example 21 with ResourceInterface

use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.

the class ResourceAction method checkDeleteResource.

protected String checkDeleteResource() throws Throwable {
    String resourceId = this.getResourceId();
    ResourceInterface resource = this.loadResource(resourceId);
    if (resource == null) {
        this.addActionError(this.getText("error.resource.delete.invalid"));
        return INPUT;
    }
    Map<String, List> references = this.getResourceActionHelper().getReferencingObjects(resource, this.getRequest());
    this.setReferences(references);
    if (references.size() > 0) {
        return "references";
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Example 22 with ResourceInterface

use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.

the class ExtendedResourceAction method save.

@Override
public String save() {
    try {
        if (ApsAdminSystemConstants.ADD == this.getStrutsAction()) {
            ResourceInterface resource = this.getResourceManager().addResource(this);
            this.buildEntryContentAnchorDest();
            ResourceAttributeActionHelper.joinResource(resource, this.getRequest());
        }
    } catch (Throwable t) {
        _logger.error("error in save", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Example 23 with ResourceInterface

use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.

the class ExtendedResourceFinderAction method joinResource.

/**
 * Aggiunge una risorsa ad un Attributo.
 * @return SUCCESS se รจ andato a buon fine, FAILURE in caso contrario
 */
public String joinResource() {
    try {
        String resourceId = this.getResourceId();
        ResourceInterface resource = this.getResourceManager().loadResource(resourceId);
        this.buildEntryContentAnchorDest();
        ResourceAttributeActionHelper.joinResource(resource, this.getRequest());
    } catch (Throwable t) {
        _logger.error("error in joinResource", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Example 24 with ResourceInterface

use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.

the class ApiResourceInterface method deleteResource.

/**
 * Delete a Resource. The method can be called by Entando API Engine.
 * @param properties The properties of the DELETE method call.
 * @throws Throwable Il case of error.
 */
public StringApiResponse deleteResource(Properties properties) throws Throwable {
    StringApiResponse response = null;
    try {
        String id = properties.getProperty("id");
        ResourceInterface resource = this.getResourceManager().loadResource(id);
        response = this.deleteResource(properties, resource);
    } catch (Throwable t) {
        _logger.error("Error deleting resource", t);
        // ApsSystemUtils.logThrowable(t, this, "deleteResource");
        throw new ApsSystemException("Error deleting resource", t);
    }
    return response;
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) StringApiResponse(org.entando.entando.aps.system.services.api.model.StringApiResponse)

Example 25 with ResourceInterface

use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.

the class ApiResourceInterface method deleteResource.

private StringApiResponse deleteResource(Properties properties, String expectedTypeCode) throws ApiException, Throwable {
    StringApiResponse response = null;
    try {
        String id = properties.getProperty("id");
        ResourceInterface resource = this.getResourceManager().loadResource(id);
        if (null != resource && !resource.getType().equals(expectedTypeCode)) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Invalid resource type - '" + resource.getType() + "'", Response.Status.CONFLICT);
        }
        properties.setProperty(RESOURCE_TYPE_CODE_PARAM, expectedTypeCode);
        response = this.deleteResource(properties, resource);
    } catch (ApiException ae) {
        throw ae;
    } catch (Throwable t) {
        _logger.error("Error deleting resource", t);
        // ApsSystemUtils.logThrowable(t, this, "deleteResource");
        throw new ApsSystemException("Error deleting resource", t);
    }
    return response;
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) StringApiResponse(org.entando.entando.aps.system.services.api.model.StringApiResponse) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Aggregations

ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)45 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)8 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)7 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)5 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)4 Category (com.agiletec.aps.system.services.category.Category)4 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)4 ImageResource (com.agiletec.plugins.jacms.aps.system.services.resource.model.ImageResource)4 ResourceInstance (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInstance)3 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)2 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)2 Lang (com.agiletec.aps.system.services.lang.Lang)2 UserDetails (com.agiletec.aps.system.services.user.UserDetails)2 AttachResource (com.agiletec.plugins.jacms.aps.system.services.resource.model.AttachResource)2 ResourceRecordVO (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceRecordVO)2 ArrayList (java.util.ArrayList)2 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)2 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)2 MockResourcesDAO (com.agiletec.aps.services.mock.MockResourcesDAO)1 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)1