Last active
August 27, 2022 10:59
-
-
Save sreeni-b/6f95860ba7419511dbab0880b8433871 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.aemks.core.workflow; | |
import com.adobe.cq.dam.cfm.ContentFragment; | |
import com.adobe.granite.workflow.WorkflowException; | |
import com.adobe.granite.workflow.WorkflowSession; | |
import com.adobe.granite.workflow.exec.WorkItem; | |
import com.adobe.granite.workflow.exec.WorkflowData; | |
import com.adobe.granite.workflow.exec.WorkflowProcess; | |
import com.adobe.granite.workflow.metadata.MetaDataMap; | |
import com.day.cq.commons.jcr.JcrConstants; | |
import com.day.cq.dam.api.Asset; | |
import com.day.cq.dam.commons.util.DamUtil; | |
import com.day.cq.dam.core.process.ProcessingProfileApplier; | |
import org.apache.sling.api.resource.Resource; | |
import org.apache.sling.api.resource.ResourceResolver; | |
import org.osgi.service.component.annotations.Component; | |
import javax.jcr.RepositoryException; | |
import javax.jcr.Session; | |
/** | |
* By default, the metadata processing profile does not work for content fragments. | |
* Hence this custom process is required to apply processing profile on create | |
* of any Content Fragment. | |
*/ | |
@Component(property = { "process.label = Content Fragment Metadata Processor" }) | |
public class ContentFragmentMetadataProcessor implements WorkflowProcess { | |
private ProcessingProfileApplier processingProfileApplier = new ProcessingProfileApplier(); | |
@Override public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) | |
throws WorkflowException { | |
Session session = workflowSession.adaptTo(Session.class); | |
WorkflowData data = workItem.getWorkflowData(); | |
String payloadPath = data.getPayload().toString(); | |
if(payloadPath.endsWith("/jcr:content")){ | |
payloadPath=payloadPath.replace("/jcr:content",""); | |
} | |
ResourceResolver resourceResolver = workflowSession.adaptTo(ResourceResolver.class); | |
if(resourceResolver==null){ | |
throw new WorkflowException("Resource Resolver is null"); | |
} | |
Resource assetResource = resourceResolver.getResource(payloadPath); | |
if(assetResource==null){ | |
throw new WorkflowException("Asset resource is null"); | |
} | |
ContentFragment contentFragment = assetResource.adaptTo(ContentFragment.class); | |
if(contentFragment==null){ | |
throw new WorkflowException("Asset resource is not a content fragment"); | |
} | |
Asset asset = DamUtil.resolveToAsset(assetResource); | |
try { | |
processingProfileApplier.applyProcessingProfile(session,asset); | |
} catch (RepositoryException e) { | |
throw new WorkflowException("Error occurred while applying processing profile to Content Fragment",e); | |
} | |
} | |
} |
Hi can share project create command
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
4.0.0 com.adobe.aem.guides aem-guides-wknd pom 2.0.1-SNAPSHOT WKND Sites Project - Reactor Project WKND Sites Project https://github.com/adobe/aem-guides-wknd 2019I am facing an issue ( com.adobe.aem.guides:aem-guides-wknd.core:2.0.1-SNAPSHOT: Bundle aem-guides-wknd.core:2.0.1-SNAPSHOT is importing package(s) com.day.cq.dam.core.process in start level 20 but no bundle is exporting these for that start level. (com.adobe.aem.guides:aem-guides-wknd.all:2.0.1-SNAPSHOT))
Bundle-Category: ${componentGroupName}
export all versioned packages except for conditional ones (bndtools/bnd#3721 (comment))
-exportcontents: ${removeall;${packages;VERSIONED};${packages;CONDITIONAL}}
reproducible builds (bndtools/bnd#3521)
-noextraheaders: true
-snapshot: SNAPSHOT
Bundle-DocURL:
this is my main pom file. 6.5.12(uber jar version) import com.day.cq.dam.core.process.ProcessingProfileApplier;(this import package was also giving errors)-plugin org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin
-plugin org.apache.sling.bnd.models.ModelsScannerPlugin
]]>
org.apache.sling
org.apache.sling.caconfig.bnd-plugin
1.0.2
org.apache.sling
org.apache.sling.bnd.models
1.0.0
biz.aQute.bnd
bnd-baseline-maven-plugin
${bnd.version}
org.apache.maven.plugins
maven-resources-plugin
3.0.2
org.apache.maven.plugins
maven-compiler-plugin
3.8.1
org.apache.maven.plugins
maven-install-plugin
2.5.2
org.apache.maven.plugins
maven-surefire-plugin
2.22.1
false
org.apache.maven.plugins
maven-failsafe-plugin
2.22.1
org.apache.maven.plugins
maven-deploy-plugin
2.8.2
org.apache.sling
sling-maven-plugin
2.4.0
http://${aem.host}:${aem.port}/system/console
WebConsole
org.apache.sling
htl-maven-plugin
1.3.4-1.4.0
true
org.apache.jackrabbit
filevault-package-maven-plugin
true
1.1.4
src/main/content/META-INF/vault/filter.xml
none
tccl:aem.cnd
biz.netcentric.aem
aem-nodetypes
6.5.5.0
com.adobe.aem
aemanalyser-maven-plugin
${aemanalyser.version}
true
com.day.jcr.vault
content-package-maven-plugin
1.0.2
http://${aem.host}:${aem.port}/crx/packmgr/service.jsp
true
${vault.user}
${vault.password}
org.apache.maven.plugins
maven-enforcer-plugin
3.0.0
org.apache.maven.plugins
maven-dependency-plugin
3.0.0
org.codehaus.mojo
build-helper-maven-plugin
3.0.0
org.eclipse.m2e
lifecycle-mapping
1.0.0
org.apache.maven.plugins
maven-enforcer-plugin
[1.0.0,)
enforce
org.apache.maven.plugins
maven-dependency-plugin
[2.2,)
copy-dependencies
unpack
org.codehaus.mojo
build-helper-maven-plugin
[1.5,)
reserve-network-port
org.apache.maven.plugins
maven-javadoc-plugin
${maven-javadoc-plugin.version}
attach-javadocs
jar
-Xdoclint:none
${java.home}/bin/javadoc
com.vu.poc.test.objects