Search in sources :

Example 36 with ResourceInterface

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

the class ResourceManager method refreshMasterFileNames.

protected void refreshMasterFileNames(String resourceId) {
    try {
        ResourceInterface resource = this.loadResource(resourceId);
        if (resource.isMultiInstance()) {
            ResourceInstance instance = ((AbstractMultiInstanceResource) resource).getInstance(0, null);
            String filename = instance.getFileName();
            int index = filename.lastIndexOf("_d0.");
            String masterFileName = filename.substring(0, index) + filename.substring(index + 3);
            resource.setMasterFileName(masterFileName);
        } else {
            ResourceInstance instance = ((AbstractMonoInstanceResource) resource).getInstance();
            resource.setMasterFileName(instance.getFileName());
        }
        this.updateResource(resource);
    } catch (Throwable t) {
        logger.error("Error reloading master file name of resource {}", resourceId, t);
    }
}
Also used : ResourceInstance(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInstance) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) AbstractMultiInstanceResource(com.agiletec.plugins.jacms.aps.system.services.resource.model.AbstractMultiInstanceResource) AbstractMonoInstanceResource(com.agiletec.plugins.jacms.aps.system.services.resource.model.AbstractMonoInstanceResource)

Example 37 with ResourceInterface

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

the class ResourceManager method reloadCategoryReferences.

@Override
public void reloadCategoryReferences(String categoryCode) throws ApsSystemException {
    try {
        List<String> resources = this.getCategoryUtilizersForReloadReferences(categoryCode);
        logger.info("start reload category references for {} resources", resources.size());
        ReloadingCategoryReferencesThread th = null;
        Thread currentThread = Thread.currentThread();
        if (currentThread instanceof ReloadingCategoryReferencesThread) {
            th = (ReloadingCategoryReferencesThread) Thread.currentThread();
            th.setListSize(resources.size());
        }
        if (null != resources && !resources.isEmpty()) {
            Iterator<String> it = resources.iterator();
            while (it.hasNext()) {
                String code = it.next();
                ResourceInterface resource = this.loadResource(code);
                this.getResourceDAO().updateResourceRelations(resource);
                if (null != th)
                    th.setListIndex(th.getListIndex() + 1);
            }
        }
    } catch (Throwable t) {
        logger.error("Error searching category utilizers : category code '{}'", categoryCode, t);
        throw new ApsSystemException("Error searching category utilizers : category code '" + categoryCode + "'", t);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) ReloadingCategoryReferencesThread(com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread) ReloadingCategoryReferencesThread(com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread)

Example 38 with ResourceInterface

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

the class AbstractResourceAttribute method getJDOMElement.

@Override
public Element getJDOMElement() {
    Element attributeElement = this.createRootElement("attribute");
    Iterator<String> langIter = this.getResources().keySet().iterator();
    while (langIter.hasNext()) {
        String currentLangCode = (String) langIter.next();
        ResourceInterface res = this.getResource(currentLangCode);
        if (null != res) {
            Element resourceElement = new Element("resource");
            resourceElement.setAttribute("resourcetype", res.getType());
            String resourceId = String.valueOf(res.getId());
            resourceElement.setAttribute("id", resourceId);
            resourceElement.setAttribute("lang", currentLangCode);
            attributeElement.addContent(resourceElement);
        }
    }
    super.addTextElements(attributeElement);
    return attributeElement;
}
Also used : Element(org.jdom.Element) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Example 39 with ResourceInterface

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

the class AbstractResourceAttribute method getReferences.

@Override
public List<CmsAttributeReference> getReferences(List<Lang> systemLangs) {
    List<CmsAttributeReference> refs = new ArrayList<>();
    for (int i = 0; i < systemLangs.size(); i++) {
        Lang lang = systemLangs.get(i);
        ResourceInterface res = this.getResource(lang.getCode());
        if (null != res) {
            CmsAttributeReference ref = new CmsAttributeReference(null, null, res.getId());
            refs.add(ref);
        }
    }
    return refs;
}
Also used : ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) CmsAttributeReference(com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference)

Example 40 with ResourceInterface

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

the class AbstractResourceAttribute method appendContentReference.

/**
 * Appende, nella stringa rappresentante l'url della risorsa interna ad un
 * entità, il riferimento al entità padre con la sintassi
 * <baseUrl>/<REFERENCED_RESOURCE_INDICATOR>/<PARENT_CONTENT_ID>/. Tale
 * operazione viene effettuata nel caso che la risorsa non sia libera.
 *
 * @param basePath Il path base della risorsa.
 * @return Il path corretto.
 */
protected String appendContentReference(String basePath) {
    ResourceInterface res = this.getResource();
    if (null == res) {
        return "";
    }
    String resourceGroup = res.getMainGroup();
    if (!Group.FREE_GROUP_NAME.equals(resourceGroup) && !this.getParentEntity().getGroups().isEmpty()) {
        if (!basePath.endsWith("/")) {
            basePath += "/";
        }
        basePath += REFERENCED_RESOURCE_INDICATOR + "/" + this.getParentEntity().getId() + "/";
    }
    return basePath;
}
Also used : 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