public DeepReadValueMapDecorator(final Resource resource, final ValueMap base) { super(base); this.pathPrefix = resource.getPath() + "/"; this.resolver = resource.getResourceResolver(); this.base = base; }
public Workspace(Resource resource) { this.resource = resource; this.properties = resource.adaptTo(ModifiableValueMap.class); this.jobName = "acs-commons@bulk-workflow-execution:/" + this.resource.getPath(); }
/** * Returns the value of calling <code>getPath</code> on the * {@link #getResource() wrapped resource}. */ @Override public String getPath() { return getResource().getPath(); }
/** * Returns the path of the resource of the request as the item path. * <p> * This method may be overwritten by extension if the operation has * different requirements on path processing. * @param request The http request * @return The item path */ protected String getItemPath(SlingHttpServletRequest request) { return request.getResource().getPath(); }
public String getImagePath() { Resource image = getImageResource(); if (image == null) { return null; } return image.getPath(); }
private static Set<String> getPathsFromQuery(ResourceResolver resourceResolver, String language, String query) { if (StringUtils.isBlank(query)) { return Collections.emptySet(); } Set<String> paths = new HashSet<>(); language = StringUtils.defaultIfEmpty(language, "xpath"); Iterator<Resource> resources = resourceResolver.findResources(query, language); while (resources.hasNext()) { paths.add(resources.next().getPath()); } return paths; }
public void accept(final Resource head) throws TraversalException { if (head == null) { return; } stack.clear(); stack.add(head); int headLevel = getDepth(head.getPath()); while (!stack.isEmpty()) { visitNodesInStack(headLevel); } }
/** * 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()); }
public static void serializeToResource(Resource r, Object sourceObject) { Map<String, Object> map = r.adaptTo(ModifiableValueMap.class); if (map == null) { LOG.error("Unable to get modifiable value map for resource " + r.getPath()); } else { serializeToMap(map, sourceObject); } }
/** * Creates a new SyntheticChildAsPropertyResource. * * @param parent the synthetic nodes parent (a real JCR Resource) * @param nodeName the name of the synthetic child resource */ public SyntheticChildAsPropertyResource(Resource parent, String nodeName) { super(parent.getResourceResolver(), parent.getPath() + "/" + nodeName, RESOURCE_TYPE); this.data = new JSONModifiableValueMapDecorator(); }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { SlingHttpServletRequest req = (SlingHttpServletRequest) request; SlingHttpServletResponse res = (SlingHttpServletResponse) response; if (needsFiltering(req.getResource().getPath())) { doFilterInternal(req, res); } chain.doFilter(request, response); }
private String getReplicatedResourcePath(WorkItem workItem, ResourceResolver resourceResolver) { String payloadPath = workItem.getWorkflowData().getPayload().toString(); Resource resource = replStatusMgr.getReplicationStatusResource(payloadPath, resourceResolver); return resource.getPath(); }
public void setResourceResolver(ResourceResolver resolver) { this.mockResourceResolver = resolver; // recreate request resource with the new resolver if (resource.getResourceResolver() == null) { this.resource = new SyntheticResource(resolver, resource.getPath(), resource.getResourceType()); } }
protected void trackScriptEnd(Resource statusResource, String status) { try { ModifiableValueMap properties = statusResource.adaptTo(ModifiableValueMap.class); properties.put(SCRIPT_STATUS, status); properties.put(SCRIPT_DATE_END, Calendar.getInstance()); statusResource.getResourceResolver().commit(); } catch (PersistenceException e) { logger.error("On-deploy script status node could not be updated: {} - status: {}", statusResource.getPath(), status); throw new OnDeployEarlyTerminationException(e); } }
public CurrentEvolutionEntryImpl(Resource resource, EvolutionConfig config) { this.config = config; this.type = EvolutionEntryType.RESOURCE; this.name = resource.getName(); this.depth = EvolutionPathUtil.getLastDepthForPath(resource.getPath()); this.path = resource.getParent().getName(); this.value = null; }
private void handleReplication(Resource twitterResource) throws ReplicationException { if (isReplicationEnabled(twitterResource)) { Session session = twitterResource.getResourceResolver().adaptTo(Session.class); replicator.replicate(session, ReplicationActionType.ACTIVATE, twitterResource.getPath()); } }
public void init() { if (getField() != null) { ParameterizedType type = (ParameterizedType) getField().getGenericType(); Class clazz = (Class) type.getActualTypeArguments()[0]; extractFieldComponents(clazz); } if (sling != null && sling.getRequest() != null) { setPath(sling.getRequest().getResource().getPath()); } }
public boolean isVersionable(final Resource rsrc) throws PersistenceException { try { final Node node = rsrc.adaptTo(Node.class); return node != null && isVersionable(node); } catch ( final RepositoryException re) { throw new PersistenceException(re.getMessage(), re, rsrc.getPath(), null); } }
@Override public void run(final Resource resource) throws Exception { if (processArgs.isThrottle()) { throttledTaskRunner.waitForLowCpuAndLowMemory(); } replicator.replicate(resource.getResourceResolver().adaptTo(Session.class), processArgs.getReplicationActionType(), resource.getPath(), processArgs.getReplicationOptions(resource)); count.incrementAndGet(); } };
public AbstractCacheKey(SlingHttpServletRequest request, HttpCacheConfig cacheConfig) { this.authenticationRequirement = cacheConfig.getAuthenticationRequirement(); this.uri = request.getRequestURI(); this.resourcePath = unmangle(request.getResource().getPath()); this.hierarchyResourcePath = makeHierarchyResourcePath(this.resourcePath); this.customExpiryTime = cacheConfig.getExpiryOnCreate(); this.expiryForAccessTime = cacheConfig.getExpiryOnCreate(); this.expiryForUpdateTime = cacheConfig.getExpiryForUpdate(); this.expiryForAccessTime = cacheConfig.getExpiryForAccess(); }