You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "indra kumar gurjar (JIRA)" <ji...@apache.org> on 2016/08/11 13:29:20 UTC
[jira] [Commented] (SLING-5637) Resource.delete is not called if
resource is adaptable to Node
[ https://issues.apache.org/jira/browse/SLING-5637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15417228#comment-15417228 ]
indra kumar gurjar commented on SLING-5637:
-------------------------------------------
The patch has broken chunk delete functionality.
when trying to delete chunks it deletes asset also.
> Resource.delete is not called if resource is adaptable to Node
> --------------------------------------------------------------
>
> Key: SLING-5637
> URL: https://issues.apache.org/jira/browse/SLING-5637
> Project: Sling
> Issue Type: Bug
> Components: Servlets
> Affects Versions: Servlets Post 2.3.8
> Reporter: Carsten Ziegeler
> Assignee: Carsten Ziegeler
> Fix For: Servlets Post 2.3.10
>
>
> If a resource is adaptable to Node, the node is directly removed.
> ResourceProvider.delete is never invoked.
> While this works with the JcrResourceProvider it does not work with any other resource provider providing resources which adapt to a node
> Proposed solution:
> {code}
> ### Eclipse Workspace Patch 1.0
> #P org.apache.sling.servlets.post
> Index: src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java
> ===================================================================
> --- src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java (Revision 1737673)
> +++ src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java (Arbeitskopie)
> @@ -58,15 +58,15 @@
> // SLING-3203: selectors, extension and suffix make no sense here and
> // might lead to deleting other resources than the one the user means.
> final RequestPathInfo rpi = request.getRequestPathInfo();
> - if( (rpi.getSelectors() != null && rpi.getSelectors().length > 0)
> + if( (rpi.getSelectors() != null && rpi.getSelectors().length > 0)
> || (rpi.getExtension() != null && rpi.getExtension().length() > 0)
> || (rpi.getSuffix() != null && rpi.getSuffix().length() > 0)) {
> response.setStatus(
> - HttpServletResponse.SC_FORBIDDEN,
> + HttpServletResponse.SC_FORBIDDEN,
> "DeleteOperation request cannot include any selectors, extension or suffix");
> return;
> }
> -
> +
> final VersioningConfiguration versioningConfiguration = getVersioningConfiguration(request);
> final boolean deleteChunks = isDeleteChunkRequest(request);
> final Iterator<Resource> res = getApplyToResources(request);
> @@ -100,19 +100,17 @@
> } else {
> checkoutIfNecessary(node.getParent(), changes,
> versioningConfiguration);
> - node.remove();
> }
> -
> - } else {
> - try {
> - resource.getResourceResolver().delete(resource);
> - } catch (final PersistenceException pe) {
> - if (pe.getCause() instanceof RepositoryException) {
> - throw (RepositoryException) pe.getCause();
> - }
> - throw new RepositoryException(pe);
> + }
> + try {
> + resource.getResourceResolver().delete(resource);
> + } catch (final PersistenceException pe) {
> + if (pe.getCause() instanceof RepositoryException) {
> + throw (RepositoryException) pe.getCause();
> }
> + throw new RepositoryException(pe);
> }
> +
> changes.add(Modification.onDeleted(resource.getPath()));
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)