Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions DEV_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ Follow the official documentation page: <https://docs.github.com/en/authenticati
## Debug WUI

```bash
# If never GWT compiled before, compile once and copy gwt.rpc files
# If never GWT compiled before, compile once
mvn -pl roda-ui/roda-wui -am gwt:compile -Pdebug-main -Dscope.gwt-dev=compile
./roda-ui/roda-wui/copy_gwt_rpc.sh

mvn install -Pcore -DskipTests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ public enum RODA_TYPE {
public static final String PERMISSION_METHOD_FIND_RISK = "org.roda.wui.api.v2.services.IndexService.find(IndexedRisk)";

public static final String PERMISSION_METHOD_DELETE_AIP = "org.roda.wui.api.v2.controller.AIPController.deleteAIPs";
public static final String PERMISSION_METHOD_DELETE_DIP = "org.roda.wui.api.v2.controller.DIPController.deleteIndexedDIPs";
public static final String PERMISSION_METHOD_DELETE_DIP = "org.roda.wui.api.v2.controller.DIPController.deleteDIPs";
public static final String PERMISSION_METHOD_DELETE_REPRESENTATION = "org.roda.wui.api.v2.controller.RepresentationController.deleteRepresentation";
public static final String PERMISSION_METHOD_DELETE_FILE = "org.roda.wui.api.v2.controller.FilesController.deleteFiles";
public static final String PERMISSION_METHOD_DELETE_REPRESENTATION_INFORMATION = "org.roda.wui.api.v2.controller.RepresentationInformationController.deleteMultipleRepresentationInformation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ core.permissions.org.roda.wui.api.v2.controller.RepresentationController.retriev
# DIP permissions
core.permissions.org.roda.wui.api.v2.controller.DIPController.downloadBinary = READ
core.permissions.org.roda.wui.api.v2.controller.DIPController.updatePermissions = GRANT
core.permissions.org.roda.wui.api.v2.controller.DIPController.deleteDIPs = DELETE

# File permissions
core.permissions.org.roda.wui.api.v2.controller.FilesController.downloadBinary = READ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ core.roles.org.roda.wui.api.v2.controller.PreservationEventController.getPreserv
core.roles.org.roda.wui.api.v2.controller.PreservationAgentController.downloadPreservationAgent = preservation_metadata.read

# DIP roles
core.roles.org.roda.wui.api.v2.controller.DIPController.deleteIndexedDIPs = aip.delete
core.roles.org.roda.wui.api.v2.controller.DIPController.deleteDIPs = aip.delete
core.roles.org.roda.wui.api.v2.controller.DIPController.downloadBinary = aip.read
core.roles.org.roda.wui.api.v2.controller.DIPController.updatePermissions = aip.update

Expand Down
9 changes: 0 additions & 9 deletions roda-ui/roda-wui/copy_gwt_rpc.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public ResponseEntity<StreamingResponseBody> process(RequestContext requestConte
}

@Override
public Job deleteIndexedDIPs(@RequestBody DeleteRequest deleteRequest) {
public Job deleteDIPs(@RequestBody DeleteRequest deleteRequest) {
return requestHandler.processRequestWithTransaction(new RequestHandler.RequestProcessor<Job>() {
@Override
public Job process(RequestContext requestContext, RequestControllerAssistant controllerAssistant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public ResponseEntity<StreamingResponseBody> process(RequestContext requestConte
RequestControllerAssistant controllerAssistant) throws RODAException, RESTException {
List<String> fileFields = new ArrayList<>(RodaConstants.DIPFILE_FIELDS_TO_RETURN);
DIPFile dipFile = requestContext.getIndexService().retrieve(DIPFile.class, dipFileUUID, fileFields);
controllerAssistant.setRelatedObjectId(dipFile.getDipId());
controllerAssistant.setParameters(RodaConstants.CONTROLLER_DIP_FILE_ID_PARAM, dipFile.getId(),
RodaConstants.CONTROLLER_DIP_FILE_UUID_PARAM, dipFileUUID);
return ApiUtils.okResponse(dipFileService.retrieveDIPFileStreamResponse(requestContext, dipFile));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@ public ResponseEntity<StreamingResponseBody> downloadBinary(
@Override
public ResponseEntity<StreamingResponseBody> process(RequestContext requestContext,
RequestControllerAssistant controllerAssistant) throws RODAException, RESTException {
controllerAssistant.setRelatedObjectId(fileUUID);
controllerAssistant.setParameters(RodaConstants.CONTROLLER_FILE_UUID_PARAM, fileUUID);
List<String> fileFields = new ArrayList<>(RodaConstants.FILE_FIELDS_TO_RETURN);
fileFields.add(RodaConstants.FILE_ISDIRECTORY);
IndexedFile file = indexService.retrieve(IndexedFile.class, fileUUID, fileFields);
controllerAssistant.setRelatedObjectId(file.getAipId());
controllerAssistant.setParameters(RodaConstants.CONTROLLER_FILE_UUID_PARAM, fileUUID, RodaConstants.CONTROLLER_FILE_ID_PARAM, file.getId());

controllerAssistant.checkObjectPermissions(requestContext.getUser(), file);

StreamResponse response = filesService.retrieveAIPRepresentationFile(requestContext, file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;

Expand All @@ -37,9 +38,7 @@
import org.roda.core.data.v2.ip.RepresentationLink;
import org.roda.wui.client.browse.tabs.BrowseDIPTabs;
import org.roda.wui.client.common.ActionsToolbar;
import org.roda.wui.client.common.BrowseDIPActionsToolbar;
import org.roda.wui.client.common.BrowseDIPFileActionsToolbar;
import org.roda.wui.client.common.BrowseObjectActionsToolbar;
import org.roda.wui.client.common.BrowseDIPContentActionsToolbar;
import org.roda.wui.client.common.NavigationToolbar;
import org.roda.wui.client.common.NoAsyncCallback;
import org.roda.wui.client.common.UserLogin;
Expand All @@ -49,6 +48,7 @@
import org.roda.wui.client.common.utils.JavascriptUtils;
import org.roda.wui.client.services.ConfigurationRestService;
import org.roda.wui.client.services.Services;
import org.roda.wui.common.client.ClientLogger;
import org.roda.wui.common.client.HistoryResolver;
import org.roda.wui.common.client.tools.HistoryUtils;
import org.roda.wui.common.client.tools.ListUtils;
Expand Down Expand Up @@ -77,6 +77,7 @@ public class BrowseDIP extends Composite {

public static final Sorter DEFAULT_DIPFILE_SORTER = new Sorter(new SortParameter(RodaConstants.DIPFILE_ID, false));
private static final ClientMessages messages = GWT.create(ClientMessages.class);
private static final ClientLogger logger = new ClientLogger(BrowseDIP.class.getName());
public static final HistoryResolver RESOLVER = new HistoryResolver() {

@Override
Expand Down Expand Up @@ -169,14 +170,22 @@ private void applyWhenIndexedAIP(Services services, String historyDipUUID, Strin
return response;
}).whenComplete((response, throwable1) -> {
if (response.getDipFile() != null) {
List<CompletableFuture<DIPFile>> dipFileAncestors = response.getDipFile().getAncestorsUUIDs().stream()
.map(m -> services.dipFileResource(s -> s.findByUuid(m, LocaleInfo.getCurrentLocale().getLocaleName())))
List<CompletableFuture<Optional<DIPFile>>> dipFileAncestors = response.getDipFile().getAncestorsUUIDs()
.stream()
.map(
uuid -> services.dipFileResource(s -> s.findByUuid(uuid, LocaleInfo.getCurrentLocale().getLocaleName()))
.handle((file, e) -> {
if (e != null) {
logger.warn("Failed to retrieve DIP file for DIP ID " + uuid + ": " + e.getMessage());
return Optional.<DIPFile> empty();
} else
return Optional.ofNullable(file);
}))
.collect(Collectors.toList());
CompletableFuture<?>[] futuresArray = dipFileAncestors.toArray(new CompletableFuture<?>[0]);
CompletableFuture.allOf(futuresArray).thenApply(v -> {
for (CompletableFuture<DIPFile> dipFileAncestor : dipFileAncestors) {
DIPFile file = dipFileAncestor.join();
response.getDipFileAncestors().add(file);
for (CompletableFuture<Optional<DIPFile>> dipFileAncestor : dipFileAncestors) {
dipFileAncestor.join().ifPresent(response.getDipFileAncestors()::add);
}
return response;
}).whenComplete((o, throwable) -> render(o, viewers, callback, services));
Expand Down Expand Up @@ -243,13 +252,21 @@ private void applyWhenIndexedRepresentation(Services services, String historyDip
}).whenComplete((response, throwable1) -> {
if (response.getDipFile() != null) {
List<CompletableFuture<DIPFile>> dipFileAncestors = response.getDipFile().getAncestorsUUIDs().stream()
.map(m -> services.dipFileResource(s -> s.findByUuid(m, LocaleInfo.getCurrentLocale().getLocaleName())))
.map(
uuid -> services.dipFileResource(s -> s.findByUuid(uuid, LocaleInfo.getCurrentLocale().getLocaleName()))
.handle((file, e) -> {
if (e != null)
return null;
else
return file;
}))
.collect(Collectors.toList());
CompletableFuture<?>[] futuresArray = dipFileAncestors.toArray(new CompletableFuture<?>[0]);
CompletableFuture.allOf(futuresArray).thenApply(v -> {
for (CompletableFuture<DIPFile> dipFileAncestor : dipFileAncestors) {
DIPFile file = dipFileAncestor.join();
response.getDipFileAncestors().add(file);
if (file != null)
response.getDipFileAncestors().add(file);
}
return response;
}).whenComplete((o, throwable) -> render(o, viewers, callback, services));
Expand Down Expand Up @@ -306,13 +323,22 @@ private void applyWhenIndexedFile(Services services, String historyDipUUID, Stri
}).whenComplete((response, throwable1) -> {
if (response.getDipFile() != null) {
List<CompletableFuture<DIPFile>> dipFileAncestors = response.getDipFile().getAncestorsUUIDs().stream()
.map(m -> services.dipFileResource(s -> s.findByUuid(m, LocaleInfo.getCurrentLocale().getLocaleName())))
.map(
uuid -> services.dipFileResource(s -> s.findByUuid(uuid, LocaleInfo.getCurrentLocale().getLocaleName()))
.handle((file, e) -> {
if (e != null)
return null;
else
return file;
}))
.collect(Collectors.toList());

CompletableFuture<?>[] futuresArray = dipFileAncestors.toArray(new CompletableFuture<?>[0]);
CompletableFuture.allOf(futuresArray).thenApply(v -> {
for (CompletableFuture<DIPFile> dipFileAncestor : dipFileAncestors) {
DIPFile file = dipFileAncestor.join();
response.getDipFileAncestors().add(file);
if (file != null)
response.getDipFileAncestors().add(file);
}
return response;
}).whenComplete((o, throwable) -> render(o, viewers, callback, services));
Expand Down Expand Up @@ -358,34 +384,25 @@ public BrowseDIP(Viewers viewers, BrowseDIPResponse response, Services services)
IndexedDIP dip = response.getDip();
DIPFile dipFile = response.getDipFile();

if (dipFile != null) {
BrowseObjectActionsToolbar<DIPFile> toolbar = new BrowseDIPFileActionsToolbar();
toolbar.setObjectAndBuild(dipFile, response.getPermissions(), handler);
objectToolbar = toolbar;

} else {
BrowseObjectActionsToolbar<IndexedDIP> toolbar = new BrowseDIPActionsToolbar();
toolbar.setObjectAndBuild(dip, dip.getPermissions(), handler);
objectToolbar = toolbar;
}
BrowseDIPContentActionsToolbar toolbar = new BrowseDIPContentActionsToolbar();
toolbar.setObjectsAndBuild(dip, dipFile, response.getPermissions(), handler);
objectToolbar = toolbar;

initWidget(uiBinder.createAndBindUi(this));

navigationToolbar.withObject(dipFile != null ? dipFile : dip);

handlers.put(Actionable.ActionImpact.DESTROYED, () -> {
if (dipFile == null) {
// dip was removed
if (!dip.getFileIds().isEmpty()) {
FileLink link = dip.getFileIds().get(0);
HistoryUtils.openBrowse(link.getAipId(), link.getRepresentationId(), link.getPath(), link.getFileId());
} else if (!dip.getRepresentationIds().isEmpty()) {
RepresentationLink link = dip.getRepresentationIds().get(0);
HistoryUtils.openBrowse(link.getAipId(), link.getRepresentationId());
} else if (!dip.getAipIds().isEmpty()) {
AIPLink link = dip.getAipIds().get(0);
HistoryUtils.openBrowse(link.getAipId());
}
// dip was removed
if (!dip.getAipIds().isEmpty()) {
AIPLink link = dip.getAipIds().get(0);
HistoryUtils.openBrowse(link.getAipId());
} else if (!dip.getRepresentationIds().isEmpty()) {
RepresentationLink link = dip.getRepresentationIds().get(0);
HistoryUtils.openBrowse(link.getAipId());
} else if (!dip.getFileIds().isEmpty()) {
AIPLink link = dip.getFileIds().get(0);
HistoryUtils.openBrowse(link.getAipId());
}
});

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.roda.wui.client.common;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.SimplePanel;
import org.roda.core.data.common.RodaConstants;
import org.roda.core.data.v2.ip.DIPFile;
import org.roda.core.data.v2.ip.IndexedDIP;
import org.roda.core.data.v2.ip.Permissions;
import org.roda.wui.client.common.actions.Actionable;
import org.roda.wui.client.common.actions.DisseminationActions;
import org.roda.wui.client.common.actions.DisseminationFileActions;
import org.roda.wui.client.common.actions.model.ActionableObject;
import org.roda.wui.client.common.actions.widgets.ActionableWidgetBuilder;
import org.roda.wui.common.client.tools.ConfigurationManager;

import java.util.ArrayList;
import java.util.List;

/**
*
* @author Eduardo Teixeira <[email protected]>
*/
public class BrowseDIPContentActionsToolbar extends ActionsToolbar {
protected IndexedDIP dip;
protected DIPFile dipFile;
protected Permissions dipPermissions;
protected AsyncCallback<Actionable.ActionImpact> actionCallback;

public void setObjectsAndBuild(IndexedDIP dip, DIPFile dipFile, Permissions permissions,
AsyncCallback<Actionable.ActionImpact> actionCallback) {
this.dip = dip;
this.dipFile = dipFile;
this.dipPermissions = permissions;
this.actionCallback = actionCallback;

buildIcon();
buildTags();
buildActions();
}

public void buildActions() {
this.actions.clear();
List<Actionable.Action<IndexedDIP>> actionsToshow = new ArrayList<>();
DisseminationActions dipActions = DisseminationActions.get(this.dipPermissions);
if(this.dipFile != null) {
DisseminationFileActions dipFileActions = DisseminationFileActions.get(this.dipPermissions);
this.actions.add(new ActionableWidgetBuilder<DIPFile>(dipFileActions).withActionCallback(this.actionCallback)
.buildGroupedListWithObjects(new ActionableObject<>(this.dipFile), java.util.Collections.emptyList(),
List.of(DisseminationFileActions.DisseminationFileAction.DOWNLOAD)));

actionsToshow.add(DisseminationActions.DisseminationAction.REMOVE);
actionsToshow.add(DisseminationActions.DisseminationAction.NEW_PROCESS);
//keeping ui consistency
SimplePanel divider = new SimplePanel();
divider.addStyleName("verticalDivider");
this.actions.add(divider);

} else {
actionsToshow.add(DisseminationActions.DisseminationAction.DOWNLOAD);
actionsToshow.add(DisseminationActions.DisseminationAction.REMOVE);
actionsToshow.add(DisseminationActions.DisseminationAction.NEW_PROCESS);
}


this.actions.add(new ActionableWidgetBuilder<IndexedDIP>(dipActions).withActionCallback(this.actionCallback)
.buildGroupedListWithObjects(new ActionableObject<>(this.dip), actionsToshow, actionsToshow));

};

public void buildIcon() {
setIcon(ConfigurationManager.getString(RodaConstants.UI_ICONS_CLASS, IndexedDIP.class.getSimpleName()));
}

public void buildTags() {
// do nothing
}

}
Loading
Loading