Search in sources :

Example 1 with AbstractMultiInstanceResource

use of com.agiletec.plugins.jacms.aps.system.services.resource.model.AbstractMultiInstanceResource 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)

Aggregations

AbstractMonoInstanceResource (com.agiletec.plugins.jacms.aps.system.services.resource.model.AbstractMonoInstanceResource)1 AbstractMultiInstanceResource (com.agiletec.plugins.jacms.aps.system.services.resource.model.AbstractMultiInstanceResource)1 ResourceInstance (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInstance)1 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)1