diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/Browser.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/Browser.java index 7f9d97618c..b722cbba5c 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/Browser.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/Browser.java @@ -320,33 +320,6 @@ public static T retrieve(final User user, final Class c } } - public static List retrieve(final User user, final Class classToReturn, - final SelectedItems selectedItems, final List fieldsToReturn) - throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException { - final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; - - // check user permissions - controllerAssistant.checkRoles(user, classToReturn); - - LogEntryState state = LogEntryState.SUCCESS; - - try { - // delegate - final List objects = BrowserHelper.retrieve(classToReturn, selectedItems, fieldsToReturn); - for (T obj : objects) { - controllerAssistant.checkObjectPermissions(user, obj, classToReturn); - } - - return objects; - } catch (RODAException e) { - state = LogEntryState.FAILURE; - throw e; - } finally { - // register action - controllerAssistant.registerAction(user, state, RodaConstants.CONTROLLER_SELECTED_ITEMS_PARAM, selectedItems); - } - } - public static void delete(final User user, final Class classToReturn, final SelectedItems ids) throws AuthorizationDeniedException, GenericException, RequestNotValidException { final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/BrowserHelper.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/BrowserHelper.java index e37f2c5987..0618c5d4af 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/BrowserHelper.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/BrowserHelper.java @@ -572,27 +572,6 @@ protected static void commit(Class returnClass) RodaCoreFactory.getIndexService().commit(returnClass); } - protected static List retrieve(Class returnClass, SelectedItems selectedItems, - List fieldsToReturn) throws GenericException, NotFoundException, RequestNotValidException { - List ret; - - if (selectedItems instanceof SelectedItemsList) { - SelectedItemsList selectedList = (SelectedItemsList) selectedItems; - ret = RodaCoreFactory.getIndexService().retrieve(returnClass, selectedList.getIds(), fieldsToReturn); - } else if (selectedItems instanceof SelectedItemsFilter) { - SelectedItemsFilter selectedFilter = (SelectedItemsFilter) selectedItems; - int counter = RodaCoreFactory.getIndexService().count(returnClass, selectedFilter.getFilter()).intValue(); - ret = RodaCoreFactory.getIndexService() - .find(returnClass, selectedFilter.getFilter(), Sorter.NONE, new Sublist(0, counter), fieldsToReturn) - .getResults(); - } else { - throw new RequestNotValidException( - "Unsupported SelectedItems implementation: " + selectedItems.getClass().getName()); - } - - return ret; - } - public static void validateGetFileParams(String acceptFormat) throws RequestNotValidException { if (!RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_BIN.equals(acceptFormat) && !RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_JSON.equals(acceptFormat) diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowserService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowserService.java index 8052449570..17c45d98ca 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowserService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowserService.java @@ -103,10 +103,6 @@ void deleteDescriptiveMetadataVersion(String aipId, String representationId, Str String versionId) throws AuthorizationDeniedException, RequestNotValidException, NotFoundException, GenericException; - List retrieve(String classNameToReturn, SelectedItems selectedItems, - List fieldsToReturn) - throws GenericException, AuthorizationDeniedException, NotFoundException, RequestNotValidException; - Job updateAIPPermissions(SelectedItems aips, Permissions permissions, String details, boolean recursive) throws GenericException, AuthorizationDeniedException, RequestNotValidException, NotFoundException, JobAlreadyStartedException; @@ -142,36 +138,12 @@ void deleteDistributedInstance(String distributedInstancesId) DistributedInstance updateDistributedInstance(DistributedInstance distributedInstance) throws AuthorizationDeniedException, RequestNotValidException, NotFoundException, GenericException; - AccessKey createAccessKey(AccessKey accessKey) throws AuthorizationDeniedException, AlreadyExistsException, - NotFoundException, GenericException, RequestNotValidException, IOException; - AccessKeys listAccessKey() throws AuthorizationDeniedException, IOException, GenericException, RequestNotValidException; AccessKey retrieveAccessKey(String accessKeyId) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException; - void deleteAccessKey(String accessKeyId) - throws NotFoundException, GenericException, AuthorizationDeniedException, RequestNotValidException; - - AccessKey updateAccessKey(AccessKey accessKey) - throws AuthorizationDeniedException, RequestNotValidException, NotFoundException, GenericException; - - AccessKeys listAccessKeyByUser(String userId) - throws AuthorizationDeniedException, IOException, GenericException, RequestNotValidException; - - void deactivateUserAccessKeys(String userId) - throws AuthorizationDeniedException, RequestNotValidException, GenericException, NotFoundException; - - void deleteUserAccessKeys(String userId) - throws AuthorizationDeniedException, RequestNotValidException, GenericException, NotFoundException; - - AccessKey regenerateAccessKey(AccessKey accessKey) throws AuthorizationDeniedException, RequestNotValidException, - NotFoundException, GenericException, AuthenticationDeniedException; - - AccessKey revokeAccessKey(AccessKey accessKey) - throws AuthorizationDeniedException, RequestNotValidException, NotFoundException, GenericException; - void createLocalInstance(LocalInstance localInstance) throws AuthorizationDeniedException, GenericException; LocalInstance retrieveLocalInstance() throws AuthorizationDeniedException, GenericException; diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowserServiceAsync.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowserServiceAsync.java index cdcc681ac8..f9a35be35c 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowserServiceAsync.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowserServiceAsync.java @@ -77,9 +77,6 @@ void revertDescriptiveMetadataVersion(String aipId, String representationId, Str void deleteDescriptiveMetadataVersion(String aipId, String representationId, String descriptiveMetadataId, String versionId, AsyncCallback callback); - void retrieve(String classNameToReturn, SelectedItems selectedItems, - List fieldsToReturn, AsyncCallback> asyncCallback); - void updateAIPPermissions(SelectedItems aips, Permissions permissions, String details, boolean recursive, AsyncCallback callback); @@ -106,26 +103,10 @@ void changeAIPType(SelectedItems selectedAIP, String newType, String void deleteDistributedInstance(String distributedInstanceId, AsyncCallback async); - void createAccessKey(AccessKey accessKey, AsyncCallback async); - void listAccessKey(AsyncCallback async); void retrieveAccessKey(String accessKeyId, AsyncCallback async); - void deleteAccessKey(String accessKeyId, AsyncCallback async); - - void updateAccessKey(AccessKey accessKey, AsyncCallback async); - - void listAccessKeyByUser(String userId, AsyncCallback async); - - void deactivateUserAccessKeys(String userId, AsyncCallback async); - - void deleteUserAccessKeys(String userId, AsyncCallback async); - - void regenerateAccessKey(AccessKey accessKey, AsyncCallback async); - - void revokeAccessKey(AccessKey accessKey, AsyncCallback async); - void createLocalInstance(LocalInstance localInstance, AsyncCallback async); void retrieveLocalInstance(AsyncCallback async); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/EditPermissions.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/EditPermissions.java index fd2eed9a17..9ce5632105 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/EditPermissions.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/EditPermissions.java @@ -409,6 +409,11 @@ public void onSuccess(final Void nothing) { @UiHandler("buttonApply") void buttonApplyHandler(ClickEvent e) { apply(false); + } + + @UiHandler("buttonApplyToAll") + void buttonApplyToAllHandler(ClickEvent e) { + apply(true); } public static final HistoryResolver AIP_RESOLVER = new HistoryResolver() { @Override @@ -481,11 +486,6 @@ public String getHistoryToken() { } }; - @UiHandler("buttonApplyToAll") - void buttonApplyToAllHandler(ClickEvent e) { - apply(true); - } - @UiHandler("buttonClose") void buttonCancelHandler(ClickEvent e) { if (objectId != null) { @@ -659,25 +659,34 @@ public void resolve(List historyTokens, final AsyncCallback call }); } else if (historyTokens.isEmpty()) { LastSelectedItemsSingleton selectedItems = LastSelectedItemsSingleton.getInstance(); - final SelectedItems selected = (SelectedItems) selectedItems.getSelectedItems(); - if (!ClientSelectedItemsUtils.isEmpty(selected)) { - BrowserService.Util.getInstance().retrieve(IndexedDIP.class.getName(), selected, - RodaConstants.DIP_PERMISSIONS_FIELDS_TO_RETURN, new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - HistoryUtils.newHistory(BrowseTop.RESOLVER); - callback.onSuccess(null); - } - - @Override - public void onSuccess(List dips) { - List hasPermissionsObjects = dips; - EditPermissions edit = new EditPermissions(IndexedDIP.class.getName(), selected, hasPermissionsObjects); - callback.onSuccess(edit); - } - }); + SelectedItems selected = selectedItems.getSelectedItems(); + if (selected instanceof SelectedItemsList) { + if (!ClientSelectedItemsUtils.isEmpty(selected)) { + List ids = ((SelectedItemsList) selected).getIds(); + List collect = ids.stream() + .map(m -> new SimpleFilterParameter(RodaConstants.INDEX_UUID, m)).collect(Collectors.toList()); + OrFiltersParameters orFiltersParameters = new OrFiltersParameters(collect); + FindRequest findRequest = FindRequest + .getBuilder(IndexedAIP.class.getName(), new Filter(orFiltersParameters), true) + .withSublist(new Sublist(0, 20)).build(); + Services services = new Services("Find DIPs", "get"); + services.aipResource(s -> s.find(findRequest, LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((result, throwable) -> { + if (throwable != null) { + HistoryUtils.newHistory(BrowseTop.RESOLVER); + callback.onFailure(throwable); + } else { + List hasPermissionsObjects = result.getResults(); + EditPermissions edit = new EditPermissions(IndexedDIP.class.getName(), + (SelectedItems) selectedItems.getSelectedItems(), hasPermissionsObjects); + callback.onSuccess(edit); + } + }); + } + } else { + EditPermissions editPermissions = new EditPermissions(IndexedDIP.class.getName(), selected); + callback.onSuccess(editPermissions); } } else { HistoryUtils.newHistory(BrowseTop.RESOLVER); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/server/browse/BrowserServiceImpl.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/server/browse/BrowserServiceImpl.java index 005632079a..67894d5de8 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/server/browse/BrowserServiceImpl.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/server/browse/BrowserServiceImpl.java @@ -129,15 +129,6 @@ public DescriptiveMetadataEditBundle retrieveDescriptiveMetadataEditBundle(Strin return Browser.retrieveDescriptiveMetadataEditBundle(user, aipId, representationId, descId, locale); } - @Override - public List retrieve(String classNameToReturn, SelectedItems selectedItems, - List fieldsToReturn) - throws GenericException, AuthorizationDeniedException, NotFoundException, RequestNotValidException { - User user = UserUtility.getUser(getThreadLocalRequest()); - Class classToReturn = SelectedItemsUtils.parseClass(classNameToReturn); - return Browser.retrieve(user, classToReturn, selectedItems, fieldsToReturn); - } - @Override public Job moveAIPInHierarchy(SelectedItems selected, String parentId, String details) throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException { @@ -357,13 +348,6 @@ public void deleteDistributedInstance(String distributedInstanceId) RODAInstance.deleteDistributedInstance(user, distributedInstanceId); } - @Override - public AccessKey createAccessKey(AccessKey accessKey) throws AuthorizationDeniedException, AlreadyExistsException, - NotFoundException, GenericException, RequestNotValidException, IOException { - User user = UserUtility.getUser(getThreadLocalRequest()); - return ApplicationAuth.createAccessKey(user, accessKey); - } - @Override public AccessKeys listAccessKey() throws AuthorizationDeniedException, IOException, GenericException, RequestNotValidException { @@ -378,55 +362,6 @@ public AccessKey retrieveAccessKey(String accessKeyId) return ApplicationAuth.retrieveAccessKey(user, accessKeyId); } - @Override - public AccessKey updateAccessKey(AccessKey accessKey) - throws AuthorizationDeniedException, RequestNotValidException, NotFoundException, GenericException { - User user = UserUtility.getUser(getThreadLocalRequest()); - return ApplicationAuth.updateAccessKey(user, accessKey); - } - - @Override - public void deleteAccessKey(String accessKeyId) - throws NotFoundException, GenericException, AuthorizationDeniedException, RequestNotValidException { - User user = UserUtility.getUser(getThreadLocalRequest()); - ApplicationAuth.deleteAccessKey(user, accessKeyId); - } - - @Override - public AccessKeys listAccessKeyByUser(String userId) - throws AuthorizationDeniedException, IOException, GenericException, RequestNotValidException { - User user = UserUtility.getUser(getThreadLocalRequest()); - return ApplicationAuth.listAccessKeyByUser(user, userId); - } - - @Override - public void deactivateUserAccessKeys(String userId) - throws AuthorizationDeniedException, RequestNotValidException, GenericException, NotFoundException { - User user = UserUtility.getUser(getThreadLocalRequest()); - ApplicationAuth.deactivateUserAccessKeys(user, userId); - } - - @Override - public void deleteUserAccessKeys(String userId) - throws AuthorizationDeniedException, RequestNotValidException, GenericException, NotFoundException { - User user = UserUtility.getUser(getThreadLocalRequest()); - ApplicationAuth.deleteUserAccessKeys(user, userId); - } - - @Override - public AccessKey regenerateAccessKey(AccessKey accessKey) throws AuthorizationDeniedException, - RequestNotValidException, NotFoundException, GenericException, AuthenticationDeniedException { - User user = UserUtility.getUser(getThreadLocalRequest()); - return ApplicationAuth.regenerateAccessKey(user, accessKey); - } - - @Override - public AccessKey revokeAccessKey(AccessKey accessKey) - throws AuthorizationDeniedException, RequestNotValidException, NotFoundException, GenericException { - User user = UserUtility.getUser(getThreadLocalRequest()); - return ApplicationAuth.revokeAccessKey(user, accessKey); - } - @Override public void createLocalInstance(LocalInstance localInstance) throws AuthorizationDeniedException, GenericException { User user = UserUtility.getUser(getThreadLocalRequest());