
com.adobe.aem.formsndocuments.transferobjects.AssetInfo Maven / Gradle / Ivy
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2015 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.transferobjects;
import com.adobe.aem.formsndocuments.util.ExceptionCodes;
import com.adobe.aem.formsndocuments.util.FMConstants;
import com.adobe.aem.formsndocuments.util.FMConstants.CoreAssetType;
import com.adobe.aem.formsndocuments.util.FMUtils;
import com.adobe.aemforms.fm.exception.FormsMgrException;
import org.apache.sling.api.resource.Resource;
import javax.jcr.Session;
public class AssetInfo {
private Resource resource;
private CoreAssetType type;
private String nonFMAssetPublishType;
public AssetInfo(Resource resource, CoreAssetType type) throws FormsMgrException{
if(resource == null){
Object[] args = { "resource", resource };
throw new FormsMgrException(ExceptionCodes.INVALID_PARAMETER, args);
}
this.resource = resource;
this.type = type;
}
public Resource getResource() {
return resource;
}
public void setResource(Resource resource) {
this.resource = resource;
}
public CoreAssetType getType() {
return type;
}
public void setType(CoreAssetType type) {
this.type = type;
}
public String getNonFMAssetPublishType() {
return nonFMAssetPublishType;
}
public void setNonFMAssetType(String nonFMAssetPublishType) {
this.nonFMAssetPublishType = nonFMAssetPublishType;
}
@Override
public boolean equals(Object obj) {
if(!(obj instanceof AssetInfo)){
return false;
}
AssetInfo formInfo = (AssetInfo)obj;
return resource.getPath().equals(formInfo.resource.getPath());
}
@Override
public String toString() {
return "Form Path : " + resource.getPath() + " Form Type : " + type;
}
@Override
public int hashCode() {
return resource.getPath().hashCode();
}
public String getPublishAssetType(){
switch (type) {
case FORM:
return FMConstants.PUBLISH_ASSET_TYPE_XDPFORM;
case FORMSET:
return FMConstants.PUBLISH_ASSET_TYPE_FORMSET;
case GUIDE:
return FMConstants.PUBLISH_ASSET_TYPE_GUIDE;
case PDFFORM:
return FMConstants.PUBLISH_ASSET_TYPE_PDFFORM;
case PRINTFORM:
return FMConstants.PUBLISH_ASSET_TYPE_PRINTFORM;
case RESOURCE:
return FMConstants.PUBLISH_ASSET_TYPE_RESOURCE;
case AFFRAGMENT:
return FMConstants.PUBLISH_ASSET_TYPE_AFFRAGMENT;
case ADAPTIVEDOCUMENT:
return FMConstants.PUBLISH_ASSET_TYPE_ADAPTIVEDOCUMENT;
case THEME:
return FMConstants.PUBLISH_ASSET_TYPE_THEME;
case FORMDATAMODEL:
return FMConstants.PUBLISH_ASSET_TYPE_FORM_DATA_MODEL;
case NONFMASSET:
if(resource.getPath().startsWith(FMConstants.AF_ROOT)){
return FMConstants.PUBLISH_ASSET_TYPE_AFCQPAGE;
} else if(resource.getPath().startsWith("/etc")){
return FMConstants.PUBLISH_ASSET_TYPE_THEME_CLIENT_LIB;
} if (FMConstants.STR_TEMPLATE.equals(nonFMAssetPublishType)) {
return FMConstants.PUBLISH_ASSET_TYPE_AF_TEMPLATE;
} else if (FMConstants.STR_CONTENT_POLICY.equals(nonFMAssetPublishType)) {
return FMConstants.PUBLISH_TYPE_CONTENT_POLICY;
} else if(nonFMAssetPublishType != null){
return nonFMAssetPublishType;
}
case DOCUMENT_TEMPLATE:
return FMConstants.PUBLISH_ASSET_TYPE_ADAPTIVEDOCUMENT;
default:
return FMConstants.PUBLISH_ASSET_TYPE_ASSET;
}
}
public long getLastModifiedOrCreatedTime(Session session) throws FormsMgrException {
return FMUtils.getLastModifiedOrCreated(session, getResource().getPath());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy