@Override public void handleEvent(Event event) { EventContext ec = event.getContext(); if (!(ec instanceof DocumentEventContext)) { return; } String evtName = event.getName(); if (!DocumentEventTypes.DOCUMENT_REMOVED.equals(evtName) && !TrashService.DOCUMENT_TRASHED.equals(evtName) && !TrashService.DOCUMENT_UNTRASHED.equals(evtName)) { return; } DocumentEventContext context = (DocumentEventContext) ec; DocumentModel doc = context.getSourceDocument(); Path path = doc.getPath(); if (path == null) { // Placeless document return; } if (path.segmentCount() == 1) { // the document is under root like are the domains // we need to invalidate user workspace location Framework.getService(UserWorkspaceService.class).invalidate(); } }