Search in sources :

Example 11 with ResourceInterface

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

the class AttachAttribute method getAttachPath.

/**
 * Restituisce il path URL dell'attachment.
 *
 * @return Il path dell'attachment.
 */
public String getAttachPath() {
    String attachPath = "";
    ResourceInterface res = this.getResource();
    if (null != res) {
        attachPath = ((AttachResource) res).getAttachPath();
        attachPath = this.appendContentReference(attachPath);
    }
    return attachPath;
}
Also used : ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Example 12 with ResourceInterface

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

the class ImageAttribute method getImagePath.

/**
 * Restituisce il path URL dell'immagine
 * relativo all'istanza specificata dal size.
 * @param size L'istanza della risorsa immagine.
 * @return Il path dell'immagine.
 */
public String getImagePath(String size) {
    String imagePath = "";
    ResourceInterface res = this.getResource();
    if (null != res) {
        imagePath = ((ImageResource) res).getImagePath(size);
        imagePath = this.appendContentReference(imagePath);
    }
    return imagePath;
}
Also used : ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Example 13 with ResourceInterface

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

the class ResourceAttributeHandler method startResource.

private void startResource(Attributes attributes, String qName) throws SAXException {
    String id = extractAttribute(attributes, "id", qName, true);
    String langCode = extractAttribute(attributes, "lang", qName, false);
    try {
        ResourceInterface resource = this.getResourceManager().loadResource(id);
        if (null != this.getCurrentAttr() && null != resource) {
            ((ResourceAttributeInterface) this.getCurrentAttr()).setResource(resource, langCode);
        }
    } catch (Exception e) {
        _logger.error("Error loading resource {}", id, e);
    }
}
Also used : ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) SAXException(org.xml.sax.SAXException)

Example 14 with ResourceInterface

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

the class LinkResolverManager method resolveLink.

@Override
public String resolveLink(SymbolicLink symbolicLink, String contentId, RequestContext reqCtx) {
    if (null == symbolicLink) {
        _logger.error("Null Symbolic Link");
        return "";
    }
    String url = null;
    try {
        if (symbolicLink.getDestType() == SymbolicLink.URL_TYPE) {
            url = symbolicLink.getUrlDest();
        } else if (symbolicLink.getDestType() == SymbolicLink.PAGE_TYPE) {
            PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
            pageUrl.setPageCode(symbolicLink.getPageDest());
            url = pageUrl.getURL();
        } else if (symbolicLink.getDestType() == SymbolicLink.CONTENT_ON_PAGE_TYPE) {
            PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
            pageUrl.setPageCode(symbolicLink.getPageDest());
            pageUrl.addParam(SystemConstants.K_CONTENT_ID_PARAM, symbolicLink.getContentDest());
            url = pageUrl.getURL();
        } else if (symbolicLink.getDestType() == SymbolicLink.CONTENT_TYPE) {
            PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
            String contentIdDest = symbolicLink.getContentDest();
            String pageCode = this.getContentPageMapperManager().getPageCode(contentIdDest);
            boolean forwardToDefaultPage = !this.isPageAllowed(reqCtx, pageCode);
            if (forwardToDefaultPage) {
                String viewPageCode = this.getContentManager().getViewPage(contentIdDest);
                pageUrl.setPageCode(viewPageCode);
                pageUrl.addParam(SystemConstants.K_CONTENT_ID_PARAM, contentIdDest);
            } else {
                pageUrl.setPageCode(pageCode);
            }
            url = pageUrl.getURL();
        } else if (symbolicLink.getDestType() == SymbolicLink.RESOURCE_TYPE) {
            ResourceInterface resource = this.getResourceManager().loadResource(symbolicLink.getResourceDest());
            if (null != resource) {
                url = resource.getDefaultUrlPath();
                if (!resource.getMainGroup().equals(Group.FREE_GROUP_NAME)) {
                    if (!url.endsWith("/")) {
                        url += "/";
                    }
                    url += AbstractResourceAttribute.REFERENCED_RESOURCE_INDICATOR + "/" + contentId + "/";
                }
            }
        }
    } catch (Throwable t) {
        _logger.error("Error resolve link from SymbolicLink", t);
        throw new RuntimeException("Error resolve link from SymbolicLink", t);
    }
    return url;
}
Also used : PageURL(com.agiletec.aps.system.services.url.PageURL) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Example 15 with ResourceInterface

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

the class TestResourceAction method testDelete.

/*
	 * NOTE: we create a fake resource using the manager rather than the most obvious 'save' action.
	 *
	 */
public void testDelete() throws Throwable {
    ResourceInterface resource = this._resourceManager.createResourceType("Image");
    String resourceId = null;
    String result = null;
    ResourceAction action = null;
    assertNotNull(resource);
    try {
        this.setUserOnSession("admin");
        resource.setMainGroup(Group.FREE_GROUP_NAME);
        resource.setDescr("Levò la bocca dal fero pasto quel peccator");
        resource.setCategories(new ArrayList<Category>());
        this._resourceManager.addResource(resource);
        resourceId = resource.getId();
        ResourceInterface verify = this._resourceManager.loadResource(resourceId);
        assertNotNull(verify);
        // test with invalid ID
        this.initAction("/do/jacms/Resource", "delete");
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        action = (ResourceAction) this.getAction();
        assertEquals(1, action.getActionErrors().size());
        // test with a valid ID
        this.initAction("/do/jacms/Resource", "delete");
        this.addParameter("resourceId", resourceId);
        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        verify = this._resourceManager.loadResource(resourceId);
        assertNull(verify);
    } catch (Throwable t) {
        throw t;
    } finally {
        this._resourceManager.deleteResource(resource);
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

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