use of org.apache.sling.api.resource.ModifiableValueMap in project APM by Cognifide.
the class ModifiableScriptWrapper method setProperty.
public void setProperty(String name, Object value) throws PersistenceException {
Resource resource = resolver.getResource(script.getPath());
ModifiableValueMap vm = resource.getChild(JcrConstants.JCR_CONTENT).adaptTo(ModifiableValueMap.class);
ResourceMixinUtil.addMixin(vm, ScriptContent.CQSM_FILE);
vm.put(name, convertValue(value));
resource.getResourceResolver().commit();
}
use of org.apache.sling.api.resource.ModifiableValueMap in project CQ-Actions by Cognifide.
the class MessageSerializer method saveMessageToResource.
public static void saveMessageToResource(Resource resource, String type, Map<String, String> message) {
final ModifiableValueMap map = resource.adaptTo(ModifiableValueMap.class);
map.put("sling:resourceType", type);
map.putAll(message);
map.put(ACTION_PROPERTIES, getArray(message.keySet()));
}
use of org.apache.sling.api.resource.ModifiableValueMap in project CQ-Actions by Cognifide.
the class ReplicationMessageProducer method createActionResource.
private Resource createActionResource(ResourceResolver resolver, String actionType, String relPath) throws PersistenceException {
final String path = createPath(relPath, config.getActionRoot(), config.getRandomPathPattern());
final Resource page = ResourceUtil.getOrCreateResource(resolver, path, Collections.singletonMap(JcrConstants.JCR_PRIMARYTYPE, (Object) "cq:Page"), null, false);
final Map<String, Object> contentMap = new LinkedHashMap<String, Object>();
contentMap.put(JcrConstants.JCR_PRIMARYTYPE, "cq:PageContent");
contentMap.put("cq:distribute", false);
final Resource content = resolver.create(page, JcrConstants.JCR_CONTENT, contentMap);
resolver.commit();
final ModifiableValueMap map = content.adaptTo(ModifiableValueMap.class);
map.put(NameConstants.PN_PAGE_LAST_MOD, Calendar.getInstance());
map.put(NameConstants.PN_PAGE_LAST_MOD_BY, resolver.getUserID());
map.put("cq:distribute", true);
return content;
}
use of org.apache.sling.api.resource.ModifiableValueMap in project acs-aem-commons by Adobe-Consulting-Services.
the class EnsureOakIndexJobHandler method forceRefresh.
/**
* Forces index refresh for create or updates (that require updating).
*
* @param oakIndex the index representing the oak index
* @throws PersistenceException
*/
public void forceRefresh(@Nonnull final Resource oakIndex) throws PersistenceException {
final ModifiableValueMap mvm = oakIndex.adaptTo(ModifiableValueMap.class);
if (mvm == null) {
String msg = String.format("Cannot adapt {} to a ModifiableValueMap (permissions?)", oakIndex.getPath());
throw new PersistenceException(msg);
}
mvm.put(PN_REINDEX, true);
log.info("Forcing re-index of [ {} ]", oakIndex.getPath());
}
use of org.apache.sling.api.resource.ModifiableValueMap in project acs-aem-commons by Adobe-Consulting-Services.
the class EnsureOakIndexJobHandler method disableIndex.
/**
* Disables an index, so it's no longer updated by Oak.
*
* @param oakIndex the index
* @throws PersistenceException
*/
public void disableIndex(@Nonnull Resource oakIndex) throws PersistenceException {
final ModifiableValueMap oakIndexProperties = oakIndex.adaptTo(ModifiableValueMap.class);
oakIndexProperties.put(PN_TYPE, DISABLED);
log.info("Disabled index at {}", oakIndex.getPath());
}
Aggregations