
com.adobe.aem.formsndocuments.rnc.RnCJcrPathBuilder Maven / Gradle / Ivy
/***************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2013 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
package com.adobe.aem.formsndocuments.rnc;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import com.adobe.aem.formsndocuments.util.FMConstants;
import com.adobe.aem.formsndocuments.util.FMConstants.CoreAssetType;
import com.adobe.aem.formsndocuments.util.FMUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.jcr.api.SlingRepository;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.workflow.exec.WorkItem;
import com.day.cq.workflow.ui.JcrPayloadPathBuilder;
/**
* The RnCJcrPathBuilder
return the "wrapped" payload path for
* Forms and Documents console.
*
* @author sakarora
*/
@Component(metatype = false, immediate = true)
@Service
@Properties(value = { @Property(name = "service.ranking", intValue = -5) })
public class RnCJcrPathBuilder implements JcrPayloadPathBuilder {
public static final String TYPE_JCR_PATH = "JCR_PATH";
private static final String GENERIC_FORMS_N_DOCUMENTS_PREFIX = "/aem/formdetails.html";
private static final String FORMSET_PREFIX = "/aem/viewformset.html";
@Reference(policy = ReferencePolicy.STATIC)
private SlingRepository repository;
private static Logger logger = LoggerFactory
.getLogger(RnCJcrPathBuilder.class);
public String buildPath(WorkItem item) {
logger.trace("Entering RncJcrPathBuilder buildPath.");
if (item.getWorkflowData().getPayloadType().equals(TYPE_JCR_PATH)) {
String path = item.getWorkflowData().getPayload().toString();
logger.trace("Payload Path for RncJcrPathBuilder : " + path);
Session bundleSession = null;
try {
if (path.startsWith(FMConstants.SHADOW_NODES_ROOT)) {
bundleSession = FMUtils.getFnDServiceUserSession(repository);
Node assetNode = bundleSession.getNode(path);
if (assetNode != null) {
CoreAssetType assetType = FMUtils.getAssetType(bundleSession, path);
if(assetType.equals(CoreAssetType.FORMSET)){
return FORMSET_PREFIX + path;
}else if(! assetType.equals(CoreAssetType.NONFMASSET)){
return GENERIC_FORMS_N_DOCUMENTS_PREFIX + path;
}
}
}
} catch (Exception e) {
logger.trace("Error while retrieving type for asset " + path,e);
} finally {
if (bundleSession != null) {
bundleSession.logout();
}
}
}
logger.trace("Exiting RncJcrPathBuilder buildPath.");
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy