Created
May 24, 2018 17:25
-
-
Save fredrick-dominy/b0bc483df1a0745eaae0741cd9613fed to your computer and use it in GitHub Desktop.
getServiceResourceResolver
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
/** Note: this service user must be created from 4502/crx/explorer/index.jsp (must re-login) | |
* then go to normal user admin menu at 4502/useradmin and add permissions | |
* finally add the username to the Apache Sling Service User Mapper Service in the following format: | |
* com.myproject.core:writeService=serviceuser (serviceuser is the name of the user I created locally, | |
* one must be created in each author env. | |
* | |
* */ | |
private void performActivateAction(String path) throws ReplicationException { | |
ResourceResolver resourceResolver = null; | |
Map<String, Object> param = new HashMap<String, Object>(); | |
param.put(ResourceResolverFactory.SUBSERVICE, "writeService"); | |
try { | |
resourceResolver = resourceResolverFactory.getServiceResourceResolver(param); | |
Resource replicatedResource = resourceResolver.getResource(path); | |
/* Logic */ | |
} | |
catch (LoginException e) { | |
log.error("Error performing Activation ==> {}", e.getMessage()); | |
} | |
finally { | |
resourceResolver.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment