entries.add(new PageSelection<>(entry, false)); allSelected = false; entries.add(new PageSelection<>(entry, selected.booleanValue())); // NOSONAR
/** * @return The list of selected rows in the local rights table. * @since 6.0 */ private List<PageSelection<String>> getSelectedRows() { List<PageSelection<String>> selectedRows = new ArrayList<PageSelection<String>>(); if (!getDataTableModel().isEmpty()) { for (PageSelection<String> entry : getDataTableModel().getEntries()) { if (entry.isSelected()) { selectedRows.add(entry); } } } return selectedRows; }
/** * Processes the version selection row. * * @param versionModelSelection the version model selection */ protected final void processVersionSelectRow(PageSelection<VersionModel> versionModelSelection) { DocumentModel currentDocument = navigationContext.getCurrentDocument(); if (currentDocument == null) { throw new NuxeoException("Cannot process version select row since current document is null."); } DocumentModel version = documentManager.getDocumentWithVersion(currentDocument.getRef(), versionModelSelection.getData()); if (version == null) { throw new NuxeoException("Cannot process version select row since selected version document is null."); } if (Boolean.TRUE.equals(versionModelSelection.isSelected())) { documentsListsManager.addToWorkingList(DocumentsListsManager.CURRENT_VERSION_SELECTION, version); } else { documentsListsManager.removeFromWorkingList(DocumentsListsManager.CURRENT_VERSION_SELECTION, version); } }
@Override public String removePermissions() { for (PageSelection<String> user : getSelectedRows()) { securityData.removeModifiablePrivilege(user.getData()); if (!checkPermissions()) { facesMessages.add(StatusMessage.Severity.ERROR, resourcesAccessor.getMessages().get("message.error.removeRight")); return null; } } reconstructTableModel(); return null; }
@Override public String removePermissionsAndUpdate() { for (PageSelection<String> user : getDataTableModel().getEntries()) { securityData.removeModifiablePrivilege(user.getData()); if (!checkPermissions()) { facesMessages.add(StatusMessage.Severity.ERROR, resourcesAccessor.getMessages().get("message.error.removeRight")); return null; } } updateSecurityOnDocument(); facesMessages.add(StatusMessage.Severity.INFO, resourcesAccessor.getMessages().get("message.updated.rights")); // do not redirect to the default folder view return null; }
/** * Update the dataTableModel from the current {@link SecurityData} this method is automatically called by * rebuildSecurityData method */ protected void reconstructTableModel() { List<String> items = getCurrentDocumentUsers(); entries = new PageSelections<String>(); if (items != null) { for (String item : items) { if (SecurityConstants.EVERYONE.equals(item)) { final List<String> grantedPerms = securityData.getCurrentDocGrant().get(item); final List<String> deniedPerms = securityData.getCurrentDocDeny().get(item); if (deniedPerms != null && deniedPerms.contains(SecurityConstants.EVERYTHING) && grantedPerms == null && deniedPerms.size() == 1) { // the only perm is deny everything, there is no need to display the row continue; } } entries.add(new PageSelection<String>(item, false)); } } }
@Override public void retrieveVersions() { /** * in case the document is a proxy,meaning is the result of a publishing,to have the history of the document * from which this proxy was created,first we have to get to the version that was created when the document was * publish,and to which the proxy document indicates,and then from that version we have to get to the root * document. */ DocumentModel currentDocument = navigationContext.getCurrentDocument(); DocumentModel doc; if (currentDocument.isProxy()) { DocumentRef ref = currentDocument.getRef(); DocumentModel version = documentManager.getSourceDocument(ref); doc = documentManager.getSourceDocument(version.getRef()); } else { doc = currentDocument; } List<PageSelection<VersionModel>> versionModelSelections = new ArrayList<PageSelection<VersionModel>>(); for (VersionModel versionModel : documentVersioning.getItemVersioningHistory(doc)) { versionModelSelections.add(new PageSelection<VersionModel>(versionModel, isVersionSelected(versionModel))); } versionModelList = new PageSelections<VersionModel>(versionModelSelections); }