All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dynamicextensionsalfresco.resources.TimestampCompareStrategy Maven / Gradle / Ivy

Go to download

Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features

There is a newer version: 3.1.0
Show newest version
package com.github.dynamicextensionsalfresco.resources;

import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.util.Date;

/**
 * Compare time stamps
 *
 * @author Laurent Van der Linden
 */
public class TimestampCompareStrategy implements UpdateStrategy {
    private final static Logger logger = LoggerFactory.getLogger(TimestampCompareStrategy.class);

    private final NodeService nodeService;

    public TimestampCompareStrategy(NodeService nodeService) {
        this.nodeService = nodeService;
    }

    @Override
    public boolean updateNode(Resource resource, NodeRef nodeRef) throws IOException {
        final Date modifiedDate = (Date) nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIED);
        if (logger.isDebugEnabled()) {
            logger.debug(
                "JAR resource {} was last modified {}, the repository version is at {}",
                resource.getFilename(), new Date(resource.lastModified()), modifiedDate
            );
        }
        if (modifiedDate == null) {
            return true;
        }
        return resource.lastModified() > modifiedDate.getTime();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy