@Override DirectoryEntry run(Session session) { session.deleteEntry(entry.getDocumentModel()); return null; } });
@Override public void deleteProvider(String providerId) { try { DirectoryService ds = Framework.getService(DirectoryService.class); try (Session session = ds.open(DIRECTORY_NAME)) { session.deleteEntry(providerId); } } catch (DirectoryException e) { log.error("Unable to delete provider " + providerId, e); } }
@Override public void removeAccessToken(String token) { DirectoryService ds = Framework.getService(DirectoryService.class); try (Session session = ds.open(DIRECTORY_NAME)) { session.deleteEntry(token); } }
@Override public DataStore<StoredCredential> delete(String key) throws IOException { DirectoryService ds = Framework.getService(DirectoryService.class); try (Session session = ds.open(DIRECTORY_NAME)) { Map<String, Serializable> filter = new HashMap<>(); filter.put("serviceName", serviceName); filter.put(ENTRY_ID, key); DocumentModelList entries = session.query(filter); for (DocumentModel entry : entries) { session.deleteEntry(entry); } } return this; }
public void delete(String token, String clientId) { DirectoryService ds = Framework.getService(DirectoryService.class); Framework.doPrivileged(() -> { try (Session session = ds.open(DIRECTORY_NAME)) { Map<String, Serializable> filter = new HashMap<String, Serializable>(); filter.put("serviceName", serviceName); filter.put("clientId", clientId); filter.put("accessToken", token); DocumentModelList entries = session.query(filter); for (DocumentModel entry : entries) { session.deleteEntry(entry); } } }); }
@Override public void deleteConsumer(String consumerKey) { Framework.doPrivileged(() -> { try { DirectoryService ds = Framework.getService(DirectoryService.class); try (Session session = ds.open(DIRECTORY_NAME)) { session.deleteEntry(consumerKey); } } catch (DirectoryException e) { log.error("Unable to delete consumer " + consumerKey, e); } }); }
protected void deleteToken(DocumentModel token) { Framework.doPrivileged(() -> { DirectoryService ds = Framework.getService(DirectoryService.class); try (Session session = ds.open(TOKEN_DIR)) { session.deleteEntry(token); } }); }
public boolean removeDocumentFromPersistentList(String userName, String listName, DocumentModel doc) { if (!initPersistentService()) { return false; } try { String entryId = getIdForEntry(userName, listName, doc); try { dirSession.deleteEntry(entryId); } catch (DirectoryException e) { log.error("Unable to delete entry", e); return false; } return true; } finally { releasePersistenceService(); } }
public boolean clearPersistentList(String userName, String listName) { if (!initPersistentService()) { return false; } try { Map<String, Serializable> filter = new HashMap<>(); filter.put(DIR_COL_LISTID, listName); filter.put(DIR_COL_USERID, userName); try { DocumentModelList entriesToDelete = dirSession.query(filter); for (DocumentModel entry : entriesToDelete) { dirSession.deleteEntry(entry.getId()); } } catch (DirectoryException e) { log.error("Unable to clear DocumentList", e); return false; } return true; } finally { releasePersistenceService(); } }
@Override public void deleteProvider(String serviceName) { DirectoryService ds = Framework.getService(DirectoryService.class); try (Session session = ds.open(DIRECTORY_NAME)) { DocumentModel entry = getProviderDocModel(serviceName); session.deleteEntry(entry); } }
@Override public void removeClientAccessToken(String appId, String owner) { DirectoryService ds = Framework.getService(DirectoryService.class); try (Session session = ds.open(DIRECTORY_NAME)) { Map<String, Serializable> filter = new HashMap<String, Serializable>(); filter.put("appId", appId); filter.put("clientId", owner); filter.put("clientToken", 1); DocumentModelList entries = session.query(filter); if (entries.size() == 0) { return; } if (entries.size() > 1) { log.error("Found several tokens"); } session.deleteEntry(entries.get(0)); } }
log.warn("Entry with id " + id + " is already present : please check DB integrity"); if (FIX_SANITY_ERROR) { dirSession.deleteEntry(id);
if (FIX_SANITY_ERROR) { try { dirSession.deleteEntry(entry.getId()); } catch (DirectoryException e) { log.error("Sanity fix failed", e); dirSession.deleteEntry(entry.getId()); } catch (DirectoryException e) { log.error("Unable to remove non existing document model entry : " + entry.getId(), e);
public void deleteDirectoryEntry(String entryId) { String dirName = currentDirectoryInfo.getName(); List<DirectoryDeleteConstraint> deleteConstraints = currentDirectoryInfo.getDeleteConstraints(); if (deleteConstraints != null && !deleteConstraints.isEmpty()) { for (DirectoryDeleteConstraint deleteConstraint : deleteConstraints) { if (!deleteConstraint.canDelete(dirService, entryId)) { facesMessages.add(StatusMessage.Severity.ERROR, messages.get("feedback.directory.deleteEntry.constraintError")); return; } } } try (Session dirSession = dirService.open(dirName)) { try { dirSession.deleteEntry(entryId); // invalidate directory entries list currentDirectoryEntries = null; Events.instance().raiseEvent(EventNames.DIRECTORY_CHANGED, dirName); facesMessages.add(StatusMessage.Severity.INFO, messages.get("vocabulary.entry.deleted")); } catch (DirectoryDeleteConstraintException e) { facesMessages.add(StatusMessage.Severity.ERROR, messages.get("feedback.directory.deleteEntry.constraintError")); } } }
@Override public void deleteEntry(String id) { checkPermission(SecurityConstants.WRITE); checkDeleteConstraints(id); init(); for (SourceInfo sourceInfo : sourceInfos) { for (SubDirectoryInfo dirInfo : sourceInfo.subDirectoryInfos) { if (!dirInfo.getSession().isReadOnly()) { // Check if the platform is able to manage entry if (!sourceInfo.source.creation) { // If not check if entry exist to prevent exception that may // stop the deletion loop to other subdirectories // Do not raise exception, because creation is not managed // by the platform DocumentModel docModel = dirInfo.getSession().getEntry(id); if (docModel == null) { log.warn(String.format( "MultiDirectory '%s' : The entry id '%s' could not be deleted on subdirectory '%s' because it does not exist", getName(), id, dirInfo.dirName)); } else { dirInfo.getSession().deleteEntry(id); } } else { dirInfo.getSession().deleteEntry(id); } } } } }