Skip to content

Commit

Permalink
fixed script, history delete
Browse files Browse the repository at this point in the history
  • Loading branch information
dprzybyl committed Nov 4, 2023
1 parent 60cb4e4 commit 0a0f5a4
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.apache.sling.models.factory.ModelFactory;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component(
service = Servlet.class,
Expand All @@ -44,6 +46,8 @@
)
public class ScriptDeleteServlet extends SlingAllMethodsServlet {

private static final Logger LOGGER = LoggerFactory.getLogger(ScriptDeleteServlet.class);

@Reference
private ModelFactory modelFactory;

Expand All @@ -55,11 +59,13 @@ protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse
for (String path : form.getPaths()) {
if (session.nodeExists(path)) {
session.removeItem(path);
LOGGER.info("Item {} successfully deleted", path);
}
}
session.save();
return ResponseEntity.ok("Item(s) successfully deleted");
} catch (Exception e) {
LOGGER.error("Error while deleting item(s)", e);
return ResponseEntity.badRequest(StringUtils.defaultString(e.getMessage(), "Errors while deleting item(s)"));
}
});
Expand Down

0 comments on commit 0a0f5a4

Please sign in to comment.