diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/common/RodaConstants.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/common/RodaConstants.java index 7292791cf4..997d48d160 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/common/RodaConstants.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/common/RodaConstants.java @@ -359,6 +359,9 @@ public enum DateGranularity { // files public static final String API_REST_V2_FILES = "api/v2/files/"; + // dips + public static final String API_REST_V2_DIPS = "api/v2/dips/"; + // representation-information public static final String API_REST_V2_REPRESENTATION_INFORMATION = "api/v2/representation-information/"; @@ -372,6 +375,12 @@ public enum DateGranularity { // members public static final String API_REST_V2_MEMBERS = "api/v2/members/"; + // disposal confirmation + public static final String API_REST_V2_DISPOSAL_CONFIRMATION = "api/v2/disposal/confirmations/"; + public static final String API_REST_V2_DISPOSAL_CONFIRMATION_REPORT = "report"; + public static final String API_REST_V2_DISPOSAL_CONFIRMATION_REPORT_HTML = "html"; + public static final String API_REST_V2_DISPOSAL_CONFIRMATION_QUERY_PARAM_TO_PRINT = "to-print"; + // themes public static final String API_REST_V2_THEME = "api/v2/themes"; public static final String API_V2_QUERY_PARAM_RESOURCE_ID = "resource-id"; @@ -648,6 +657,7 @@ public String toString() { public static final String CONTROLLER_DIP_PARAM = RODA_OBJECT_DIP; public static final String CONTROLLER_DIPS_PARAM = RODA_OBJECT_DIPS; public static final String CONTROLLER_DIP_ID_PARAM = "dipId"; + public static final String CONTROLLER_DIP_UUID_PARAM = "dipUUID"; public static final String CONTROLLER_DIP_FILE_ID_PARAM = "dipFileId"; public static final String CONTROLLER_DIP_FILE_UUID_PARAM = "dipFileUUID"; public static final String CONTROLLER_AGENT_ID_PARAM = "agentId"; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/disposal/confirmation/DisposalConfirmationCreateRequest.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/disposal/confirmation/DisposalConfirmationCreateRequest.java index b387cf1cb0..73d31f6381 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/disposal/confirmation/DisposalConfirmationCreateRequest.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/disposal/confirmation/DisposalConfirmationCreateRequest.java @@ -3,6 +3,7 @@ import org.roda.core.data.v2.index.select.SelectedItems; import org.roda.core.data.v2.ip.IndexedAIP; +import java.io.Serial; import java.io.Serializable; /** @@ -10,12 +11,19 @@ */ public class DisposalConfirmationCreateRequest implements Serializable { + @Serial + private static final long serialVersionUID = -3852472973580068030L; + private String title; private SelectedItems selectedItems; private DisposalConfirmationForm form; + public DisposalConfirmationCreateRequest() { + // empty constructor + } + public DisposalConfirmationCreateRequest(String title, SelectedItems selectedItems, - DisposalConfirmationForm form) { + DisposalConfirmationForm form) { this.title = title; this.selectedItems = selectedItems; this.form = form; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/file/DeleteFilesRequest.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/file/DeleteFilesRequest.java deleted file mode 100644 index c7d81e4401..0000000000 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/file/DeleteFilesRequest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.roda.core.data.v2.file; - -import org.roda.core.data.v2.index.select.SelectedItems; -import org.roda.core.data.v2.ip.IndexedFile; - -import java.io.Serial; -import java.io.Serializable; - -/** - * @author Miguel Guimarães - */ -public class DeleteFilesRequest implements Serializable { - @Serial - private static final long serialVersionUID = -6900617582311532828L; - - private SelectedItems itemsToDelete; - private String details; - - public DeleteFilesRequest() { - //empty constructor - } - - public SelectedItems getItemsToDelete() { - return itemsToDelete; - } - - public void setItemsToDelete(SelectedItems itemsToDelete) { - this.itemsToDelete = itemsToDelete; - } - - public String getDetails() { - return details; - } - - public void setDetails(String details) { - this.details = details; - } -} diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/generics/DeleteRequest.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/generics/DeleteRequest.java new file mode 100644 index 0000000000..e59da3d1ca --- /dev/null +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/generics/DeleteRequest.java @@ -0,0 +1,41 @@ +package org.roda.core.data.v2.generics; + +/** + * @author Miguel Guimarães + */ + +import org.roda.core.data.v2.index.IsIndexed; +import org.roda.core.data.v2.index.select.SelectedItems; + +import java.io.Serial; +import java.io.Serializable; + + +public class DeleteRequest implements Serializable { + + @Serial + private static final long serialVersionUID = -6600408657058206155L; + + private SelectedItems itemsToDelete; + private String details; + + public DeleteRequest() { + // empty constructor + } + + public SelectedItems getItemsToDelete() { + return itemsToDelete; + } + + public void setItemsToDelete(SelectedItems itemsToDelete) { + this.itemsToDelete = itemsToDelete; + } + + public String getDetails() { + return details; + } + + public void setDetails(String details) { + this.details = details; + } +} diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/generics/UpdatePermissionsRequest.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/generics/UpdatePermissionsRequest.java new file mode 100644 index 0000000000..a75df5a861 --- /dev/null +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/generics/UpdatePermissionsRequest.java @@ -0,0 +1,57 @@ +package org.roda.core.data.v2.generics; + +import java.io.Serial; +import java.io.Serializable; + +import org.roda.core.data.v2.index.IsIndexed; +import org.roda.core.data.v2.index.select.SelectedItems; +import org.roda.core.data.v2.ip.Permissions; + +/** + * @author Miguel Guimarães + */ +public class UpdatePermissionsRequest implements Serializable { + @Serial + private static final long serialVersionUID = -3807428982711600007L; + + private SelectedItems itemsToUpdate; + private String details; + private Permissions permissions; + private boolean recursive; + + public UpdatePermissionsRequest() { + // empty constructor + } + + public SelectedItems getItemsToUpdate() { + return itemsToUpdate; + } + + public void setItemsToUpdate(SelectedItems itemsToUpdate) { + this.itemsToUpdate = itemsToUpdate; + } + + public String getDetails() { + return details; + } + + public void setDetails(String details) { + this.details = details; + } + + public Permissions getPermissions() { + return permissions; + } + + public void setPermissions(Permissions permissions) { + this.permissions = permissions; + } + + public boolean isRecursive() { + return recursive; + } + + public void setRecursive(boolean recursive) { + this.recursive = recursive; + } +} diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/FiltersParameters.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/FiltersParameters.java index fb0dd4af2c..fd34849970 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/FiltersParameters.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/FiltersParameters.java @@ -7,9 +7,11 @@ */ package org.roda.core.data.v2.index.filter; +import java.io.Serial; import java.util.List; public abstract class FiltersParameters extends FilterParameter { + @Serial private static final long serialVersionUID = -7444113772637341849L; private List values = null; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/OrFiltersParameters.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/OrFiltersParameters.java index 857b861a85..4a967ff65c 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/OrFiltersParameters.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/OrFiltersParameters.java @@ -7,9 +7,11 @@ */ package org.roda.core.data.v2.index.filter; +import java.io.Serial; import java.util.List; public class OrFiltersParameters extends FiltersParameters { + @Serial private static final long serialVersionUID = -7444113772637341849L; /** diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/RangeFilterParameter.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/RangeFilterParameter.java index a15df24851..808e36fd8a 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/RangeFilterParameter.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/RangeFilterParameter.java @@ -7,6 +7,7 @@ */ package org.roda.core.data.v2.index.filter; +import java.io.Serial; import java.io.Serializable; /** @@ -14,6 +15,7 @@ * @author Luis Faria */ public abstract class RangeFilterParameter extends FilterParameter { + @Serial private static final long serialVersionUID = -2923383960685420739L; private T fromValue; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/SimpleFilterParameter.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/SimpleFilterParameter.java index a81ed5639c..5cf6a4a828 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/SimpleFilterParameter.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/index/filter/SimpleFilterParameter.java @@ -7,11 +7,14 @@ */ package org.roda.core.data.v2.index.filter; +import java.io.Serial; + /** * @author Rui Castro * */ public class SimpleFilterParameter extends FilterParameter { + @Serial private static final long serialVersionUID = -2122986808484304112L; private String value; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/AIP.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/AIP.java index 249d967421..722687bae7 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/AIP.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/AIP.java @@ -7,6 +7,7 @@ */ package org.roda.core.data.v2.ip; +import java.io.Serial; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -27,6 +28,7 @@ @JsonInclude(JsonInclude.Include.NON_NULL) public class AIP implements IsModelObject, HasId, HasState, HasPermissions, HasDisposal, HasInstanceID { + @Serial private static final long serialVersionUID = 430629679119752757L; private static final int VERSION = 1; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/AIPLink.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/AIPLink.java index 08b00cdd67..5028d49402 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/AIPLink.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/AIPLink.java @@ -7,9 +7,12 @@ */ package org.roda.core.data.v2.ip; +import java.io.Serial; import java.io.Serializable; public class AIPLink implements Serializable { + + @Serial private static final long serialVersionUID = 6222816570283361558L; private String aipId; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/DIP.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/DIP.java index 25f77ee189..959bcb4781 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/DIP.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/DIP.java @@ -7,6 +7,7 @@ */ package org.roda.core.data.v2.ip; +import java.io.Serial; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -24,6 +25,7 @@ @JsonInclude(JsonInclude.Include.NON_NULL) public class DIP implements IsModelObject, HasId, HasPermissions, HasInstanceID { + @Serial private static final long serialVersionUID = -7335470043357396783L; private static final int VERSION = 1; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/DIPFile.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/DIPFile.java index 67380c8c47..c401db6cb7 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/DIPFile.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/DIPFile.java @@ -7,6 +7,7 @@ */ package org.roda.core.data.v2.ip; +import java.io.Serial; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -23,6 +24,7 @@ @jakarta.xml.bind.annotation.XmlRootElement(name = RodaConstants.RODA_OBJECT_DIPFILE) public class DIPFile implements IsModelObject, IsIndexed, HasId, SetsUUID, HasPermissionFilters { + @Serial private static final long serialVersionUID = 1L; private static final int VERSION = 1; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/IndexedAIP.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/IndexedAIP.java index 437ffe75b4..436c800d3e 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/IndexedAIP.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/IndexedAIP.java @@ -43,9 +43,11 @@ public class IndexedAIP private AIPState state; private String type = null; - private String instanceId = null; + private String instanceId = null; private String instanceName = null; + private boolean isLocalInstance = false; + private String level = null; private String title = null; private Date dateInitial = null; @@ -563,7 +565,7 @@ public AIPDisposalScheduleAssociationType getScheduleAssociationType() { return scheduleAssociationType; } - public IndexedAIP setDisposalScheduleAssociationType(AIPDisposalScheduleAssociationType scheduleAssociationType) { + public IndexedAIP setScheduleAssociationType(AIPDisposalScheduleAssociationType scheduleAssociationType) { this.scheduleAssociationType = scheduleAssociationType; return this; } @@ -772,4 +774,12 @@ public String getInstanceName() { public void setInstanceName(String instanceName) { this.instanceName = instanceName; } + + public boolean isLocalInstance() { + return isLocalInstance; + } + + public void setLocalInstance(boolean localInstance) { + isLocalInstance = localInstance; + } } diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/IndexedDIP.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/IndexedDIP.java index 962d88e867..4b6e686c36 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/IndexedDIP.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/IndexedDIP.java @@ -7,6 +7,7 @@ */ package org.roda.core.data.v2.ip; +import java.io.Serial; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -20,8 +21,10 @@ @jakarta.xml.bind.annotation.XmlRootElement(name = RodaConstants.RODA_OBJECT_DIP) @JsonInclude(JsonInclude.Include.NON_NULL) public class IndexedDIP extends DIP implements IsIndexed, HasInstanceName { + + @Serial private static final long serialVersionUID = 4188689893034771594L; - private String openExternalURL = ""; + private String openExternalURL = null; private String instanceName = null; private Map fields; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/RepresentationLink.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/RepresentationLink.java index 7740e2b8be..3ea6444254 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/RepresentationLink.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/ip/RepresentationLink.java @@ -7,10 +7,12 @@ */ package org.roda.core.data.v2.ip; +import java.io.Serial; import java.io.Serializable; public class RepresentationLink extends AIPLink implements Serializable { + @Serial private static final long serialVersionUID = -1203642066028643508L; private String representationId; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/common/ConversionProfile.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ConversionProfile.java similarity index 97% rename from roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/common/ConversionProfile.java rename to roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ConversionProfile.java index 25459829b4..1094705ab2 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/common/ConversionProfile.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ConversionProfile.java @@ -5,7 +5,7 @@ * * https://github.com/keeps/roda */ -package org.roda.core.data.v2.common; +package org.roda.core.data.v2.properties; import java.io.Serial; import java.io.Serializable; @@ -16,8 +16,10 @@ * @author António Lindo */ public class ConversionProfile implements Serializable { + @Serial private static final long serialVersionUID = -117396300862413045L; + private String title; private String profile; private String description; diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ConversionProfileOutcomeType.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ConversionProfileOutcomeType.java new file mode 100644 index 0000000000..745ca63e34 --- /dev/null +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ConversionProfileOutcomeType.java @@ -0,0 +1,9 @@ +package org.roda.core.data.v2.properties; + +/** + * @author Miguel Guimarães + */ +public enum ConversionProfileOutcomeType { + + REPRESENTATION, DISSEMINATION +} diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ConversionProfiles.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ConversionProfiles.java new file mode 100644 index 0000000000..8da00e718c --- /dev/null +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ConversionProfiles.java @@ -0,0 +1,36 @@ +package org.roda.core.data.v2.properties; + +import java.io.Serial; +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Miguel Guimarães + */ +public class ConversionProfiles implements Serializable { + @Serial + private static final long serialVersionUID = -4673854066618821461L; + + private Set conversionProfileSet; + + public ConversionProfiles() { + conversionProfileSet = new HashSet<>(); + } + + public Set getConversionProfileSet() { + return conversionProfileSet; + } + + public void setConversionProfileSet(Set conversionProfileSet) { + this.conversionProfileSet = conversionProfileSet; + } + + public boolean addObject(ConversionProfile item) { + return this.conversionProfileSet.add(item); + } + + public boolean addObjects(Set list) { + return this.conversionProfileSet.addAll(list); + } +} diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/DropdownPluginParameterItem.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/DropdownPluginParameterItem.java new file mode 100644 index 0000000000..55eba0d601 --- /dev/null +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/DropdownPluginParameterItem.java @@ -0,0 +1,40 @@ +package org.roda.core.data.v2.properties; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author Miguel Guimarães + */ +public class DropdownPluginParameterItem implements Serializable { + @Serial + private static final long serialVersionUID = -1886414999985024868L; + + private String id; + private String label; + + public DropdownPluginParameterItem(String id, String label) { + this.id = id; + this.label = label; + } + + public DropdownPluginParameterItem() { + // empty constructor + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } +} diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/DropdownPluginParameterItems.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/DropdownPluginParameterItems.java new file mode 100644 index 0000000000..b2eed7a752 --- /dev/null +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/DropdownPluginParameterItems.java @@ -0,0 +1,38 @@ +package org.roda.core.data.v2.properties; + +import java.io.Serial; +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import java.util.TreeSet; + +/** + * @author Miguel Guimarães + */ +public class DropdownPluginParameterItems implements Serializable { + + @Serial + private static final long serialVersionUID = 7674597493405842939L; + + private Set items; + + public DropdownPluginParameterItems() { + items = new HashSet<>(); + } + + public Set getItems() { + return items; + } + + public void setItems(Set items) { + this.items = items; + } + + public boolean addObject(DropdownPluginParameterItem item) { + return this.items.add(item); + } + + public boolean addObjects(Set list) { + return this.items.addAll(list); + } +} diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ReindexPluginObjects.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ReindexPluginObjects.java index e31a954275..35cf15fb0b 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ReindexPluginObjects.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/properties/ReindexPluginObjects.java @@ -2,6 +2,7 @@ import java.io.Serial; import java.io.Serializable; +import java.util.HashSet; import java.util.Set; /** @@ -15,7 +16,7 @@ public class ReindexPluginObjects implements Serializable { private Set pluginsObjects; public ReindexPluginObjects() { - // empty constructor + pluginsObjects = new HashSet<>(); } public ReindexPluginObjects(Set pluginsObjects) { diff --git a/roda-core/roda-core/src/main/java/org/roda/core/index/schema/collections/AIPCollection.java b/roda-core/roda-core/src/main/java/org/roda/core/index/schema/collections/AIPCollection.java index 1779cebcd4..8eb8d07293 100644 --- a/roda-core/roda-core/src/main/java/org/roda/core/index/schema/collections/AIPCollection.java +++ b/roda-core/roda-core/src/main/java/org/roda/core/index/schema/collections/AIPCollection.java @@ -393,7 +393,7 @@ public IndexedAIP fromSolrDocument(SolrDocument doc, List fieldsToReturn ret.setOverdueDate(overdueDate); ret.setOnHold(disposalHoldStatus); ret.setDisposalConfirmationId(disposalConfirmationId); - ret.setDisposalScheduleAssociationType(aipDisposalScheduleAssociationType); + ret.setScheduleAssociationType(aipDisposalScheduleAssociationType); return ret; } diff --git a/roda-core/roda-core/src/main/resources/config/roda-core.properties b/roda-core/roda-core/src/main/resources/config/roda-core.properties index 5d6aa2b52a..aa12984c2f 100644 --- a/roda-core/roda-core/src/main/resources/config/roda-core.properties +++ b/roda-core/roda-core/src/main/resources/config/roda-core.properties @@ -570,7 +570,7 @@ core.user_registration.disabled = false # Plugins certificates setting # ########################################################################## -# core.plugins.external.certificates.opt-in = true +core.plugins.external.certificates.opt-in = true # core.plugins.external.certificates.custom.truststore.enable = false # core.plugins.external.certificates.custom.truststore.type = PKCS12 # core.plugins.external.certificates.custom.truststore.name = custom-truststore.p12 diff --git a/roda-core/roda-core/src/main/resources/config/roda-permissions.properties b/roda-core/roda-core/src/main/resources/config/roda-permissions.properties index f47c79f92f..b77353e950 100644 --- a/roda-core/roda-core/src/main/resources/config/roda-permissions.properties +++ b/roda-core/roda-core/src/main/resources/config/roda-permissions.properties @@ -26,7 +26,11 @@ core.permissions.org.roda.wui.api.v2.controller.RepresentationController.changeR core.permissions.org.roda.wui.api.v2.controller.RepresentationController.deleteRepresentation = DELETE core.permissions.org.roda.wui.api.v2.controller.RepresentationController.getRepresentationBinary = READ core.permissions.org.roda.wui.api.v2.controller.RepresentationController.getRepresentationOtherMetadataBinary = READ -core.permissions.org.roda.wui.api.v2.controller.RepresentationController.retrieveIndexedRepresentation = READ +core.permissions.org.roda.wui.api.v2.controller.RepresentationController.retrieveIndexedRepresentationViaRequest = READ + +# DIP permissions +core.permissions.org.roda.wui.api.v2.controller.DIPController.downloadBinary = READ +core.permissions.org.roda.wui.api.v2.controller.DIPController.updatePermissions = GRANT # File permissions core.permissions.org.roda.wui.api.v2.controller.FilesController.downloadBinary = READ @@ -46,6 +50,8 @@ core.permissions.org.roda.wui.api.v2.services.IndexService.retrieve(IndexedAIP) core.permissions.org.roda.wui.api.v2.services.IndexService.retrieve(IndexedRepresentation) = READ core.permissions.org.roda.wui.api.v2.services.IndexService.retrieve(IndexedFile) = READ core.permissions.org.roda.wui.api.v2.services.IndexService.retrieve(IndexedPreservationEvent) = READ +core.permissions.org.roda.wui.api.v2.services.IndexService.retrieve(IndexedDIP) = READ +core.permissions.org.roda.wui.api.v2.services.IndexService.retrieve(DIPFile) = READ # Old permissions - deprecated - and soon to be deleted core.permissions.org.roda.wui.api.controllers.Browser.appraisal = UPDATE diff --git a/roda-core/roda-core/src/main/resources/config/roda-roles.properties b/roda-core/roda-core/src/main/resources/config/roda-roles.properties index f78798398e..a57eb51ef3 100644 --- a/roda-core/roda-core/src/main/resources/config/roda-roles.properties +++ b/roda-core/roda-core/src/main/resources/config/roda-roles.properties @@ -81,6 +81,8 @@ core.roles.org.roda.wui.api.v2.controller.DisposalScheduleController.retrieveDis core.roles.org.roda.wui.api.v2.controller.DisposalScheduleController.createDisposalSchedule = disposal_schedule.manage core.roles.org.roda.wui.api.v2.controller.DisposalScheduleController.updateDisposalSchedule = disposal_schedule.manage core.roles.org.roda.wui.api.v2.controller.DisposalScheduleController.deleteDisposalSchedule = disposal_schedule.manage +core.roles.org.roda.wui.api.v2.controller.DisposalScheduleController.associatedDisposalSchedule = disposal_schedule.associate +core.roles.org.roda.wui.api.v2.controller.DisposalScheduleController.disassociatedDisposalSchedule = disposal_schedule.associate # Disposal hold roles core.roles.org.roda.wui.api.v2.controller.DisposalHoldController.listDisposalHolds = disposal_hold.read @@ -91,9 +93,18 @@ core.roles.org.roda.wui.api.v2.controller.DisposalRuleController.updateDisposalR core.roles.org.roda.wui.api.v2.controller.DisposalHoldController.applyDisposalHold = disposal_hold.apply core.roles.org.roda.wui.api.v2.controller.DisposalHoldController.liftDisposalHoldBySelectedItems = disposal_hold.apply core.roles.org.roda.wui.api.v2.controller.DisposalHoldController.disassociateDisposalHold = disposal_hold.apply +core.roles.org.roda.wui.api.v2.controller.DisposalHoldController.listTransitiveHolds = disposal_hold.read +core.roles.org.roda.wui.api.v2.controller.DisposalHoldController.listDisposalHoldsAssociation = disposal_hold.read # Disposal confirmation roles core.roles.org.roda.wui.api.v2.controller.DisposalConfirmationController.retrieveDisposalConfirmationForm = disposal_confirmation.manage +core.roles.org.roda.wui.api.v2.controller.DisposalConfirmationController.createDisposalConfirmation = disposal_confirmation.manage +core.roles.org.roda.wui.api.v2.controller.DisposalConfirmationController.retrieveDisposalConfirmationReport = disposal_confirmation.manage +core.roles.org.roda.wui.api.v2.controller.DisposalConfirmationController.deleteDisposalConfirmation = disposal_confirmation.manage +core.roles.org.roda.wui.api.v2.controller.DisposalConfirmationController.destroyRecordsInDisposalConfirmation = disposal_confirmation.destroy +core.roles.org.roda.wui.api.v2.controller.DisposalConfirmationController.permanentlyDeleteRecordsInDisposalConfirmation = disposal_confirmation.delete_bin +core.roles.org.roda.wui.api.v2.controller.DisposalConfirmationController.restoreDisposalConfirmation = disposal_confirmation.restore +core.roles.org.roda.wui.api.v2.controller.DisposalConfirmationController.recoverDisposalConfirmation = disposal_confirmation.destroy # Disposal rule roles core.roles.org.roda.wui.api.v2.controller.DisposalRuleController.listDisposalRules = disposal_rule.read @@ -134,7 +145,7 @@ core.roles.org.roda.wui.api.v2.controller.RepresentationController.getRepresenta core.roles.org.roda.wui.api.v2.controller.RepresentationController.createFormatIdentificationJob = representation.update core.roles.org.roda.wui.api.v2.controller.RepresentationController.getRepresentationOtherMetadataBinary = representation.read core.roles.org.roda.wui.api.v2.controller.RepresentationController.getRepresentationTypeOptions = representation.update -core.roles.org.roda.wui.api.v2.controller.RepresentationController.retrieveIndexedRepresentation = representation.read +core.roles.org.roda.wui.api.v2.controller.RepresentationController.retrieveIndexedRepresentationViaRequest = representation.read # Risk incidence roles core.roles.org.roda.wui.api.v2.controller.RiskIncidenceController.deleteRiskIncidences = incidence.manage @@ -155,9 +166,16 @@ core.roles.org.roda.wui.api.v2.controller.AIPController.getAncestors = aip.read core.roles.org.roda.wui.api.v2.controller.AIPController.retrieveRepresentationDescriptiveMetadata = aip.read core.roles.org.roda.wui.api.v2.controller.AIPController.retrieveRepresentationDescriptiveMetadataHTML = aip.read +# DIP roles +core.roles.org.roda.wui.api.v2.controller.DIPController.deleteIndexedDIPs = 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 + # Configuration roles core.roles.org.roda.wui.api.v2.controller.ConfigurationController.retrievePluginsInfo = job.read core.roles.org.roda.wui.api.v2.controller.ConfigurationController.retrieveReindexPluginObjectClasses = job.read +core.roles.org.roda.wui.api.v2.controller.ConfigurationController.retrieveDropdownPluginItems = job.read +core.roles.org.roda.wui.api.v2.controller.ConfigurationController.retrieveConversionProfiles = job.read # Generic find roles core.roles.org.roda.wui.api.v2.services.IndexService.find(Notification) = notification.read @@ -177,6 +195,7 @@ core.roles.org.roda.wui.api.v2.services.IndexService.find(IndexedDIP) = aip.view core.roles.org.roda.wui.api.v2.services.IndexService.find(IndexedDIP) = aip.read core.roles.org.roda.wui.api.v2.services.IndexService.find(IndexedFile) = representation.read core.roles.org.roda.wui.api.v2.services.IndexService.find(IndexedRepresentation) = aip.read +core.roles.org.roda.wui.api.v2.services.IndexService.find(DIPFile) = aip.read # Generic count roles core.roles.org.roda.wui.api.v2.services.IndexService.count(TransferredResource) = transfer.read @@ -193,6 +212,8 @@ core.roles.org.roda.wui.api.v2.services.IndexService.count(IndexedRepresentation core.roles.org.roda.wui.api.v2.services.IndexService.count(IndexedRepresentation) = aip.read core.roles.org.roda.wui.api.v2.services.IndexService.count(IndexedFile) = aip.view core.roles.org.roda.wui.api.v2.services.IndexService.count(IndexedFile) = aip.read +core.roles.org.roda.wui.api.v2.services.IndexService.count(DIPFile) = aip.read +core.roles.org.roda.wui.api.v2.services.IndexService.count(IndexedReport) = job.read # Generic suggest roles core.roles.org.roda.wui.api.v2.services.IndexService.suggest(IndexedAIP) = aip.read @@ -214,6 +235,9 @@ core.roles.org.roda.wui.api.v2.services.IndexService.retrieve(RiskIncidence) = i core.roles.org.roda.wui.api.v2.services.IndexService.retrieve(RepresentationInformation) = ri.read core.roles.org.roda.wui.api.v2.services.IndexService.retrieve(Job) = job.read core.roles.org.roda.wui.api.v2.services.IndexService.retrieve(IndexedReport) = job.read +core.roles.org.roda.wui.api.v2.services.IndexService.retrieve(IndexedDIP) = aip.read +core.roles.org.roda.wui.api.v2.services.IndexService.retrieve(DIPFile) = aip.read +core.roles.org.roda.wui.api.v2.services.IndexService.retrieve(DisposalConfirmation) = disposal_confirmation.read # Old roles - deprecated - and soon to be deleted core.roles.org.roda.wui.api.controllers.Browser.appraisal = aip.appraisal 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 a8290ad68b..7f9d97618c 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 @@ -70,7 +70,6 @@ import org.roda.core.data.v2.jobs.Report; import org.roda.core.data.v2.jobs.Reports; import org.roda.core.data.v2.log.LogEntryState; -import org.roda.core.data.v2.notifications.Notification; import org.roda.core.data.v2.ri.RepresentationInformation; import org.roda.core.data.v2.risks.IndexedRisk; import org.roda.core.data.v2.risks.Risk; @@ -84,13 +83,9 @@ import org.roda.core.storage.fs.FSUtils; import org.roda.core.util.IdUtils; import org.roda.wui.client.browse.bundle.BrowseAIPBundle; -import org.roda.wui.client.browse.bundle.BrowseDipBundle; -import org.roda.wui.client.browse.bundle.BrowseRepresentationBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataEditBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataVersionsBundle; -import org.roda.wui.client.browse.bundle.PreservationEventViewBundle; import org.roda.wui.client.browse.bundle.RepresentationInformationExtraBundle; -import org.roda.wui.client.browse.bundle.RepresentationInformationFilterBundle; import org.roda.wui.client.browse.bundle.SupportedMetadataTypeBundle; import org.roda.wui.client.planning.RelationTypeTranslationsBundle; import org.roda.wui.client.planning.RiskVersionsBundle; @@ -232,32 +227,6 @@ public static DescriptiveMetadataVersionsBundle retrieveDescriptiveMetadataVersi } } - public static BrowseDipBundle retrieveDipBundle(User user, String dipUUID, String dipFileUUID, Locale locale) - throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException { - final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; - - // check user permissions - controllerAssistant.checkRoles(user); - - LogEntryState state = LogEntryState.SUCCESS; - - try { - // delegate - IndexedDIP dip = BrowserHelper.retrieve(IndexedDIP.class, dipUUID, - RodaConstants.DIP_PERMISSIONS_FIELDS_TO_RETURN); - controllerAssistant.checkObjectPermissions(user, dip); - - return BrowserHelper.retrieveDipBundle(dipUUID, dipFileUUID, user, locale); - } catch (RODAException e) { - state = LogEntryState.FAILURE; - throw e; - } finally { - // register action - controllerAssistant.registerAction(user, dipUUID, state, RodaConstants.CONTROLLER_DIP_ID_PARAM, dipUUID, - RodaConstants.CONTROLLER_DIP_FILE_ID_PARAM, dipFileUUID); - } - } - public static IndexResult find(final Class classToReturn, final Filter filter, final Sorter sorter, final Sublist sublist, final Facets facets, final User user, final boolean justActive, final List fieldsToReturn) throws GenericException, AuthorizationDeniedException, RequestNotValidException { @@ -2139,28 +2108,6 @@ public static Job updateAIPPermissions(User user, SelectedItems aips } } - public static Job updateDIPPermissions(User user, SelectedItems dips, Permissions permissions, - String details) throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException { - final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; - - // check user permissions - controllerAssistant.checkRoles(user); - controllerAssistant.checkObjectPermissions(user, dips); - - LogEntryState state = LogEntryState.SUCCESS; - - try { - return BrowserHelper.updateDIPPermissions(user, dips, permissions, details); - } catch (RODAException e) { - state = LogEntryState.FAILURE; - throw e; - } finally { - // register action - controllerAssistant.registerAction(user, state, RodaConstants.CONTROLLER_DIPS_PARAM, dips, - RodaConstants.CONTROLLER_PERMISSIONS_PARAM, permissions, RodaConstants.CONTROLLER_DETAILS_PARAM, details); - } - } - public static void updateRisk(User user, Risk risk, int incidences) throws AuthorizationDeniedException, GenericException { final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; @@ -2682,29 +2629,6 @@ public static Job updateMultipleIncidences(User user, SelectedItems dips, String details) - throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException { - final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; - - // check user permissions - controllerAssistant.checkRoles(user); - controllerAssistant.checkObjectPermissions(user, dips); - - LogEntryState state = LogEntryState.SUCCESS; - - try { - // delegate - return BrowserHelper.deleteDIPs(user, dips, details); - } catch (RODAException e) { - state = LogEntryState.FAILURE; - throw e; - } finally { - // register action - controllerAssistant.registerAction(user, state, RodaConstants.CONTROLLER_SELECTED_PARAM, dips, - RodaConstants.CONTROLLER_DETAILS_PARAM, details, RodaConstants.CONTROLLER_DETAILS_PARAM, details); - } - } - public static EntityResponse retrieveDIP(User user, String dipId, String acceptFormat) throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException { final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; @@ -2999,29 +2923,6 @@ public static boolean hasSubmissions(User user, String aipId) } } - public static Notification acknowledgeNotification(User user, String notificationId, String ackToken) - throws GenericException, NotFoundException, AuthorizationDeniedException { - ControllerAssistant controllerAssistant = new ControllerAssistant() {}; - - // 20170515 nvieira: decided to not check roles considering the ackToken - // should be enough and it is not necessary nor usable to create a new role - // only for this purpose - // controllerAssistant.checkRoles(user); - - LogEntryState state = LogEntryState.SUCCESS; - - try { - return BrowserHelper.acknowledgeNotification(notificationId, ackToken); - } catch (RODAException e) { - state = LogEntryState.FAILURE; - throw e; - } finally { - // register action - controllerAssistant.registerAction(user, notificationId, state, RodaConstants.CONTROLLER_NOTIFICATION_ID_PARAM, - notificationId, RodaConstants.CONTROLLER_NOTIFICATION_TOKEN_PARAM, ackToken); - } - } - public static Reports listReports(User user, String id, String resourceOrSip, int start, int limit, String acceptFormat) throws AuthorizationDeniedException, GenericException, RequestNotValidException, NotFoundException { 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 2586415b95..e37f2c5987 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 @@ -23,7 +23,6 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -82,9 +81,7 @@ import org.roda.core.data.v2.index.facet.FacetValue; import org.roda.core.data.v2.index.facet.Facets; import org.roda.core.data.v2.index.facet.SimpleFacetParameter; -import org.roda.core.data.v2.index.filter.AndFiltersParameters; import org.roda.core.data.v2.index.filter.BasicSearchFilterParameter; -import org.roda.core.data.v2.index.filter.EmptyKeyFilterParameter; import org.roda.core.data.v2.index.filter.Filter; import org.roda.core.data.v2.index.filter.OneOfManyFilterParameter; import org.roda.core.data.v2.index.filter.SimpleFilterParameter; @@ -177,14 +174,10 @@ import org.roda.wui.api.v1.utils.ObjectResponse; import org.roda.wui.client.browse.bundle.BinaryVersionBundle; import org.roda.wui.client.browse.bundle.BrowseAIPBundle; -import org.roda.wui.client.browse.bundle.BrowseDipBundle; -import org.roda.wui.client.browse.bundle.BrowseFileBundle; -import org.roda.wui.client.browse.bundle.BrowseRepresentationBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataEditBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataVersionsBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataViewBundle; import org.roda.wui.client.browse.bundle.RepresentationInformationExtraBundle; -import org.roda.wui.client.browse.bundle.RepresentationInformationFilterBundle; import org.roda.wui.client.browse.bundle.SupportedMetadataTypeBundle; import org.roda.wui.client.planning.RelationTypeTranslationsBundle; import org.roda.wui.client.planning.RiskVersionsBundle; @@ -319,189 +312,6 @@ protected static BrowseAIPBundle retrieveBrowseAipBundle(User user, IndexedAIP a return bundle; } - public static BrowseRepresentationBundle retrieveBrowseRepresentationBundle(User user, IndexedAIP aip, - IndexedRepresentation representation, Locale locale) - throws GenericException, RequestNotValidException, AuthorizationDeniedException { - BrowseRepresentationBundle bundle = new BrowseRepresentationBundle(); - - bundle.setAip(aip); - bundle.setRepresentation(representation); - - // set aip ancestors - List ancestors = retrieveAncestors(aip, user, aipAncestorsFieldsToReturn); - bundle.setAipAncestors(ancestors); - - // set representation desc. metadata - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_LIST_REPRESENTATION_DESCRIPTIVE_METADATA)) { - try { - bundle.setRepresentationDescriptiveMetadata( - retrieveDescriptiveMetadataBundles(aip.getId(), representation.getId(), locale)); - } catch (NotFoundException e) { - // do nothing - } - } - - // Count DIPs - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_FIND_DIP)) { - Filter dipsFilter = new Filter( - new SimpleFilterParameter(RodaConstants.DIP_REPRESENTATION_UUIDS, representation.getUUID())); - Long dipCount = RodaCoreFactory.getIndexService().count(IndexedDIP.class, dipsFilter); - bundle.setDipCount(dipCount); - } else { - bundle.setDipCount(-1L); - } - - // Count risk incidences - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_FIND_RISK_INCIDENCE)) { - - AndFiltersParameters andFiltersParameters = new AndFiltersParameters( - Arrays.asList(new SimpleFilterParameter(RodaConstants.RISK_INCIDENCE_REPRESENTATION_ID, representation.getId()), - new SimpleFilterParameter(RodaConstants.RISK_INCIDENCE_AIP_ID, representation.getAipId()))); - - Long riskIncidenceCount = RodaCoreFactory.getIndexService().count(RiskIncidence.class, - new Filter(andFiltersParameters)); - bundle.setRiskIncidenceCount(riskIncidenceCount); - } else { - bundle.setRiskIncidenceCount(-1L); - } - - // Count preservation events - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_FIND_PRESERVATION_EVENT)) { - Filter preservationEventFilter = new Filter( - new SimpleFilterParameter(RodaConstants.PRESERVATION_EVENT_REPRESENTATION_UUID, representation.getUUID())); - Long preservationEventCount = RodaCoreFactory.getIndexService().count(IndexedPreservationEvent.class, - preservationEventFilter); - bundle.setPreservationEventCount(preservationEventCount); - } else { - bundle.setPreservationEventCount(-1L); - } - - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_FIND_REPRESENTATION_INFORMATION)) { - List rodaConfigurationAsList = RodaCoreFactory.getRodaConfigurationAsList("ui.ri.rule.Representation") - .stream().map(r -> RodaCoreFactory.getRodaConfigurationAsString(r, RodaConstants.SEARCH_FIELD_FIELDS)) - .collect(Collectors.toList()); - bundle.setRepresentationInformationFields(rodaConfigurationAsList); - } else { - bundle.setRepresentationInformationFields(Collections.emptyList()); - } - - RodaConstants.DistributedModeType distributedModeType = RodaCoreFactory.getDistributedModeType(); - - if (RODAInstanceUtils.isConfiguredAsDistributedMode() - && RodaConstants.DistributedModeType.CENTRAL.equals(distributedModeType)) { - bundle.setLocalToInstance(aip.getInstanceId().equals(RODAInstanceUtils.getLocalInstanceIdentifier())); - retrieveDistributedInstanceName(aip.getInstanceId(), bundle.isLocalToInstance()) - .ifPresent(bundle::setInstanceName); - } - - return bundle; - } - - public static BrowseFileBundle retrieveBrowseFileBundle(IndexedAIP aip, IndexedRepresentation representation, - IndexedFile file, User user) throws GenericException, RequestNotValidException, AuthorizationDeniedException { - BrowseFileBundle bundle = new BrowseFileBundle(); - - bundle.setAip(aip); - bundle.setRepresentation(representation); - bundle.setFile(file); - - // set aip ancestors - List ancestors = retrieveAncestors(aip, user, aipAncestorsFieldsToReturn); - bundle.setAipAncestors(ancestors); - - // set sibling count - String parentUUID = bundle.getFile().getParentUUID(); - - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_FIND_FILE)) { - Filter siblingFilter = new Filter( - new SimpleFilterParameter(RodaConstants.FILE_REPRESENTATION_UUID, bundle.getFile().getRepresentationUUID())); - - if (parentUUID != null) { - siblingFilter.add(new SimpleFilterParameter(RodaConstants.FILE_PARENT_UUID, parentUUID)); - } else { - siblingFilter.add(new EmptyKeyFilterParameter(RodaConstants.FILE_PARENT_UUID)); - } - - boolean justActive = AIPState.ACTIVE.equals(aip.getState()); - bundle.setTotalSiblingCount(count(IndexedFile.class, siblingFilter, justActive, user)); - } else { - bundle.setTotalSiblingCount(-1L); - } - - // Count DIPs - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_FIND_DIP)) { - Filter dipsFilter = new Filter(new SimpleFilterParameter(RodaConstants.DIP_FILE_UUIDS, file.getUUID())); - Long dipCount = RodaCoreFactory.getIndexService().count(IndexedDIP.class, dipsFilter); - bundle.setDipCount(dipCount); - } else { - bundle.setDipCount(-1L); - } - - // Count risk incidences - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_FIND_RISK_INCIDENCE)) { - Filter riskIncidenceFilter = new Filter( - new SimpleFilterParameter(RodaConstants.RISK_INCIDENCE_FILE_ID, file.getId())); - Long riskIncidenceCount = RodaCoreFactory.getIndexService().count(RiskIncidence.class, riskIncidenceFilter); - bundle.setRiskIncidenceCount(riskIncidenceCount); - } else { - bundle.setRiskIncidenceCount(-1L); - } - - // Count preservation events - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_FIND_PRESERVATION_EVENT)) { - Filter preservationEventFilter = new Filter( - new SimpleFilterParameter(RodaConstants.PRESERVATION_EVENT_FILE_UUID, file.getUUID())); - Long preservationEventCount = RodaCoreFactory.getIndexService().count(IndexedPreservationEvent.class, - preservationEventFilter); - bundle.setPreservationEventCount(preservationEventCount); - } else { - bundle.setPreservationEventCount(-1L); - } - - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_FIND_REPRESENTATION_INFORMATION)) { - List rodaConfigurationAsList = RodaCoreFactory.getRodaConfigurationAsList("ui.ri.rule.File").stream() - .map(r -> RodaCoreFactory.getRodaConfigurationAsString(r, RodaConstants.SEARCH_FIELD_FIELDS)) - .collect(Collectors.toList()); - bundle.setRepresentationInformationFields(rodaConfigurationAsList); - } else { - bundle.setRepresentationInformationFields(Collections.emptyList()); - } - - if (file.isReference()) { - bundle.setAvailable(isShallowFileAvailable(file.getUUID())); - } else { - bundle.setAvailable(true); - } - - RodaConstants.DistributedModeType distributedModeType = RodaCoreFactory.getDistributedModeType(); - - if (RODAInstanceUtils.isConfiguredAsDistributedMode() - && RodaConstants.DistributedModeType.CENTRAL.equals(distributedModeType)) { - bundle.setLocalToInstance(aip.getInstanceId().equals(RODAInstanceUtils.getLocalInstanceIdentifier())); - retrieveDistributedInstanceName(aip.getInstanceId(), bundle.isLocalToInstance()) - .ifPresent(bundle::setInstanceName); - } - - return bundle; - } - - private static Boolean isShallowFileAvailable(String fileUUID) { - IndexService index = RodaCoreFactory.getIndexService(); - try { - IndexedFile indexedFile = index.retrieve(IndexedFile.class, fileUUID, new ArrayList<>()); - if (indexedFile.isReference()) { - String referenceURL = indexedFile.getReferenceURL(); - final Protocol protocol = RodaCoreFactory.getProtocol(new URI(referenceURL)); - return protocol.isAvailable(); - } - } catch (URISyntaxException e) { - LOGGER.warn("Cannot convet referenceURL to URI: " + fileUUID); - } catch (GenericException | NotFoundException e) { - LOGGER.warn("File is not available: " + fileUUID); - } - return false; - } - private static Optional retrieveDistributedInstanceName(String instanceId, boolean isLocalInstance) throws AuthorizationDeniedException, RequestNotValidException, GenericException { ModelService model = RodaCoreFactory.getModelService(); @@ -729,90 +539,6 @@ public static DescriptiveMetadataEditBundle retrieveDescriptiveMetadataEditBundl return ret; } - public static BrowseDipBundle retrieveDipBundle(String dipUUID, String dipFileUUID, User user, Locale locale) - throws GenericException, NotFoundException, RequestNotValidException { - BrowseDipBundle bundle = new BrowseDipBundle(); - - bundle.setDip(retrieve(IndexedDIP.class, dipUUID, - Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.DIP_ID, RodaConstants.DIP_TITLE, RodaConstants.DIP_AIP_IDS, - RodaConstants.DIP_AIP_UUIDS, RodaConstants.DIP_FILE_IDS, RodaConstants.DIP_REPRESENTATION_IDS))); - - List dipFileFields = new ArrayList<>(); - - if (dipFileUUID != null) { - DIPFile dipFile = retrieve(DIPFile.class, dipFileUUID, dipFileFields); - bundle.setDipFile(dipFile); - - List dipFileAncestors = new ArrayList<>(); - for (String dipFileAncestor : dipFile.getAncestorsUUIDs()) { - try { - dipFileAncestors.add(retrieve(DIPFile.class, dipFileAncestor, - Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.DIPFILE_DIP_ID, RodaConstants.DIPFILE_ID))); - } catch (NotFoundException e) { - // ignore - } - } - - bundle.setDipFileAncestors(dipFileAncestors); - } else { - // if there is only one DIPFile in the DIP and it is NOT a directory - // then select it - Filter filter = new Filter(new SimpleFilterParameter(RodaConstants.DIPFILE_DIP_ID, dipUUID)); - Sublist sublist = new Sublist(0, 1); - IndexResult dipFiles = find(DIPFile.class, filter, Sorter.NONE, sublist, Facets.NONE, user, false, - dipFileFields); - if (dipFiles.getTotalCount() == 1 && !dipFiles.getResults().get(0).isDirectory()) { - bundle.setDipFile(dipFiles.getResults().get(0)); - } - } - - List aipFields = new ArrayList<>(RodaConstants.AIP_PERMISSIONS_FIELDS_TO_RETURN); - aipFields.addAll(Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.AIP_TITLE, RodaConstants.AIP_LEVEL, - RodaConstants.AIP_DATE_FINAL, RodaConstants.AIP_DATE_INITIAL, RodaConstants.AIP_GHOST)); - List representationFields = Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.REPRESENTATION_TYPE, - RodaConstants.REPRESENTATION_NUMBER_OF_DATA_FILES, RodaConstants.REPRESENTATION_NUMBER_OF_DATA_FOLDERS, - RodaConstants.REPRESENTATION_ORIGINAL, RodaConstants.REPRESENTATION_AIP_ID, RodaConstants.REPRESENTATION_ID); - List fileFields = new ArrayList<>(); - - // infer from DIP - IndexedDIP dip = bundle.getDip(); - try { - if (!dip.getFileIds().isEmpty()) { - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_RETRIEVE_AIP, - RodaConstants.PERMISSION_METHOD_RETRIEVE_FILE)) { - IndexedFile file = BrowserHelper.retrieve(IndexedFile.class, IdUtils.getFileId(dip.getFileIds().get(0)), - fileFields); - IndexedAIP aip = retrieve(IndexedAIP.class, file.getAipId(), aipFields); - bundle.setReferrer(file); - bundle.setReferrerBundle(retrieveBrowseFileBundle(aip, - retrieve(IndexedRepresentation.class, file.getRepresentationUUID(), representationFields), file, user)); - bundle.setReferrerPermissions(aip.getPermissions()); - } - } else if (!dip.getRepresentationIds().isEmpty()) { - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_RETRIEVE_AIP, - RodaConstants.PERMISSION_METHOD_RETRIEVE_REPRESENTATION)) { - IndexedRepresentation representation = BrowserHelper.retrieve(IndexedRepresentation.class, - IdUtils.getRepresentationId(dip.getRepresentationIds().get(0)), representationFields); - IndexedAIP aip = retrieve(IndexedAIP.class, representation.getAipId(), aipFields); - bundle.setReferrer(representation); - bundle.setReferrerBundle(retrieveBrowseRepresentationBundle(user, aip, representation, locale)); - bundle.setReferrerPermissions(aip.getPermissions()); - } - } else if (!dip.getAipIds().isEmpty()) { - if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_RETRIEVE_AIP)) { - IndexedAIP aip = BrowserHelper.retrieve(IndexedAIP.class, dip.getAipIds().get(0).getAipId(), aipFields); - bundle.setReferrer(aip); - bundle.setReferrerBundle(retrieveBrowseAipBundle(user, aip, locale)); - bundle.setReferrerPermissions(aip.getPermissions()); - } - } - } catch (AuthorizationDeniedException | NotFoundException e) { - // ignore this as it is normal to have access to the DIP but not its referrer - } - - return bundle; - } - protected static List retrieveAncestors(IndexedAIP aip, User user, List fieldsToReturn) throws GenericException { return RodaCoreFactory.getIndexService().retrieveAncestors(aip, user, fieldsToReturn); @@ -2329,15 +2055,6 @@ public static Job updateAIPPermissions(User user, SelectedItems aips pluginParameters, "Could not execute AIP permissions recursively action"); } - public static Job updateDIPPermissions(User user, SelectedItems dips, Permissions permissions, - String details) throws GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException { - // TODO 20170222 nvieira it should create an event associated with DIP - Map pluginParameters = new HashMap<>(); - pluginParameters.put(RodaConstants.PLUGIN_PARAMS_PERMISSIONS_JSON, JsonUtils.getJsonFromObject(permissions)); - return createAndExecuteInternalJob("Update DIP permissions recursively", dips, UpdatePermissionsPlugin.class, user, - pluginParameters, "Could not execute DIP permissions recursively action"); - } - public static Risk createRisk(Risk risk, User user, boolean commit) throws GenericException, AuthorizationDeniedException { risk.setCreatedBy(user.getName()); @@ -2819,14 +2536,6 @@ public static DIP updateDIP(DIP dip) throws GenericException, AuthorizationDenie return RodaCoreFactory.getModelService().updateDIP(dip); } - public static Job deleteDIPs(User user, SelectedItems selected, String details) - throws AuthorizationDeniedException, GenericException, RequestNotValidException, NotFoundException { - Map pluginParameters = new HashMap<>(); - pluginParameters.put(RodaConstants.PLUGIN_PARAMS_DETAILS, details); - return createAndExecuteInternalJob("Delete DIP", selected, DeleteRODAObjectPlugin.class, user, pluginParameters, - "Could not execute DIP delete action"); - } - protected static EntityResponse retrieveDIP(String dipId, String acceptFormat) throws GenericException, RequestNotValidException, NotFoundException, AuthorizationDeniedException { @@ -2991,11 +2700,6 @@ public static void deleteNotification(String notificationId) RodaCoreFactory.getModelService().deleteNotification(notificationId); } - public static Notification acknowledgeNotification(String notificationId, String ackToken) - throws GenericException, NotFoundException, AuthorizationDeniedException { - return RodaCoreFactory.getModelService().acknowledgeNotification(notificationId, ackToken); - } - public static RepresentationInformation createRepresentationInformation(RepresentationInformation ri, RepresentationInformationExtraBundle extra, String createdBy, boolean commit) throws GenericException, AuthorizationDeniedException { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v1/DipsResource.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v1/DipsResource.java index bb41af6895..ca89d45cc2 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v1/DipsResource.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v1/DipsResource.java @@ -164,28 +164,4 @@ public Response updateDIP(DIP dip, DIP updatedDIP = Dips.updateDIP(user, dip); return Response.ok(updatedDIP, mediaType).build(); } - - @DELETE - @Path("/{" + RodaConstants.API_PATH_PARAM_DIP_ID + "}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, ExtraMediaType.APPLICATION_JAVASCRIPT}) - @JSONP(callback = RodaConstants.API_QUERY_DEFAULT_JSONP_CALLBACK, queryParam = RodaConstants.API_QUERY_KEY_JSONP_CALLBACK) - @Operation(summary = "Delete DIP", description = "Delete existing DIP", responses = { - @ApiResponse(responseCode = "204", description = "OK", content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = ApiResponseMessage.class)))}) - public Response deleteDIP( - @Parameter(description = "The ID of the DIP to delete.", required = true) @PathParam(RodaConstants.API_PATH_PARAM_DIP_ID) String dipId, - @Parameter(description = "Reason to delete AIP", required = true) @QueryParam(RodaConstants.API_QUERY_PARAM_DETAILS) String details, - @Parameter(description = "Choose format in which to get the response", schema = @Schema(implementation = RodaConstants.APIMediaTypes.class)) @QueryParam(RodaConstants.API_QUERY_KEY_ACCEPT_FORMAT) String acceptFormat, - @Parameter(description = "JSONP callback name", required = false, schema = @Schema(defaultValue = RodaConstants.API_QUERY_DEFAULT_JSONP_CALLBACK)) @QueryParam(RodaConstants.API_QUERY_KEY_JSONP_CALLBACK) String jsonpCallbackName) - throws RODAException { - String mediaType = ApiUtils.getMediaType(acceptFormat, request); - - // get user - User user = UserUtility.getApiUser(request); - - // delegate action to controller - Browser.deleteDIPs(user, SelectedItemsList.create(IndexedDIP.class, dipId), details); - - return Response.ok(new ApiResponseMessage(ApiResponseMessage.OK, "DIP deleted"), mediaType).build(); - } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v1/NotificationsResource.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v1/NotificationsResource.java index f0e201386d..4935c2fd7c 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v1/NotificationsResource.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v1/NotificationsResource.java @@ -178,32 +178,4 @@ public Response deleteNotification(@PathParam(RodaConstants.API_PATH_PARAM_NOTIF org.roda.wui.api.controllers.Notifications.deleteNotification(user, notificationId); return Response.ok(new ApiResponseMessage(ApiResponseMessage.OK, "Notification deleted"), mediaType).build(); } - - @GET - @Path("/{" + RodaConstants.API_PATH_PARAM_NOTIFICATION_ID + "}/" + RodaConstants.API_ACKNOWLEDGE) - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, ExtraMediaType.APPLICATION_JAVASCRIPT}) - @JSONP(callback = RodaConstants.API_QUERY_DEFAULT_JSONP_CALLBACK, queryParam = RodaConstants.API_QUERY_KEY_JSONP_CALLBACK) - @Operation(summary = "Acknowledge notification", description = "Acknowledges a notification", responses = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = ApiResponseMessage.class)))}) - public Response acknowledgeNotification( - @Parameter(description = "The notification id", required = true) @PathParam(RodaConstants.API_PATH_PARAM_NOTIFICATION_ID) String notificationId, - @Parameter(description = "The notification user token (with email uuid)", required = true) @QueryParam(RodaConstants.API_QUERY_PARAM_NOTIFICATION_TOKEN) String token, - @Parameter(description = "Choose format in which to get the result", schema = @Schema(implementation = RodaConstants.ListMediaTypes.class, defaultValue = RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_JSON)) @QueryParam(RodaConstants.API_QUERY_KEY_ACCEPT_FORMAT) String acceptFormat, - @Parameter(description = "JSONP callback name", required = false, schema = @Schema(defaultValue = RodaConstants.API_QUERY_DEFAULT_JSONP_CALLBACK)) @QueryParam(RodaConstants.API_QUERY_KEY_JSONP_CALLBACK) String jsonpCallbackName) - throws RODAException { - String mediaType = ApiUtils.getMediaType(acceptFormat, request); - - if (token == null) { - return Response.ok(new ApiResponseMessage(ApiResponseMessage.ERROR, "Token argument is required"), mediaType) - .build(); - } - - // get user - User user = UserUtility.getApiUser(request); - - // delegate action to controller - Browser.acknowledgeNotification(user, notificationId, token); - return Response.ok(new ApiResponseMessage(ApiResponseMessage.OK, "Notification acknowledged"), mediaType).build(); - } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/AIPController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/AIPController.java index 7886cadbfe..3e2539b6fc 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/AIPController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/AIPController.java @@ -22,6 +22,7 @@ import org.roda.core.data.v2.ip.metadata.DescriptiveMetadataInfos; import org.roda.core.data.v2.log.LogEntryState; import org.roda.core.model.utils.UserUtility; +import org.roda.core.storage.utils.RODAInstanceUtils; import org.roda.core.util.IdUtils; import org.roda.wui.api.v2.exceptions.RESTException; import org.roda.wui.api.v2.exceptions.model.ErrorResponseMessage; @@ -73,7 +74,20 @@ public class AIPController implements AIPRestService { @Override public IndexedAIP findByUuid(String uuid, String localeString) { RequestContext requestContext = RequestUtils.parseHTTPRequest(request); - return indexService.retrieve(requestContext, IndexedAIP.class, uuid, new ArrayList<>()); + + IndexedAIP retrieve = indexService.retrieve(requestContext, IndexedAIP.class, uuid, new ArrayList<>()); + + RodaConstants.DistributedModeType distributedModeType = RodaCoreFactory.getDistributedModeType(); + + if (RODAInstanceUtils.isConfiguredAsDistributedMode() + && RodaConstants.DistributedModeType.CENTRAL.equals(distributedModeType)) { + boolean isLocalInstance = retrieve.getInstanceId().equals(RODAInstanceUtils.getLocalInstanceIdentifier()); + aipService.retrieveDistributedInstanceName(retrieve.getInstanceId(), isLocalInstance) + .ifPresent(retrieve::setInstanceName); + retrieve.setLocalInstance(isLocalInstance); + } + + return retrieve; } @Override @@ -122,7 +136,7 @@ public List getAncestors(String id) { state = LogEntryState.FAILURE; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), id, state, RodaConstants.CONTROLLER_ID_PARAM, id); + controllerAssistant.registerAction(requestContext, id, state, RodaConstants.CONTROLLER_ID_PARAM, id); } } @@ -159,14 +173,27 @@ public DescriptiveMetadataInfos retrieveRepresentationDescriptiveMetadata(String state = LogEntryState.FAILURE; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_AIP_ID_PARAM, aipId, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, aipId, RodaConstants.CONTROLLER_REPRESENTATION_ID_PARAM, representationId); } } + @Override + public List retrieveAIPRuleProperties() { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + ControllerAssistant controllerAssistant = new ControllerAssistant() {}; + + try { + // delegate + return aipService.getConfigurationAIPRules(requestContext.getUser()); + } finally { + controllerAssistant.registerAction(requestContext, LogEntryState.SUCCESS); + } + } + @GetMapping(path = "/{id}/representations/{representation-id}/metadata/descriptive/{descriptive-metadata-id}/html", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) @Operation(summary = "Retrieves descriptive metadata result", responses = { - @ApiResponse(responseCode = "200", description = "Returns an object ", content = @Content(schema = @Schema(implementation = StringResponse.class))), + @ApiResponse(responseCode = "200", description = "Returns an object ", content = @Content(schema = @Schema(implementation = ResponseEntity.class))), @ApiResponse(responseCode = "401", description = "Unauthorized access", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))), @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))), @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))),}) @@ -198,7 +225,7 @@ ResponseEntity retrieveRepresentationDescriptiveMetadataH state = LogEntryState.FAILURE; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_AIP_ID_PARAM, aipId, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, aipId, RodaConstants.CONTROLLER_REPRESENTATION_ID_PARAM, representationId, RodaConstants.CONTROLLER_METADATA_ID_PARAM, descriptiveMetadataId); } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/ClassificationPlanController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/ClassificationPlanController.java index 31631bf273..a5b00f73bb 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/ClassificationPlanController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/ClassificationPlanController.java @@ -40,7 +40,7 @@ public class ClassificationPlanController { ClassificationPlanService classificationPlanService; @GetMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Retrieves the classificaton plan from Catalogue", responses = { + @Operation(summary = "Retrieves the classification plan from Catalogue", responses = { @ApiResponse(responseCode = "200", description = "OK")}) public ResponseEntity getClassificationPlan( @Parameter(description = "Choose file name", schema = @Schema(defaultValue = "plan.json")) @RequestParam(value = "filename", defaultValue = "plan.json", required = false) String filename) { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/ConfigurationController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/ConfigurationController.java index 90b7a0e94b..99883eeb07 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/ConfigurationController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/ConfigurationController.java @@ -10,6 +10,9 @@ import org.roda.core.data.v2.jobs.PluginInfoList; import org.roda.core.data.v2.jobs.PluginType; import org.roda.core.data.v2.log.LogEntryState; +import org.roda.core.data.v2.properties.ConversionProfileOutcomeType; +import org.roda.core.data.v2.properties.ConversionProfiles; +import org.roda.core.data.v2.properties.DropdownPluginParameterItems; import org.roda.core.data.v2.properties.ObjectClassFields; import org.roda.core.data.v2.properties.ReindexPluginObject; import org.roda.core.data.v2.properties.ReindexPluginObjects; @@ -63,7 +66,7 @@ public ObjectClassFields retrieveObjectClassFields(String localeString) { return configurationsService.retrieveObjectClassFields(localeString); } finally { - controllerAssistant.registerAction(requestContext.getUser(), LogEntryState.SUCCESS); + controllerAssistant.registerAction(requestContext, LogEntryState.SUCCESS); } } @@ -80,7 +83,7 @@ public PluginInfoList retrievePluginsInfo(List types) { state = LogEntryState.UNAUTHORIZED; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state); + controllerAssistant.registerAction(requestContext, state); } } @@ -108,8 +111,47 @@ public ReindexPluginObjects retrieveReindexPluginObjectClasses() { state = LogEntryState.UNAUTHORIZED; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state); + controllerAssistant.registerAction(requestContext, state); } } + @Override + public Boolean retrieveShowEmbeddedDIP() { + return RodaCoreFactory.getRodaConfiguration().getBoolean("ui.dip.externalURL.showEmbedded", false); + } + + @Override + public DropdownPluginParameterItems retrieveDropdownPluginItems(String parameterId, String localeString) { + final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + LogEntryState state = LogEntryState.SUCCESS; + + try { + controllerAssistant.checkRoles(requestContext.getUser()); + + return configurationsService.retrieveDropDownPluginParameterItems(parameterId, localeString); + } catch (AuthorizationDeniedException e) { + state = LogEntryState.UNAUTHORIZED; + throw new RESTException(e); + } finally { + controllerAssistant.registerAction(requestContext, state); + } + } + + @Override + public ConversionProfiles retrieveConversionProfiles(String pluginId, ConversionProfileOutcomeType outcomeType, + String localeString) { + final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + LogEntryState state = LogEntryState.SUCCESS; + try { + controllerAssistant.checkRoles(requestContext.getUser()); + return configurationsService.retrieveConversionProfilePluginItems(pluginId, outcomeType, localeString); + } catch (AuthorizationDeniedException e) { + state = LogEntryState.UNAUTHORIZED; + throw new RESTException(e); + } finally { + controllerAssistant.registerAction(requestContext, state); + } + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPController.java index aa9d36a9d9..498c0723c6 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPController.java @@ -4,26 +4,49 @@ import java.util.List; import org.roda.core.data.common.RodaConstants; +import org.roda.core.data.exceptions.AuthorizationDeniedException; +import org.roda.core.data.exceptions.GenericException; +import org.roda.core.data.exceptions.NotFoundException; import org.roda.core.data.exceptions.NotImplementedException; +import org.roda.core.data.exceptions.RODAException; +import org.roda.core.data.exceptions.RequestNotValidException; +import org.roda.core.data.v2.generics.DeleteRequest; import org.roda.core.data.v2.generics.LongResponse; +import org.roda.core.data.v2.generics.UpdatePermissionsRequest; import org.roda.core.data.v2.index.CountRequest; import org.roda.core.data.v2.index.FindRequest; import org.roda.core.data.v2.index.IndexResult; import org.roda.core.data.v2.index.SuggestRequest; import org.roda.core.data.v2.ip.IndexedDIP; +import org.roda.core.data.v2.jobs.Job; +import org.roda.core.data.v2.log.LogEntryState; import org.roda.core.model.utils.UserUtility; import org.roda.wui.api.v2.exceptions.RESTException; +import org.roda.wui.api.v2.exceptions.model.ErrorResponseMessage; +import org.roda.wui.api.v2.services.DIPService; import org.roda.wui.api.v2.services.IndexService; +import org.roda.wui.api.v2.utils.ApiUtils; import org.roda.wui.client.services.DIPRestService; +import org.roda.wui.common.ControllerAssistant; import org.roda.wui.common.model.RequestContext; import org.roda.wui.common.utils.RequestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import jakarta.servlet.http.HttpServletRequest; /** @@ -40,6 +63,9 @@ public class DIPController implements DIPRestService { @Autowired private IndexService indexService; + @Autowired + private DIPService dipService; + @Override public IndexedDIP findByUuid(String uuid, String localeString) { RequestContext requestContext = RequestUtils.parseHTTPRequest(request); @@ -63,10 +89,87 @@ public LongResponse count(@RequestBody CountRequest countRequest) { } } - @Override @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public List suggest(SuggestRequest suggestRequest) { throw new RESTException(new NotImplementedException()); } + + @GetMapping(path = "{uuid}/binary", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + @Operation(summary = "Downloads file", description = "Downloads a DIP", responses = { + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = StreamingResponseBody.class))), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))), + @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) + public ResponseEntity downloadBinary( + @Parameter(description = "The UUID of the existing DIP", required = true) @PathVariable(name = "uuid") String dipUUID) { + final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + LogEntryState state = LogEntryState.SUCCESS; + + try { + // check user permissions + controllerAssistant.checkRoles(requestContext.getUser()); + IndexedDIP dip = indexService.retrieve(requestContext, IndexedDIP.class, dipUUID, new ArrayList<>()); + controllerAssistant.checkObjectPermissions(requestContext.getUser(), dip); + + return ApiUtils.okResponse(dipService.createStreamResponse(dip.getUUID())); + } catch (RODAException e) { + state = LogEntryState.FAILURE; + throw new RESTException(e); + } finally { + // register action + controllerAssistant.registerAction(requestContext, dipUUID, state, RodaConstants.CONTROLLER_DIP_UUID_PARAM, + dipUUID); + } + } + + @Override + public Job deleteIndexedDIPs(@RequestBody DeleteRequest deleteRequest) { + final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + LogEntryState state = LogEntryState.SUCCESS; + + try { + // check user permissions + controllerAssistant.checkRoles(requestContext.getUser()); + + // delegate + return dipService.deleteDIPsJob(deleteRequest, requestContext.getUser()); + } catch (AuthorizationDeniedException e) { + state = LogEntryState.UNAUTHORIZED; + throw new RESTException(e); + } catch (RequestNotValidException | GenericException | NotFoundException e) { + state = LogEntryState.FAILURE; + throw new RESTException(e); + } finally { + // register action + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_SELECTED_PARAM, + deleteRequest.getItemsToDelete(), RodaConstants.CONTROLLER_DETAILS_PARAM, deleteRequest.getDetails()); + } + } + + @Override + public Job updatePermissions(@RequestBody UpdatePermissionsRequest updateRequest) { + final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + LogEntryState state = LogEntryState.SUCCESS; + try { + // check user permissions + controllerAssistant.checkRoles(requestContext.getUser()); + controllerAssistant.checkObjectPermissions(requestContext.getUser(), updateRequest.getItemsToUpdate()); + + return dipService.updateDIPPermissions(requestContext.getUser(), updateRequest); + } catch (AuthorizationDeniedException e) { + state = LogEntryState.UNAUTHORIZED; + throw new RESTException(e); + } catch (RequestNotValidException | GenericException | NotFoundException e) { + state = LogEntryState.FAILURE; + throw new RESTException(e); + } finally { + // register action + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_DIPS_PARAM, + updateRequest.getItemsToUpdate(), RodaConstants.CONTROLLER_PERMISSIONS_PARAM, updateRequest.getPermissions(), + RodaConstants.CONTROLLER_DETAILS_PARAM, updateRequest.getDetails()); + } + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPFileController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPFileController.java new file mode 100644 index 0000000000..9aeab43e7c --- /dev/null +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DIPFileController.java @@ -0,0 +1,69 @@ +package org.roda.wui.api.v2.controller; + +import java.util.ArrayList; +import java.util.List; + +import org.roda.core.data.common.RodaConstants; +import org.roda.core.data.exceptions.NotImplementedException; +import org.roda.core.data.v2.generics.LongResponse; +import org.roda.core.data.v2.index.CountRequest; +import org.roda.core.data.v2.index.FindRequest; +import org.roda.core.data.v2.index.IndexResult; +import org.roda.core.data.v2.index.SuggestRequest; +import org.roda.core.data.v2.ip.DIPFile; +import org.roda.core.model.utils.UserUtility; +import org.roda.wui.api.v2.exceptions.RESTException; +import org.roda.wui.api.v2.services.IndexService; +import org.roda.wui.client.services.DIPFileRestService; +import org.roda.wui.common.model.RequestContext; +import org.roda.wui.common.utils.RequestUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; + +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Miguel Guimarães + */ +@RestController +@RequestMapping(path = "/api/v2/dip-files") +public class DIPFileController implements DIPFileRestService { + @Autowired + HttpServletRequest request; + + @Autowired + IndexService indexService; + + @Override + public DIPFile findByUuid(String uuid, String localeString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + return indexService.retrieve(requestContext, DIPFile.class, uuid, new ArrayList<>()); + } + + @Override + public IndexResult find(@RequestBody FindRequest findRequest, String localeString) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + return indexService.find(DIPFile.class, findRequest, localeString, requestContext); + } + + @Override + public LongResponse count(@RequestBody CountRequest countRequest) { + RequestContext requestContext = RequestUtils.parseHTTPRequest(request); + + if (UserUtility.hasPermissions(requestContext.getUser(), RodaConstants.PERMISSION_METHOD_FIND_AIP)) { + return new LongResponse(indexService.count(DIPFile.class, countRequest, requestContext)); + } else { + return new LongResponse(-1L); + } + } + + @Override + @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) + public List suggest(SuggestRequest suggestRequest) { + throw new RESTException(new NotImplementedException()); + } +} diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DisposalConfirmationController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DisposalConfirmationController.java index 90c0d901b5..bc18f0deea 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DisposalConfirmationController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/DisposalConfirmationController.java @@ -8,6 +8,7 @@ import org.roda.core.data.exceptions.AuthorizationDeniedException; import org.roda.core.data.exceptions.NotImplementedException; import org.roda.core.data.exceptions.RODAException; +import org.roda.core.data.v2.StreamResponse; import org.roda.core.data.v2.disposal.confirmation.DisposalConfirmation; import org.roda.core.data.v2.disposal.confirmation.DisposalConfirmationCreateRequest; import org.roda.core.data.v2.disposal.confirmation.DisposalConfirmationForm; @@ -21,19 +22,32 @@ import org.roda.core.data.v2.log.LogEntryState; import org.roda.core.model.utils.UserUtility; import org.roda.wui.api.v2.exceptions.RESTException; +import org.roda.wui.api.v2.exceptions.model.ErrorResponseMessage; import org.roda.wui.api.v2.services.DisposalConfirmationService; import org.roda.wui.api.v2.services.IndexService; +import org.roda.wui.api.v2.utils.ApiUtils; import org.roda.wui.client.services.DisposalConfirmationRestService; import org.roda.wui.common.ControllerAssistant; import org.roda.wui.common.model.RequestContext; import org.roda.wui.common.utils.RequestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import jakarta.servlet.http.HttpServletRequest; /** @@ -80,8 +94,13 @@ public List suggest(SuggestRequest suggestRequest) { throw new RESTException(new NotImplementedException()); } - @Override - public String retrieveDisposalConfirmationReport(String disposalConfirmationId, boolean toPrint) { + @RequestMapping(method = RequestMethod.GET, path = "/{id}/report/html", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + @Operation(summary = "Retrieves the disposal confirmation report", responses = { + @ApiResponse(responseCode = "200", description = "Returns the disposal confirmation report", content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) + public ResponseEntity retrieveDisposalConfirmationReport( + @Parameter(description = "The ID of the disposal confirmation", required = true) @PathVariable(name = "id") String disposalConfirmationId, + @Parameter(description = "Use a print-friendly layout", schema = @Schema(defaultValue = "false", implementation = Boolean.class)) @RequestParam(name = "to-print", defaultValue = "false", required = false) boolean toPrint) { final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; RequestContext requestContext = RequestUtils.parseHTTPRequest(request); LogEntryState state = LogEntryState.SUCCESS; @@ -91,7 +110,10 @@ public String retrieveDisposalConfirmationReport(String disposalConfirmationId, controllerAssistant.checkRoles(requestContext.getUser()); // delegate - return disposalConfirmationService.createDisposalConfirmationReport(disposalConfirmationId, toPrint); + StreamResponse disposalConfirmationReport = disposalConfirmationService + .createDisposalConfirmationReport(disposalConfirmationId, toPrint); + + return ApiUtils.okResponse(disposalConfirmationReport, null); } catch (AuthorizationDeniedException e) { state = LogEntryState.UNAUTHORIZED; throw new RESTException(e); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/FilesController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/FilesController.java index 382b029455..98a39e6446 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/FilesController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/FilesController.java @@ -17,9 +17,9 @@ import org.roda.core.data.exceptions.RequestNotValidException; import org.roda.core.data.v2.StreamResponse; import org.roda.core.data.v2.file.CreateFolderRequest; -import org.roda.core.data.v2.file.DeleteFilesRequest; import org.roda.core.data.v2.file.MoveFilesRequest; import org.roda.core.data.v2.file.RenameFolderRequest; +import org.roda.core.data.v2.generics.DeleteRequest; import org.roda.core.data.v2.generics.LongResponse; import org.roda.core.data.v2.index.CountRequest; import org.roda.core.data.v2.index.FindRequest; @@ -147,7 +147,7 @@ public List suggest(@RequestBody SuggestRequest suggestRequest) { } @Override - public IndexedFile retrieveIndexedFile(@RequestBody IndexedFileRequest indexedFileRequest) { + public IndexedFile retrieveIndexedFileViaRequest(@RequestBody IndexedFileRequest indexedFileRequest) { RequestContext requestContext = RequestUtils.parseHTTPRequest(request); String uuid = IdUtils.getFileId(indexedFileRequest.getAipId(), indexedFileRequest.getRepresentationId(), indexedFileRequest.getDirectoryPaths(), indexedFileRequest.getFileId()); @@ -197,7 +197,7 @@ public Job moveFileToFolder(@RequestBody MoveFilesRequest moveFilesRequest) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), moveFilesRequest.getAipId(), state, + controllerAssistant.registerAction(requestContext, moveFilesRequest.getAipId(), state, RodaConstants.CONTROLLER_AIP_ID_PARAM, moveFilesRequest.getAipId(), RodaConstants.CONTROLLER_REPRESENTATION_ID_PARAM, moveFilesRequest.getRepresentationId(), RodaConstants.CONTROLLER_FILES_PARAM, moveFilesRequest.getItemsToMove(), RodaConstants.CONTROLLER_FILE_PARAM, @@ -206,7 +206,7 @@ public Job moveFileToFolder(@RequestBody MoveFilesRequest moveFilesRequest) { } @Override - public Job deleteFiles(@RequestBody DeleteFilesRequest deleteFilesRequest) { + public Job deleteFiles(@RequestBody DeleteRequest deleteRequest) { final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; RequestContext requestContext = RequestUtils.parseHTTPRequest(request); LogEntryState state = LogEntryState.SUCCESS; @@ -214,9 +214,9 @@ public Job deleteFiles(@RequestBody DeleteFilesRequest deleteFilesRequest) { try { // check user permissions controllerAssistant.checkRoles(requestContext.getUser()); - controllerAssistant.checkObjectPermissions(requestContext.getUser(), deleteFilesRequest.getItemsToDelete()); + controllerAssistant.checkObjectPermissions(requestContext.getUser(), deleteRequest.getItemsToDelete()); - return filesService.deleteFiles(requestContext.getUser(), deleteFilesRequest); + return filesService.deleteFiles(requestContext.getUser(), deleteRequest); } catch (AuthorizationDeniedException e) { state = LogEntryState.UNAUTHORIZED; throw new RESTException(e); @@ -225,8 +225,8 @@ public Job deleteFiles(@RequestBody DeleteFilesRequest deleteFilesRequest) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_SELECTED_PARAM, - deleteFilesRequest.getItemsToDelete(), RodaConstants.CONTROLLER_DETAILS_PARAM, deleteFilesRequest.getDetails()); + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_SELECTED_PARAM, + deleteRequest.getItemsToDelete(), RodaConstants.CONTROLLER_DETAILS_PARAM, deleteRequest.getDetails()); } } @@ -255,7 +255,7 @@ public IndexedFile renameFolder(@RequestBody RenameFolderRequest renameFolderReq throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_FILE_UUID_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_FILE_UUID_PARAM, renameFolderRequest.getFolderUUID(), RodaConstants.CONTROLLER_FOLDERNAME_PARAM, renameFolderRequest.getRenameTo(), RodaConstants.CONTROLLER_DETAILS_PARAM, renameFolderRequest.getDetails()); } @@ -282,7 +282,7 @@ public Job identifyFileFormat(@RequestBody SelectedItems selected) throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_SELECTED_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_SELECTED_PARAM, selected); } } @@ -329,7 +329,7 @@ public File uploadFileResource( throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), aipId, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, + controllerAssistant.registerAction(requestContext, aipId, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, aipId, RodaConstants.CONTROLLER_REPRESENTATION_ID_PARAM, representationId, RodaConstants.CONTROLLER_DIRECTORY_PATH_PARAM, directories, RodaConstants.CONTROLLER_FILE_ID_PARAM, fileName, RodaConstants.CONTROLLER_DETAILS_PARAM, details); @@ -363,7 +363,7 @@ public IndexedFile createFolderUnderRepresentation(@RequestBody CreateFolderRequ throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_AIP_ID_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, createFolderRequest.getAipId(), RodaConstants.CONTROLLER_REPRESENTATION_ID_PARAM, createFolderRequest.getRepresentationId(), RodaConstants.CONTROLLER_FILE_UUID_PARAM, createFolderRequest.getFolderUUID(), RodaConstants.CONTROLLER_FOLDERNAME_PARAM, createFolderRequest.getName(), diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java index 54c4d552bc..4645800344 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/MembersController.java @@ -100,7 +100,7 @@ public User getUser(String name) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_USERNAME_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_USERNAME_PARAM, name); } } @@ -129,7 +129,7 @@ public Void deleteUser(String name) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_USERNAME_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_USERNAME_PARAM, name); } } @@ -149,7 +149,7 @@ public Void deleteAccessKey(String accessKeyId) { state = LogEntryState.FAILURE; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM); + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM); } } @@ -174,7 +174,7 @@ public AccessKeys getAccessKeysByUser(String username) { state = LogEntryState.FAILURE; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM); + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM); } } @@ -194,7 +194,7 @@ public AccessKey getAccessKey(String accessKeyId) { state = LogEntryState.FAILURE; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM); + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM); } } @@ -217,7 +217,7 @@ public AccessKey regenerateAccessKey(String id, @RequestBody CreateAccessKeyRequ state = LogEntryState.FAILURE; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM, regenerateAccessKeyRequest); } } @@ -245,7 +245,7 @@ public AccessKey createAccessKey(@RequestBody CreateAccessKeyRequest accessKeyRe state = LogEntryState.FAILURE; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM, accessKeyRequest); } } @@ -266,7 +266,7 @@ public AccessKey revokeAccessKey(String id) { state = LogEntryState.FAILURE; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM); + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_ACCESS_KEY_PARAM); } } @@ -285,7 +285,7 @@ public Group getGroup(String name) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_GROUPNAME_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_GROUPNAME_PARAM, name); } } @@ -306,7 +306,7 @@ public Void deleteGroup(String name) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_GROUPNAME_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_GROUPNAME_PARAM, name); } return null; @@ -333,7 +333,7 @@ public Void changeActive(@RequestBody SelectedItems members, Boolean throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_SELECTED_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_SELECTED_PARAM, members, RodaConstants.CONTROLLER_ACTIVATE_PARAM, activate); } return null; @@ -355,7 +355,7 @@ public Void deleteMultipleMembers(@RequestBody SelectedItems members throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_SELECTED_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_SELECTED_PARAM, members); } return null; @@ -380,7 +380,7 @@ public Group createGroup(@RequestBody CreateGroupRequest groupRequest) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_GROUP_PARAM, group); + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_GROUP_PARAM, group); } } @@ -400,7 +400,7 @@ public Void updateGroup(@RequestBody Group modifiedGroup) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_GROUP_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_GROUP_PARAM, modifiedGroup); } return null; @@ -423,7 +423,7 @@ public User updateUser(@RequestBody CreateUserRequest userRequest) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_USER_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_USER_PARAM, requestContext.getUser()); } } @@ -445,7 +445,7 @@ public User updateMyUser(@RequestBody CreateUserRequest userOperations) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_USER_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_USER_PARAM, userOperations.getUser()); } } @@ -464,7 +464,7 @@ public Void resetUserPassword(String username, String resetPasswordToken, @Reque throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), LogEntryState.SUCCESS, + controllerAssistant.registerAction(requestContext, LogEntryState.SUCCESS, RodaConstants.CONTROLLER_USER_PARAM, user); } return null; @@ -499,7 +499,7 @@ public String confirmUserEmail(String username, String token) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), LogEntryState.SUCCESS, + controllerAssistant.registerAction(requestContext, LogEntryState.SUCCESS, RodaConstants.CONTROLLER_USER_PARAM, user); } } @@ -512,7 +512,7 @@ public CreateUserExtraFormFields getDefaultUserExtra() { Set userExtra = membersService.retrieveDefaultExtraFormFields(); CreateUserExtraFormFields createUserExtraFormFields = new CreateUserExtraFormFields(userExtra); // register action - controllerAssistant.registerAction(requestContext.getUser(), LogEntryState.SUCCESS); + controllerAssistant.registerAction(requestContext, LogEntryState.SUCCESS); return createUserExtraFormFields; } @@ -596,7 +596,7 @@ public User createUser(@RequestBody CreateUserRequest userOperations, String loc throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_USER_PARAM, user); + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_USER_PARAM, user); } } @@ -618,7 +618,7 @@ public User registerUser(@RequestBody CreateUserRequest createUserRequest, Strin throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_USER_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_USER_PARAM, createUserRequest.getUser()); } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationController.java index b3464a5cc8..348cff6aed 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationController.java @@ -29,6 +29,7 @@ import org.roda.core.data.v2.ip.IndexedAIP; import org.roda.core.data.v2.ip.IndexedRepresentation; import org.roda.core.data.v2.ip.Representation; +import org.roda.core.data.v2.ip.RepresentationLink; import org.roda.core.data.v2.jobs.Job; import org.roda.core.data.v2.log.LogEntryState; import org.roda.core.data.v2.representation.ChangeRepresentationStatesRequest; @@ -113,7 +114,7 @@ public List suggest(@RequestBody SuggestRequest suggestRequest) { } @Override - public IndexedRepresentation retrieveIndexedRepresentation( + public IndexedRepresentation retrieveIndexedRepresentationViaRequest( @RequestBody IndexedRepresentationRequest indexedRepresentationRequest) { final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; RequestContext requestContext = RequestUtils.parseHTTPRequest(request); @@ -138,10 +139,10 @@ public IndexedRepresentation retrieveIndexedRepresentation( RodaConstants.DistributedModeType distributedModeType = RodaCoreFactory.getDistributedModeType(); if (RODAInstanceUtils.isConfiguredAsDistributedMode() - && RodaConstants.DistributedModeType.CENTRAL.equals(distributedModeType)) { + && RodaConstants.DistributedModeType.CENTRAL.equals(distributedModeType)) { boolean isLocalInstance = representation.getInstanceId().equals(RODAInstanceUtils.getLocalInstanceIdentifier()); representationsService.retrieveDistributedInstanceName(representation.getInstanceId(), isLocalInstance) - .ifPresent(representation::setInstanceName); + .ifPresent(representation::setInstanceName); representation.setLocalInstance(isLocalInstance); } @@ -154,7 +155,7 @@ public IndexedRepresentation retrieveIndexedRepresentation( throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_AIP_ID_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, indexedRepresentationRequest.getAipId(), RodaConstants.CONTROLLER_REPRESENTATION_ID_PARAM, indexedRepresentationRequest.getRepresentationId()); } @@ -183,7 +184,7 @@ public Representation getRepresentation(String aipId, String representationId) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), aipId, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, + controllerAssistant.registerAction(requestContext, aipId, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, aipId, RodaConstants.CONTROLLER_REPRESENTATION_ID_PARAM, representationId); } } @@ -217,7 +218,7 @@ public Representation createRepresentation(String aipId, String type, String det throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), aipId, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, + controllerAssistant.registerAction(requestContext, aipId, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, aipId, RodaConstants.CONTROLLER_REPRESENTATION_ID_PARAM, representationId, RodaConstants.CONTROLLER_TYPE_PARAM, type, RodaConstants.CONTROLLER_DETAILS_PARAM, details); } @@ -267,7 +268,7 @@ public RepresentationTypeOptions getRepresentationTypeOptions(String localeStrin state = LogEntryState.UNAUTHORIZED; throw new RESTException(e); } finally { - controllerAssistant.registerAction(requestContext.getUser(), state); + controllerAssistant.registerAction(requestContext, state); } } @@ -290,7 +291,7 @@ public Job changeRepresentationType(@RequestBody ChangeRepresentationTypeRequest throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_SELECTED_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_SELECTED_PARAM, changeRepresentationTypeRequest.getItems(), RodaConstants.CONTROLLER_TYPE_PARAM, changeRepresentationTypeRequest.getType(), RodaConstants.CONTROLLER_DETAILS_PARAM, changeRepresentationTypeRequest.getDetails()); @@ -313,7 +314,7 @@ public Job deleteRepresentation(@RequestBody SelectedItems getRepresentationBinary( throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), aipId, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, + controllerAssistant.registerAction(requestContext, aipId, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, aipId, RodaConstants.CONTROLLER_REPRESENTATION_ID_PARAM, representationId); } } @@ -451,7 +452,7 @@ public ResponseEntity getRepresentationOtherMetadataBinar throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), aipId, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, + controllerAssistant.registerAction(requestContext, aipId, state, RodaConstants.CONTROLLER_AIP_ID_PARAM, aipId, RodaConstants.CONTROLLER_REPRESENTATION_ID_PARAM, representationId); } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationInformationController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationInformationController.java index 3b974848d6..690e88ca5b 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationInformationController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RepresentationInformationController.java @@ -333,7 +333,7 @@ public Job addFilterToRepresentationInformation( throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, "filter_request", + controllerAssistant.registerAction(requestContext, state, "filter_request", representationInformationFilterRequest); } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskController.java index 49e455499f..e9c4675060 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskController.java @@ -137,7 +137,7 @@ public Risk updateRisk(@RequestBody Risk risk, String incidences) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), risk.getId(), state, + controllerAssistant.registerAction(requestContext, risk.getId(), state, RodaConstants.CONTROLLER_RISK_PARAM, risk, RodaConstants.CONTROLLER_MESSAGE_PARAM, RodaConstants.VersionAction.UPDATED.toString()); } @@ -163,7 +163,7 @@ public Risk createRisk(@RequestBody Risk risk) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_RISK_PARAM, risk); + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_RISK_PARAM, risk); } } @@ -185,7 +185,7 @@ public RiskVersions retrieveRiskVersions(String id) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), id, state, RodaConstants.CONTROLLER_RISK_ID_PARAM, + controllerAssistant.registerAction(requestContext, id, state, RodaConstants.CONTROLLER_RISK_ID_PARAM, id); } } @@ -207,7 +207,7 @@ public Risk retrieveRiskVersion(String id, String versionId) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), id, state, RodaConstants.CONTROLLER_RISK_ID_PARAM, + controllerAssistant.registerAction(requestContext, id, state, RodaConstants.CONTROLLER_RISK_ID_PARAM, id, RodaConstants.CONTROLLER_SELECTED_VERSION_PARAM, versionId); } } @@ -241,7 +241,7 @@ public Risk revertRiskVersion(String id, String versionId) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), id, state, RodaConstants.CONTROLLER_RISK_ID_PARAM, + controllerAssistant.registerAction(requestContext, id, state, RodaConstants.CONTROLLER_RISK_ID_PARAM, id, RodaConstants.CONTROLLER_VERSION_ID_PARAM, versionId, RodaConstants.CONTROLLER_MESSAGE_PARAM, RodaConstants.VersionAction.REVERTED.toString()); } @@ -269,7 +269,7 @@ public Void deleteRiskVersion(String id, String versionId) { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), id, state, RodaConstants.CONTROLLER_RISK_ID_PARAM, + controllerAssistant.registerAction(requestContext, id, state, RodaConstants.CONTROLLER_RISK_ID_PARAM, id, RodaConstants.CONTROLLER_VERSION_ID_PARAM, versionId); } } @@ -318,7 +318,7 @@ public RiskMitigationProperties retrieveRiskMitigationProperties() { throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state); + controllerAssistant.registerAction(requestContext, state); } } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskIncidenceController.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskIncidenceController.java index bd7d188cf6..285de97f96 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskIncidenceController.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/controller/RiskIncidenceController.java @@ -97,7 +97,7 @@ public Job deleteRiskIncidences(@RequestBody SelectedItems select throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_SELECTED_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_SELECTED_PARAM, selected, RodaConstants.CONTROLLER_DETAILS_PARAM, details); } } @@ -117,7 +117,7 @@ public Job updateMultipleIncidences(@RequestBody SelectedIncidences */ @Service public class AIPService { + private static final Logger LOGGER = LoggerFactory.getLogger(AIPService.class); public List getAncestors(IndexedAIP indexedAIP, User user) throws GenericException { return RodaCoreFactory.getIndexService().retrieveAncestors(indexedAIP, user, new ArrayList<>()); } + + public Optional retrieveDistributedInstanceName(String instanceId, boolean isLocalInstance) { + try { + ModelService model = RodaCoreFactory.getModelService(); + RodaConstants.DistributedModeType distributedModeType = RodaCoreFactory.getDistributedModeType(); + + if (RodaConstants.DistributedModeType.CENTRAL.equals(distributedModeType)) { + if (isLocalInstance) { + return Optional.of(RodaCoreFactory.getProperty(RodaConstants.CENTRAL_INSTANCE_NAME_PROPERTY, + RodaConstants.DEFAULT_CENTRAL_INSTANCE_NAME)); + } else { + DistributedInstance distributedInstance = model.retrieveDistributedInstance(instanceId); + return Optional.of(distributedInstance.getName()); + } + } + } catch (GenericException | AuthorizationDeniedException | RequestNotValidException | NotFoundException e) { + LOGGER.warn("Could not retrieve the distributed instance", e); + return Optional.empty(); + } + + return Optional.empty(); + } + + public List getConfigurationAIPRules(User user) { + if (UserUtility.hasPermissions(user, RodaConstants.PERMISSION_METHOD_FIND_REPRESENTATION_INFORMATION)) { + return RodaCoreFactory.getRodaConfigurationAsList("ui.ri.rule.AIP").stream() + .map(r -> RodaCoreFactory.getRodaConfigurationAsString(r, RodaConstants.SEARCH_FIELD_FIELDS)).toList(); + } else { + return Collections.emptyList(); + } + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/ConfigurationsService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/ConfigurationsService.java index c374037a65..97fbdc5f6d 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/ConfigurationsService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/ConfigurationsService.java @@ -6,6 +6,8 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.MissingResourceException; +import java.util.ResourceBundle; import org.apache.commons.configuration.Configuration; import org.apache.commons.lang3.StringUtils; @@ -13,6 +15,11 @@ import org.roda.core.common.Messages; import org.roda.core.common.RodaUtils; import org.roda.core.data.common.RodaConstants; +import org.roda.core.data.v2.properties.ConversionProfile; +import org.roda.core.data.v2.properties.ConversionProfileOutcomeType; +import org.roda.core.data.v2.properties.ConversionProfiles; +import org.roda.core.data.v2.properties.DropdownPluginParameterItem; +import org.roda.core.data.v2.properties.DropdownPluginParameterItems; import org.roda.core.data.v2.properties.ObjectClassFields; import org.roda.wui.client.browse.Viewers; import org.roda.wui.common.server.ServerTools; @@ -55,6 +62,95 @@ public Viewers getViewerConfigurations() { return viewers; } + public DropdownPluginParameterItems retrieveDropDownPluginParameterItems(String parameterId, String localeString) { + DropdownPluginParameterItems items = new DropdownPluginParameterItems(); + + List dropdownItems = RodaUtils + .copyList(RodaCoreFactory.getRodaConfiguration().getList("core.plugins.dropdown." + parameterId + "[]")); + Locale locale = ServerTools.parseLocale(localeString); + Messages messages = RodaCoreFactory.getI18NMessages(locale); + + for (String item : dropdownItems) { + String i18nProperty = RodaCoreFactory.getRodaConfiguration() + .getString("core.plugins.dropdown." + parameterId + "[]." + item + ".i18n"); + items.addObject(new DropdownPluginParameterItem(item, messages.getTranslation(i18nProperty, item))); + } + + return items; + } + + public ConversionProfiles retrieveConversionProfilePluginItems(String pluginId, + ConversionProfileOutcomeType outcomeType, String localeString) { + ConversionProfiles items = new ConversionProfiles(); + + String pluginName = RodaCoreFactory.getRodaConfiguration().getString("core.plugins.conversion.profile." + pluginId); + + List dropdownItems = RodaUtils.copyList( + RodaCoreFactory.getRodaConfiguration().getList("core.plugins.conversion.profile." + pluginName + ".profiles[]")); + Locale locale = ServerTools.parseLocale(localeString); + + ResourceBundle pluginMessages = RodaCoreFactory.getPluginMessages(pluginId, locale); + + for (String item : dropdownItems) { + ConversionProfile conversionProfile = retrieveConversionProfileItem(item, pluginName, pluginMessages); + if (outcomeType.equals(ConversionProfileOutcomeType.REPRESENTATION) + && conversionProfile.canBeUsedForRepresentation()) { + items.addObject(conversionProfile); + } + + if (outcomeType.equals(ConversionProfileOutcomeType.DISSEMINATION) + && conversionProfile.canBeUsedForDissemination()) { + items.addObject(conversionProfile); + } + } + + return items; + } + + private ConversionProfile retrieveConversionProfileItem(String item, String pluginName, + ResourceBundle resourceBundle) { + ConversionProfile conversionProfile = new ConversionProfile(); + Map optionsValues = new HashMap<>(); + + String i18nKey = RodaCoreFactory.getRodaConfiguration() + .getString("core.plugins.conversion.profile." + pluginName + ".profiles.i18nPrefix"); + + String title; + String description; + + try { + title = resourceBundle.getString(i18nKey + "." + item + ".title"); + } catch (MissingResourceException e) { + title = i18nKey + "." + item + ".title"; + } + + try { + description = resourceBundle.getString(i18nKey + "." + item + ".description"); + } catch (MissingResourceException e) { + description = i18nKey + "." + item + ".description"; + } + + conversionProfile.setTitle(title); + conversionProfile.setDescription(description); + conversionProfile.setProfile(item); + + conversionProfile.setCanBeUsedForDissemination(RodaCoreFactory.getRodaConfiguration() + .getBoolean("core.plugins.conversion.profile." + pluginName + "." + item + ".canBeUsedForDissemination", false)); + conversionProfile.setCanBeUsedForRepresentation(RodaCoreFactory.getRodaConfiguration() + .getBoolean("core.plugins.conversion.profile." + pluginName + "." + item + ".canBeUsedForRepresentation", false)); + + String[] options = RodaCoreFactory.getRodaConfiguration() + .getStringArray("core.plugins.conversion.profile." + pluginName + "." + item + ".options[]"); + for (String option : options) { + String optionValue = RodaCoreFactory.getRodaConfiguration() + .getString("core.plugins.conversion.profile." + pluginName + "." + item + "." + option); + optionsValues.put(option, optionValue); + } + conversionProfile.setOptions(optionsValues); + + return conversionProfile; + } + public ObjectClassFields retrieveObjectClassFields(String localeString) { Locale locale = ServerTools.parseLocale(localeString); Messages messages = RodaCoreFactory.getI18NMessages(locale); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/DIPService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/DIPService.java new file mode 100644 index 0000000000..e115756dab --- /dev/null +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/DIPService.java @@ -0,0 +1,66 @@ +package org.roda.wui.api.v2.services; + +import java.util.HashMap; +import java.util.Map; + +import org.roda.core.RodaCoreFactory; +import org.roda.core.common.DownloadUtils; +import org.roda.core.data.common.RodaConstants; +import org.roda.core.data.exceptions.AuthorizationDeniedException; +import org.roda.core.data.exceptions.GenericException; +import org.roda.core.data.exceptions.NotFoundException; +import org.roda.core.data.exceptions.RequestNotValidException; +import org.roda.core.data.utils.JsonUtils; +import org.roda.core.data.v2.ConsumesOutputStream; +import org.roda.core.data.v2.StreamResponse; +import org.roda.core.data.v2.generics.DeleteRequest; +import org.roda.core.data.v2.generics.UpdatePermissionsRequest; +import org.roda.core.data.v2.ip.IndexedDIP; +import org.roda.core.data.v2.ip.StoragePath; +import org.roda.core.data.v2.jobs.Job; +import org.roda.core.data.v2.user.User; +import org.roda.core.model.utils.ModelUtils; +import org.roda.core.plugins.base.maintenance.DeleteRODAObjectPlugin; +import org.roda.core.plugins.base.maintenance.UpdatePermissionsPlugin; +import org.roda.core.storage.StorageService; +import org.roda.wui.api.v2.utils.CommonServicesUtils; +import org.springframework.stereotype.Service; + +/** + * @author Miguel Guimarães + */ +@Service +public class DIPService { + + public StreamResponse createStreamResponse(String dipUUID) + throws RequestNotValidException, AuthorizationDeniedException, NotFoundException, GenericException { + StorageService storage = RodaCoreFactory.getStorageService(); + StoragePath storagePath = ModelUtils.getDIPDataStoragePath(dipUUID); + + if (!storage.hasDirectory(storagePath)) { + storagePath = ModelUtils.getDIPStoragePath(dipUUID); + } + + ConsumesOutputStream download = DownloadUtils.download(RodaCoreFactory.getStorageService(), + storage.getDirectory(storagePath), dipUUID); + return new StreamResponse(download); + } + + public Job deleteDIPsJob(DeleteRequest request, User user) + throws GenericException, RequestNotValidException, NotFoundException, AuthorizationDeniedException { + Map pluginParameters = new HashMap<>(); + pluginParameters.put(RodaConstants.PLUGIN_PARAMS_DETAILS, request.getDetails()); + return CommonServicesUtils.createAndExecuteInternalJob("Delete DIPs", request.getItemsToDelete(), + DeleteRODAObjectPlugin.class, user, pluginParameters, "Could not execute delete DIP action"); + } + + public Job updateDIPPermissions(User user, UpdatePermissionsRequest request) + throws GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException { + Map pluginParameters = new HashMap<>(); + pluginParameters.put(RodaConstants.PLUGIN_PARAMS_PERMISSIONS_JSON, + JsonUtils.getJsonFromObject(request.getPermissions())); + return CommonServicesUtils.createAndExecuteInternalJob("Update DIP permissions recursively", + request.getItemsToUpdate(), UpdatePermissionsPlugin.class, user, pluginParameters, + "Could not execute DIP permissions recursively action"); + } +} diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/DisposalConfirmationService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/DisposalConfirmationService.java index 678592efd4..af3f8d5840 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/DisposalConfirmationService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/DisposalConfirmationService.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.io.InputStream; +import java.io.PrintStream; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.time.Instant; @@ -25,6 +26,9 @@ import org.roda.core.data.exceptions.RODAException; import org.roda.core.data.exceptions.RequestNotValidException; import org.roda.core.data.utils.JsonUtils; +import org.roda.core.data.v2.ConsumesOutputStream; +import org.roda.core.data.v2.DefaultConsumesOutputStream; +import org.roda.core.data.v2.StreamResponse; import org.roda.core.data.v2.disposal.confirmation.DisposalConfirmation; import org.roda.core.data.v2.disposal.confirmation.DisposalConfirmationCreateRequest; import org.roda.core.data.v2.disposal.confirmation.DisposalConfirmationForm; @@ -53,7 +57,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.jknack.handlebars.Handlebars; import com.github.jknack.handlebars.Helper; -import com.github.jknack.handlebars.Options; import com.github.jknack.handlebars.Template; /** @@ -69,6 +72,8 @@ public class DisposalConfirmationService { private static final String SCHEDULES_FILE_PLACEHOLDER = "schedulesFile"; private static final String HOLDS_FILE_PLACEHOLDER = "holdsFile"; + private static final String HTML_EXTENSION = ".html"; + private static final String DISPOSAL_CONFIRMATION_REPORT_HBS = "disposal_confirmation_report.html.hbs"; private static final String DISPOSAL_CONFIRMATION_REPORT_PRINT_HBS = "disposal_confirmation_report_print.html.hbs"; @@ -149,7 +154,7 @@ private Map getDisposalConfirmationExtra(DisposalConfirmationFor return data; } - public String createDisposalConfirmationReport(String confirmationId, boolean isToPrint) + public StreamResponse createDisposalConfirmationReport(String confirmationId, boolean isToPrint) throws RODAException, IOException { String jqCommandTemplate = RodaCoreFactory.getRodaConfigurationAsString(DISPOSAL_CONFIRMATION_COMMAND_PROPERTY); @@ -170,7 +175,7 @@ public String createDisposalConfirmationReport(String confirmationId, boolean is List jqCommand = new ArrayList<>(); Collections.addAll(jqCommand, jqCommandParams.split(" ")); - String output = null; + String output; try { output = CommandUtility.execute(jqCommand); } catch (CommandException e) { @@ -191,15 +196,21 @@ public String createDisposalConfirmationReport(String confirmationId, boolean is String reportTemplate = IOUtils.toString(templateStream, StandardCharsets.UTF_8); Handlebars handlebars = new Handlebars(); - handlebars.registerHelper(HBS_DATEFORMAT_HELPER_NAME, new Helper() { - @Override - public Object apply(Long value, Options options) throws IOException { - ZonedDateTime date = Instant.ofEpochMilli(value).atZone(ZoneOffset.UTC); - return DateTimeFormatter.ofPattern(DATETIME_FORMAT).format(date); - } + handlebars.registerHelper(HBS_DATEFORMAT_HELPER_NAME, (Helper) (value, options) -> { + ZonedDateTime date = Instant.ofEpochMilli(value).atZone(ZoneOffset.UTC); + return DateTimeFormatter.ofPattern(DATETIME_FORMAT).format(date); }); Template template = handlebars.compileInline(reportTemplate); - return template.apply(confirmationValues); + String apply = template.apply(confirmationValues); + + final ConsumesOutputStream stream = new DefaultConsumesOutputStream(confirmationId + HTML_EXTENSION, + RodaConstants.MEDIA_TYPE_TEXT_HTML, out -> { + PrintStream printStream = new PrintStream(out); + printStream.print(apply); + printStream.close(); + }); + + return new StreamResponse(stream); } private Path getDisposalConfirmationMetadataPath(String confirmationId) throws RequestNotValidException { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/FilesService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/FilesService.java index 5c3797caed..bce3a552e4 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/FilesService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/FilesService.java @@ -21,8 +21,8 @@ import org.roda.core.data.v2.ConsumesOutputStream; import org.roda.core.data.v2.StreamResponse; import org.roda.core.data.v2.file.CreateFolderRequest; -import org.roda.core.data.v2.file.DeleteFilesRequest; import org.roda.core.data.v2.file.MoveFilesRequest; +import org.roda.core.data.v2.generics.DeleteRequest; import org.roda.core.data.v2.index.select.SelectedItems; import org.roda.core.data.v2.ip.File; import org.roda.core.data.v2.ip.IndexedFile; @@ -96,7 +96,7 @@ public Job createFormatIdentificationJob(User user, SelectedItems selected) "Could not execute format identification using Siegfrid action"); } - public Job deleteFiles(User user, DeleteFilesRequest request) + public Job deleteFiles(User user, DeleteRequest request) throws AuthorizationDeniedException, GenericException, RequestNotValidException, NotFoundException { Map pluginParameters = new HashMap<>(); pluginParameters.put(RodaConstants.PLUGIN_PARAMS_DETAILS, request.getDetails()); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/IndexService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/IndexService.java index 27e6f5c09d..36647be5d6 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/IndexService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/IndexService.java @@ -43,7 +43,7 @@ public List suggest(SuggestRequest suggestRequest, throw new RESTException(e); } finally { // register action - controllerAssistant.registerAction(requestContext.getUser(), state, RodaConstants.CONTROLLER_CLASS_PARAM, + controllerAssistant.registerAction(requestContext, state, RodaConstants.CONTROLLER_CLASS_PARAM, classToReturn, RodaConstants.CONTROLLER_FIELD_PARAM, suggestRequest.getField(), RodaConstants.CONTROLLER_QUERY_PARAM, suggestRequest.getQuery()); } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/RepresentationService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/RepresentationService.java index 0ffa27e365..78f569d2e5 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/RepresentationService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/services/RepresentationService.java @@ -112,11 +112,10 @@ public Representation retrieveAIPRepresentation(IndexedRepresentation representa public StreamResponse retrieveAIPRepresentationBinary(IndexedRepresentation representation) throws GenericException, RequestNotValidException, NotFoundException, AuthorizationDeniedException { - String aipId = representation.getAipId(); String representationId = representation.getId(); StoragePath storagePath = ModelUtils.getRepresentationStoragePath(representation.getAipId(), representation.getId()); - // ModelUtils.getOtherMetadataStoragePath(); + Directory directory = RodaCoreFactory.getStorageService().getDirectory(storagePath); return ApiUtils.download(directory, representationId); } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/utils/ApiUtils.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/utils/ApiUtils.java index e364391e2c..fa74ee19bc 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/utils/ApiUtils.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/v2/utils/ApiUtils.java @@ -17,6 +17,10 @@ public class ApiUtils { + public static ResponseEntity okResponse(StreamResponse streamResponse) { + return okResponse(streamResponse, null); + } + public static ResponseEntity okResponse(StreamResponse streamResponse, WebRequest request) { if (request != null && request.checkNotModified(streamResponse.getLastModified().getTime())) { return ResponseEntity.status(304).build(); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseDIP.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseDIP.java index 9cf6a60872..ff51320254 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseDIP.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseDIP.java @@ -12,11 +12,18 @@ import java.util.Arrays; import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; import org.roda.core.data.common.RodaConstants; +import org.roda.core.data.exceptions.NotFoundException; +import org.roda.core.data.v2.generics.LongResponse; +import org.roda.core.data.v2.index.CountRequest; +import org.roda.core.data.v2.index.FindRequest; import org.roda.core.data.v2.index.IndexResult; +import org.roda.core.data.v2.index.IndexedFileRequest; +import org.roda.core.data.v2.index.IndexedRepresentationRequest; import org.roda.core.data.v2.index.IsIndexed; -import org.roda.core.data.v2.index.facet.Facets; import org.roda.core.data.v2.index.filter.EmptyKeyFilterParameter; import org.roda.core.data.v2.index.filter.Filter; import org.roda.core.data.v2.index.filter.SimpleFilterParameter; @@ -31,11 +38,8 @@ import org.roda.core.data.v2.ip.IndexedFile; import org.roda.core.data.v2.ip.IndexedRepresentation; import org.roda.core.data.v2.ip.RepresentationLink; -import org.roda.wui.client.browse.bundle.BrowseAIPBundle; -import org.roda.wui.client.browse.bundle.BrowseDipBundle; -import org.roda.wui.client.browse.bundle.BrowseFileBundle; -import org.roda.wui.client.browse.bundle.BrowseRepresentationBundle; -import org.roda.wui.client.browse.bundle.Bundle; +import org.roda.core.data.v2.ip.metadata.IndexedPreservationEvent; +import org.roda.core.data.v2.risks.RiskIncidence; import org.roda.wui.client.common.NavigationToolbar; import org.roda.wui.client.common.UserLogin; import org.roda.wui.client.common.actions.Actionable; @@ -44,12 +48,19 @@ import org.roda.wui.client.common.lists.pagination.ListSelectionUtils; import org.roda.wui.client.common.lists.utils.AsyncTableCellOptions; import org.roda.wui.client.common.lists.utils.ListBuilder; +import org.roda.wui.client.common.model.BrowseAIPResponse; +import org.roda.wui.client.common.model.BrowseDIPResponse; +import org.roda.wui.client.common.model.BrowseFileResponse; +import org.roda.wui.client.common.model.BrowseRepresentationResponse; import org.roda.wui.client.common.search.SearchWrapper; import org.roda.wui.client.common.slider.Sliders; import org.roda.wui.client.common.utils.AsyncCallbackUtils; import org.roda.wui.client.common.utils.IndexedDIPUtils; import org.roda.wui.client.common.utils.JavascriptUtils; +import org.roda.wui.client.services.AIPRestService; import org.roda.wui.client.services.ConfigurationRestService; +import org.roda.wui.client.services.FileRestService; +import org.roda.wui.client.services.RepresentationRestService; import org.roda.wui.client.services.Services; import org.roda.wui.common.client.HistoryResolver; import org.roda.wui.common.client.tools.HistoryUtils; @@ -67,6 +78,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.FocusPanel; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; @@ -84,7 +96,6 @@ public class BrowseDIP extends Composite { @Override public void resolve(final List historyTokens, final AsyncCallback callback) { - Services services = new Services("Retrieve viewers configuration", "get"); services.configurationsResource(ConfigurationRestService::retrieveViewersProperties) .whenComplete((viewers, throwable) -> { @@ -116,36 +127,25 @@ private void load(final Viewers viewers, final List historyTokens, final final String historyDipUUID = historyTokens.get(0); final String historyDipFileUUID = historyTokens.size() > 1 ? historyTokens.get(1) : null; - BrowserService.Util.getInstance().retrieveDipBundle(historyDipUUID, historyDipFileUUID, - LocaleInfo.getCurrentLocale().getLocaleName(), new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - AsyncCallbackUtils.defaultFailureTreatment(caught); - } - - @Override - public void onSuccess(BrowseDipBundle browseDipBundle) { - BrowserService.Util.getInstance().showDIPEmbedded(new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - AsyncCallbackUtils.defaultFailureTreatment(caught); - } - - @Override - public void onSuccess(Boolean showEmbedded) { - IndexedDIP dip = browseDipBundle.getDip(); - if (StringUtils.isNotBlank(dip.getOpenExternalURL()) && !showEmbedded) { - String url = IndexedDIPUtils.interpolateOpenExternalURL(dip, - LocaleInfo.getCurrentLocale().getLocaleName()); - Window.open(url, "_blank", ""); - Toast.showInfo(messages.browseFileDipOpenedExternalURL(), url); - History.back(); - } else { - callback.onSuccess(new BrowseDIP(viewers, browseDipBundle)); - } - } - }); + Services services = new Services("Retrieve DIP", "get"); + + services.dipResource(s -> s.findByUuid(historyDipUUID, LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((indexedDIP, throwable) -> { + if (throwable != null) { + if (throwable instanceof NotFoundException) { + // Toast.showError(messages.notFoundError(), + // messages.couldNotFindPreservationEvent()); + HistoryUtils.newHistory(BrowseTop.RESOLVER); + } + } else { + if (!indexedDIP.getAipIds().isEmpty()) { + applyWhenIndexedAIP(services, historyDipUUID, historyDipFileUUID, indexedDIP, viewers, callback); + } else if (!indexedDIP.getRepresentationIds().isEmpty()) { + applyWhenIndexedRepresentation(services, historyDipUUID, historyDipFileUUID, indexedDIP, viewers, + callback); + } else if (!indexedDIP.getFileIds().isEmpty()) { + applyWhenIndexedFile(services, historyDipUUID, historyDipFileUUID, indexedDIP, viewers, callback); + } } }); } else { @@ -153,6 +153,186 @@ public void onSuccess(Boolean showEmbedded) { } } + private void applyWhenIndexedAIP(Services services, String historyDipUUID, String historyDipFileUUID, + IndexedDIP indexedDIP, Viewers viewers, AsyncCallback callback) { + CompletableFuture indexedAIPCompletableFuture = services.aipResource( + s -> s.findByUuid(indexedDIP.getAipIds().get(0).getAipId(), LocaleInfo.getCurrentLocale().getLocaleName())); + CompletableFuture showEmbeddedDIPFuture = services + .configurationsResource(ConfigurationRestService::retrieveShowEmbeddedDIP).exceptionally(throwable1 -> false); + + CompletableFuture> retrieveDIPFileCompletableFuture = buildCompletableFutureRetrieveDIPFile( + historyDipUUID, historyDipFileUUID, services); + + CompletableFuture.allOf(indexedAIPCompletableFuture, retrieveDIPFileCompletableFuture, showEmbeddedDIPFuture) + .thenApply(v -> { + BrowseDIPResponse response = new BrowseDIPResponse(); + response.setEmbeddedDIP(showEmbeddedDIPFuture.join()); + IndexedAIP indexedAIP = indexedAIPCompletableFuture.join(); + IndexResult dipFileIndexResult = retrieveDIPFileCompletableFuture.join(); + response.setIndexedAIP(indexedAIP); + response.setPermissions(indexedAIP.getPermissions()); + response.setReferred(indexedAIP); + response.setDip(indexedDIP); + + if (historyDipFileUUID != null) { + response.setDipFile(dipFileIndexResult.getResults().get(0)); + } else { + if (dipFileIndexResult.getTotalCount() == 1 && !dipFileIndexResult.getResults().get(0).isDirectory()) { + response.setDipFile(dipFileIndexResult.getResults().get(0)); + } + } + return response; + }).whenComplete((response, throwable1) -> { + if (response.getDipFile() != null) { + List> dipFileAncestors = response.getDipFile().getAncestorsUUIDs().stream() + .map(m -> services.dipFileResource(s -> s.findByUuid(m, LocaleInfo.getCurrentLocale().getLocaleName()))) + .collect(Collectors.toList()); + CompletableFuture[] futuresArray = dipFileAncestors.toArray(new CompletableFuture[0]); + CompletableFuture.allOf(futuresArray).thenApply(v -> { + for (CompletableFuture dipFileAncestor : dipFileAncestors) { + DIPFile file = dipFileAncestor.join(); + response.getDipFileAncestors().add(file); + } + return response; + }).whenComplete((o, throwable) -> render(o, viewers, callback, services)); + } else { + render(response, viewers, callback, services); + } + }); + } + + private void render(BrowseDIPResponse response, Viewers viewers, AsyncCallback callback, + Services services) { + if (StringUtils.isNotBlank(response.getDip().getOpenExternalURL()) && !response.isEmbeddedDIP()) { + String url = IndexedDIPUtils.interpolateOpenExternalURL(response.getDip(), + LocaleInfo.getCurrentLocale().getLocaleName()); + Window.open(url, "_blank", ""); + Toast.showInfo(messages.browseFileDipOpenedExternalURL(), url); + History.back(); + } else { + callback.onSuccess(new BrowseDIP(viewers, response, services)); + } + } + + private void applyWhenIndexedRepresentation(Services services, String historyDipUUID, String historyDipFileUUID, + IndexedDIP indexedDIP, Viewers viewers, AsyncCallback callback) { + RepresentationLink representationLink = indexedDIP.getRepresentationIds().get(0); + IndexedRepresentationRequest request = new IndexedRepresentationRequest(); + request.setAipId(representationLink.getAipId()); + request.setRepresentationId(representationLink.getRepresentationId()); + + CompletableFuture indexedRepresentationCompletableFuture = services + .representationResource(s -> s.retrieveIndexedRepresentationViaRequest(request)); + CompletableFuture indexedAIPCompletableFuture = services + .aipResource(s -> s.findByUuid(request.getAipId(), LocaleInfo.getCurrentLocale().getLocaleName())); + CompletableFuture showEmbeddedDIPFuture = services + .configurationsResource(ConfigurationRestService::retrieveShowEmbeddedDIP).exceptionally(throwable1 -> false); + + CompletableFuture> retrieveDIPFileCompletableFuture = buildCompletableFutureRetrieveDIPFile( + historyDipUUID, historyDipFileUUID, services); + + CompletableFuture.allOf(indexedAIPCompletableFuture, retrieveDIPFileCompletableFuture, + indexedRepresentationCompletableFuture, showEmbeddedDIPFuture).thenApply(v -> { + BrowseDIPResponse response = new BrowseDIPResponse(); + response.setEmbeddedDIP(showEmbeddedDIPFuture.join()); + IndexedAIP indexedAIP = indexedAIPCompletableFuture.join(); + IndexedRepresentation indexedRepresentation = indexedRepresentationCompletableFuture.join(); + IndexResult dipFileIndexResult = retrieveDIPFileCompletableFuture.join(); + + response.setIndexedAIP(indexedAIP); + response.setPermissions(indexedAIP.getPermissions()); + response.setIndexedRepresentation(indexedRepresentation); + response.setReferred(indexedRepresentation); + response.setDip(indexedDIP); + + if (historyDipFileUUID != null) { + response.setDipFile(dipFileIndexResult.getResults().get(0)); + } else { + if (dipFileIndexResult.getTotalCount() == 1 && !dipFileIndexResult.getResults().get(0).isDirectory()) { + response.setDipFile(dipFileIndexResult.getResults().get(0)); + } + } + + return response; + + }).whenComplete((response, throwable1) -> { + if (response.getDipFile() != null) { + List> dipFileAncestors = response.getDipFile().getAncestorsUUIDs().stream() + .map(m -> services.dipFileResource(s -> s.findByUuid(m, LocaleInfo.getCurrentLocale().getLocaleName()))) + .collect(Collectors.toList()); + CompletableFuture[] futuresArray = dipFileAncestors.toArray(new CompletableFuture[0]); + CompletableFuture.allOf(futuresArray).thenApply(v -> { + for (CompletableFuture dipFileAncestor : dipFileAncestors) { + DIPFile file = dipFileAncestor.join(); + response.getDipFileAncestors().add(file); + } + return response; + }).whenComplete((o, throwable) -> render(o, viewers, callback, services)); + } else { + render(response, viewers, callback, services); + } + }); + } + + private void applyWhenIndexedFile(Services services, String historyDipUUID, String historyDipFileUUID, + IndexedDIP indexedDIP, Viewers viewers, AsyncCallback callback) { + FileLink fileLink = indexedDIP.getFileIds().get(0); + IndexedFileRequest request = new IndexedFileRequest(); + request.setAipId(fileLink.getAipId()); + request.setDirectoryPaths(fileLink.getPath()); + request.setFileId(fileLink.getFileId()); + request.setRepresentationId(fileLink.getRepresentationId()); + + CompletableFuture indexedFileCompletableFuture = services + .fileResource(s -> s.retrieveIndexedFileViaRequest(request)); + CompletableFuture indexedAIPCompletableFuture = services + .aipResource(s -> s.findByUuid(request.getAipId(), LocaleInfo.getCurrentLocale().getLocaleName())); + CompletableFuture showEmbeddedDIPFuture = services + .configurationsResource(ConfigurationRestService::retrieveShowEmbeddedDIP).exceptionally(throwable1 -> false); + + CompletableFuture> retrieveDIPFileCompletableFuture = buildCompletableFutureRetrieveDIPFile( + historyDipUUID, historyDipFileUUID, services); + + CompletableFuture.allOf(indexedAIPCompletableFuture, retrieveDIPFileCompletableFuture, + indexedFileCompletableFuture, showEmbeddedDIPFuture).thenApply(v -> { + BrowseDIPResponse response = new BrowseDIPResponse(); + IndexedAIP indexedAIP = indexedAIPCompletableFuture.join(); + IndexedFile indexedFile = indexedFileCompletableFuture.join(); + IndexResult dipFileIndexResult = retrieveDIPFileCompletableFuture.join(); + + response.setIndexedAIP(indexedAIP); + response.setPermissions(indexedAIP.getPermissions()); + response.setIndexedFile(indexedFile); + response.setReferred(indexedFile); + response.setDip(indexedDIP); + + if (historyDipFileUUID != null) { + response.setDipFile(dipFileIndexResult.getResults().get(0)); + } else { + if (dipFileIndexResult.getTotalCount() == 1 && !dipFileIndexResult.getResults().get(0).isDirectory()) { + response.setDipFile(dipFileIndexResult.getResults().get(0)); + } + } + return response; + }).whenComplete((response, throwable1) -> { + if (response.getDipFile() != null) { + List> dipFileAncestors = response.getDipFile().getAncestorsUUIDs().stream() + .map(m -> services.dipFileResource(s -> s.findByUuid(m, LocaleInfo.getCurrentLocale().getLocaleName()))) + .collect(Collectors.toList()); + CompletableFuture[] futuresArray = dipFileAncestors.toArray(new CompletableFuture[0]); + CompletableFuture.allOf(futuresArray).thenApply(v -> { + for (CompletableFuture dipFileAncestor : dipFileAncestors) { + DIPFile file = dipFileAncestor.join(); + response.getDipFileAncestors().add(file); + } + return response; + }).whenComplete((o, throwable) -> render(o, viewers, callback, services)); + } else { + render(response, viewers, callback, services); + } + }); + } + private void errorRedirect(AsyncCallback callback) { HistoryUtils.newHistory(BrowseTop.RESOLVER); callback.onSuccess(null); @@ -169,10 +349,10 @@ private void errorRedirect(AsyncCallback callback) { @UiField FlowPanel container; - public BrowseDIP(Viewers viewers, BrowseDipBundle bundle) { + public BrowseDIP(Viewers viewers, BrowseDIPResponse response, Services services) { // target - IndexedDIP dip = bundle.getDip(); - DIPFile dipFile = bundle.getDipFile(); + IndexedDIP dip = response.getDip(); + DIPFile dipFile = response.getDipFile(); initWidget(uiBinder.createAndBindUi(this)); @@ -184,7 +364,7 @@ public BrowseDIP(Viewers viewers, BrowseDipBundle bundle) { final Filter filter = new Filter(new SimpleFilterParameter(RodaConstants.DIPFILE_DIP_ID, dip.getId()), new EmptyKeyFilterParameter(RodaConstants.DIPFILE_PARENT_UUID)); - ListBuilder dipFileListBuilder = new ListBuilder<>(() -> new DIPFileList(), + ListBuilder dipFileListBuilder = new ListBuilder<>(DIPFileList::new, new AsyncTableCellOptions<>(DIPFile.class, "BrowseDIP_dipFiles").withFilter(filter) .withSummary(messages.allOfAObject(DIPFile.class.getName())).bindOpener() .withActionable(DisseminationFileActions.get(dip.getPermissions()))); @@ -199,6 +379,7 @@ public BrowseDIP(Viewers viewers, BrowseDipBundle bundle) { NavigationToolbar bottomNavigationToolbar = new NavigationToolbar<>(); bottomNavigationToolbar.withObject(dipFile != null ? dipFile : dip); + bottomNavigationToolbar.withActionImpactHandler(Actionable.ActionImpact.DESTROYED, () -> { if (dipFile == null) { // dip was removed @@ -215,16 +396,13 @@ public BrowseDIP(Viewers viewers, BrowseDipBundle bundle) { } }); bottomNavigationToolbar.withPermissions(dip.getPermissions()); - bottomNavigationToolbar.updateBreadcrumb(bundle); + bottomNavigationToolbar.updateBreadcrumb(dip, dipFile, response.getDipFileAncestors()); bottomNavigationToolbar.setHeader(messages.catalogueDIPTitle()); bottomNavigationToolbar.build(); container.insert(bottomNavigationToolbar, 0); - Bundle referrerBundle = bundle.getReferrerBundle(); - - // if referrerBundle is not present (lack of permissions), show only the DIP - if (referrerBundle instanceof BrowseAIPBundle || referrerBundle instanceof BrowseRepresentationBundle - || referrerBundle instanceof BrowseFileBundle) { + if (response.getReferred() instanceof IndexedAIP || response.getReferred() instanceof IndexedRepresentation + || response.getReferred() instanceof IndexedFile) { bottomNavigationToolbar.withAlternativeStyle(true); Runnable deleteActionImpactHandler; @@ -232,46 +410,47 @@ public BrowseDIP(Viewers viewers, BrowseDipBundle bundle) { ListSelectionUtils.ProcessRelativeItem processor; String title; - if (referrerBundle instanceof BrowseFileBundle) { + if (response.getReferred() instanceof IndexedAIP) { processor = referredObject -> openReferred(referredObject, - new Filter(new SimpleFilterParameter(RodaConstants.DIP_FILE_UUIDS, referredObject.getUUID()))); - title = messages.catalogueFileTitle(); + new Filter(new SimpleFilterParameter(RodaConstants.DIP_AIP_UUIDS, referredObject.getUUID())), services); + title = messages.catalogueItemTitle(); deleteActionImpactHandler = () -> { - IndexedFile file = (IndexedFile) bundle.getReferrer(); - HistoryUtils.newHistory(BrowseRepresentation.RESOLVER, file.getAipId(), file.getRepresentationId()); + IndexedAIP aip = response.getIndexedAIP(); + if (StringUtils.isNotBlank(aip.getParentID())) { + HistoryUtils.newHistory(BrowseTop.RESOLVER, aip.getParentID()); + } else { + HistoryUtils.newHistory(BrowseTop.RESOLVER); + } }; - } else if (referrerBundle instanceof BrowseRepresentationBundle) { + } else if (response.getReferred() instanceof IndexedRepresentation) { processor = referredObject -> openReferred(referredObject, - new Filter(new SimpleFilterParameter(RodaConstants.DIP_REPRESENTATION_UUIDS, referredObject.getUUID()))); + new Filter(new SimpleFilterParameter(RodaConstants.DIP_REPRESENTATION_UUIDS, referredObject.getUUID())), + services); title = messages.catalogueRepresentationTitle(); deleteActionImpactHandler = () -> { - IndexedRepresentation representation = (IndexedRepresentation) bundle.getReferrer(); + IndexedRepresentation representation = response.getIndexedRepresentation(); HistoryUtils.newHistory(BrowseTop.RESOLVER, representation.getAipId()); }; } else { processor = referredObject -> openReferred(referredObject, - new Filter(new SimpleFilterParameter(RodaConstants.DIP_AIP_UUIDS, referredObject.getUUID()))); - title = messages.catalogueItemTitle(); + new Filter(new SimpleFilterParameter(RodaConstants.DIP_FILE_UUIDS, referredObject.getUUID())), services); + title = messages.catalogueFileTitle(); deleteActionImpactHandler = () -> { - IndexedAIP aip = (IndexedAIP) bundle.getReferrer(); - if (StringUtils.isNotBlank(aip.getParentID())) { - HistoryUtils.newHistory(BrowseTop.RESOLVER, aip.getParentID()); - } else { - HistoryUtils.newHistory(BrowseTop.RESOLVER); - } + IndexedFile file = response.getIndexedFile(); + HistoryUtils.newHistory(BrowseRepresentation.RESOLVER, file.getAipId(), file.getRepresentationId()); }; } topNavigationToolbar.setHeader(title); - topNavigationToolbar.withObject(bundle.getReferrer()); + topNavigationToolbar.withObject(response.getReferred()); topNavigationToolbar.withProcessor(processor); topNavigationToolbar.withActionImpactHandler(Actionable.ActionImpact.DESTROYED, deleteActionImpactHandler); topNavigationToolbar.withModifierKeys(true, true, false); - topNavigationToolbar.withPermissions(bundle.getReferrerPermissions()); - topNavigationToolbar.updateBreadcrumb(bundle.getReferrerBundle()); + topNavigationToolbar.withPermissions(response.getPermissions()); + topNavigationToolbar.updateBreadcrumb(response); topNavigationToolbar.build(); - Sliders.createDisseminationSlider(center, topNavigationToolbar.getDisseminationsButton(), bundle.getReferrer()); - Sliders.createInfoSlider(center, topNavigationToolbar.getInfoSidebarButton(), bundle.getReferrerBundle()); + Sliders.createDisseminationSlider(center, topNavigationToolbar.getDisseminationsButton(), response.getReferred()); + buildInfoSlider(center, topNavigationToolbar.getInfoSidebarButton(), response); container.insert(topNavigationToolbar, 0); } @@ -279,21 +458,20 @@ public BrowseDIP(Viewers viewers, BrowseDipBundle bundle) { keyboardFocus.setFocus(true); } - private static void openReferred(final T object, Filter filter) { - BrowserService.Util.getInstance().find(IndexedDIP.class.getName(), filter, DEFAULT_DIPFILE_SORTER, - new Sublist(0, 1), Facets.NONE, LocaleInfo.getCurrentLocale().getLocaleName(), true, - Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.DIP_ID), new AsyncCallback>() { + private static void openReferred(final T object, Filter filter, Services services) { - @Override - public void onFailure(Throwable caught) { - AsyncCallbackUtils.defaultFailureTreatment(caught); - } + FindRequest findRequest = FindRequest.getBuilder(IndexedDIP.class.getName(), filter, true) + .withSorter(DEFAULT_DIPFILE_SORTER).withSublist(new Sublist(0, 1)) + .withFieldsToReturn(Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.DIP_ID)).build(); - @Override - public void onSuccess(IndexResult result) { - if (result.getTotalCount() > 0) { + services.dipResource(s -> s.find(findRequest, LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((indexedDIPIndexResult, throwable) -> { + if (throwable != null) { + AsyncCallbackUtils.defaultFailureTreatment(throwable.getCause()); + } else { + if (indexedDIPIndexResult.getTotalCount() > 0) { // open DIP - HistoryUtils.openBrowse(result.getResults().get(0)); + HistoryUtils.openBrowse(indexedDIPIndexResult.getResults().get(0)); } else { // open object HistoryUtils.resolve(object); @@ -302,6 +480,89 @@ public void onSuccess(IndexResult result) { }); } + private static CompletableFuture> buildCompletableFutureRetrieveDIPFile(String historyDipUUID, + String historyDipFileUUID, Services services) { + if (historyDipFileUUID != null) { + Filter filter = new Filter(new SimpleFilterParameter(RodaConstants.INDEX_UUID, historyDipFileUUID)); + Sublist sublist = new Sublist(0, 1); + FindRequest findRequest = FindRequest.getBuilder(DIPFile.class.getName(), filter, false).withSublist(sublist) + .build(); + return services.dipFileResource(s -> s.find(findRequest, LocaleInfo.getCurrentLocale().getLocaleName())); + } else { + Filter filter = new Filter(new SimpleFilterParameter(RodaConstants.DIPFILE_DIP_ID, historyDipUUID)); + Sublist sublist = new Sublist(0, 1); + FindRequest findRequest = FindRequest.getBuilder(DIPFile.class.getName(), filter, false).withSublist(sublist) + .build(); + return services.dipFileResource(s -> s.find(findRequest, LocaleInfo.getCurrentLocale().getLocaleName())); + } + } + + private void buildInfoSlider(FlowPanel container, FocusPanel toggleButton, BrowseDIPResponse response) { + Services services = new Services("Retrieve info slider information", "get"); + + if (response.getReferred() instanceof IndexedAIP) { + BrowseAIPResponse browseAIPResponse = new BrowseAIPResponse(); + browseAIPResponse.setIndexedAIP(response.getIndexedAIP()); + + services.aipResource(AIPRestService::retrieveAIPRuleProperties).whenComplete((strings, throwable) -> { + browseAIPResponse.setRepresentationInformationFields(strings); + Sliders.createAipInfoSlider(container, toggleButton, browseAIPResponse); + }); + } else if (response.getReferred() instanceof IndexedRepresentation) { + BrowseRepresentationResponse representationResponse = new BrowseRepresentationResponse(); + representationResponse.setIndexedAIP(response.getIndexedAIP()); + representationResponse.setIndexedRepresentation(response.getIndexedRepresentation()); + + services.representationResource(RepresentationRestService::retrieveRepresentationRuleProperties) + .whenComplete((strings, throwable) -> { + representationResponse.setRiRules(strings); + Sliders.createRepresentationInfoSlider(container, toggleButton, representationResponse); + }); + } else { + BrowseFileResponse browseFileResponse = new BrowseFileResponse(); + + Filter riskIncidenceFilter = new Filter( + new SimpleFilterParameter(RodaConstants.RISK_INCIDENCE_FILE_ID, response.getIndexedFile().getId())); + CountRequest riskIncidenceCountRequest = new CountRequest(RiskIncidence.class.getName(), riskIncidenceFilter, + true); + CompletableFuture riskCounterCompletableFuture = services + .rodaEntityRestService(s -> s.count(riskIncidenceCountRequest), RiskIncidence.class) + .handle((longResponse, throwable1) -> { + if (throwable1 != null) { + return new LongResponse(-1L); + } + return longResponse; + }); + + Filter preservationEventFilter = new Filter( + new SimpleFilterParameter(RodaConstants.PRESERVATION_EVENT_FILE_UUID, response.getIndexedFile().getUUID())); + CountRequest preservationEventsCountRequest = new CountRequest(IndexedPreservationEvent.class.getName(), + preservationEventFilter, true); + + CompletableFuture preservationCounterCompletableFuture = services + .rodaEntityRestService(s -> s.count(preservationEventsCountRequest), IndexedPreservationEvent.class) + .handle((longResponse, throwable2) -> { + if (throwable2 != null) { + return new LongResponse(-1L); + } + return longResponse; + }); + + CompletableFuture> riRulesCompletableFuture = services + .fileResource(FileRestService::retrieveFileRuleProperties); + + CompletableFuture + .allOf(riskCounterCompletableFuture, preservationCounterCompletableFuture, riRulesCompletableFuture) + .thenApply(v -> { + browseFileResponse.setRiskCounterResponse(riskCounterCompletableFuture.join()); + browseFileResponse.setPreservationCounterResponse(preservationCounterCompletableFuture.join()); + browseFileResponse.setRepresentationInformationFields(riRulesCompletableFuture.join()); + return browseFileResponse; + }).whenComplete((fileResponse, throwable) -> Sliders.createFileInfoSlider(container, toggleButton, + response.getIndexedFile(), fileResponse)); + } + } + @Override protected void onLoad() { super.onLoad(); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseFile.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseFile.java index b863620030..4144ab35ad 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseFile.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseFile.java @@ -109,7 +109,7 @@ private void load(final Viewers viewers, final List historyTokens, final request.setRepresentationId(historyRepresentationId); request.setDirectoryPaths(historyFilePath); request.setFileId(historyFileId); - services.fileResource(s -> s.retrieveIndexedFile(request)).whenComplete((indexedFile, throwable) -> { + services.fileResource(s -> s.retrieveIndexedFileViaRequest(request)).whenComplete((indexedFile, throwable) -> { if (throwable != null) { AsyncCallbackUtils.defaultFailureTreatment(throwable); } else { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseRepresentation.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseRepresentation.java index 7ee561741b..df89196ad7 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseRepresentation.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/BrowseRepresentation.java @@ -437,7 +437,7 @@ private static void refresh(String aipId, String representationId, CompletableFuture indexedAIPCompletableFuture = services .aipResource(s -> s.findByUuid(aipId, LocaleInfo.getCurrentLocale().getLocaleName())); CompletableFuture indexedRepresentationCompletableFuture = services.representationResource( - s -> s.retrieveIndexedRepresentation(new IndexedRepresentationRequest(aipId, representationId))); + s -> s.retrieveIndexedRepresentationViaRequest(new IndexedRepresentationRequest(aipId, representationId))); CompletableFuture descriptiveMetadataInfosCompletableFuture = services .aipResource(s -> s.retrieveRepresentationDescriptiveMetadata(aipId, representationId, LocaleInfo.getCurrentLocale().getLocaleName())); 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 5551c5add8..8052449570 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 @@ -23,27 +23,18 @@ import org.roda.core.data.exceptions.RequestNotValidException; import org.roda.core.data.v2.accessKey.AccessKey; import org.roda.core.data.v2.accessKey.AccessKeys; -import org.roda.core.data.v2.common.ConversionProfile; +import org.roda.core.data.v2.properties.ConversionProfile; import org.roda.core.data.v2.common.Pair; -import org.roda.core.data.v2.index.IndexResult; import org.roda.core.data.v2.index.IsIndexed; -import org.roda.core.data.v2.index.facet.Facets; -import org.roda.core.data.v2.index.filter.Filter; import org.roda.core.data.v2.index.select.SelectedItems; -import org.roda.core.data.v2.index.sort.Sorter; -import org.roda.core.data.v2.index.sublist.Sublist; import org.roda.core.data.v2.ip.IndexedAIP; -import org.roda.core.data.v2.ip.IndexedDIP; import org.roda.core.data.v2.ip.Permissions; import org.roda.core.data.v2.jobs.Job; -import org.roda.core.data.v2.jobs.Report; -import org.roda.core.data.v2.notifications.Notification; import org.roda.core.data.v2.synchronization.central.DistributedInstance; import org.roda.core.data.v2.synchronization.central.DistributedInstances; import org.roda.core.data.v2.synchronization.local.LocalInstance; import org.roda.core.data.v2.validation.ValidationException; import org.roda.wui.client.browse.bundle.BrowseAIPBundle; -import org.roda.wui.client.browse.bundle.BrowseDipBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataEditBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataVersionsBundle; import org.roda.wui.client.browse.bundle.SupportedMetadataTypeBundle; @@ -97,10 +88,6 @@ void createDescriptiveMetadataFile(String aipId, String representationId, Descri String retrieveDescriptiveMetadataPreview(SupportedMetadataTypeBundle bundle) throws AuthorizationDeniedException, GenericException, ValidationException, NotFoundException, RequestNotValidException; - Set> retrieveDropdownPluginItems(String parameterId, String localeString); - - Set retrieveConversionProfilePluginItems(String pluginId, String repOrDip, String localeString); - List retrieveSupportedMetadata(String aipId, String representationUUID, String locale) throws RODAException; @@ -116,13 +103,6 @@ void deleteDescriptiveMetadataVersion(String aipId, String representationId, Str String versionId) throws AuthorizationDeniedException, RequestNotValidException, NotFoundException, GenericException; - IndexResult find(String classNameToReturn, Filter filter, Sorter sorter, Sublist sublist, - Facets facets, String localeString, boolean justActive, List fieldsToReturn) - throws GenericException, AuthorizationDeniedException, RequestNotValidException; - - T retrieve(String classNameToReturn, String id, List fieldsToReturn) - throws RODAException; - List retrieve(String classNameToReturn, SelectedItems selectedItems, List fieldsToReturn) throws GenericException, AuthorizationDeniedException, NotFoundException, RequestNotValidException; @@ -131,31 +111,17 @@ Job updateAIPPermissions(SelectedItems aips, Permissions permissions throws GenericException, AuthorizationDeniedException, RequestNotValidException, NotFoundException, JobAlreadyStartedException; - Job updateDIPPermissions(SelectedItems dips, Permissions permissions, String details) - throws GenericException, AuthorizationDeniedException, RequestNotValidException, NotFoundException; - Job appraisal(SelectedItems selected, boolean accept, String rejectReason) throws GenericException, AuthorizationDeniedException, RequestNotValidException, NotFoundException; Job changeAIPType(SelectedItems selectedAIP, String newType, String details) throws AuthorizationDeniedException, GenericException, RequestNotValidException, NotFoundException; - BrowseDipBundle retrieveDipBundle(String dipUUID, String dipFileUUID, String localeString) - throws RequestNotValidException, AuthorizationDeniedException, GenericException, NotFoundException; - - Job deleteDIPs(SelectedItems dips, String details) - throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException; - boolean hasDocumentation(String aipId) throws AuthorizationDeniedException, RequestNotValidException, GenericException; boolean hasSubmissions(String aipId) throws AuthorizationDeniedException, RequestNotValidException, GenericException; - boolean showDIPEmbedded(); - - Notification acknowledgeNotification(String notificationId, String ackToken) - throws GenericException, NotFoundException, AuthorizationDeniedException; - int getExportLimit(); Pair> retrieveAIPTypeOptions(String locale); 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 b2a3b4152b..cdcc681ac8 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 @@ -15,25 +15,17 @@ import org.roda.core.data.v2.accessKey.AccessKey; import org.roda.core.data.v2.accessKey.AccessKeys; -import org.roda.core.data.v2.common.ConversionProfile; +import org.roda.core.data.v2.properties.ConversionProfile; import org.roda.core.data.v2.common.Pair; -import org.roda.core.data.v2.index.IndexResult; import org.roda.core.data.v2.index.IsIndexed; -import org.roda.core.data.v2.index.facet.Facets; -import org.roda.core.data.v2.index.filter.Filter; import org.roda.core.data.v2.index.select.SelectedItems; -import org.roda.core.data.v2.index.sort.Sorter; -import org.roda.core.data.v2.index.sublist.Sublist; import org.roda.core.data.v2.ip.IndexedAIP; -import org.roda.core.data.v2.ip.IndexedDIP; import org.roda.core.data.v2.ip.Permissions; import org.roda.core.data.v2.jobs.Job; -import org.roda.core.data.v2.notifications.Notification; import org.roda.core.data.v2.synchronization.central.DistributedInstance; import org.roda.core.data.v2.synchronization.central.DistributedInstances; import org.roda.core.data.v2.synchronization.local.LocalInstance; import org.roda.wui.client.browse.bundle.BrowseAIPBundle; -import org.roda.wui.client.browse.bundle.BrowseDipBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataEditBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataVersionsBundle; import org.roda.wui.client.browse.bundle.SupportedMetadataTypeBundle; @@ -73,12 +65,6 @@ void createDescriptiveMetadataFile(String aipId, String representationId, Descri void retrieveDescriptiveMetadataPreview(SupportedMetadataTypeBundle bundle, AsyncCallback async); - void retrieveDropdownPluginItems(String parameterId, String localeString, - AsyncCallback>> asyncCallback); - - void retrieveConversionProfilePluginItems(String pluginId, String repOrDip, String localeString, - AsyncCallback> asyncCallback); - void retrieveSupportedMetadata(String aipId, String representationUUID, String locale, AsyncCallback> callback); @@ -91,40 +77,21 @@ void revertDescriptiveMetadataVersion(String aipId, String representationId, Str void deleteDescriptiveMetadataVersion(String aipId, String representationId, String descriptiveMetadataId, String versionId, AsyncCallback callback); - void find(String classNameToReturn, Filter filter, Sorter sorter, Sublist sublist, - Facets facets, String localeString, boolean justActive, List fieldsToReturn, - AsyncCallback> callback); - - void retrieve(String classNameToReturn, String id, List fieldsToReturn, - AsyncCallback callback); - void retrieve(String classNameToReturn, SelectedItems selectedItems, List fieldsToReturn, AsyncCallback> asyncCallback); void updateAIPPermissions(SelectedItems aips, Permissions permissions, String details, boolean recursive, AsyncCallback callback); - void updateDIPPermissions(SelectedItems dips, Permissions permissions, String details, - AsyncCallback callback); - void appraisal(SelectedItems selected, boolean accept, String rejectReason, AsyncCallback callback); void changeAIPType(SelectedItems selectedAIP, String newType, String details, AsyncCallback loadingAsyncCallback); - void retrieveDipBundle(String dipUUID, String dipFileUUID, String localeString, - AsyncCallback callback); - - void deleteDIPs(SelectedItems dips, String details, AsyncCallback async); - void hasDocumentation(String aipId, AsyncCallback asyncCallback); void hasSubmissions(String aipId, AsyncCallback asyncCallback); - void showDIPEmbedded(AsyncCallback asyncCallback); - - void acknowledgeNotification(String notificationId, String ackToken, AsyncCallback asyncCallback); - void getExportLimit(AsyncCallback asyncCallback); void retrieveAIPTypeOptions(String locale, AsyncCallback>> asyncCallback); 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 06664b6d7a..fd2eed9a17 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 @@ -15,12 +15,21 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.stream.Collectors; import org.roda.core.data.common.RodaConstants; +import org.roda.core.data.v2.generics.UpdatePermissionsRequest; +import org.roda.core.data.v2.index.FindRequest; +import org.roda.core.data.v2.index.IsIndexed; +import org.roda.core.data.v2.index.filter.BasicSearchFilterParameter; import org.roda.core.data.v2.index.filter.Filter; +import org.roda.core.data.v2.index.filter.FilterParameter; import org.roda.core.data.v2.index.filter.NotSimpleFilterParameter; +import org.roda.core.data.v2.index.filter.OrFiltersParameters; +import org.roda.core.data.v2.index.filter.SimpleFilterParameter; import org.roda.core.data.v2.index.select.SelectedItems; import org.roda.core.data.v2.index.select.SelectedItemsList; +import org.roda.core.data.v2.index.sublist.Sublist; import org.roda.core.data.v2.ip.HasPermissions; import org.roda.core.data.v2.ip.IndexedAIP; import org.roda.core.data.v2.ip.IndexedDIP; @@ -37,6 +46,7 @@ import org.roda.wui.client.common.lists.utils.ClientSelectedItemsUtils; import org.roda.wui.client.common.utils.JavascriptUtils; import org.roda.wui.client.ingest.process.ShowJob; +import org.roda.wui.client.services.Services; import org.roda.wui.common.client.HistoryResolver; import org.roda.wui.common.client.tools.DescriptionLevelUtils; import org.roda.wui.common.client.tools.HistoryUtils; @@ -52,6 +62,7 @@ import com.google.gwt.event.logical.shared.AttachEvent.Handler; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.i18n.client.LocaleInfo; import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.safehtml.shared.SafeHtmlUtils; import com.google.gwt.uibinder.client.UiBinder; @@ -71,165 +82,35 @@ public class EditPermissions extends Composite { - public static final HistoryResolver AIP_RESOLVER = new HistoryResolver() { - - @Override - public void resolve(List historyTokens, final AsyncCallback callback) { - if (historyTokens.size() == 1) { - final String aipId = historyTokens.get(0); - BrowserService.Util.getInstance().retrieve(IndexedAIP.class.getName(), aipId, - RodaConstants.AIP_PERMISSIONS_FIELDS_TO_RETURN, new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - HistoryUtils.newHistory(BrowseTop.RESOLVER); - callback.onSuccess(null); - } - - @Override - public void onSuccess(IndexedAIP aip) { - EditPermissions edit = new EditPermissions(IndexedAIP.class.getName(), aip); - edit.title.setIcon(DescriptionLevelUtils.getElementLevelIconSafeHtml(aip.getLevel(), false)); - edit.title.setText(aip.getTitle() != null ? aip.getTitle() : aip.getId()); - callback.onSuccess(edit); - } - }); - - } else if (historyTokens.isEmpty()) { - LastSelectedItemsSingleton selectedItems = LastSelectedItemsSingleton.getInstance(); - final SelectedItems selected = (SelectedItems) selectedItems.getSelectedItems(); - - if (!ClientSelectedItemsUtils.isEmpty(selected)) { - BrowserService.Util.getInstance().retrieve(IndexedAIP.class.getName(), selected, - RodaConstants.AIP_PERMISSIONS_FIELDS_TO_RETURN, new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - HistoryUtils.newHistory(BrowseTop.RESOLVER); - callback.onSuccess(null); - } - - @Override - public void onSuccess(List aips) { - List hasPermissionsObjects = aips; - EditPermissions edit = new EditPermissions(IndexedAIP.class.getName(), selected, hasPermissionsObjects); - callback.onSuccess(edit); - } - }); - } - } else { - HistoryUtils.newHistory(BrowseTop.RESOLVER); - callback.onSuccess(null); - } - } - - @Override - public void isCurrentUserPermitted(AsyncCallback callback) { - UserLogin.getInstance().checkRoles(new HistoryResolver[] {EditPermissions.AIP_RESOLVER}, false, callback); - } - - @Override - public List getHistoryPath() { - return ListUtils.concat(BrowseTop.RESOLVER.getHistoryPath(), getHistoryToken()); - } - - @Override - public String getHistoryToken() { - return "edit_permissions"; - } - }; - - public static final HistoryResolver DIP_RESOLVER = new HistoryResolver() { - - @Override - public void resolve(List historyTokens, final AsyncCallback callback) { - if (historyTokens.size() == 1) { - final String dipId = historyTokens.get(0); - BrowserService.Util.getInstance().retrieve(IndexedDIP.class.getName(), dipId, - RodaConstants.DIP_PERMISSIONS_FIELDS_TO_RETURN, new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - HistoryUtils.newHistory(BrowseDIP.RESOLVER, dipId); - callback.onSuccess(null); - } - - @Override - public void onSuccess(IndexedDIP dip) { - EditPermissions edit = new EditPermissions(IndexedDIP.class.getName(), dip); - callback.onSuccess(edit); - } - }); - } 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); - } - }); - } - } else { - HistoryUtils.newHistory(BrowseTop.RESOLVER); - callback.onSuccess(null); - } - } - - @Override - public void isCurrentUserPermitted(AsyncCallback callback) { - UserLogin.getInstance().checkRoles(new HistoryResolver[] {EditPermissions.DIP_RESOLVER}, false, callback); - } - - @Override - public List getHistoryPath() { - return ListUtils.concat(BrowseTop.RESOLVER.getHistoryPath(), getHistoryToken()); - } - - @Override - public String getHistoryToken() { - return "edit_dip_permissions"; - } - }; - - interface MyUiBinder extends UiBinder { - } - - private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); private static final ClientMessages messages = GWT.create(ClientMessages.class); - + private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); + private final String objectClass; @UiField FlowPanel editPermissionsDescription; - @UiField - Label userPermissionsEmpty, groupPermissionsEmpty; - + Label userPermissionsEmpty; @UiField - FlowPanel userPermissionsPanel, groupPermissionsPanel; - + Label groupPermissionsEmpty; + @UiField + FlowPanel userPermissionsPanel; + @UiField + FlowPanel groupPermissionsPanel; @UiField Button buttonApplyToAll; - @UiField TitlePanel title; - private List objects = new ArrayList<>(); - private String objectClass = null; private String objectId = null; private SelectedItems selectedItems; + public EditPermissions(String objectClass, SelectedItems items) { + this.objectClass = objectClass; + this.selectedItems = items; + initWidget(uiBinder.createAndBindUi(this)); + buttonApplyToAll.setVisible(IndexedAIP.class.getName().equals(objectClass)); + editPermissionsDescription.add(new HTMLWidgetWrapper("EditMultiplePermissionsDescription.html")); + } + public EditPermissions(String objectClass, HasPermissions object) { this.objects.add(object); this.objectClass = objectClass; @@ -393,6 +274,10 @@ void buttonAddHandler(ClickEvent e) { filter.add(new NotSimpleFilterParameter(RodaConstants.MEMBERS_ID, groupname)); } + if (getAssignedUserNames().isEmpty() && getAssignedGroupNames().isEmpty()) { + filter = new Filter(new BasicSearchFilterParameter(RodaConstants.INDEX_SEARCH, RodaConstants.INDEX_WILDCARD)); + } + MemberSelectDialog selectDialog = new MemberSelectDialog(messages.selectUserOrGroupToAdd(), filter); selectDialog.showAndCenter(); selectDialog.addValueChangeHandler(new ValueChangeHandler() { @@ -496,27 +381,26 @@ public void onSuccess(final Void nothing) { } }); } else if (IndexedDIP.class.getName().equals(objectClass)) { - SelectedItems dips = (SelectedItems) selectedItems; - BrowserService.Util.getInstance().updateDIPPermissions(dips, permissions, details, - new LoadingAsyncCallback() { + Services services = new Services("Update DIP permissions", "update"); + UpdatePermissionsRequest request = new UpdatePermissionsRequest<>(); + request.setPermissions(permissions); + request.setItemsToUpdate((SelectedItems) selectedItems); + request.setDetails(details); + services.dipResource(s -> s.updatePermissions(request)).whenComplete((job, throwable) -> { + Toast.showInfo(messages.runningInBackgroundTitle(), messages.runningInBackgroundDescription()); + Dialogs.showJobRedirectDialog(messages.jobCreatedMessage(), new AsyncCallback() { @Override - public void onSuccessImpl(Job result) { - Toast.showInfo(messages.runningInBackgroundTitle(), messages.runningInBackgroundDescription()); - Dialogs.showJobRedirectDialog(messages.jobCreatedMessage(), new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - // do nothing - } + public void onFailure(Throwable caught) { + // do nothing + } - @Override - public void onSuccess(final Void nothing) { - HistoryUtils.newHistory(ShowJob.RESOLVER, result.getId()); - } - }); + @Override + public void onSuccess(final Void nothing) { + HistoryUtils.newHistory(ShowJob.RESOLVER, job.getId()); } }); + }); } } }); @@ -525,7 +409,77 @@ public void onSuccess(final Void nothing) { @UiHandler("buttonApply") void buttonApplyHandler(ClickEvent e) { apply(false); - } + } public static final HistoryResolver AIP_RESOLVER = new HistoryResolver() { + + @Override + public void resolve(List historyTokens, final AsyncCallback callback) { + if (historyTokens.size() == 1) { + final String aipId = historyTokens.get(0); + Services services = new Services("Retrieve AIP", "get"); + services.aipResource(s -> s.findByUuid(aipId, LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((aip, throwable) -> { + if (throwable != null) { + HistoryUtils.newHistory(BrowseTop.RESOLVER); + callback.onSuccess(null); + } else { + EditPermissions edit = new EditPermissions(IndexedAIP.class.getName(), aip); + edit.title.setIcon(DescriptionLevelUtils.getElementLevelIconSafeHtml(aip.getLevel(), false)); + edit.title.setText(aip.getTitle() != null ? aip.getTitle() : aip.getId()); + callback.onSuccess(edit); + } + }); + } else if (historyTokens.isEmpty()) { + LastSelectedItemsSingleton selectedItems = LastSelectedItemsSingleton.getInstance(); + + 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 AIPs", "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(IndexedAIP.class.getName(), + (SelectedItems) selectedItems.getSelectedItems(), hasPermissionsObjects); + callback.onSuccess(edit); + } + }); + } + } else { + EditPermissions editPermissions = new EditPermissions(IndexedAIP.class.getName(), selected); + callback.onSuccess(editPermissions); + } + } else { + HistoryUtils.newHistory(BrowseTop.RESOLVER); + callback.onSuccess(null); + } + } + + @Override + public void isCurrentUserPermitted(AsyncCallback callback) { + UserLogin.getInstance().checkRoles(new HistoryResolver[] {EditPermissions.AIP_RESOLVER}, false, callback); + } + + @Override + public List getHistoryPath() { + return ListUtils.concat(BrowseTop.RESOLVER.getHistoryPath(), getHistoryToken()); + } + + @Override + public String getHistoryToken() { + return "edit_permissions"; + } + }; @UiHandler("buttonApplyToAll") void buttonApplyToAllHandler(ClickEvent e) { @@ -545,6 +499,9 @@ void buttonCancelHandler(ClickEvent e) { } } + interface MyUiBinder extends UiBinder { + } + public class PermissionPanel extends Composite { private FlowPanel panel; private FlowPanel panelBody; @@ -680,4 +637,68 @@ public PermissionType getPermissionType() { } } } + + + + public static final HistoryResolver DIP_RESOLVER = new HistoryResolver() { + + @Override + public void resolve(List historyTokens, final AsyncCallback callback) { + if (historyTokens.size() == 1) { + final String dipId = historyTokens.get(0); + Services services = new Services("Retrieve DIP", "get"); + services.dipResource(s -> s.findByUuid(dipId, LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((indexedDIP, throwable) -> { + if (throwable != null) { + HistoryUtils.newHistory(BrowseDIP.RESOLVER, dipId); + callback.onSuccess(null); + } else { + EditPermissions edit = new EditPermissions(IndexedDIP.class.getName(), indexedDIP); + callback.onSuccess(edit); + } + }); + } 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); + } + }); + } + } else { + HistoryUtils.newHistory(BrowseTop.RESOLVER); + callback.onSuccess(null); + } + } + + @Override + public void isCurrentUserPermitted(AsyncCallback callback) { + UserLogin.getInstance().checkRoles(new HistoryResolver[] {EditPermissions.DIP_RESOLVER}, false, callback); + } + + @Override + public List getHistoryPath() { + return ListUtils.concat(BrowseTop.RESOLVER.getHistoryPath(), getHistoryToken()); + } + + @Override + public String getHistoryToken() { + return "edit_dip_permissions"; + } + }; + } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/ShowPreservationEvent.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/ShowPreservationEvent.java index b91d8630b4..e0e0708f93 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/ShowPreservationEvent.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/ShowPreservationEvent.java @@ -162,7 +162,7 @@ public ShowPreservationEvent(final String eventId) { .thenCompose(event -> services.preservationEventsResource(s -> s.getPreservationAgents(event.getId())) .thenCompose(indexedPreservationAgents -> services .preservationEventsResource(s -> s.getLinkingIdentifierObjects(event.getId())) - .whenComplete((test, throwable) -> { + .whenComplete((linkingObjects, throwable) -> { if (throwable != null) { if (throwable instanceof NotFoundException) { Toast.showError(messages.notFoundError(), messages.couldNotFindPreservationEvent()); @@ -173,7 +173,7 @@ public ShowPreservationEvent(final String eventId) { } else { this.preservationEvent = event; this.agents = indexedPreservationAgents; - this.linkingObjects = test; + this.linkingObjects = linkingObjects; viewAction(); } }))); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/bundle/BrowseDipBundle.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/bundle/BrowseDipBundle.java deleted file mode 100644 index 12be11dbff..0000000000 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/bundle/BrowseDipBundle.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE file at the root of the source - * tree and available online at - * - * https://github.com/keeps/roda - */ -package org.roda.wui.client.browse.bundle; - -import java.util.List; - -import org.roda.core.data.v2.index.IsIndexed; -import org.roda.core.data.v2.ip.DIPFile; -import org.roda.core.data.v2.ip.IndexedDIP; -import org.roda.core.data.v2.ip.Permissions; - -public class BrowseDipBundle implements Bundle { - - private static final long serialVersionUID = 1L; - - private IsIndexed referrer; - private Bundle referrerBundle; - - private IndexedDIP dip; - - private DIPFile dipFile; - private List dipFileAncestors; - - private Permissions referrerPermissions; - - public BrowseDipBundle() { - super(); - } - - public IsIndexed getReferrer() { - return referrer; - } - - public void setReferrer(IsIndexed referrer) { - this.referrer = referrer; - } - - public Bundle getReferrerBundle() { - return referrerBundle; - } - - public void setReferrerBundle(Bundle referrerBundle) { - this.referrerBundle = referrerBundle; - } - - public IndexedDIP getDip() { - return dip; - } - - public void setDip(IndexedDIP dip) { - this.dip = dip; - } - - public DIPFile getDipFile() { - return dipFile; - } - - public void setDipFile(DIPFile dipFile) { - this.dipFile = dipFile; - } - - public List getDipFileAncestors() { - return dipFileAncestors; - } - - public void setDipFileAncestors(List dipFileAncestors) { - this.dipFileAncestors = dipFileAncestors; - } - - public Permissions getReferrerPermissions() { - return referrerPermissions; - } - - public void setReferrerPermissions(Permissions referrerPermissions) { - this.referrerPermissions = referrerPermissions; - } -} diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/bundle/BrowseFileBundle.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/bundle/BrowseFileBundle.java deleted file mode 100644 index 074a5eea19..0000000000 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/bundle/BrowseFileBundle.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE file at the root of the source - * tree and available online at - * - * https://github.com/keeps/roda - */ -package org.roda.wui.client.browse.bundle; - -import java.util.List; - -import org.roda.core.data.v2.ip.IndexedAIP; -import org.roda.core.data.v2.ip.IndexedFile; -import org.roda.core.data.v2.ip.IndexedRepresentation; - -public class BrowseFileBundle implements Bundle { - - private static final long serialVersionUID = 7901536603462531124L; - - private List aipAncestors; - private IndexedAIP aip; - private IndexedRepresentation representation; - private IndexedFile file; - private Long totalSiblingCount; - private Long dipCount; - private List representationInformationFields; - private Long riskIncidenceCount; - private Long preservationEventCount; - private String instanceName; - - private boolean localToInstance; - private Boolean isAvailable; - - public BrowseFileBundle() { - super(); - } - - public List getAipAncestors() { - return aipAncestors; - } - - public void setAipAncestors(List aipAncestors) { - this.aipAncestors = aipAncestors; - } - - public IndexedAIP getAip() { - return aip; - } - - public void setAip(IndexedAIP aip) { - this.aip = aip; - } - - public IndexedRepresentation getRepresentation() { - return representation; - } - - public void setRepresentation(IndexedRepresentation representation) { - this.representation = representation; - } - - public IndexedFile getFile() { - return file; - } - - public void setFile(IndexedFile file) { - this.file = file; - } - - public Long getTotalSiblingCount() { - return totalSiblingCount; - } - - public void setTotalSiblingCount(Long totalSiblingCount) { - this.totalSiblingCount = totalSiblingCount; - } - - public Long getDipCount() { - return dipCount; - } - - public void setDipCount(Long dipCount) { - this.dipCount = dipCount; - } - - public List getRepresentationInformationFields() { - return representationInformationFields; - } - - public void setRepresentationInformationFields(List representationInformationFields) { - this.representationInformationFields = representationInformationFields; - } - - public Long getRiskIncidenceCount() { - return riskIncidenceCount; - } - - public void setRiskIncidenceCount(Long riskIncidenceCount) { - this.riskIncidenceCount = riskIncidenceCount; - } - - public Long getPreservationEventCount() { - return preservationEventCount; - } - - public void setPreservationEventCount(Long preservationEventCount) { - this.preservationEventCount = preservationEventCount; - } - - public String getInstanceName() { - return instanceName; - } - - public void setInstanceName(String instanceName) { - this.instanceName = instanceName; - } - - public boolean isLocalToInstance() { - return localToInstance; - } - - public void setLocalToInstance(boolean localToInstance) { - this.localToInstance = localToInstance; - } - - public Boolean isAvailable() { - return isAvailable; - } - - public void setAvailable(Boolean isAvailable) { - this.isAvailable = isAvailable; - } -} diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/bundle/BrowseRepresentationBundle.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/bundle/BrowseRepresentationBundle.java deleted file mode 100644 index 695e9c476d..0000000000 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/browse/bundle/BrowseRepresentationBundle.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE file at the root of the source - * tree and available online at - * - * https://github.com/keeps/roda - */ -package org.roda.wui.client.browse.bundle; - -import java.util.ArrayList; -import java.util.List; - -import org.roda.core.data.v2.ip.IndexedAIP; -import org.roda.core.data.v2.ip.IndexedRepresentation; - -public class BrowseRepresentationBundle implements Bundle { - - private static final long serialVersionUID = 7901536603462531124L; - - private List aipAncestors = new ArrayList<>(); - private IndexedAIP aip; - private IndexedRepresentation representation; - private List representationDescriptiveMetadata = new ArrayList<>(); - private Long dipCount; - private List representationInformationFields; - private Long riskIncidenceCount; - private Long preservationEventCount; - private String instanceName; - - private boolean localToInstance; - - public BrowseRepresentationBundle() { - super(); - } - - public BrowseRepresentationBundle(List aipAncestors, IndexedAIP aip, IndexedRepresentation representation, - List representationDescriptiveMetadata, Long dipCount, - List representationInformationFields) { - super(); - this.aipAncestors = aipAncestors; - this.aip = aip; - this.representation = representation; - this.representationDescriptiveMetadata = representationDescriptiveMetadata; - this.dipCount = dipCount; - this.representationInformationFields = representationInformationFields; - } - - public List getAipAncestors() { - return aipAncestors; - } - - public void setAipAncestors(List aipAncestors) { - this.aipAncestors = aipAncestors; - } - - public IndexedAIP getAip() { - return aip; - } - - public void setAip(IndexedAIP aip) { - this.aip = aip; - } - - public IndexedRepresentation getRepresentation() { - return representation; - } - - public void setRepresentation(IndexedRepresentation representation) { - this.representation = representation; - } - - public List getRepresentationDescriptiveMetadata() { - return representationDescriptiveMetadata; - } - - public void setRepresentationDescriptiveMetadata( - List representationDescriptiveMetadata) { - this.representationDescriptiveMetadata = representationDescriptiveMetadata; - } - - public Long getDipCount() { - return dipCount; - } - - public void setDipCount(Long dipCount) { - this.dipCount = dipCount; - } - - public List getRepresentationInformationFields() { - return representationInformationFields; - } - - public void setRepresentationInformationFields(List representationInformationFields) { - this.representationInformationFields = representationInformationFields; - } - - public Long getRiskIncidenceCount() { - return riskIncidenceCount; - } - - public void setRiskIncidenceCount(Long riskIncidenceCount) { - this.riskIncidenceCount = riskIncidenceCount; - } - - public Long getPreservationEventCount() { - return preservationEventCount; - } - - public void setPreservationEventCount(Long preservationEventCount) { - this.preservationEventCount = preservationEventCount; - } - - public String getInstanceName() { - return instanceName; - } - - public void setInstanceName(String instanceName) { - this.instanceName = instanceName; - } - - public boolean isLocalToInstance() { - return localToInstance; - } - - public void setLocalToInstance(boolean localToInstance) { - this.localToInstance = localToInstance; - } -} diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/NavigationToolbar.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/NavigationToolbar.java index 9dab649b30..28ba55ce6b 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/NavigationToolbar.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/NavigationToolbar.java @@ -26,10 +26,6 @@ import org.roda.core.data.v2.ip.Permissions; import org.roda.core.data.v2.ip.TransferredResource; import org.roda.wui.client.browse.bundle.BrowseAIPBundle; -import org.roda.wui.client.browse.bundle.BrowseDipBundle; -import org.roda.wui.client.browse.bundle.BrowseFileBundle; -import org.roda.wui.client.browse.bundle.BrowseRepresentationBundle; -import org.roda.wui.client.browse.bundle.Bundle; import org.roda.wui.client.common.actions.AbstractActionable; import org.roda.wui.client.common.actions.Actionable; import org.roda.wui.client.common.actions.AipActions; @@ -44,6 +40,7 @@ import org.roda.wui.client.common.actions.widgets.ActionableWidgetBuilder; import org.roda.wui.client.common.lists.pagination.ListSelectionUtils; import org.roda.wui.client.common.lists.pagination.ListSelectionUtils.ProcessRelativeItem; +import org.roda.wui.client.common.model.BrowseDIPResponse; import org.roda.wui.client.common.popup.CalloutPopup; import org.roda.wui.client.common.search.SearchFilters; import org.roda.wui.client.common.utils.HtmlSnippetUtils; @@ -70,61 +67,45 @@ import config.i18n.client.ClientMessages; public class NavigationToolbar extends Composite implements HasHandlers { - private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); private static final ClientMessages messages = GWT.create(ClientMessages.class); - - private boolean requireControlKeyModifier = true; - private boolean requireShiftKeyModifier = false; - private boolean requireAltKeyModifier = false; - private boolean skipButtonSetup = false; - - interface MyUiBinder extends UiBinder { - } - + private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); @UiField AccessibleFocusPanel keyboardFocus; - - // breadcrumb on left side - @UiField Label navigationToolbarHeader; - @UiField BreadcrumbPanel breadcrumb; - @UiField HTML aipState; - @UiField HTML pageInformation; - - // buttons on the right side - @UiField AccessibleFocusPanel disseminationsButton; + // breadcrumb on left side @UiField AccessibleFocusPanel searchButton; - @UiField - AccessibleFocusPanel nextButton, previousButton; + AccessibleFocusPanel nextButton; + @UiField + AccessibleFocusPanel previousButton; ProcessRelativeItem processor; + // buttons on the right side @UiField AccessibleFocusPanel infoSidebarButton; - @UiField AccessibleFocusPanel actionsButton; - @UiField FlowPanel toolbarPanel; - + private boolean requireControlKeyModifier = true; + private boolean requireShiftKeyModifier = false; + private boolean requireAltKeyModifier = false; + private boolean skipButtonSetup = false; private T currentObject = null; private Permissions permissions = null; private HandlerRegistration searchPopupClickHandler = null; - private Map handlers = new EnumMap<>(Actionable.ActionImpact.class); - private AsyncCallback handler = new NoAsyncCallback() { @Override public void onSuccess(Actionable.ActionImpact result) { @@ -349,20 +330,16 @@ private void setupActions() { } } - // Breadcrumb management - public void clearBreadcrumb() { breadcrumb.clear(); } + // Breadcrumb management + public void updateBreadcrumb(BrowseAIPBundle bundle) { breadcrumb.updatePath(BreadcrumbUtils.getAipBreadcrumbs(bundle.getAIPAncestors(), bundle.getAip())); } - public void updateBreadcrumb(BrowseRepresentationBundle bundle) { - breadcrumb.updatePath(BreadcrumbUtils.getRepresentationBreadcrumbs(bundle)); - } - public void updateBreadcrumb(List ancestors, IndexedAIP indexedAIP, IndexedRepresentation indexedRepresentation) { breadcrumb.updatePath(BreadcrumbUtils.getRepresentationBreadcrumbs(ancestors, indexedAIP, indexedRepresentation)); @@ -375,22 +352,19 @@ public void updateBreadcrumb(IndexedAIP indexedAIP, IndexedRepresentation indexe aipState.setVisible(AIPState.ACTIVE != indexedAIP.getState()); } - public void updateBreadcrumb(BrowseDipBundle bundle) { - breadcrumb.updatePath( - BreadcrumbUtils.getDipBreadcrumbs(bundle.getDip(), bundle.getDipFile(), bundle.getDipFileAncestors())); + public void updateBreadcrumb(IndexedDIP dip, DIPFile dipFile, List ancestors) { + breadcrumb.updatePath(BreadcrumbUtils.getDipBreadcrumbs(dip, dipFile, ancestors)); } - public void updateBreadcrumb(Bundle dipReferrerBundle) { - if (dipReferrerBundle instanceof BrowseFileBundle) { - BrowseFileBundle bundle = (BrowseFileBundle) dipReferrerBundle; - breadcrumb - .updatePath(BreadcrumbUtils.getFileBreadcrumbs(bundle.getAip(), bundle.getRepresentation(), bundle.getFile())); - } else if (dipReferrerBundle instanceof BrowseRepresentationBundle) { - BrowseRepresentationBundle bundle = (BrowseRepresentationBundle) dipReferrerBundle; - breadcrumb.updatePath(BreadcrumbUtils.getRepresentationBreadcrumbs(bundle.getAip(), bundle.getRepresentation())); - } else if (dipReferrerBundle instanceof BrowseAIPBundle) { - BrowseAIPBundle bundle = (BrowseAIPBundle) dipReferrerBundle; - breadcrumb.updatePath(BreadcrumbUtils.getAipBreadcrumbs(bundle.getAip())); + public void updateBreadcrumb(BrowseDIPResponse response) { + if (response.getReferred() instanceof IndexedFile) { + breadcrumb.updatePath(BreadcrumbUtils.getFileBreadcrumbs(response.getIndexedAIP(), + response.getIndexedRepresentation(), response.getIndexedFile())); + } else if (response.getReferred() instanceof IndexedRepresentation) { + breadcrumb.updatePath( + BreadcrumbUtils.getRepresentationBreadcrumbs(response.getIndexedAIP(), response.getIndexedRepresentation())); + } else if (response.getReferred() instanceof IndexedAIP) { + breadcrumb.updatePath(BreadcrumbUtils.getAipBreadcrumbs(response.getIndexedAIP())); } } @@ -413,6 +387,9 @@ private void clearSearchPopupHandlers() { searchPopupClickHandler = null; } + interface MyUiBinder extends UiBinder { + } + private static class SearchPopup extends CalloutPopup { public SearchPopup(IndexedAIP aip) { super(); @@ -431,19 +408,8 @@ private SearchAipActions() { // do nothing } - public enum SearchAipAction implements Action { - SEARCH_DESCENDANTS(), SEARCH_PACKAGE(); - - private List methods; - - SearchAipAction(String... methods) { - this.methods = Arrays.asList(methods); - } - - @Override - public List getMethods() { - return this.methods; - } + public static SearchAipActions get() { + return INSTANCE; } @Override @@ -456,10 +422,6 @@ public Action actionForName(String name) { return SearchAipAction.valueOf(name); } - public static SearchAipActions get() { - return INSTANCE; - } - @Override public boolean canAct(Action action, IndexedAIP object) { return POSSIBLE_ACTIONS.contains(action); @@ -521,5 +483,20 @@ public ActionableBundle createActionsBundle() { actionableBundle.addGroup(searchGroup); return actionableBundle; } + + public enum SearchAipAction implements Action { + SEARCH_DESCENDANTS(), SEARCH_PACKAGE(); + + private List methods; + + SearchAipAction(String... methods) { + this.methods = Arrays.asList(methods); + } + + @Override + public List getMethods() { + return this.methods; + } + } } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/DisposalConfirmationReportActions.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/DisposalConfirmationReportActions.java index 294cb42369..1e59b0864d 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/DisposalConfirmationReportActions.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/DisposalConfirmationReportActions.java @@ -30,10 +30,17 @@ import org.roda.wui.client.ingest.process.ShowJob; import org.roda.wui.client.services.Services; import org.roda.wui.common.client.tools.HistoryUtils; +import org.roda.wui.common.client.tools.RestUtils; import org.roda.wui.common.client.widgets.Toast; import com.google.gwt.core.client.GWT; +import com.google.gwt.http.client.Request; +import com.google.gwt.http.client.RequestBuilder; +import com.google.gwt.http.client.RequestCallback; +import com.google.gwt.http.client.RequestException; +import com.google.gwt.http.client.Response; import com.google.gwt.regexp.shared.RegExp; +import com.google.gwt.safehtml.shared.SafeUri; import com.google.gwt.user.client.rpc.AsyncCallback; import config.i18n.client.ClientMessages; @@ -124,17 +131,31 @@ public void act(Action action, DisposalConfirmation object private void retrieveDisposalConfirmationReportForPrint(DisposalConfirmation confirmation, AsyncCallback callback) { - Services services = new Services("Retrieve disposal confirmation report", "get"); - services.disposalConfirmationResource(s -> s.retrieveDisposalConfirmationReport(confirmation.getId(), true)) - .whenComplete((report, throwable) -> { - if (throwable != null) { + + SafeUri uri = RestUtils.createDisposalConfirmationHTMLUri(confirmation.getId(), true); + RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, uri.asString()); + try { + requestBuilder.sendRequest(null, new RequestCallback() { + + @Override + public void onResponseReceived(Request request, Response response) { + if (200 == response.getStatusCode()) { + JavascriptUtils.print(response.getText()); + callback.onSuccess(Actionable.ActionImpact.NONE); + } else { + callback.onFailure(null); + } + } + + @Override + public void onError(Request request, Throwable throwable) { AsyncCallbackUtils.defaultFailureTreatment(throwable); callback.onFailure(throwable); - } else { - JavascriptUtils.print(report); - callback.onSuccess(Actionable.ActionImpact.NONE); } }); + } catch (RequestException e) { + callback.onFailure(e); + } } private void reExecuteDisposalConfirmation(DisposalConfirmation confirmation, AsyncCallback callback) { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/DisseminationActions.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/DisseminationActions.java index d5c8248d31..09b71101cb 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/DisseminationActions.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/DisseminationActions.java @@ -13,21 +13,20 @@ import java.util.Set; import org.roda.core.data.common.RodaConstants; +import org.roda.core.data.v2.generics.DeleteRequest; import org.roda.core.data.v2.index.select.SelectedItems; import org.roda.core.data.v2.ip.IndexedDIP; import org.roda.core.data.v2.ip.Permissions; -import org.roda.core.data.v2.jobs.Job; import org.roda.wui.client.browse.BrowseTop; -import org.roda.wui.client.browse.BrowserService; import org.roda.wui.client.browse.EditPermissions; import org.roda.wui.client.common.LastSelectedItemsSingleton; -import org.roda.wui.client.common.actions.callbacks.ActionLoadingAsyncCallback; import org.roda.wui.client.common.actions.callbacks.ActionNoAsyncCallback; import org.roda.wui.client.common.actions.model.ActionableBundle; import org.roda.wui.client.common.actions.model.ActionableGroup; import org.roda.wui.client.common.dialogs.Dialogs; import org.roda.wui.client.ingest.process.ShowJob; import org.roda.wui.client.process.CreateSelectedJob; +import org.roda.wui.client.services.Services; import org.roda.wui.common.client.tools.HistoryUtils; import org.roda.wui.common.client.tools.RestUtils; import org.roda.wui.common.client.widgets.Toast; @@ -35,7 +34,6 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.safehtml.shared.SafeUri; -import com.google.gwt.user.client.History; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -58,21 +56,12 @@ private DisseminationActions(Permissions permissions) { this.permissions = permissions; } - public enum DisseminationAction implements Action { - DOWNLOAD(), REMOVE(RodaConstants.PERMISSION_METHOD_DELETE_DIP), - NEW_PROCESS(RodaConstants.PERMISSION_METHOD_CREATE_JOB), - UPDATE_PERMISSIONS(RodaConstants.PERMISSION_METHOD_UPDATE_DIP_PERMISSIONS); - - private List methods; - - DisseminationAction(String... methods) { - this.methods = Arrays.asList(methods); - } + public static DisseminationActions get() { + return INSTANCE; + } - @Override - public List getMethods() { - return this.methods; - } + public static DisseminationActions get(Permissions permissions) { + return new DisseminationActions(permissions); } @Override @@ -85,14 +74,6 @@ public DisseminationAction actionForName(String name) { return DisseminationAction.valueOf(name); } - public static DisseminationActions get() { - return INSTANCE; - } - - public static DisseminationActions get(Permissions permissions) { - return new DisseminationActions(permissions); - } - @Override public boolean canAct(Action action, IndexedDIP dip) { return hasPermissions(action, dip.getPermissions()) && POSSIBLE_ACTIONS_ON_SINGLE_DISSEMINATION.contains(action); @@ -143,47 +124,7 @@ private void download(IndexedDIP dissemination, AsyncCallback call } private void remove(final IndexedDIP dip, AsyncCallback callback) { - Dialogs.showConfirmDialog(messages.browseFileDipRepresentationConfirmTitle(), - messages.browseFileDipRepresentationConfirmMessage(), messages.dialogCancel(), messages.dialogYes(), - new ActionNoAsyncCallback(callback) { - - @Override - public void onSuccess(Boolean confirmed) { - if (confirmed) { - Dialogs.showPromptDialog(messages.outcomeDetailTitle(), null, null, messages.outcomeDetailPlaceholder(), - RegExp.compile(".*"), messages.cancelButton(), messages.confirmButton(), false, false, - new ActionNoAsyncCallback(callback) { - - @Override - public void onSuccess(final String details) { - BrowserService.Util.getInstance().deleteDIPs(objectToSelectedItems(dip, IndexedDIP.class), details, - new ActionLoadingAsyncCallback(callback) { - - @Override - public void onSuccessImpl(Job result) { - Toast.showInfo(messages.runningInBackgroundTitle(), messages.runningInBackgroundDescription()); - - Dialogs.showJobRedirectDialog(messages.removeJobCreatedMessage(), new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - doActionCallbackDestroyed(); - } - - @Override - public void onSuccess(final Void nothing) { - doActionCallbackNone(); - HistoryUtils.newHistory(ShowJob.RESOLVER, result.getId()); - } - }); - } - }); - } - }); - } else { - doActionCallbackNone(); - } - } - }); + remove(objectToSelectedItems(dip, IndexedDIP.class), callback); } private void remove(final SelectedItems selectedItems, final AsyncCallback callback) { @@ -200,30 +141,36 @@ public void onSuccess(Boolean confirmed) { @Override public void onSuccess(final String details) { - BrowserService.Util.getInstance().deleteDIPs(selectedItems, details, - new ActionLoadingAsyncCallback(callback) { - - @Override - public void onSuccessImpl(Job result) { - Toast.showInfo(messages.runningInBackgroundTitle(), messages.runningInBackgroundDescription()); - - Dialogs.showJobRedirectDialog(messages.removeJobCreatedMessage(), new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - doActionCallbackDestroyed(); - History.fireCurrentHistoryState(); - } - - @Override - public void onSuccess(final Void nothing) { - doActionCallbackNone(); - HistoryUtils.newHistory(ShowJob.RESOLVER, result.getId()); - } - }); - } - }); + Services services = new Services("Delete DIPs", "delete"); + DeleteRequest deleteRequest = new DeleteRequest<>(); + deleteRequest.setItemsToDelete(selectedItems); + deleteRequest.setDetails(details); + + services.dipResource(s -> s.deleteIndexedDIPs(deleteRequest)).whenComplete((job, throwable) -> { + if (throwable != null) { + doActionCallbackNone(); + Toast.showError("Unable to perform the actions", ""); + } else { + Toast.showInfo(messages.runningInBackgroundTitle(), messages.runningInBackgroundDescription()); + + Dialogs.showJobRedirectDialog(messages.removeJobCreatedMessage(), new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + doActionCallbackDestroyed(); + } + + @Override + public void onSuccess(final Void nothing) { + doActionCallbackNone(); + HistoryUtils.newHistory(ShowJob.RESOLVER, job.getId()); + } + }); + } + }); } }); + } else { + doActionCallbackNone(); } } }); @@ -278,4 +225,21 @@ public ActionableBundle createActionsBundle() { dipActionableBundle.addGroup(managementGroup).addGroup(preservationGroup); return dipActionableBundle; } + + public enum DisseminationAction implements Action { + DOWNLOAD(), REMOVE(RodaConstants.PERMISSION_METHOD_DELETE_DIP), + NEW_PROCESS(RodaConstants.PERMISSION_METHOD_CREATE_JOB), + UPDATE_PERMISSIONS(RodaConstants.PERMISSION_METHOD_UPDATE_DIP_PERMISSIONS); + + private List methods; + + DisseminationAction(String... methods) { + this.methods = Arrays.asList(methods); + } + + @Override + public List getMethods() { + return this.methods; + } + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/FileActions.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/FileActions.java index 5c235cb255..2ec7141208 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/FileActions.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/actions/FileActions.java @@ -16,9 +16,9 @@ import org.roda.core.data.common.RodaConstants; import org.roda.core.data.exceptions.AlreadyExistsException; import org.roda.core.data.v2.file.CreateFolderRequest; -import org.roda.core.data.v2.file.DeleteFilesRequest; import org.roda.core.data.v2.file.MoveFilesRequest; import org.roda.core.data.v2.file.RenameFolderRequest; +import org.roda.core.data.v2.generics.DeleteRequest; import org.roda.core.data.v2.index.filter.Filter; import org.roda.core.data.v2.index.filter.NotSimpleFilterParameter; import org.roda.core.data.v2.index.filter.SimpleFilterParameter; @@ -505,10 +505,10 @@ public void onSuccess(Boolean confirmed) { @Override public void onSuccess(final String details) { Services services = new Services("Remove files from representation", "delete"); - DeleteFilesRequest deleteFilesRequest = new DeleteFilesRequest(); - deleteFilesRequest.setDetails(details); - deleteFilesRequest.setItemsToDelete(selected); - services.fileResource(s -> s.deleteFiles(deleteFilesRequest)).whenComplete((job, throwable) -> { + DeleteRequest deleteRequest = new DeleteRequest<>(); + deleteRequest.setDetails(details); + deleteRequest.setItemsToDelete(selected); + services.fileResource(s -> s.deleteFiles(deleteRequest)).whenComplete((job, throwable) -> { if (throwable != null) { callback.onFailure(throwable); HistoryUtils.newHistory(InternalProcess.RESOLVER); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/lists/pagination/ListSelectionUtils.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/lists/pagination/ListSelectionUtils.java index 8c5cca01d0..c8948cd036 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/lists/pagination/ListSelectionUtils.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/lists/pagination/ListSelectionUtils.java @@ -7,7 +7,6 @@ */ package org.roda.wui.client.common.lists.pagination; -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -15,13 +14,12 @@ import org.roda.core.data.exceptions.NotFoundException; import org.roda.core.data.v2.common.Pair; import org.roda.core.data.v2.index.CountRequest; -import org.roda.core.data.v2.index.IndexResult; +import org.roda.core.data.v2.index.FindRequest; import org.roda.core.data.v2.index.IsIndexed; import org.roda.core.data.v2.index.facet.Facets; import org.roda.core.data.v2.index.filter.Filter; import org.roda.core.data.v2.index.sort.Sorter; import org.roda.core.data.v2.index.sublist.Sublist; -import org.roda.wui.client.browse.BrowserService; import org.roda.wui.client.common.lists.utils.AsyncTableCell; import org.roda.wui.client.common.utils.AsyncCallbackUtils; import org.roda.wui.client.common.utils.HtmlSnippetUtils; @@ -110,19 +108,18 @@ private static void openRelative(final ListSelectionState< final AsyncCallback> callback, final ProcessRelativeItem processor) { final int newIndex = state.getIndex() + relativeIndex; if (newIndex >= 0) { - BrowserService.Util.getInstance().find(state.getSelected().getClass().getName(), state.getFilter(), - state.getSorter(), new Sublist(newIndex, 1), state.getFacets(), LocaleInfo.getCurrentLocale().getLocaleName(), - state.getJustActive(), new ArrayList<>(), new AsyncCallback>() { - @Override - public void onFailure(Throwable caught) { - callback.onFailure(caught); - } - - @Override - public void onSuccess(IndexResult result) { - if (!result.getResults().isEmpty()) { - T first = result.getResults().get(0); + Services services = new Services("Find relatives", "get"); + FindRequest request = FindRequest + .getBuilder(state.getSelected().getClass().getName(), state.getFilter(), state.getJustActive()) + .withSorter(state.getSorter()).withSublist(new Sublist(newIndex, 1)).withFacets(state.getFacets()).build(); + services.rodaEntityRestService(s -> s.find(request, LocaleInfo.getCurrentLocale().getLocaleName()), + state.getSelected().getClass()).whenComplete((indexResult, throwable) -> { + if (throwable != null) { + callback.onFailure(throwable); + } else { + if (!indexResult.getResults().isEmpty()) { + T first = (T) indexResult.getResults().get(0); // if we are jumping to the same file, try the next one if (first.getUUID().equals(state.getSelected().getUUID())) { @@ -130,7 +127,7 @@ public void onSuccess(IndexResult result) { } else { processor.process(first); callback.onSuccess(ListSelectionUtils.create(first, state.getFilter(), state.getJustActive(), - state.getFacets(), state.getSorter(), newIndex, result.getTotalCount())); + state.getFacets(), state.getSorter(), newIndex, indexResult.getTotalCount())); } } else { callback.onFailure(new NotFoundException("No items were found")); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/model/BrowseAIPResponse.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/model/BrowseAIPResponse.java new file mode 100644 index 0000000000..fdab31436d --- /dev/null +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/model/BrowseAIPResponse.java @@ -0,0 +1,39 @@ +package org.roda.wui.client.common.model; + +import org.roda.core.data.v2.ip.IndexedAIP; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +/** + * @author Miguel Guimarães + */ +public class BrowseAIPResponse implements Serializable { + + @Serial + private static final long serialVersionUID = 7702752004859207610L; + + private IndexedAIP indexedAIP; + private List representationInformationFields; + + public BrowseAIPResponse() { + // empty constructor + } + + public IndexedAIP getIndexedAIP() { + return indexedAIP; + } + + public void setIndexedAIP(IndexedAIP indexedAIP) { + this.indexedAIP = indexedAIP; + } + + public List getRepresentationInformationFields() { + return representationInformationFields; + } + + public void setRepresentationInformationFields(List representationInformationFields) { + this.representationInformationFields = representationInformationFields; + } +} diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/model/BrowseDIPResponse.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/model/BrowseDIPResponse.java new file mode 100644 index 0000000000..2b0fcac967 --- /dev/null +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/model/BrowseDIPResponse.java @@ -0,0 +1,109 @@ +package org.roda.wui.client.common.model; + +import java.io.Serial; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.roda.core.data.v2.index.IsIndexed; +import org.roda.core.data.v2.ip.DIPFile; +import org.roda.core.data.v2.ip.IndexedAIP; +import org.roda.core.data.v2.ip.IndexedDIP; +import org.roda.core.data.v2.ip.IndexedFile; +import org.roda.core.data.v2.ip.IndexedRepresentation; +import org.roda.core.data.v2.ip.Permissions; + +/** + * @author Miguel Guimarães + */ +public class BrowseDIPResponse implements Serializable { + + @Serial + private static final long serialVersionUID = -1643255887537720719L; + + private IndexedDIP dip; + private DIPFile dipFile; + private IsIndexed referred; + private Permissions permissions; + private List dipFileAncestors; + private IndexedRepresentation indexedRepresentation; + private IndexedAIP indexedAIP; + private IndexedFile indexedFile; + private boolean embeddedDIP; + + public BrowseDIPResponse() { + this.dipFileAncestors = new ArrayList<>(); + } + + public IndexedDIP getDip() { + return dip; + } + + public void setDip(IndexedDIP dip) { + this.dip = dip; + } + + public DIPFile getDipFile() { + return dipFile; + } + + public void setDipFile(DIPFile dipFile) { + this.dipFile = dipFile; + } + + public IsIndexed getReferred() { + return referred; + } + + public void setReferred(IsIndexed referred) { + this.referred = referred; + } + + public Permissions getPermissions() { + return permissions; + } + + public void setPermissions(Permissions permissions) { + this.permissions = permissions; + } + + public List getDipFileAncestors() { + return dipFileAncestors; + } + + public void setDipFileAncestors(List dipFileAncestors) { + this.dipFileAncestors = dipFileAncestors; + } + + public IndexedRepresentation getIndexedRepresentation() { + return indexedRepresentation; + } + + public void setIndexedRepresentation(IndexedRepresentation indexedRepresentation) { + this.indexedRepresentation = indexedRepresentation; + } + + public IndexedAIP getIndexedAIP() { + return indexedAIP; + } + + public void setIndexedAIP(IndexedAIP indexedAIP) { + this.indexedAIP = indexedAIP; + } + + public IndexedFile getIndexedFile() { + return indexedFile; + } + + public void setIndexedFile(IndexedFile indexedFile) { + this.indexedFile = indexedFile; + } + + public boolean isEmbeddedDIP() { + return embeddedDIP; + } + + public void setEmbeddedDIP(boolean embeddedDIP) { + this.embeddedDIP = embeddedDIP; + } +} diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/DisseminationsSliderHelper.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/DisseminationsSliderHelper.java index 43656187a9..d366b44abd 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/DisseminationsSliderHelper.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/DisseminationsSliderHelper.java @@ -33,18 +33,14 @@ import org.roda.wui.client.common.popup.CalloutPopup; import org.roda.wui.client.common.popup.CalloutPopup.CalloutPosition; import org.roda.wui.client.common.utils.AsyncCallbackUtils; -import org.roda.wui.client.common.utils.IndexedDIPUtils; import org.roda.wui.client.services.Services; import org.roda.wui.common.client.tools.HistoryUtils; -import org.roda.wui.common.client.tools.StringUtils; -import org.roda.wui.common.client.widgets.Toast; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.i18n.client.LocaleInfo; import com.google.gwt.safehtml.shared.SafeHtmlUtils; -import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FocusPanel; @@ -120,19 +116,16 @@ private static void updateDisseminations(Filter filter, final SliderPanel dissem dipFields.addAll(Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.DIP_ID, RodaConstants.DIP_TITLE, RodaConstants.DIP_DESCRIPTION, RodaConstants.DIP_DELETE_EXTERNAL_URL, RodaConstants.DIP_OPEN_EXTERNAL_URL)); - BrowserService.Util.getInstance().find(IndexedDIP.class.getName(), filter, sorter, sublist, facets, localeString, - true, dipFields, new AsyncCallback>() { + FindRequest request = FindRequest.getBuilder(IndexedDIP.class.getName(), filter, true).withFieldsToReturn(dipFields).withSublist(sublist).withSorter(sorter).withFacets(facets).build(); - @Override - public void onFailure(Throwable caught) { - AsyncCallbackUtils.defaultFailureTreatment(caught); - } - - @Override - public void onSuccess(IndexResult result) { - updateDisseminationsSliderPanel(result.getResults(), disseminationsSliderPanel); - } - }); + Services services = new Services("Find Indexed DIP", "get"); + services.dipResource(s -> s.find(request, localeString)).whenComplete((indexedDIPIndexResult, throwable) -> { + if (throwable != null) { + AsyncCallbackUtils.defaultFailureTreatment(throwable.getCause()); + } else { + updateDisseminationsSliderPanel(indexedDIPIndexResult.getResults(), disseminationsSliderPanel); + } + }); } private static void updateDisseminationsSliderPanel(List dips, SliderPanel disseminationsSliderPanel) { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/InfoSliderHelper.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/InfoSliderHelper.java index 51908d1e05..8ad774a082 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/InfoSliderHelper.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/InfoSliderHelper.java @@ -27,10 +27,9 @@ import org.roda.wui.client.browse.PreservationEvents; import org.roda.wui.client.browse.RepresentationInformationHelper; import org.roda.wui.client.browse.bundle.BrowseAIPBundle; -import org.roda.wui.client.browse.bundle.BrowseFileBundle; -import org.roda.wui.client.browse.bundle.BrowseRepresentationBundle; import org.roda.wui.client.common.actions.AipActions; import org.roda.wui.client.common.dialogs.Dialogs; +import org.roda.wui.client.common.model.BrowseAIPResponse; import org.roda.wui.client.common.model.BrowseFileResponse; import org.roda.wui.client.common.model.BrowseRepresentationResponse; import org.roda.wui.client.ingest.process.ShowJob; @@ -168,32 +167,72 @@ public static void updateInfoSliderPanel(BrowseRepresentationResponse response, populate(infoSliderPanel, values); } - public static void updateInfoSliderPanel(BrowseRepresentationBundle bundle, SliderPanel infoSliderPanel) { - IndexedRepresentation representation = bundle.getRepresentation(); + public static void updateInfoSliderPanel(BrowseAIPResponse response, SliderPanel infoSliderPanel) { + IndexedAIP aip = response.getIndexedAIP(); HashMap values = new HashMap<>(); infoSliderPanel.clear(); - infoSliderPanel.addTitle(new Label(messages.oneOfAObject(IndexedRepresentation.class.getName()))); + infoSliderPanel.addTitle(new Label(messages.oneOfAObject(IndexedAIP.class.getName()))); - values.put(messages.representationId(), createIdHTML(bundle)); + values.put(messages.itemId(), createIdHTML(response)); - if (representation.getCreatedOn() != null && StringUtils.isNotBlank(representation.getCreatedBy())) { - values.put(messages.aipCreated(), new InlineHTML(messages - .dateCreatedOrUpdated(Humanize.formatDateTime(representation.getCreatedOn()), representation.getCreatedBy()))); + if (aip.getCreatedOn() != null && StringUtils.isNotBlank(aip.getCreatedBy())) { + values.put(messages.aipCreated(), + new InlineHTML(messages.dateCreatedOrUpdated(Humanize.formatDateTime(aip.getCreatedOn()), aip.getCreatedBy()))); } - if (representation.getUpdatedOn() != null && StringUtils.isNotBlank(representation.getUpdatedBy())) { - values.put(messages.aipUpdated(), new InlineHTML(messages - .dateCreatedOrUpdated(Humanize.formatDateTime(representation.getUpdatedOn()), representation.getUpdatedBy()))); + if (aip.getUpdatedOn() != null && StringUtils.isNotBlank(aip.getUpdatedBy())) { + values.put(messages.aipUpdated(), + new InlineHTML(messages.dateCreatedOrUpdated(Humanize.formatDateTime(aip.getUpdatedOn()), aip.getUpdatedBy()))); } - if (StringUtils.isNotBlank(representation.getType())) { - values.put(messages.representationType(), createRepresentationTypeHTML(bundle)); + if (StringUtils.isNotBlank(aip.getLevel())) { + values.put(messages.aipLevel(), createAipLevelHTML(response)); } - addLinkIfCentralInstance(values, bundle.getInstanceName(), bundle.isLocalToInstance(), - representation.getInstanceId()); + if (StringUtils.isNotBlank(aip.getType())) { + values.put(messages.aipType(), createAipTypeHTML(response)); + } + + addLinkIfCentralInstance(values, response.getIndexedAIP().getInstanceName(), + response.getIndexedAIP().isLocalInstance(), aip.getInstanceId()); + + if (!aip.getIngestSIPIds().isEmpty()) { + FlowPanel sipIds = new FlowPanel(); + for (String ingestSIPId : aip.getIngestSIPIds()) { + sipIds.add(new HTMLPanel("p", ingestSIPId)); + } + values.put(messages.sipId(), sipIds); + } + + if (StringUtils.isNotBlank(aip.getIngestJobId())) { + Anchor anchor = new Anchor(); + anchor.setText(aip.getIngestJobId()); + anchor.setHref(HistoryUtils.createHistoryHashLink(ShowJob.RESOLVER, aip.getIngestJobId(), + RodaConstants.JOB_REPORT_OUTCOME_OBJECT_ID, aip.getId())); + + values.put(messages.processIdTitle(), anchor); + } + + if (!aip.getIngestUpdateJobIds().isEmpty()) { + FlowPanel jobIdsList = new FlowPanel(); + jobIdsList.addStyleName("slider-info-entry-value-aip-ingest-jobs"); + + for (String updateJobId : aip.getIngestUpdateJobIds()) { + Anchor anchor = new Anchor(); + anchor.setText(updateJobId); + anchor.setHref(HistoryUtils.createHistoryHashLink(ShowJob.RESOLVER, updateJobId, + RodaConstants.JOB_REPORT_OUTCOME_OBJECT_ID, aip.getId())); + jobIdsList.add(anchor); + } + values.put(messages.updateProcessIdTitle(), jobIdsList); + } + + if (!response.getIndexedAIP().getPermissions().getUsers().equals(new Permissions().getUsers()) + || !response.getIndexedAIP().getPermissions().getGroups().equals(new Permissions().getGroups())) { + values.put(messages.aipPermissionDetails(), createAipPermissionDetailsHTML(response.getIndexedAIP())); + } populate(infoSliderPanel, values); } @@ -397,6 +436,137 @@ public SafeHtml getValue(Entry> object) return table; } + private static Widget createAipPermissionDetailsHTML(IndexedAIP aip) { + Permissions permissions = aip.getPermissions(); + + final String CSS_HAS_PERMISSION = ""; + final String CSS_NO_PERMISSION = " slider-aip-permissions-table-icon-fade"; + + List>> entryList = new ArrayList<>(); + for (String username : new TreeSet<>(permissions.getUsernames())) { + entryList.add(new AbstractMap.SimpleEntry<>("u-" + username, permissions.getUserPermissions(username))); + } + for (String groupname : new TreeSet<>(permissions.getGroupnames())) { + entryList.add(new AbstractMap.SimpleEntry<>("g-" + groupname, permissions.getGroupPermissions(groupname))); + } + + CellTable>> table = new CellTable<>(); + table.addStyleName("slider-aip-permissions-table"); + + Column>, SafeHtml> userGroupIconColumn = new Column>, SafeHtml>( + new SafeHtmlCell()) { + @Override + public SafeHtml getValue(Entry> object) { + if (object.getKey().startsWith("u-")) { + return SafeHtmlUtils.fromSafeConstant(""); + } else { + return SafeHtmlUtils.fromSafeConstant(""); + } + } + }; + + Column>, SafeHtml> nameColumn = new Column>, SafeHtml>( + new SafeHtmlCell()) { + @Override + public SafeHtml getValue(Entry> object) { + String name = object.getKey().substring(2); + return SafeHtmlUtils.fromSafeConstant( + "" + SafeHtmlUtils.htmlEscape(name) + ""); + } + }; + + Column>, SafeHtml> iconReadColumn = new Column>, SafeHtml>( + new SafeHtmlCell()) { + @Override + public SafeHtml getValue(Entry> object) { + String extraIconCss = object.getValue().contains(Permissions.PermissionType.READ) ? CSS_HAS_PERMISSION + : CSS_NO_PERMISSION; + return SafeHtmlUtils + .fromSafeConstant(""); + } + }; + + Column>, SafeHtml> iconCreateColumn = new Column>, SafeHtml>( + new SafeHtmlCell()) { + @Override + public SafeHtml getValue(Entry> object) { + String extraIconCss = object.getValue().contains(Permissions.PermissionType.CREATE) ? CSS_HAS_PERMISSION + : CSS_NO_PERMISSION; + return SafeHtmlUtils + .fromSafeConstant(""); + } + }; + + Column>, SafeHtml> iconEditColumn = new Column>, SafeHtml>( + new SafeHtmlCell()) { + @Override + public SafeHtml getValue(Entry> object) { + String extraIconCss = object.getValue().contains(Permissions.PermissionType.UPDATE) ? CSS_HAS_PERMISSION + : CSS_NO_PERMISSION; + return SafeHtmlUtils + .fromSafeConstant(""); + } + }; + + Column>, SafeHtml> iconDeleteColumn = new Column>, SafeHtml>( + new SafeHtmlCell()) { + @Override + public SafeHtml getValue(Entry> object) { + String extraIconCss = object.getValue().contains(Permissions.PermissionType.DELETE) ? CSS_HAS_PERMISSION + : CSS_NO_PERMISSION; + return SafeHtmlUtils + .fromSafeConstant(""); + } + }; + + Column>, SafeHtml> iconGrantColumn = new Column>, SafeHtml>( + new SafeHtmlCell()) { + @Override + public SafeHtml getValue(Entry> object) { + String extraIconCss = object.getValue().contains(Permissions.PermissionType.GRANT) ? CSS_HAS_PERMISSION + : CSS_NO_PERMISSION; + return SafeHtmlUtils + .fromSafeConstant(""); + } + }; + + table.addColumn(userGroupIconColumn); + table.addColumn(nameColumn); + table.addColumn(iconReadColumn); + table.addColumn(iconCreateColumn); + table.addColumn(iconEditColumn); + table.addColumn(iconDeleteColumn); + table.addColumn(iconGrantColumn); + + table.setColumnWidth(userGroupIconColumn, 23, Style.Unit.PX); + table.setColumnWidth(iconReadColumn, 23, Style.Unit.PX); + table.setColumnWidth(iconCreateColumn, 23, Style.Unit.PX); + table.setColumnWidth(iconEditColumn, 23, Style.Unit.PX); + table.setColumnWidth(iconDeleteColumn, 23, Style.Unit.PX); + table.setColumnWidth(iconGrantColumn, 23, Style.Unit.PX); + + nameColumn.setCellStyleNames("nowrap slider-aip-permissions-table-name"); + + AipActions aipActions = AipActions.get(); + if (aipActions.canAct(AipActions.AipAction.UPDATE_PERMISSIONS, aip)) { + table.addStyleName("slider-aip-permissions-table-with-grant"); + SingleSelectionModel>> selectionModel = new SingleSelectionModel<>( + item -> item.getKey().substring(2)); + selectionModel.addSelectionChangeHandler(event -> aipActions.act(AipActions.AipAction.UPDATE_PERMISSIONS, aip)); + table.setSelectionModel(selectionModel); + } + + ListDataProvider>> dataProvider = new ListDataProvider<>(entryList); + dataProvider.addDataDisplay(table); + + return table; + } + public static void createFileInfoSliderPanel(IndexedFile file, BrowseFileResponse response, SliderPanel infoSliderPanel) { HashMap values = new HashMap<>(); @@ -547,154 +717,6 @@ public void onError(Request request, Throwable throwable) { } } - public static void updateInfoSliderPanel(BrowseFileBundle bundle, SliderPanel infoSliderPanel) { - HashMap values = new HashMap<>(); - infoSliderPanel.clear(); - infoSliderPanel.addTitle(new Label(messages.oneOfAObject(IndexedFile.class.getName()))); - IndexedFile file = bundle.getFile(); - - if (file != null) { - String fileName = file.getOriginalName() != null ? file.getOriginalName() : file.getId(); - values.put(messages.viewRepresentationInfoFilename(), createIdHTML(bundle, fileName, file.getUUID())); - - if (file.getSize() > 0) { - values.put(messages.viewRepresentationInfoSize(), - new InlineHTML(SafeHtmlUtils.fromString(Humanize.readableFileSize(file.getSize())))); - } - - if (file.getFileFormat() != null) { - FileFormat fileFormat = file.getFileFormat(); - - if (StringUtils.isNotBlank(fileFormat.getExtension())) { - values.put(messages.viewRepresentationInfoExtension(), - createExtensionHTML(bundle, fileFormat.getExtension())); - } - - if (StringUtils.isNotBlank(fileFormat.getMimeType())) { - values.put(messages.viewRepresentationInfoMimetype(), createMimetypeHTML(bundle, fileFormat.getMimeType())); - } - - if (StringUtils.isNotBlank(fileFormat.getFormatDesignationName())) { - values.put(messages.viewRepresentationInfoFormat(), - createFormatDesignationHTML(bundle, fileFormat.getFormatDesignation())); - } - - if (StringUtils.isNotBlank(fileFormat.getPronom())) { - values.put(messages.viewRepresentationInfoPronom(), createPronomHTML(bundle, fileFormat.getPronom())); - } - } - - if (StringUtils.isNotBlank(file.getCreatingApplicationName())) { - values.put(messages.viewRepresentationInfoCreatingApplicationName(), - createCreatingApplicationNameHTML(bundle, file.getCreatingApplicationName())); - } - - if (StringUtils.isNotBlank(file.getCreatingApplicationVersion())) { - values.put(messages.viewRepresentationInfoCreatingApplicationVersion(), - createCreatingApplicationVersionHTML(bundle, file.getCreatingApplicationVersion())); - } - - if (StringUtils.isNotBlank(file.getDateCreatedByApplication())) { - values.put(messages.viewRepresentationInfoDateCreatedByApplication(), - new InlineHTML(SafeHtmlUtils.fromString(file.getDateCreatedByApplication()))); - } - - if (file.getHash() != null && !file.getHash().isEmpty()) { - SafeHtmlBuilder b = new SafeHtmlBuilder(); - boolean first = true; - for (String hash : file.getHash()) { - if (first) { - first = false; - } else { - b.append(SafeHtmlUtils.fromSafeConstant("
")); - } - b.append(SafeHtmlUtils.fromSafeConstant("")); - b.append(SafeHtmlUtils.fromString(hash)); - b.append(SafeHtmlUtils.fromSafeConstant("")); - } - values.put(messages.viewRepresentationInfoHash(), new InlineHTML(b.toSafeHtml())); - } - SafeHtmlBuilder b = new SafeHtmlBuilder(); - if (file.isReference()) { - b.append(SafeHtmlUtils.fromSafeConstant("")); - b.append(SafeHtmlUtils.fromString(file.getReferenceURL())); - b.append(SafeHtmlUtils.fromSafeConstant("")); - - values.put(messages.viewRepresentationInfoStoragePath(), new InlineHTML(b.toSafeHtml())); - } else { - if (file.getStoragePath() != null) { - b.append(SafeHtmlUtils.fromSafeConstant("")); - b.append(SafeHtmlUtils.fromString(file.getStoragePath())); - b.append(SafeHtmlUtils.fromSafeConstant("")); - - values.put(messages.viewRepresentationInfoStoragePath(), new InlineHTML(b.toSafeHtml())); - } - } - } - - addLinkIfCentralInstance(values, bundle.getInstanceName(), bundle.isLocalToInstance(), file.getInstanceId()); - - List history = new ArrayList<>(); - history.add(file.getAipId()); - history.add(file.getRepresentationId()); - history.addAll(file.getPath()); - history.add(file.getId()); - - Long preservationEventCount = bundle.getPreservationEventCount(); - Long riskIncidenceCount = bundle.getRiskIncidenceCount(); - - if (riskIncidenceCount >= 0) { - Anchor risksLink = new Anchor(messages.aipRiskIncidences(bundle.getRiskIncidenceCount()), - HistoryUtils.createHistoryHashLink(RiskIncidenceRegister.RESOLVER, history)); - values.put(messages.preservationRisks(), risksLink); - } - - if (preservationEventCount >= 0) { - Anchor eventsLink = new Anchor(messages.aipEvents(bundle.getPreservationEventCount()), - HistoryUtils.createHistoryHashLink(PreservationEvents.BROWSE_RESOLVER, file.getAipId(), - file.getRepresentationUUID(), file.getUUID())); - values.put(messages.preservationEvents(), eventsLink); - } - - SafeUri uri = RestUtils.createTechnicalMetadataHTMLUri(file.getAipId(), file.getUUID(), "html", null); - RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, uri.asString()); - - Anchor technicalInformationAnchor = new Anchor(); - technicalInformationAnchor.setStyleName("clickable"); - technicalInformationAnchor.setText(messages.showTechnicalMetadata()); - - // technicalInformation - try { - requestBuilder.sendRequest(null, new RequestCallback() { - @Override - public void onResponseReceived(Request request, Response response) { - if (response.getStatusCode() == 200) { - if (!response.getText().isEmpty()) { - values.put(messages.viewTechnicalInformation(), technicalInformationAnchor); - technicalInformationAnchor - .addClickHandler(e -> Dialogs.showTechnicalMetadataInformation(messages.viewTechnicalMetadata(), - messages.downloadButton(), messages.closeButton(), file, response.getText())); - } - - } else { - values.put(messages.viewTechnicalInformation(), technicalInformationAnchor); - technicalInformationAnchor - .addClickHandler(e -> Dialogs.showTechnicalMetadataInformation(messages.viewTechnicalMetadata(), - messages.downloadButton(), messages.closeButton(), file, null)); - } - populate(infoSliderPanel, values); - } - - @Override - public void onError(Request request, Throwable throwable) { - populate(infoSliderPanel, values); - } - }); - } catch (RequestException e) { - throw new RuntimeException(e); - } - } - private static void populate(SliderPanel infoSliderPanel, HashMap values) { for (Entry entry : values.entrySet()) { FlowPanel entryPanel = new FlowPanel(); @@ -786,75 +808,14 @@ private static FlowPanel createIdHTML(List representationInformationFiel return panel; } - private static FlowPanel createExtensionHTML(BrowseFileBundle bundle, String extension) { - FlowPanel panel = new FlowPanel(); - final String riFilter = RepresentationInformationUtils - .createRepresentationInformationFilter(RodaConstants.INDEX_FILE, RodaConstants.FILE_EXTENSION, extension); - RepresentationInformationHelper.addFieldWithRepresentationInformationIcon(SafeHtmlUtils.fromString(extension), - riFilter, panel, bundle.getRepresentationInformationFields().contains(RodaConstants.FILE_EXTENSION), - "browseFileInformationIcon"); - return panel; - } - - private static FlowPanel createMimetypeHTML(BrowseFileBundle bundle, String mimetype) { - FlowPanel panel = new FlowPanel(); - final String riFilter = RepresentationInformationUtils - .createRepresentationInformationFilter(RodaConstants.INDEX_FILE, RodaConstants.FILE_FORMAT_MIMETYPE, mimetype); - RepresentationInformationHelper.addFieldWithRepresentationInformationIcon(SafeHtmlUtils.fromString(mimetype), - riFilter, panel, bundle.getRepresentationInformationFields().contains(RodaConstants.FILE_FORMAT_MIMETYPE), - "browseFileInformationIcon"); - return panel; - } - - private static FlowPanel createPronomHTML(BrowseFileBundle bundle, String pronom) { + private static FlowPanel createIdHTML(BrowseAIPResponse response) { + IndexedAIP aip = response.getIndexedAIP(); FlowPanel panel = new FlowPanel(); final String riFilter = RepresentationInformationUtils - .createRepresentationInformationFilter(RodaConstants.INDEX_FILE, RodaConstants.FILE_PRONOM, pronom); - RepresentationInformationHelper.addFieldWithRepresentationInformationIcon(SafeHtmlUtils.fromString(pronom), - riFilter, panel, bundle.getRepresentationInformationFields().contains(RodaConstants.FILE_PRONOM), - "browseFileInformationIcon"); - return panel; - } - - private static FlowPanel createFormatDesignationHTML(BrowseFileBundle bundle, String designation) { - FlowPanel panel = new FlowPanel(); - final String riFilter = RepresentationInformationUtils.createRepresentationInformationFilter( - RodaConstants.INDEX_FILE, RodaConstants.FILE_FORMAT_DESIGNATION, designation); - RepresentationInformationHelper.addFieldWithRepresentationInformationIcon(SafeHtmlUtils.fromString(designation), - riFilter, panel, bundle.getRepresentationInformationFields().contains(RodaConstants.FILE_FORMAT_DESIGNATION), - "browseFileInformationIcon"); - return panel; - } - - private static FlowPanel createCreatingApplicationNameHTML(BrowseFileBundle bundle, String createApplicationName) { - FlowPanel panel = new FlowPanel(); - final String riFilter = RepresentationInformationUtils.createRepresentationInformationFilter( - RodaConstants.INDEX_FILE, RodaConstants.FILE_CREATING_APPLICATION_NAME, createApplicationName); - RepresentationInformationHelper.addFieldWithRepresentationInformationIcon( - SafeHtmlUtils.fromString(createApplicationName), riFilter, panel, - bundle.getRepresentationInformationFields().contains(RodaConstants.FILE_CREATING_APPLICATION_NAME), - "browseFileInformationIcon"); - return panel; - } - - private static FlowPanel createCreatingApplicationVersionHTML(BrowseFileBundle bundle, - String createApplicationVersion) { - FlowPanel panel = new FlowPanel(); - final String riFilter = RepresentationInformationUtils.createRepresentationInformationFilter( - RodaConstants.INDEX_FILE, RodaConstants.FILE_CREATING_APPLICATION_VERSION, createApplicationVersion); - RepresentationInformationHelper.addFieldWithRepresentationInformationIcon( - SafeHtmlUtils.fromString(createApplicationVersion), riFilter, panel, - bundle.getRepresentationInformationFields().contains(RodaConstants.FILE_CREATING_APPLICATION_VERSION), - "browseFileInformationIcon"); - return panel; - } + .createRepresentationInformationFilter(RodaConstants.INDEX_AIP, RodaConstants.INDEX_UUID, aip.getId()); - private static FlowPanel createIdHTML(BrowseFileBundle bundle, String filename, String uuid) { - FlowPanel panel = new FlowPanel(); - final String riFilter = RepresentationInformationUtils - .createRepresentationInformationFilter(RodaConstants.INDEX_FILE, RodaConstants.INDEX_UUID, uuid); - RepresentationInformationHelper.addFieldWithRepresentationInformationIcon(SafeHtmlUtils.fromString(filename), - riFilter, panel, bundle.getRepresentationInformationFields().contains(RodaConstants.INDEX_UUID), + RepresentationInformationHelper.addFieldWithRepresentationInformationIcon(SafeHtmlUtils.fromString(aip.getId()), + riFilter, panel, response.getRepresentationInformationFields().contains(RodaConstants.INDEX_UUID), "browseFileInformationIcon"); return panel; } @@ -884,16 +845,13 @@ private static FlowPanel createIdHTML(BrowseRepresentationResponse response) { return panel; } - private static FlowPanel createIdHTML(BrowseRepresentationBundle bundle) { - IndexedRepresentation representation = bundle.getRepresentation(); + private static FlowPanel createAipTypeHTML(BrowseAIPResponse response) { + IndexedAIP aip = response.getIndexedAIP(); FlowPanel panel = new FlowPanel(); - - final String riFilter = RepresentationInformationUtils.createRepresentationInformationFilter( - RodaConstants.INDEX_REPRESENTATION, RodaConstants.INDEX_UUID, representation.getUUID()); - RepresentationInformationHelper.addFieldWithRepresentationInformationIcon( - SafeHtmlUtils.fromString(representation.getId()), riFilter, panel, - bundle.getRepresentationInformationFields().contains(RodaConstants.INDEX_UUID)); - + final String riFilter = RepresentationInformationUtils + .createRepresentationInformationFilter(RodaConstants.INDEX_AIP, RodaConstants.AIP_TYPE, aip.getType()); + RepresentationInformationHelper.addFieldWithRepresentationInformationIcon(SafeHtmlUtils.fromString(aip.getType()), + riFilter, panel, response.getRepresentationInformationFields().contains(RodaConstants.AIP_TYPE)); return panel; } @@ -907,28 +865,28 @@ private static FlowPanel createAipTypeHTML(BrowseAIPBundle bundle) { return panel; } - private static FlowPanel createAipLevelHTML(BrowseAIPBundle bundle) { - IndexedAIP aip = bundle.getAip(); + private static FlowPanel createAipLevelHTML(BrowseAIPResponse response) { + IndexedAIP aip = response.getIndexedAIP(); FlowPanel panel = new FlowPanel(); final String riFilter = RepresentationInformationUtils .createRepresentationInformationFilter(RodaConstants.INDEX_AIP, RodaConstants.AIP_LEVEL, aip.getLevel()); RepresentationInformationHelper.addFieldWithRepresentationInformationIcon( SafeHtmlUtils.fromString(DescriptionLevelUtils.getElementLevelLabel(aip.getLevel())), riFilter, panel, - bundle.getRepresentationInformationFields().contains(RodaConstants.AIP_LEVEL)); + response.getRepresentationInformationFields().contains(RodaConstants.AIP_LEVEL)); return panel; } - private static FlowPanel createRepresentationTypeHTML(BrowseRepresentationBundle bundle) { - IndexedRepresentation representation = bundle.getRepresentation(); + private static FlowPanel createAipLevelHTML(BrowseAIPBundle bundle) { + IndexedAIP aip = bundle.getAip(); FlowPanel panel = new FlowPanel(); - final String riFilter = RepresentationInformationUtils.createRepresentationInformationFilter( - RodaConstants.INDEX_REPRESENTATION, RodaConstants.REPRESENTATION_TYPE, representation.getType()); + final String riFilter = RepresentationInformationUtils + .createRepresentationInformationFilter(RodaConstants.INDEX_AIP, RodaConstants.AIP_LEVEL, aip.getLevel()); RepresentationInformationHelper.addFieldWithRepresentationInformationIcon( - SafeHtmlUtils.fromString(representation.getType()), riFilter, panel, - bundle.getRepresentationInformationFields().contains(RodaConstants.REPRESENTATION_TYPE)); + SafeHtmlUtils.fromString(DescriptionLevelUtils.getElementLevelLabel(aip.getLevel())), riFilter, panel, + bundle.getRepresentationInformationFields().contains(RodaConstants.AIP_LEVEL)); return panel; } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/Sliders.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/Sliders.java index c68cc11cf1..5ee386f2f7 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/Sliders.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/slider/Sliders.java @@ -10,16 +10,14 @@ import org.roda.core.data.v2.index.IsIndexed; import org.roda.core.data.v2.ip.IndexedFile; import org.roda.wui.client.browse.bundle.BrowseAIPBundle; -import org.roda.wui.client.browse.bundle.BrowseFileBundle; -import org.roda.wui.client.browse.bundle.BrowseRepresentationBundle; -import org.roda.wui.client.browse.bundle.Bundle; - -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.FocusPanel; +import org.roda.wui.client.common.model.BrowseAIPResponse; import org.roda.wui.client.common.model.BrowseFileResponse; import org.roda.wui.client.common.model.BrowseRepresentationResponse; import org.roda.wui.client.services.Services; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.FocusPanel; + public class Sliders { private Sliders() { @@ -35,7 +33,7 @@ public static SliderPanel createSlider(FlowPanel container, FocusPanel toggleBut } public static SliderPanel createDisseminationSlider(FlowPanel container, - FocusPanel toggleButton, T object, Services services) { + FocusPanel toggleButton, T object, Services services) { SliderPanel slider = createSlider(container, toggleButton); DisseminationsSliderHelper.updateDisseminationsObjectSliderPanel(object, slider, services); return slider; @@ -48,62 +46,30 @@ public static SliderPanel createDisseminationSlider(FlowPa return slider; } - public static SliderPanel createInfoSlider(FlowPanel container, FocusPanel toggleButton, - T object) { + public static SliderPanel createAipInfoSlider(FlowPanel container, FocusPanel toggleButton, + BrowseAIPResponse response) { SliderPanel slider = createSlider(container, toggleButton); - InfoSliderHelper.updateInfoObjectSliderPanel(object, slider); + InfoSliderHelper.updateInfoSliderPanel(response, slider); return slider; } - public static SliderPanel createInfoSlider(FlowPanel container, FocusPanel toggleButton, Bundle bundle) { - if (bundle instanceof BrowseFileBundle) { - return createFileInfoSlider(container, toggleButton, (BrowseFileBundle) bundle); - } else if (bundle instanceof BrowseRepresentationBundle) { - return createRepresentationInfoSlider(container, toggleButton, (BrowseRepresentationBundle) bundle); - } else if (bundle instanceof BrowseAIPBundle) { - return createAipInfoSlider(container, toggleButton, (BrowseAIPBundle) bundle); - } - return null; - } - - public static SliderPanel createFileInfoSlider(FlowPanel container, FocusPanel toggleButton, IndexedFile file, BrowseFileResponse response) { + public static SliderPanel createFileInfoSlider(FlowPanel container, FocusPanel toggleButton, IndexedFile file, + BrowseFileResponse response) { SliderPanel slider = createSlider(container, toggleButton); InfoSliderHelper.createFileInfoSliderPanel(file, response, slider); return slider; } public static SliderPanel createRepresentationInfoSlider(FlowPanel container, FocusPanel toggleButton, - BrowseRepresentationResponse response) { + BrowseRepresentationResponse response) { SliderPanel slider = createSlider(container, toggleButton); InfoSliderHelper.updateInfoSliderPanel(response, slider); return slider; } - public static SliderPanel createFileInfoSlider(FlowPanel container, FocusPanel toggleButton, - BrowseFileBundle bundle) { - SliderPanel slider = createSlider(container, toggleButton); - InfoSliderHelper.updateInfoSliderPanel(bundle, slider); - return slider; - } - public static SliderPanel createAipInfoSlider(FlowPanel container, FocusPanel toggleButton, BrowseAIPBundle bundle) { SliderPanel slider = createSlider(container, toggleButton); InfoSliderHelper.updateInfoSliderPanel(bundle, slider); return slider; } - - public static SliderPanel createRepresentationInfoSlider(FlowPanel container, FocusPanel toggleButton, - BrowseRepresentationBundle bundle) { - SliderPanel slider = createSlider(container, toggleButton); - InfoSliderHelper.updateInfoSliderPanel(bundle, slider); - return slider; - } - - public static SliderPanel createOptionsSlider(FlowPanel container, FocusPanel toggleButton, - T object) { - SliderPanel slider = createSlider(container, toggleButton); - OptionsSliderHelper.updateOptionsObjectSliderPanel(object, slider); - return slider; - } - } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/disposal/confirmations/ShowDisposalConfirmation.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/disposal/confirmations/ShowDisposalConfirmation.java index 11d23c69bf..906b0328da 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/disposal/confirmations/ShowDisposalConfirmation.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/disposal/confirmations/ShowDisposalConfirmation.java @@ -22,10 +22,17 @@ import org.roda.wui.common.client.HistoryResolver; import org.roda.wui.common.client.tools.HistoryUtils; import org.roda.wui.common.client.tools.ListUtils; +import org.roda.wui.common.client.tools.RestUtils; import com.google.gwt.core.client.GWT; +import com.google.gwt.http.client.Request; +import com.google.gwt.http.client.RequestBuilder; +import com.google.gwt.http.client.RequestCallback; +import com.google.gwt.http.client.RequestException; +import com.google.gwt.http.client.Response; import com.google.gwt.i18n.client.LocaleInfo; import com.google.gwt.safehtml.shared.SafeHtmlUtils; +import com.google.gwt.safehtml.shared.SafeUri; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -87,24 +94,40 @@ void resolve(List historyTokens, final AsyncCallback callback) { if (historyTokens.size() == 1) { String confirmationId = historyTokens.get(0); Services services = new Services("Retrieve the disposal confirmation", "get"); - services.rodaEntityRestService(s -> s.findByUuid(confirmationId, LocaleInfo.getCurrentLocale().getLocaleName()), DisposalConfirmation.class) - .thenCompose(disposalConfirmation -> services - .disposalConfirmationResource(s -> s.retrieveDisposalConfirmationReport(disposalConfirmation.getId(), false)) - .whenComplete((report, throwable) -> { - if (throwable != null) { - AsyncCallbackUtils.defaultFailureTreatment(throwable); - } else { - final DisposalConfirmationReportActions confirmationActions = DisposalConfirmationReportActions.get(); - instance = new ShowDisposalConfirmation(); - SidebarUtils.toggleSidebar(contentFlowPanel, sidebarFlowPanel, confirmationActions.hasAnyRoles()); - instance.actionsSidebar.setWidget(new ActionableWidgetBuilder<>(confirmationActions).withBackButton() - .buildListWithObjects(new ActionableObject<>(disposalConfirmation))); - HTML reportHtml = new HTML(SafeHtmlUtils.fromSafeConstant(report)); - instance.contentFlowPanel.add(reportHtml); - callback.onSuccess(instance); - } + services.rodaEntityRestService(s -> s.findByUuid(confirmationId, LocaleInfo.getCurrentLocale().getLocaleName()), + DisposalConfirmation.class).whenComplete((disposalConfirmation, throwable) -> { + if (throwable != null) { + AsyncCallbackUtils.defaultFailureTreatment(throwable); + } else { + SafeUri uri = RestUtils.createDisposalConfirmationHTMLUri(disposalConfirmation.getId(), false); + RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, uri.asString()); + try { + requestBuilder.sendRequest(null, new RequestCallback() { + + @Override + public void onResponseReceived(Request request, Response response) { + if (200 == response.getStatusCode()) { + final DisposalConfirmationReportActions confirmationActions = DisposalConfirmationReportActions.get(); + instance = new ShowDisposalConfirmation(); + SidebarUtils.toggleSidebar(contentFlowPanel, sidebarFlowPanel, confirmationActions.hasAnyRoles()); + instance.actionsSidebar.setWidget(new ActionableWidgetBuilder<>(confirmationActions).withBackButton() + .buildListWithObjects(new ActionableObject<>(disposalConfirmation))); + HTML reportHtml = new HTML(SafeHtmlUtils.fromSafeConstant(response.getText())); + instance.contentFlowPanel.add(reportHtml); + callback.onSuccess(instance); + } + } - })); + @Override + public void onError(Request request, Throwable throwable) { + callback.onFailure(throwable); + } + }); + } catch (RequestException e) { + callback.onFailure(e); + } + } + }); } else { HistoryUtils.newHistory(DisposalConfirmations.RESOLVER); callback.onSuccess(null); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/disposal/hold/ShowDisposalHold.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/disposal/hold/ShowDisposalHold.java index 01d21a2a92..61f4a49258 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/disposal/hold/ShowDisposalHold.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/disposal/hold/ShowDisposalHold.java @@ -241,7 +241,7 @@ public void initButtons() { Services services = new Services("Lift disposal hold", "job"); CountRequest countRequest = new CountRequest(IndexedAIP.class.getName(), filter, true); - services.rodaEntityRestService(s -> s.count(countRequest), IndexedFile.class) + services.rodaEntityRestService(s -> s.count(countRequest), IndexedAIP.class) .whenComplete((longResponse, throwable) -> { if (longResponse.getResult() != 0) { services diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginParameterPanel.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginParameterPanel.java index 9d9bdbbabd..c546df05b1 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginParameterPanel.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/ingest/process/PluginParameterPanel.java @@ -16,8 +16,6 @@ import org.roda.core.data.common.RodaConstants; import org.roda.core.data.utils.RepresentationInformationUtils; -import org.roda.core.data.v2.common.ConversionProfile; -import org.roda.core.data.v2.common.Pair; import org.roda.core.data.v2.ip.AIP; import org.roda.core.data.v2.ip.File; import org.roda.core.data.v2.ip.IndexedAIP; @@ -28,10 +26,12 @@ import org.roda.core.data.v2.jobs.PluginParameter; import org.roda.core.data.v2.jobs.PluginParameter.PluginParameterType; import org.roda.core.data.v2.jobs.PluginType; +import org.roda.core.data.v2.properties.ConversionProfile; +import org.roda.core.data.v2.properties.ConversionProfileOutcomeType; +import org.roda.core.data.v2.properties.DropdownPluginParameterItem; import org.roda.core.data.v2.properties.ReindexPluginObject; import org.roda.core.data.v2.risks.IndexedRisk; import org.roda.core.data.v2.risks.SeverityLevel; -import org.roda.wui.client.browse.BrowserService; import org.roda.wui.client.common.IncrementalAssociativeList; import org.roda.wui.client.common.dialogs.SelectAipDialog; import org.roda.wui.client.common.utils.PluginUtils; @@ -52,7 +52,6 @@ import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.i18n.client.LocaleInfo; import com.google.gwt.safehtml.shared.SafeHtmlUtils; -import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.CheckBox; @@ -165,15 +164,17 @@ private void createConversionLayout() { dropdown.addStyleName(FORM_SELECTBOX); dropdown.addStyleName(FORM_TEXTBOX_SMALL); - dropdown.addItem("Representation", RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION); - dropdown.addItem("Dissemination", RodaConstants.PLUGIN_PARAMS_CONVERSION_DISSEMINATION); + dropdown.addItem("Representation", ConversionProfileOutcomeType.REPRESENTATION.toString()); + dropdown.addItem("Dissemination", ConversionProfileOutcomeType.DISSEMINATION.toString()); value = dropdown.getSelectedValue(); FlowPanel innerPanel = new FlowPanel(); dropdown.addChangeHandler(event -> { value = dropdown.getSelectedValue(); innerPanel.clear(); - FlowPanel profiles = createConversionProfileLayout(value, pluginId); + + FlowPanel profiles = new FlowPanel(); + createConversionProfileLayout(profiles, value, pluginId); innerPanel.add(profiles); if (value.equals(RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION)) { @@ -456,22 +457,19 @@ private void createDropdownLayout() { dropdown.addStyleName(FORM_SELECTBOX); dropdown.addStyleName(FORM_TEXTBOX_SMALL); - BrowserService.Util.getInstance().retrieveDropdownPluginItems(parameter.getId(), - LocaleInfo.getCurrentLocale().getLocaleName(), new AsyncCallback>>() { - - @Override - public void onFailure(Throwable caught) { - // do nothing - } + Services services = new Services("Retrieve dropdown plugin parameter items", "get"); + services + .configurationsResource( + s -> s.retrieveDropdownPluginItems(parameter.getId(), LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((dropdownPluginParameterItems, throwable) -> { + if (throwable == null) { - @Override - public void onSuccess(Set> result) { - Set> treeSet = new TreeSet<>( - (p1, p2) -> p1.getFirst().compareToIgnoreCase(p2.getFirst())); + Set items = new TreeSet<>( + (i1, i2) -> i1.getLabel().compareToIgnoreCase(i2.getLabel())); + items.addAll(dropdownPluginParameterItems.getItems()); - treeSet.addAll(result); - for (Pair item : treeSet) { - dropdown.addItem(item.getFirst(), item.getSecond()); + for (DropdownPluginParameterItem item : items) { + dropdown.addItem(item.getLabel(), item.getId()); } value = dropdown.getSelectedValue(); @@ -486,7 +484,7 @@ public void onSuccess(Set> result) { addHelp(); } - private FlowPanel createConversionProfileLayout(String repOrDip, String pluginId) { + private void createConversionProfileLayout(FlowPanel result, String repOrDip, String pluginId) { Set treeSet = new HashSet<>(); Label parameterName = new Label(messages.conversionProfileTitle()); final Label description = new Label(); @@ -494,21 +492,17 @@ private FlowPanel createConversionProfileLayout(String repOrDip, String pluginId dropdown.addStyleName(FORM_SELECTBOX); dropdown.addStyleName(FORM_TEXTBOX_SMALL); - FlowPanel result = new FlowPanel(); FlowPanel panel = new FlowPanel(); FlowPanel descriptionPanel = new FlowPanel(); - BrowserService.Util.getInstance().retrieveConversionProfilePluginItems(pluginId, repOrDip, - LocaleInfo.getCurrentLocale().getLocaleName(), new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - // do nothing - } + Services services = new Services("Retrieve conversion profiles", "get"); + services + .configurationsResource(s -> s.retrieveConversionProfiles(pluginId, + ConversionProfileOutcomeType.valueOf(repOrDip), LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((conversionProfiles, throwable) -> { + if (throwable == null) { + treeSet.addAll(conversionProfiles.getConversionProfileSet()); - @Override - public void onSuccess(Set result) { - treeSet.addAll(result); for (ConversionProfile item : treeSet) { dropdown.addItem(item.getTitle(), item.getProfile()); description.setText(item.getDescription()); @@ -522,29 +516,28 @@ public void onSuccess(Set result) { break; } } - } - }); - dropdown.addChangeHandler(event -> { - profile = dropdown.getSelectedValue(); - for (ConversionProfile conversionProfile : treeSet) { - if (conversionProfile.getProfile().equals(profile)) { - description.setText(conversionProfile.getDescription()); - break; - } - } - }); + dropdown.addChangeHandler(event -> { + profile = dropdown.getSelectedValue(); + for (ConversionProfile conversionProfile : treeSet) { + if (conversionProfile.getProfile().equals(profile)) { + description.setText(conversionProfile.getDescription()); + break; + } + } + }); - panel.add(dropdown); - descriptionPanel.add(description); - panel.addStyleName("conversion-profile"); + panel.add(dropdown); + descriptionPanel.add(description); + panel.addStyleName("conversion-profile"); - dropdown.setTitle(OBJECT_BOX); - result.add(parameterName); - addHelp(result, messages.conversionProfileDescription()); - result.add(panel); - result.add(descriptionPanel); - return result; + dropdown.setTitle(OBJECT_BOX); + result.add(parameterName); + addHelp(result, messages.conversionProfileDescription()); + result.add(panel); + result.add(descriptionPanel); + } + }); } private void createPluginObjectFieldsLayout(final String className) { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/main/BreadcrumbUtils.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/main/BreadcrumbUtils.java index 5e6a548a55..d6637a5192 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/main/BreadcrumbUtils.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/main/BreadcrumbUtils.java @@ -20,7 +20,6 @@ import org.roda.core.data.v2.ip.TransferredResource; import org.roda.wui.client.browse.BrowseTop; import org.roda.wui.client.browse.PreservationEvents; -import org.roda.wui.client.browse.bundle.BrowseRepresentationBundle; import org.roda.wui.client.ingest.transfer.IngestTransfer; import org.roda.wui.common.client.tools.DescriptionLevelUtils; import org.roda.wui.common.client.tools.HistoryUtils; @@ -116,13 +115,6 @@ public void execute() { return breadcrumb; } - public static List getRepresentationBreadcrumbs(BrowseRepresentationBundle bundle) { - List aipAncestors = bundle.getAipAncestors(); - IndexedAIP aip = bundle.getAip(); - IndexedRepresentation representation = bundle.getRepresentation(); - return getRepresentationBreadcrumbs(aipAncestors, aip, representation); - } - public static List getRepresentationBreadcrumbs(List aipAncestors, IndexedAIP aip, IndexedRepresentation representation) { List breadcrumb = new ArrayList<>(); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/AcknowledgeNotification.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/AcknowledgeNotification.java index d245327089..b5baab9925 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/AcknowledgeNotification.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/AcknowledgeNotification.java @@ -14,7 +14,9 @@ import java.util.List; import org.roda.core.data.v2.notifications.Notification; +import org.roda.core.data.v2.notifications.NotificationAcknowledgeRequest; import org.roda.wui.client.browse.BrowserService; +import org.roda.wui.client.services.Services; import org.roda.wui.common.client.HistoryResolver; import org.roda.wui.common.client.tools.HistoryUtils; import org.roda.wui.common.client.widgets.HTMLWidgetWrapper; @@ -73,19 +75,17 @@ public void resolve(List historyTokens, final AsyncCallback call final String notificationId = historyTokens.get(0); final String ackToken = historyTokens.get(1); - BrowserService.Util.getInstance().acknowledgeNotification(notificationId, ackToken, - new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - callback.onFailure(caught); - } - - @Override - public void onSuccess(Notification notification) { - callback.onSuccess(acknowledgeBody); - } - }); + Services services = new Services("Acknowledge a notification", "ack"); + NotificationAcknowledgeRequest request = new NotificationAcknowledgeRequest(); + request.setNotificationUUID(notificationId); + request.setToken(ackToken); + services.notificationResource(s -> s.acknowledgeNotification(request)).whenComplete((s, throwable) -> { + if (throwable != null) { + callback.onFailure(throwable); + } else { + callback.onSuccess(acknowledgeBody); + } + }); } else { HistoryUtils.newHistory(NotificationRegister.RESOLVER); callback.onSuccess(null); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/GroupSelect.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/GroupSelect.java index b81e58bbee..7ca7715eaa 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/GroupSelect.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/management/GroupSelect.java @@ -7,7 +7,6 @@ */ package org.roda.wui.client.management; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -17,16 +16,14 @@ import java.util.Vector; import org.roda.core.data.common.RodaConstants; -import org.roda.core.data.v2.index.IndexResult; -import org.roda.core.data.v2.index.facet.Facets; +import org.roda.core.data.v2.index.FindRequest; import org.roda.core.data.v2.index.filter.Filter; import org.roda.core.data.v2.index.filter.SimpleFilterParameter; import org.roda.core.data.v2.index.sort.SortParameter; import org.roda.core.data.v2.index.sort.Sorter; -import org.roda.core.data.v2.index.sublist.Sublist; import org.roda.core.data.v2.user.Group; import org.roda.core.data.v2.user.RODAMember; -import org.roda.wui.client.browse.BrowserService; +import org.roda.wui.client.services.Services; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -48,6 +45,122 @@ */ public class GroupSelect extends FlowPanel implements HasValueChangeHandlers> { + private final List blacklist; + private final List groups; + private HashMap userSelections; + private boolean enabled; + + /** + * Create a new group selection widget + * + * @param visible + * start as visible or wait until its initialized + */ + public GroupSelect() { + this.groups = new Vector<>(); + this.blacklist = new Vector<>(); + this.userSelections = new HashMap<>(); + enabled = true; + this.addStyleName("groups"); + } + + public void init(final AsyncCallback callback) { + // TODO use RodaMemberList instead of a list of checkboxes + + boolean isUser = false; + boolean justActive = true; + Filter filter = new Filter(); + filter.add(new SimpleFilterParameter(RodaConstants.MEMBERS_IS_USER, Boolean.toString(isUser))); + Sorter sorter = new Sorter(new SortParameter(RodaConstants.MEMBERS_FULLNAME, false)); + + Services services = new Services("Find RODA members", "get"); + FindRequest request = FindRequest.getBuilder(RODAMember.class.getName(), filter, justActive).withSorter(sorter) + .build(); + services.membersResource(s -> s.find(request, LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((indexedResult, throwable) -> { + if (throwable != null) { + callback.onFailure(throwable); + } else { + for (RODAMember member : indexedResult.getResults()) { + if (member instanceof Group) { + Group group = (Group) member; + GroupCheckbox groupCheckbox = new GroupCheckbox(group, group.getFullName(), group.getId()); + groups.add(groupCheckbox); + } + } + + for (final GroupCheckbox groupCheckbox : groups) { + GroupSelect.this.add(groupCheckbox); + groupCheckbox.addValueChangeHandler(new ValueChangeHandler() { + + @Override + public void onValueChange(ValueChangeEvent event) { + if (userSelections.keySet().contains(event.getValue().getId())) { + userSelections.remove(event.getValue().getId()); + } else { + userSelections.put(event.getValue().getId(), event.getValue()); + } + onChange(); + } + }); + } + callback.onSuccess(true); + } + }); + } + + public Map getUserSelections() { + return userSelections; + } + + public boolean isEnabled() { + return enabled; + } + + public Set getMemberGroups() { + Set memberGroups = new HashSet<>(); + for (GroupCheckbox g : groups) { + if (g.isChecked()) { + memberGroups.add(g.getGroup().getId()); + } + } + return memberGroups; + } + + public void setMemberGroups(Set memberGroups) { + Iterator it = memberGroups.iterator(); + + while (it.hasNext()) { + String group = it.next(); + boolean foundit = false; + for (Iterator j = groups.iterator(); j.hasNext() && !foundit;) { + GroupCheckbox g = j.next(); + if (g.getGroup().getId().equals(group)) { + foundit = true; + g.setChecked(true); + userSelections.put(group, g.getGroup()); + } + } + } + } + + public void addGroupToBlacklist(String group) { + blacklist.add(group); + } + + @Override + public HandlerRegistration addValueChangeHandler(ValueChangeHandler> handler) { + return addHandler(handler, ValueChangeEvent.getType()); + } + + protected void onChange() { + ValueChangeEvent.fire(this, getValue()); + } + + public List getValue() { + return new Vector<>(getUserSelections().values()); + } + private class GroupCheckbox extends HorizontalPanel implements HasValueChangeHandlers, Comparable { @@ -168,123 +281,4 @@ private GroupSelect getOuterType() { return GroupSelect.this; } } - - private final List blacklist; - private final List groups; - private HashMap userSelections; - private boolean enabled; - - /** - * Create a new group selection widget - * - * @param visible - * start as visible or wait until its initialized - */ - public GroupSelect() { - this.groups = new Vector<>(); - this.blacklist = new Vector<>(); - this.userSelections = new HashMap<>(); - enabled = true; - this.addStyleName("groups"); - } - - public void init(final AsyncCallback callback) { - // TODO use RodaMemberList instead of a list of checkboxes - - boolean isUser = false; - boolean justActive = true; - Filter filter = new Filter(); - filter.add(new SimpleFilterParameter(RodaConstants.MEMBERS_IS_USER, Boolean.toString(isUser))); - Sorter sorter = new Sorter(new SortParameter(RodaConstants.MEMBERS_FULLNAME, false)); - - BrowserService.Util.getInstance().find(RODAMember.class.getName(), filter, sorter, Sublist.ALL, Facets.NONE, - LocaleInfo.getCurrentLocale().getLocaleName(), justActive, new ArrayList<>(), - new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - callback.onFailure(caught); - } - - @Override - public void onSuccess(IndexResult members) { - for (RODAMember member : members.getResults()) { - if (member instanceof Group) { - Group group = (Group) member; - GroupCheckbox groupCheckbox = new GroupCheckbox(group, group.getFullName(), group.getId()); - groups.add(groupCheckbox); - } - } - - for (final GroupCheckbox groupCheckbox : groups) { - GroupSelect.this.add(groupCheckbox); - groupCheckbox.addValueChangeHandler(new ValueChangeHandler() { - - @Override - public void onValueChange(ValueChangeEvent event) { - if (userSelections.keySet().contains(event.getValue().getId())) { - userSelections.remove(event.getValue().getId()); - } else { - userSelections.put(event.getValue().getId(), event.getValue()); - } - onChange(); - } - }); - } - callback.onSuccess(true); - } - }); - } - - public Map getUserSelections() { - return userSelections; - } - - public boolean isEnabled() { - return enabled; - } - - public void setMemberGroups(Set memberGroups) { - Iterator it = memberGroups.iterator(); - - while (it.hasNext()) { - String group = it.next(); - boolean foundit = false; - for (Iterator j = groups.iterator(); j.hasNext() && !foundit;) { - GroupCheckbox g = j.next(); - if (g.getGroup().getId().equals(group)) { - foundit = true; - g.setChecked(true); - userSelections.put(group, g.getGroup()); - } - } - } - } - - public Set getMemberGroups() { - Set memberGroups = new HashSet<>(); - for (GroupCheckbox g : groups) { - if (g.isChecked()) { - memberGroups.add(g.getGroup().getId()); - } - } - return memberGroups; - } - - public void addGroupToBlacklist(String group) { - blacklist.add(group); - } - - @Override - public HandlerRegistration addValueChangeHandler(ValueChangeHandler> handler) { - return addHandler(handler, ValueChangeEvent.getType()); - } - - protected void onChange() { - ValueChangeEvent.fire(this, getValue()); - } - - public List getValue() { - return new Vector<>(getUserSelections().values()); - } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/planning/RiskHistory.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/planning/RiskHistory.java index 1572781d9d..e09fce6e7f 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/planning/RiskHistory.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/planning/RiskHistory.java @@ -113,7 +113,7 @@ public RiskHistory(final String riskId, final RiskVersions versions) { list.addChangeHandler(event -> { selectedVersion = list.getSelectedValue(); - Services services = new Services("Retreive risk version", "get"); + Services services = new Services("Retrieve risk version", "get"); services.riskResource(s -> s.retrieveRiskVersion(riskId, selectedVersion)).whenComplete((result, throwable) -> { if (throwable != null) { AsyncCallbackUtils.defaultFailureTreatment(throwable); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/planning/RiskIncidenceRegister.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/planning/RiskIncidenceRegister.java index 6e87723b80..0f0906d0b9 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/planning/RiskIncidenceRegister.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/planning/RiskIncidenceRegister.java @@ -60,7 +60,7 @@ */ public class RiskIncidenceRegister extends Composite { - public static final HistoryResolver RESOLVER = new HistoryResolver() { + private static final ClientMessages messages = GWT.create(ClientMessages.class); public static final HistoryResolver RESOLVER = new HistoryResolver() { @Override public void resolve(List historyTokens, AsyncCallback callback) { @@ -125,31 +125,20 @@ public String getHistoryToken() { return "riskincidenceregister"; } }; - - interface MyUiBinder extends UiBinder { - } - - private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); - private static final ClientMessages messages = GWT.create(ClientMessages.class); - private static final List aipFieldsToReturn = new ArrayList<>( Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.AIP_GHOST, RodaConstants.AIP_TITLE, RodaConstants.AIP_LEVEL)); - private static final List representationFieldsToReturn = new ArrayList<>( Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.REPRESENTATION_AIP_ID, RodaConstants.REPRESENTATION_ID, RodaConstants.REPRESENTATION_TYPE)); - private static final List fileFieldsToReturn = new ArrayList<>( Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.FILE_PARENT_UUID, RodaConstants.FILE_PATH, RodaConstants.FILE_ANCESTORS_PATH, RodaConstants.FILE_ORIGINALNAME, RodaConstants.INDEX_ID, RodaConstants.FILE_AIP_ID, RodaConstants.FILE_REPRESENTATION_ID, RodaConstants.FILE_ISDIRECTORY)); - + private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); @UiField BreadcrumbPanel breadcrumb; - @UiField FlowPanel riskIncidenceRegisterDescription; - @UiField(provided = true) SearchWrapper searchWrapper; @@ -222,10 +211,10 @@ private void getRepresentationBreadCrumbs(String aipId, String representationId) * representationId, LocaleInfo.getCurrentLocale().getLocaleName(), * representationFieldsToReturn, new AsyncCallback() * { - * + * * @Override public void onFailure(Throwable caught) { * AsyncCallbackUtils.defaultFailureTreatment(caught); } - * + * * @Override public void onSuccess(BrowseRepresentationBundle repBundle) { * breadcrumb.updatePath(BreadcrumbUtils.getRepresentationBreadcrumbs(repBundle) * ); breadcrumb.setVisible(true); } }); @@ -240,22 +229,24 @@ private void getFileBreadCrumbs(String aipId, String representationId, List s.retrieveIndexedFile(request)).whenComplete((indexedFile, throwable) -> { + services.fileResource(s -> s.retrieveIndexedFileViaRequest(request)) + .whenComplete((indexedFile, throwable) -> { - CompletableFuture indexedAIPCompletableFuture = services - .aipResource(s -> s.findByUuid(indexedFile.getAipId(), LocaleInfo.getCurrentLocale().getLocaleName())); - CompletableFuture indexedRepresentationCompletableFuture = services.representationResource( - s -> s.findByUuid(indexedFile.getRepresentationUUID(), LocaleInfo.getCurrentLocale().getLocaleName())); + CompletableFuture indexedAIPCompletableFuture = services + .aipResource(s -> s.findByUuid(indexedFile.getAipId(), LocaleInfo.getCurrentLocale().getLocaleName())); + CompletableFuture indexedRepresentationCompletableFuture = services + .representationResource( + s -> s.findByUuid(indexedFile.getRepresentationUUID(), LocaleInfo.getCurrentLocale().getLocaleName())); - CompletableFuture allFutures = CompletableFuture.allOf(indexedAIPCompletableFuture, - indexedRepresentationCompletableFuture); + CompletableFuture allFutures = CompletableFuture.allOf(indexedAIPCompletableFuture, + indexedRepresentationCompletableFuture); - allFutures.thenRun(() -> { - breadcrumb.updatePath(BreadcrumbUtils.getFileBreadcrumbs(indexedAIPCompletableFuture.join(), - indexedRepresentationCompletableFuture.join(), indexedFile)); - breadcrumb.setVisible(true); + allFutures.thenRun(() -> { + breadcrumb.updatePath(BreadcrumbUtils.getFileBreadcrumbs(indexedAIPCompletableFuture.join(), + indexedRepresentationCompletableFuture.join(), indexedFile)); + breadcrumb.setVisible(true); + }); }); - }); } @Override @@ -263,4 +254,9 @@ protected void onLoad() { super.onLoad(); JavascriptUtils.stickSidebar(); } + + interface MyUiBinder extends UiBinder { + } + + } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/portal/BrowseAIPPortal.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/portal/BrowseAIPPortal.java index eb1577df3e..05e51d7639 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/portal/BrowseAIPPortal.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/portal/BrowseAIPPortal.java @@ -15,8 +15,7 @@ import java.util.List; import org.roda.core.data.common.RodaConstants; -import org.roda.core.data.v2.index.IndexResult; -import org.roda.core.data.v2.index.facet.Facets; +import org.roda.core.data.v2.index.FindRequest; import org.roda.core.data.v2.index.filter.Filter; import org.roda.core.data.v2.index.filter.SimpleFilterParameter; import org.roda.core.data.v2.index.sort.SortParameter; @@ -83,7 +82,19 @@ public class BrowseAIPPortal extends Composite { private static final List fieldsToReturn = new ArrayList<>(RodaConstants.AIP_PERMISSIONS_FIELDS_TO_RETURN); - private static final ClientMessages messages = GWT.create(ClientMessages.class); public static final HistoryResolver RESOLVER = new HistoryResolver() { + private static final ClientMessages messages = GWT.create(ClientMessages.class); + private static SimplePanel container; + private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); + + static { + fieldsToReturn.addAll( + Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.AIP_STATE, RodaConstants.AIP_TITLE, RodaConstants.AIP_LEVEL, + RodaConstants.INGEST_SIP_IDS, RodaConstants.INGEST_JOB_ID, RodaConstants.INGEST_UPDATE_JOB_IDS)); + } + + // Focus + @UiField + FocusPanel keyboardFocus; public static final HistoryResolver RESOLVER = new HistoryResolver() { @Override public void resolve(List historyTokens, AsyncCallback callback) { @@ -110,18 +121,6 @@ public List getHistoryPath() { return Arrays.asList(getHistoryToken()); } }; - private static SimplePanel container; - private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); - - static { - fieldsToReturn.addAll( - Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.AIP_STATE, RodaConstants.AIP_TITLE, RodaConstants.AIP_LEVEL, - RodaConstants.INGEST_SIP_IDS, RodaConstants.INGEST_JOB_ID, RodaConstants.INGEST_UPDATE_JOB_IDS)); - } - - // Focus - @UiField - FocusPanel keyboardFocus; @UiField NavigationToolbar navigationToolbar; @UiField @@ -136,18 +135,15 @@ public List getHistoryPath() { // DISSEMINATIONS @UiField SimplePanel disseminationsCard; - // HEADER @UiField FlowPanel preDisseminations; - // STATUS // AIP CHILDREN @UiField SimplePanel aipChildrenCard; @UiField FlowPanel preChildren; - // DESCRIPTIVE METADATA @UiField FlowPanel center; @@ -155,7 +151,6 @@ public List getHistoryPath() { Label dateCreatedAndModified; private String aipId; private IndexedAIP aip; - private BrowseAIPPortal(BrowseAIPBundle bundle) { aip = bundle.getAip(); aipId = aip.getId(); @@ -193,38 +188,32 @@ public void onSuccess(Actionable.ActionImpact impact) { Filter filter = new Filter(new SimpleFilterParameter(RodaConstants.DIP_AIP_UUIDS, aip.getId())); Sorter sorter = new Sorter(new SortParameter(RodaConstants.DIP_DATE_CREATED, true)); - BrowserService.Util.getInstance().find(IndexedDIP.class.getName(), filter, sorter, new Sublist(0, 1), - Facets.NONE, LocaleInfo.getCurrentLocale().getLocaleName(), true, - Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.DIP_ID), - new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - AsyncCallbackUtils.defaultFailureTreatment(caught); - } - - @Override - public void onSuccess(IndexResult result) { - if (result.getTotalCount() > 0) { - String dipId = result.getResults().get(0).getId(); + FindRequest request = FindRequest.getBuilder(IndexedDIP.class.getName(), filter, true) + .withFieldsToReturn(Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.DIP_ID)).withSorter(sorter) + .withSublist(new Sublist(0, 1)).build(); + + Services service = new Services("Find DIPs", "get"); + service.dipResource(s -> s.find(request, LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((indexedDIPIndexResult, throwable1) -> { + if (throwable1 != null) { + AsyncCallbackUtils.defaultFailureTreatment(throwable1); + } else { + if (indexedDIPIndexResult.getTotalCount() > 0) { + String dipId = indexedDIPIndexResult.getResults().get(0).getId(); Filter fileFilter = new Filter(new SimpleFilterParameter(RodaConstants.DIPFILE_DIP_ID, dipId)); - BrowserService.Util.getInstance().find( - DIPFile.class.getName(), fileFilter, Sorter.NONE, new Sublist(0, 1), Facets.NONE, - LocaleInfo.getCurrentLocale().getLocaleName(), true, Arrays.asList(RodaConstants.INDEX_UUID, - RodaConstants.DIPFILE_ID, RodaConstants.DIPFILE_SIZE, RodaConstants.DIPFILE_IS_DIRECTORY), - new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - AsyncCallbackUtils.defaultFailureTreatment(caught); - } - - @Override - public void onSuccess(IndexResult result) { - if (result.getTotalCount() > 0) { + FindRequest findRequest = FindRequest.getBuilder(DIPFile.class.getName(), fileFilter, true) + .withFieldsToReturn(Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.DIPFILE_ID, + RodaConstants.DIPFILE_SIZE, RodaConstants.DIPFILE_IS_DIRECTORY)) + .withSublist(new Sublist(0, 1)).build(); + service.dipFileResource(s -> s.find(findRequest, LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((dipFileIndexResult, throwable2) -> { + if (throwable2 != null) { + AsyncCallbackUtils.defaultFailureTreatment(throwable2); + } else { + if (dipFileIndexResult.getTotalCount() > 0) { disseminationsCard.setVisible(true); preDisseminations.setVisible(true); - disseminationsCard.add(new DipFilePreview(viewers, result.getResults().get(0))); + disseminationsCard.add(new DipFilePreview(viewers, dipFileIndexResult.getResults().get(0))); } } }); @@ -422,4 +411,5 @@ interface MyUiBinder extends UiBinder { } + } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/search/Relation.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/search/Relation.java index 0a6640995a..0f5708170f 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/search/Relation.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/search/Relation.java @@ -12,7 +12,7 @@ import java.util.List; import org.roda.core.data.common.RodaConstants; -import org.roda.core.data.v2.index.IndexResult; +import org.roda.core.data.v2.index.FindRequest; import org.roda.core.data.v2.index.facet.Facets; import org.roda.core.data.v2.index.filter.Filter; import org.roda.core.data.v2.index.filter.FilterParameter; @@ -21,7 +21,7 @@ import org.roda.core.data.v2.index.sublist.Sublist; import org.roda.core.data.v2.ip.IndexedAIP; import org.roda.wui.client.browse.BrowseTop; -import org.roda.wui.client.browse.BrowserService; +import org.roda.wui.client.services.Services; import org.roda.wui.common.client.HistoryResolver; import org.roda.wui.common.client.tools.HistoryUtils; @@ -36,6 +36,7 @@ */ public class Relation { + private static Relation instance = null; public static final HistoryResolver RESOLVER = new HistoryResolver() { @Override @@ -59,8 +60,6 @@ public String getHistoryToken() { } }; - private static Relation instance = null; - /** * Get the singleton instance * @@ -88,17 +87,15 @@ public void resolve(final List historyTokens, final AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { + Services services = new Services("Find AIPs", "get"); + FindRequest request = FindRequest.getBuilder(IndexedAIP.class.getName(), filter, false).withSorter(Sorter.NONE) + .withSublist(new Sublist(0, 1)).withFacets(Facets.NONE) + .withFieldsToReturn(Arrays.asList(RodaConstants.INDEX_UUID)).build(); + services.aipResource(s -> s.find(request, LocaleInfo.getCurrentLocale().getLocaleName())) + .whenComplete((result, throwable) -> { + if (throwable != null) { HistoryUtils.newHistory(Search.RESOLVER); - } - - @Override - public void onSuccess(IndexResult result) { + } else { if (result.getTotalCount() == 1) { HistoryUtils.newHistory(BrowseTop.RESOLVER, result.getResults().get(0).getUUID()); } else { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/AIPRestService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/AIPRestService.java index fde059f923..1484674e1a 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/AIPRestService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/AIPRestService.java @@ -40,4 +40,10 @@ DescriptiveMetadataInfos retrieveRepresentationDescriptiveMetadata( @Parameter(description = "The AIP identifier", required = true) @PathVariable(name = "id") String aipId, @Parameter(description = "The representation identifier", required = true) @PathVariable(name = "representation-id") String representationId, @Parameter(description = "The language to be used for internationalization", content = @Content(schema = @Schema(defaultValue = "en", implementation = String.class))) @RequestParam(name = "lang", defaultValue = "en", required = false) String localeString); + + @RequestMapping(method = RequestMethod.GET, path = "/configuration/rules", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Retrieves from the configuration the rules for the Representation information", responses = { + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = List.class))), + @ApiResponse(responseCode = "401", description = "Bad request", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) + List retrieveAIPRuleProperties(); } \ No newline at end of file diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/ConfigurationRestService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/ConfigurationRestService.java index 7739e7f25a..724f9ee913 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/ConfigurationRestService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/ConfigurationRestService.java @@ -5,12 +5,16 @@ import org.fusesource.restygwt.client.DirectRestService; import org.roda.core.data.v2.jobs.PluginInfoList; import org.roda.core.data.v2.jobs.PluginType; +import org.roda.core.data.v2.properties.ConversionProfileOutcomeType; +import org.roda.core.data.v2.properties.ConversionProfiles; +import org.roda.core.data.v2.properties.DropdownPluginParameterItems; import org.roda.core.data.v2.properties.ObjectClassFields; import org.roda.core.data.v2.properties.ReindexPluginObjects; import org.roda.core.data.v2.properties.SharedProperties; import org.roda.wui.api.v2.exceptions.model.ErrorResponseMessage; import org.roda.wui.client.browse.Viewers; import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -55,8 +59,32 @@ ObjectClassFields retrieveObjectClassFields( @RequestMapping(method = RequestMethod.GET, path = "/plugins/reindex", produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Retrieves a list of resources that are used by reindex plugins", responses = { - @ApiResponse(responseCode = "200", description = "Returns a set of objects classes", content = @Content(schema = @Schema(implementation = ReindexPluginObjects.class))), - @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))), - @ApiResponse(responseCode = "403", description = "Access forbidden", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) + @ApiResponse(responseCode = "200", description = "Returns a set of objects classes", content = @Content(schema = @Schema(implementation = ReindexPluginObjects.class))), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))), + @ApiResponse(responseCode = "403", description = "Access forbidden", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) ReindexPluginObjects retrieveReindexPluginObjectClasses(); + + @RequestMapping(method = RequestMethod.GET, path = "/embedded-dip", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Retrieves the configuration value associated to the property of show DIP embedded in system or externally", responses = { + @ApiResponse(responseCode = "200", description = "Returns true or false", content = @Content(schema = @Schema(implementation = Boolean.class))),}) + Boolean retrieveShowEmbeddedDIP(); + + @RequestMapping(method = RequestMethod.GET, path = "/plugins/dropdown/{parameter-id}", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Retrieves a list of items from the configurations according to the parameter identifier", responses = { + @ApiResponse(responseCode = "200", description = "Returns a set of dropdown items", content = @Content(schema = @Schema(implementation = DropdownPluginParameterItems.class))), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))), + @ApiResponse(responseCode = "403", description = "Access forbidden", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) + DropdownPluginParameterItems retrieveDropdownPluginItems( + @Parameter(description = "The plugin parameter identifier", required = true) @PathVariable(name = "parameter-id") String parameterId, + @Parameter(description = "The language to be used for internationalization", content = @Content(schema = @Schema(defaultValue = "en", implementation = String.class))) @RequestParam(name = "lang", defaultValue = "en", required = false) String localeString); + + @RequestMapping(method = RequestMethod.GET, path = "/plugins/{id}/conversion/profiles", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Retrieves a list of conversion profiles from the configurations according to the plugin identifier", responses = { + @ApiResponse(responseCode = "200", description = "Returns a set of conversion profiles for a specific plugin", content = @Content(schema = @Schema(implementation = DropdownPluginParameterItems.class))), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))), + @ApiResponse(responseCode = "403", description = "Access forbidden", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) + ConversionProfiles retrieveConversionProfiles( + @Parameter(description = "The plugin identifier", required = true) @PathVariable(name = "id") String pluginId, + @Parameter(description = "The type of outcome", required = true, content = @Content(schema = @Schema(implementation = ConversionProfileOutcomeType.class))) @RequestParam(name = "outcome") ConversionProfileOutcomeType outcomeType, + @Parameter(description = "The language to be used for internationalization", content = @Content(schema = @Schema(defaultValue = "en", implementation = String.class))) @RequestParam(name = "lang", defaultValue = "en", required = false) String localeString); } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DIPFileRestService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DIPFileRestService.java new file mode 100644 index 0000000000..e115d12377 --- /dev/null +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DIPFileRestService.java @@ -0,0 +1,13 @@ +package org.roda.wui.client.services; + +import io.swagger.v3.oas.annotations.tags.Tag; +import org.roda.core.data.v2.ip.DIPFile; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * @author Miguel Guimarães + */ +@Tag(name = "v2 dip files") +@RequestMapping(path = "../api/v2/dip-files") +public interface DIPFileRestService extends RODAEntityRestService { +} diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DIPRestService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DIPRestService.java index d6b6915bc4..f6b37b0262 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DIPRestService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DIPRestService.java @@ -1,8 +1,20 @@ package org.roda.wui.client.services; -import io.swagger.v3.oas.annotations.tags.Tag; +import org.roda.core.data.v2.generics.DeleteRequest; +import org.roda.core.data.v2.generics.UpdatePermissionsRequest; import org.roda.core.data.v2.ip.IndexedDIP; +import org.roda.core.data.v2.jobs.Job; +import org.roda.wui.api.v2.exceptions.model.ErrorResponseMessage; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; /** * @author Miguel Guimarães @@ -10,4 +22,17 @@ @Tag(name = "v2 dips") @RequestMapping(path = "../api/v2/dips") public interface DIPRestService extends RODAEntityRestService { + + @RequestMapping(path = "/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Creates an internal action to delete file(s) from the representation", requestBody = @RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = DeleteRequest.class))), responses = { + @ApiResponse(responseCode = "200", description = "Job created", content = @Content(schema = @Schema(implementation = Job.class))), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) + Job deleteIndexedDIPs(DeleteRequest deleteRequest); + + @RequestMapping(path = "/permissions/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Creates an internal actions to update the permissions of DIP(s)", requestBody = @RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = UpdatePermissionsRequest.class))), responses = { + @ApiResponse(responseCode = "200", description = "Job created", content = @Content(schema = @Schema(implementation = Job.class))), + @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) + Job updatePermissions(UpdatePermissionsRequest updateRequest); + } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DisposalConfirmationRestService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DisposalConfirmationRestService.java index aa6dcac45d..05afef1a3a 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DisposalConfirmationRestService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DisposalConfirmationRestService.java @@ -29,14 +29,6 @@ @RequestMapping(path = "../api/v2/disposal/confirmations") public interface DisposalConfirmationRestService extends RODAEntityRestService { - @RequestMapping(method = RequestMethod.GET, path = "/{id}/report", produces = MediaType.TEXT_PLAIN_VALUE) - @Operation(summary = "Retrieves the disposal confirmation report", responses = { - @ApiResponse(responseCode = "200", description = "Returns the disposal confirmation report", content = @Content(schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) - String retrieveDisposalConfirmationReport( - @Parameter(description = "The ID of the disposal confirmation", required = true) @PathVariable("id") String disposalConfirmationId, - @Parameter(description = "Use a print-friendly layout", schema = @Schema(defaultValue = "false", implementation = Boolean.class)) @RequestParam(name = "to-print", defaultValue = "false", required = false) boolean toPrint); - @RequestMapping(method = RequestMethod.POST, path = "/destroy", produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Destroys the records in the disposal confirmations", description = "Creates an internal job to destroy the records in the disposal confirmations", responses = { @ApiResponse(responseCode = "200", description = "Job created")}) diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DisposalHoldRestService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DisposalHoldRestService.java index 7f6f9c5060..d173f1d3c4 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DisposalHoldRestService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/DisposalHoldRestService.java @@ -1,10 +1,10 @@ package org.roda.wui.client.services; import org.fusesource.restygwt.client.DirectRestService; -import org.roda.core.data.v2.disposal.metadata.DisposalHoldsAIPMetadata; -import org.roda.core.data.v2.disposal.metadata.DisposalTransitiveHoldsAIPMetadata; import org.roda.core.data.v2.disposal.hold.DisposalHold; import org.roda.core.data.v2.disposal.hold.DisposalHolds; +import org.roda.core.data.v2.disposal.metadata.DisposalHoldsAIPMetadata; +import org.roda.core.data.v2.disposal.metadata.DisposalTransitiveHoldsAIPMetadata; import org.roda.core.data.v2.index.select.SelectedItems; import org.roda.core.data.v2.ip.IndexedAIP; import org.roda.core.data.v2.jobs.Job; @@ -64,7 +64,7 @@ DisposalHold retrieveDisposalHold( @ApiResponse(responseCode = "204", description = "Resource deleted"), @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) Void deleteDisposalHold( - @Parameter(description = "The ID of the disposal hold to delete.", required = true) @PathVariable("id") String disposalHoldId); + @Parameter(description = "The ID of the disposal hold to delete.", required = true) @PathVariable(name = "id") String disposalHoldId); @RequestMapping(method = RequestMethod.POST, path = "/apply", produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Apply disposal hold to selected AIPs", requestBody = @RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = SelectedItems.class))), responses = { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/FileRestService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/FileRestService.java index d4d6b6e7ba..a345ba5d0b 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/FileRestService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/FileRestService.java @@ -3,11 +3,10 @@ import java.util.List; import org.roda.core.data.v2.file.CreateFolderRequest; -import org.roda.core.data.v2.file.DeleteFilesRequest; import org.roda.core.data.v2.file.MoveFilesRequest; import org.roda.core.data.v2.file.RenameFolderRequest; +import org.roda.core.data.v2.generics.DeleteRequest; import org.roda.core.data.v2.index.IndexedFileRequest; -import org.roda.core.data.v2.index.SuggestRequest; import org.roda.core.data.v2.index.select.SelectedItems; import org.roda.core.data.v2.ip.IndexedFile; import org.roda.core.data.v2.jobs.Job; @@ -33,12 +32,12 @@ @RequestMapping(path = "../api/v2/files") public interface FileRestService extends RODAEntityRestService { - @RequestMapping(method = RequestMethod.POST, path = "/get", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Retrieves a file", requestBody = @RequestBody(required = true, content = @Content(schema = @Schema(implementation = IndexedFileRequest.class))), responses = { + @RequestMapping(method = RequestMethod.POST, path = "/find-via-request", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Retrieves a file using a dedicated request", requestBody = @RequestBody(required = true, content = @Content(schema = @Schema(implementation = IndexedFileRequest.class))), responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = IndexedFile.class))), @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))), @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) - IndexedFile retrieveIndexedFile(IndexedFileRequest request); + IndexedFile retrieveIndexedFileViaRequest(IndexedFileRequest request); @RequestMapping(path = "/move", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Create an internal action to move file(s) to another folder within the representation", requestBody = @RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = MoveFilesRequest.class))), responses = { @@ -48,10 +47,10 @@ public interface FileRestService extends RODAEntityRestService { Job moveFileToFolder(MoveFilesRequest moveFilesRequest); @RequestMapping(path = "/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Creates an internal action to delete file(s) from the representation", requestBody = @RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = DeleteFilesRequest.class))), responses = { + @Operation(summary = "Creates an internal action to delete file(s) from the representation", requestBody = @RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = DeleteRequest.class))), responses = { @ApiResponse(responseCode = "200", description = "Job created", content = @Content(schema = @Schema(implementation = Job.class))), @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) - Job deleteFiles(DeleteFilesRequest deleteFilesRequest); + Job deleteFiles(DeleteRequest deleteRequest); @RequestMapping(path = "/rename", method = RequestMethod.PATCH, produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Rename folder", description = "Renames a folder", requestBody = @RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = RenameFolderRequest.class))), responses = { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/RepresentationRestService.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/RepresentationRestService.java index 71037baac7..334ea4b3d8 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/RepresentationRestService.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/RepresentationRestService.java @@ -4,7 +4,6 @@ import org.roda.core.data.common.RodaConstants; import org.roda.core.data.v2.index.IndexedRepresentationRequest; -import org.roda.core.data.v2.index.SuggestRequest; import org.roda.core.data.v2.index.select.SelectedItems; import org.roda.core.data.v2.ip.IndexedFile; import org.roda.core.data.v2.ip.IndexedRepresentation; @@ -38,11 +37,11 @@ public interface RepresentationRestService extends RODAEntityRestService { @RequestMapping(method = RequestMethod.POST, path = "/find-via-request", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Retrieves a representation", requestBody = @RequestBody(required = true, content = @Content(schema = @Schema(implementation = IndexedRepresentationRequest.class))), responses = { + @Operation(summary = "Retrieves a representation using a dedicated request", requestBody = @RequestBody(required = true, content = @Content(schema = @Schema(implementation = IndexedRepresentationRequest.class))), responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = IndexedFile.class))), @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))), @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))}) - IndexedRepresentation retrieveIndexedRepresentation(IndexedRepresentationRequest request); + IndexedRepresentation retrieveIndexedRepresentationViaRequest(IndexedRepresentationRequest request); @RequestMapping(path = "/{" + RodaConstants.API_PATH_PARAM_AIP_ID + "}/{" + RodaConstants.API_PATH_PARAM_REPRESENTATION_ID diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/Services.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/Services.java index 21dfbbf9ce..7931e55d99 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/Services.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/services/Services.java @@ -10,6 +10,7 @@ import org.roda.core.data.exceptions.RODAException; import org.roda.core.data.v2.disposal.confirmation.DisposalConfirmation; import org.roda.core.data.v2.index.IsIndexed; +import org.roda.core.data.v2.ip.DIPFile; import org.roda.core.data.v2.ip.IndexedAIP; import org.roda.core.data.v2.ip.IndexedDIP; import org.roda.core.data.v2.ip.IndexedFile; @@ -78,6 +79,10 @@ private S get(Class serviceClass) { return GWT.create(RepresentationRestService.class); } else if (AIPRestService.class.equals(serviceClass)) { return GWT.create(AIPRestService.class); + } else if (DIPRestService.class.equals(serviceClass)) { + return GWT.create(DIPRestService.class); + } else if (DIPFileRestService.class.equals(serviceClass)) { + return GWT.create(DIPFileRestService.class); } else { throw new IllegalArgumentException(serviceClass.getName() + " not supported"); } @@ -141,6 +146,8 @@ private , O extends IsIndexed, T> Completable service = GWT.create(RepresentationRestService.class); } else if (IndexedFile.class.getName().equals(objectClassString)) { service = GWT.create(FileRestService.class); + } else if (DIPFile.class.getName().equals(objectClassString)) { + service = GWT.create(DIPFileRestService.class); } else { throw new IllegalArgumentException(objectClassString + " not supported"); } @@ -172,7 +179,7 @@ public CompletableFuture rodaEntityRestService( } public CompletableFuture rodaEntityRestService( - CheckedFunction, T> method, String objectClassName) { + CheckedFunction, T> method, String objectClassName) { return futureFromObjectClass(objectClassName, method); } @@ -245,4 +252,12 @@ public CompletableFuture configurationsResource(CheckedFunction CompletableFuture aipResource(CheckedFunction method) { return future(AIPRestService.class, method); } + + public CompletableFuture dipResource(CheckedFunction method) { + return future(DIPRestService.class, method); + } + + public CompletableFuture dipFileResource(CheckedFunction method) { + return future(DIPFileRestService.class, method); + } } diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/common/client/tools/RestUtils.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/common/client/tools/RestUtils.java index ce3b2f32fb..a35a71ff4d 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/common/client/tools/RestUtils.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/common/client/tools/RestUtils.java @@ -68,8 +68,9 @@ public static SafeUri createRepresentationDownloadUri(String aipId, String repre // api/v2/representations/{aip_id}/{representation_id}/binary StringBuilder b = new StringBuilder(); // base uri - b.append(RodaConstants.API_REST_V2_REPRESENTATIONS).append(RodaConstants.API_SEP).append(URL.encodeQueryString(aipId)) - .append(RodaConstants.API_SEP).append(URL.encodeQueryString(representationId)).append(RodaConstants.API_REST_V2_DOWNLOAD_HANDLER); + b.append(RodaConstants.API_REST_V2_REPRESENTATIONS).append(RodaConstants.API_SEP) + .append(URL.encodeQueryString(aipId)).append(RodaConstants.API_SEP) + .append(URL.encodeQueryString(representationId)).append(RodaConstants.API_REST_V2_DOWNLOAD_HANDLER); return UriUtils.fromSafeConstant(b.toString()); } @@ -79,8 +80,9 @@ public static SafeUri createRepresentationOtherMetadataDownloadUri(String aipId, // api/v2/representations/{aip_id}/{representation_id}/other-metadata/binary StringBuilder b = new StringBuilder(); // base uri - b.append(RodaConstants.API_REST_V2_REPRESENTATIONS).append(RodaConstants.API_SEP).append(URL.encodeQueryString(aipId)) - .append(RodaConstants.API_SEP).append(URL.encodeQueryString(representationId)).append(RodaConstants.API_REST_V2_REPRESENTATION_OTHER_METADATA) + b.append(RodaConstants.API_REST_V2_REPRESENTATIONS).append(RodaConstants.API_SEP) + .append(URL.encodeQueryString(aipId)).append(RodaConstants.API_SEP) + .append(URL.encodeQueryString(representationId)).append(RodaConstants.API_REST_V2_REPRESENTATION_OTHER_METADATA) .append(RodaConstants.API_REST_V2_DOWNLOAD_HANDLER); return UriUtils.fromSafeConstant(b.toString()); @@ -111,14 +113,10 @@ public static SafeUri createRepresentationFileDownloadUri(String fileUuid, boole } public static SafeUri createDipDownloadUri(String dipUUID) { - - // api/v1/dips/{dip_uuid}?acceptFormat=zip + // api/v2/dips/{uuid}/binary StringBuilder b = new StringBuilder(); - // base uri - b.append(RodaConstants.API_REST_V1_DIPS).append(URL.encodeQueryString(dipUUID)); - // accept format attribute - b.append(RodaConstants.API_QUERY_START).append(RodaConstants.API_QUERY_KEY_ACCEPT_FORMAT) - .append(RodaConstants.API_QUERY_ASSIGN_SYMBOL).append(RodaConstants.API_QUERY_VALUE_ACCEPT_FORMAT_ZIP); + b.append(RodaConstants.API_REST_V2_DIPS).append(URL.encodeQueryString(dipUUID)) + .append(RodaConstants.API_REST_V2_DOWNLOAD_HANDLER); return UriUtils.fromSafeConstant(b.toString()); } @@ -318,8 +316,9 @@ public static SafeUri createRepresentationDescriptiveMetadataHTMLUri(String aipI StringBuilder b = new StringBuilder(); // base uri b.append(RodaConstants.API_REST_V2_AIPS).append(RodaConstants.API_SEP).append(URL.encodeQueryString(aipId)) - .append(RodaConstants.API_SEP).append("representations").append(RodaConstants.API_SEP).append(URL.encodeQueryString(representationId)).append(RodaConstants.API_SEP) - .append("metadata").append(RodaConstants.API_SEP).append("descriptive").append(RodaConstants.API_SEP) + .append(RodaConstants.API_SEP).append("representations").append(RodaConstants.API_SEP) + .append(URL.encodeQueryString(representationId)).append(RodaConstants.API_SEP).append("metadata") + .append(RodaConstants.API_SEP).append("descriptive").append(RodaConstants.API_SEP) .append(URL.encodeQueryString(descId)).append(RodaConstants.API_SEP).append("html"); // locale @@ -340,8 +339,8 @@ public static SafeUri createPreservationEventDownloadUri(String eventId) { public static SafeUri createPreservationEventDetailsUri(String eventId) { // api/v2/preservation/events/{id}/details/html?lang={lang} String b = RodaConstants.API_REST_V2_PRESERVATION_EVENTS + URL.encodeQueryString(eventId) - + RodaConstants.API_REST_V2_PRESERVATION_EVENTS_DETAILS_HTML - + RodaConstants.API_QUERY_START + RodaConstants.API_QUERY_KEY_LANG + RodaConstants.API_QUERY_ASSIGN_SYMBOL + + RodaConstants.API_REST_V2_PRESERVATION_EVENTS_DETAILS_HTML + RodaConstants.API_QUERY_START + + RodaConstants.API_QUERY_KEY_LANG + RodaConstants.API_QUERY_ASSIGN_SYMBOL + LocaleInfo.getCurrentLocale().getLocaleName(); return UriUtils.fromSafeConstant(b); @@ -368,8 +367,7 @@ public static String createTransferredResourceUploadUri(String parentUUID, Strin } if (parentUUID != null) { - b.append("parent-uuid").append(RodaConstants.API_QUERY_ASSIGN_SYMBOL) - .append(parentUUID); + b.append("parent-uuid").append(RodaConstants.API_QUERY_ASSIGN_SYMBOL).append(parentUUID); } if (parentUUID != null && locale != null) { @@ -394,8 +392,7 @@ public static String createFileUploadUri(String aipId, String representationId, // base uri b.append(RodaConstants.API_REST_V2_FILES).append("upload").append(RodaConstants.API_QUERY_START); - b.append("aip-id").append(RodaConstants.API_QUERY_ASSIGN_SYMBOL) - .append(URL.encodeQueryString(aipId)); + b.append("aip-id").append(RodaConstants.API_QUERY_ASSIGN_SYMBOL).append(URL.encodeQueryString(aipId)); b.append(RodaConstants.API_QUERY_SEP); b.append("representation-id").append(RodaConstants.API_QUERY_ASSIGN_SYMBOL) .append(URL.encodeQueryString(representationId)); @@ -458,8 +455,8 @@ public static SafeUri createThemeResourceUri(String resourceId, String defaultRe StringBuilder b = new StringBuilder(); b.append(RodaConstants.API_REST_V2_THEME).append(RodaConstants.API_QUERY_START) - .append(RodaConstants.API_V2_QUERY_PARAM_RESOURCE_ID) - .append(RodaConstants.API_QUERY_ASSIGN_SYMBOL).append(URL.encode(resourceId)); + .append(RodaConstants.API_V2_QUERY_PARAM_RESOURCE_ID).append(RodaConstants.API_QUERY_ASSIGN_SYMBOL) + .append(URL.encode(resourceId)); if (defaultResourceId != null) { b.append(RodaConstants.API_QUERY_SEP).append(RodaConstants.API_V2_QUERY_PARAM_DEFAULT_RESOURCE_ID) @@ -532,6 +529,24 @@ public void run() { form.submit(); } + public static SafeUri createDisposalConfirmationHTMLUri(String disposalConfirmationId, boolean toPrint) { + // api/v2/disposal/confirmations/{id}/report/html?to-print= + + final StringBuilder b = new StringBuilder(); + // base uri + b.append(RodaConstants.API_REST_V2_DISPOSAL_CONFIRMATION).append(disposalConfirmationId) + .append(RodaConstants.API_SEP).append(RodaConstants.API_REST_V2_DISPOSAL_CONFIRMATION_REPORT) + .append(RodaConstants.API_SEP).append(RodaConstants.API_REST_V2_DISPOSAL_CONFIRMATION_REPORT_HTML); + + if (toPrint) { + b.append(RodaConstants.API_QUERY_START) + .append(RodaConstants.API_REST_V2_DISPOSAL_CONFIRMATION_QUERY_PARAM_TO_PRINT) + .append(RodaConstants.API_QUERY_ASSIGN_SYMBOL).append(true); + } + + return UriUtils.fromSafeConstant(b.toString()); + } + public static interface FindRequestMapper extends ObjectMapper { } } 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 2f7d29ca13..005632079a 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 @@ -20,10 +20,7 @@ import java.util.ResourceBundle; import java.util.Set; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.lang.StringEscapeUtils; import org.roda.core.RodaCoreFactory; -import org.roda.core.common.Messages; import org.roda.core.common.RodaUtils; import org.roda.core.common.SelectedItemsUtils; import org.roda.core.data.common.RodaConstants; @@ -32,17 +29,14 @@ import org.roda.core.data.exceptions.AuthorizationDeniedException; import org.roda.core.data.exceptions.GenericException; import org.roda.core.data.exceptions.IllegalOperationException; -import org.roda.core.data.exceptions.JobAlreadyStartedException; import org.roda.core.data.exceptions.LockingException; import org.roda.core.data.exceptions.NotFoundException; import org.roda.core.data.exceptions.RODAException; import org.roda.core.data.exceptions.RequestNotValidException; -import org.roda.core.data.utils.JsonUtils; -import org.roda.core.data.v2.IsRODAObject; import org.roda.core.data.v2.Void; import org.roda.core.data.v2.accessKey.AccessKey; import org.roda.core.data.v2.accessKey.AccessKeys; -import org.roda.core.data.v2.common.ConversionProfile; +import org.roda.core.data.v2.properties.ConversionProfile; import org.roda.core.data.v2.common.Pair; import org.roda.core.data.v2.index.IndexResult; import org.roda.core.data.v2.index.IsIndexed; @@ -50,28 +44,12 @@ import org.roda.core.data.v2.index.facet.FacetValue; import org.roda.core.data.v2.index.facet.Facets; import org.roda.core.data.v2.index.facet.SimpleFacetParameter; -import org.roda.core.data.v2.index.filter.Filter; import org.roda.core.data.v2.index.select.SelectedItems; import org.roda.core.data.v2.index.select.SelectedItemsAll; -import org.roda.core.data.v2.index.select.SelectedItemsList; import org.roda.core.data.v2.index.select.SelectedItemsNone; -import org.roda.core.data.v2.index.sort.Sorter; -import org.roda.core.data.v2.index.sublist.Sublist; import org.roda.core.data.v2.ip.IndexedAIP; -import org.roda.core.data.v2.ip.IndexedDIP; import org.roda.core.data.v2.ip.Permissions; import org.roda.core.data.v2.jobs.Job; -import org.roda.core.data.v2.jobs.JobMixIn; -import org.roda.core.data.v2.jobs.JobParallelism; -import org.roda.core.data.v2.jobs.JobPriority; -import org.roda.core.data.v2.jobs.JobUserDetails; -import org.roda.core.data.v2.jobs.PluginInfo; -import org.roda.core.data.v2.jobs.PluginParameter; -import org.roda.core.data.v2.jobs.PluginParameter.PluginParameterType; -import org.roda.core.data.v2.jobs.PluginType; -import org.roda.core.data.v2.jobs.Report; -import org.roda.core.data.v2.notifications.Notification; -import org.roda.core.data.v2.risks.RiskIncidence; import org.roda.core.data.v2.synchronization.central.DistributedInstance; import org.roda.core.data.v2.synchronization.central.DistributedInstances; import org.roda.core.data.v2.synchronization.local.LocalInstance; @@ -81,27 +59,16 @@ import org.roda.core.plugins.PluginHelper; import org.roda.core.storage.ContentPayload; import org.roda.core.storage.StringContentPayload; -import org.roda.core.util.IdUtils; import org.roda.wui.api.controllers.ApplicationAuth; import org.roda.wui.api.controllers.Browser; -import org.roda.wui.api.controllers.Jobs; import org.roda.wui.api.controllers.RODAInstance; import org.roda.wui.client.browse.BrowserService; -import org.roda.wui.client.browse.Viewers; import org.roda.wui.client.browse.bundle.BrowseAIPBundle; -import org.roda.wui.client.browse.bundle.BrowseDipBundle; -import org.roda.wui.client.browse.bundle.BrowseRepresentationBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataEditBundle; import org.roda.wui.client.browse.bundle.DescriptiveMetadataVersionsBundle; -import org.roda.wui.client.browse.bundle.PreservationEventViewBundle; -import org.roda.wui.client.browse.bundle.RepresentationInformationFilterBundle; import org.roda.wui.client.browse.bundle.SupportedMetadataTypeBundle; -import org.roda.wui.client.ingest.process.CreateIngestJobBundle; -import org.roda.wui.client.ingest.process.JobBundle; -import org.roda.wui.common.I18nUtility; import org.roda.wui.common.client.tools.StringUtils; import org.roda.wui.common.server.ServerTools; -import org.roda.wui.servlets.ContextListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -162,33 +129,6 @@ public DescriptiveMetadataEditBundle retrieveDescriptiveMetadataEditBundle(Strin return Browser.retrieveDescriptiveMetadataEditBundle(user, aipId, representationId, descId, locale); } - @Override - public IndexResult find(String classNameToReturn, Filter filter, Sorter sorter, - Sublist sublist, Facets facets, String localeString, boolean justActive, List fieldsToReturn) - throws GenericException, AuthorizationDeniedException, RequestNotValidException { - try { - User user = UserUtility.getUser(getThreadLocalRequest()); - Class classToReturn = SelectedItemsUtils.parseClass(classNameToReturn); - IndexResult result = Browser.find(classToReturn, filter, sorter, sublist, facets, user, justActive, - fieldsToReturn); - return I18nUtility.translate(result, classToReturn, localeString); - } catch (RuntimeException e) { - LOGGER.error("Unexpected error in find", e); - throw new GenericException(e); - } catch (GenericException e) { - LOGGER.error("Unexpected error in find", e); - throw e; - } - } - - @Override - public T retrieve(String classNameToReturn, String id, List fieldsToReturn) - throws RODAException { - User user = UserUtility.getUser(getThreadLocalRequest()); - Class classToReturn = SelectedItemsUtils.parseClass(classNameToReturn); - return Browser.retrieve(user, classToReturn, id, fieldsToReturn); - } - @Override public List retrieve(String classNameToReturn, SelectedItems selectedItems, List fieldsToReturn) @@ -274,96 +214,6 @@ public void deleteDescriptiveMetadataFile(String aipId, String representationId, Browser.deleteDescriptiveMetadataFile(user, aipId, representationId, descriptiveMetadataId); } - @Override - public Set> retrieveDropdownPluginItems(String parameterId, String localeString) { - Set> items = new HashSet<>(); - List dropdownItems = RodaUtils - .copyList(RodaCoreFactory.getRodaConfiguration().getList("core.plugins.dropdown." + parameterId + "[]")); - Locale locale = ServerTools.parseLocale(localeString); - Messages messages = RodaCoreFactory.getI18NMessages(locale); - - for (String item : dropdownItems) { - String i18nProperty = RodaCoreFactory.getRodaConfiguration() - .getString("core.plugins.dropdown." + parameterId + "[]." + item + ".i18n"); - items.add(Pair.of(messages.getTranslation(i18nProperty, item), item)); - } - - return items; - } - - @Override - public Set retrieveConversionProfilePluginItems(String pluginId, String repOrDip, - String localeString) { - Set items = new HashSet<>(); - - String pluginName = RodaCoreFactory.getRodaConfiguration().getString("core.plugins.conversion.profile." + pluginId); - - List dropdownItems = RodaUtils.copyList( - RodaCoreFactory.getRodaConfiguration().getList("core.plugins.conversion.profile." + pluginName + ".profiles[]")); - Locale locale = ServerTools.parseLocale(localeString); - - ResourceBundle pluginMessages = RodaCoreFactory.getPluginMessages(pluginId, locale); - - for (String item : dropdownItems) { - ConversionProfile conversionProfile = retrieveConversionProfileItem(item, pluginName, pluginMessages); - if (repOrDip.equals(RodaConstants.PLUGIN_PARAMS_CONVERSION_REPRESENTATION) - && conversionProfile.canBeUsedForRepresentation()) { - items.add(conversionProfile); - } - - if (repOrDip.equals(RodaConstants.PLUGIN_PARAMS_CONVERSION_DISSEMINATION) - && conversionProfile.canBeUsedForDissemination()) { - items.add(conversionProfile); - } - } - - return items; - } - - private ConversionProfile retrieveConversionProfileItem(String item, String pluginName, - ResourceBundle resourceBundle) { - ConversionProfile conversionProfile = new ConversionProfile(); - Map optionsValues = new HashMap<>(); - - String i18nKey = RodaCoreFactory.getRodaConfiguration() - .getString("core.plugins.conversion.profile." + pluginName + ".profiles.i18nPrefix"); - - String title; - String description; - - try { - title = resourceBundle.getString(i18nKey + "." + item + ".title"); - } catch (MissingResourceException e) { - title = i18nKey + "." + item + ".title"; - } - - try { - description = resourceBundle.getString(i18nKey + "." + item + ".description"); - } catch (MissingResourceException e) { - description = i18nKey + "." + item + ".description"; - } - - conversionProfile.setTitle(title); - conversionProfile.setDescription(description); - conversionProfile.setProfile(item); - - conversionProfile.setCanBeUsedForDissemination(RodaCoreFactory.getRodaConfiguration() - .getBoolean("core.plugins.conversion.profile." + pluginName + "." + item + ".canBeUsedForDissemination", false)); - conversionProfile.setCanBeUsedForRepresentation(RodaCoreFactory.getRodaConfiguration() - .getBoolean("core.plugins.conversion.profile." + pluginName + "." + item + ".canBeUsedForRepresentation", false)); - - String[] options = RodaCoreFactory.getRodaConfiguration() - .getStringArray("core.plugins.conversion.profile." + pluginName + "." + item + ".options[]"); - for (String option : options) { - String optionValue = RodaCoreFactory.getRodaConfiguration() - .getString("core.plugins.conversion.profile." + pluginName + "." + item + "." + option); - optionsValues.put(option, optionValue); - } - conversionProfile.setOptions(optionsValues); - - return conversionProfile; - } - @Override public List retrieveSupportedMetadata(String aipId, String representationId, String localeString) throws RODAException { @@ -406,13 +256,6 @@ public Job updateAIPPermissions(SelectedItems aips, Permissions perm return Browser.updateAIPPermissions(user, aips, permissions, details, recursive); } - @Override - public Job updateDIPPermissions(SelectedItems dips, Permissions permissions, String details) - throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException { - User user = UserUtility.getUser(getThreadLocalRequest()); - return Browser.updateDIPPermissions(user, dips, permissions, details); - } - private SelectedItems getAllItemsByClass(String selectedClass) { if (selectedClass == null || Void.class.getName().equals(selectedClass)) { return new SelectedItemsNone<>(); @@ -435,21 +278,6 @@ public Job changeAIPType(SelectedItems selected, String newType, Str return Browser.changeAIPType(user, selected, newType, details); } - @Override - public BrowseDipBundle retrieveDipBundle(String dipUUID, String dipFileUUID, String localeString) - throws RequestNotValidException, AuthorizationDeniedException, GenericException, NotFoundException { - User user = UserUtility.getUser(getThreadLocalRequest()); - Locale locale = ServerTools.parseLocale(localeString); - return Browser.retrieveDipBundle(user, dipUUID, dipFileUUID, locale); - } - - @Override - public Job deleteDIPs(SelectedItems dips, String details) - throws AuthorizationDeniedException, GenericException, NotFoundException, RequestNotValidException { - User user = UserUtility.getUser(getThreadLocalRequest()); - return Browser.deleteDIPs(user, dips, details); - } - @Override public boolean hasDocumentation(String aipId) throws AuthorizationDeniedException, RequestNotValidException, GenericException { @@ -464,18 +292,6 @@ public boolean hasSubmissions(String aipId) return Browser.hasSubmissions(user, aipId); } - @Override - public boolean showDIPEmbedded() { - return RodaCoreFactory.getRodaConfiguration().getBoolean("ui.dip.externalURL.showEmbedded", false); - } - - @Override - public Notification acknowledgeNotification(String notificationId, String ackToken) - throws GenericException, NotFoundException, AuthorizationDeniedException { - User user = UserUtility.getUser(getThreadLocalRequest()); - return Browser.acknowledgeNotification(user, notificationId, ackToken); - } - @Override public int getExportLimit() { return RodaCoreFactory.getRodaConfiguration().getInt("ui.list.export_limit", @@ -491,18 +307,15 @@ public Pair> retrieveAIPTypeOptions(String locale) { if (isControlled) { types = RodaCoreFactory.getRodaConfigurationAsList("core.aip_type.value"); } else { - try { - Facets facets = new Facets(new SimpleFacetParameter(RodaConstants.AIP_TYPE)); - IndexResult result = find(IndexedAIP.class.getName(), Filter.ALL, Sorter.NONE, Sublist.NONE, facets, - locale, false, new ArrayList<>()); - - List facetResults = result.getFacetResults(); - for (FacetValue facetValue : facetResults.get(0).getValues()) { - types.add(facetValue.getValue()); - } - } catch (GenericException | AuthorizationDeniedException | RequestNotValidException e) { - LOGGER.error("Could not execute find request on AIPs", e); + + Facets facets = new Facets(new SimpleFacetParameter(RodaConstants.AIP_TYPE)); + IndexResult result = null; + + List facetResults = result.getFacetResults(); + for (FacetValue facetValue : facetResults.get(0).getValues()) { + types.add(facetValue.getValue()); } + } return Pair.of(isControlled, types); diff --git a/roda-ui/roda-wui/src/main/resources/config/i18n/client/ClientMessages.properties b/roda-ui/roda-wui/src/main/resources/config/i18n/client/ClientMessages.properties index 84ee81e275..4c2bf08a21 100644 --- a/roda-ui/roda-wui/src/main/resources/config/i18n/client/ClientMessages.properties +++ b/roda-ui/roda-wui/src/main/resources/config/i18n/client/ClientMessages.properties @@ -223,10 +223,10 @@ someOfAObject[org.roda.core.data.v2.formats.Format]:formats someOfAObject[org.roda.core.data.v2.ip.metadata.IndexedPreservationEvent]:preservation events someOfAObject[org.roda.core.data.v2.ip.metadata.IndexedPreservationAgent]:preservation agents someOfAObject[org.roda.core.data.v2.Void]:No input objects -someOfAObject[org.roda.core.data.v2.ip.disposal.DisposalSchedules]:disposal schedules -someOfAObject[org.roda.core.data.v2.ip.disposal.DisposalHolds]:disposal holds -someOfAObject[org.roda.core.data.v2.ip.disposal.DisposalConfirmation]:disposal confirmation -someOfAObject[org.roda.core.data.v2.ip.disposal.DisposalRules]:disposal rules +someOfAObject[org.roda.core.data.v2.disposal.schedule.DisposalSchedules]:disposal schedules +someOfAObject[org.roda.core.data.v2.disposal.hold.DisposalHolds]:disposal holds +someOfAObject[org.roda.core.data.v2.disposal.confirmation.DisposalConfirmation]:disposal confirmation +someOfAObject[org.roda.core.data.v2.disposal.rule.DisposalRules]:disposal rules someOfAObject[org.roda.core.data.v2.synchronization.central.DistributedInstances]:distributed instances someOfAObject[org.roda.core.data.v2.accessKey.AccessKeys]:access tokens oneOfAObject:{0} @@ -255,10 +255,10 @@ oneOfAObject[org.roda.core.data.v2.ip.metadata.PreservationMetadata]:preservatio oneOfAObject[org.roda.core.data.v2.formats.Format]:format oneOfAObject[org.roda.core.data.v2.ip.metadata.IndexedPreservationEvent]:preservation event oneOfAObject[org.roda.core.data.v2.ip.metadata.IndexedPreservationAgent]:preservation agent -oneOfAObject[org.roda.core.data.v2.ip.disposal.DisposalSchedule]:disposal schedule -oneOfAObject[org.roda.core.data.v2.ip.disposal.DisposalHold]:disposal hold -oneOfAObject[org.roda.core.data.v2.ip.disposal.DisposalConfirmation]:disposal confirmation -oneOfAObject[org.roda.core.data.v2.ip.disposal.DisposalRule]:disposal rule +oneOfAObject[org.roda.core.data.v2.disposal.schedule.DisposalSchedule]:disposal schedule +oneOfAObject[org.roda.core.data.v2.disposal.hold.DisposalHold]:disposal hold +oneOfAObject[org.roda.core.data.v2.disposal.confirmation.DisposalConfirmation]:disposal confirmation +oneOfAObject[org.roda.core.data.v2.disposal.rule.DisposalRule]:disposal rule selected[\=1]:{0,number} {1} selected selected:{0,number} {1} selected inspectTransferredResource:Inspect transferred resource @@ -1474,8 +1474,8 @@ disposalOnHoldStatusLabel:On hold disposalClearStatusLabel:Not on hold disposalScheduleListAips:Records with this schedule disposalHoldListAips:Records with this hold -deleteConfirmationReportDialogTitle:Confirm intellectual entities destruction -deleteConfirmationReportDialogMessage:Are you sure you want to destroy the intellectual entities? +deleteConfirmationReportDialogTitle:Confirm intellectual entities deletion +deleteConfirmationReportDialogMessage:Are you sure you want to withdraw the intellectual entities from this disposal confirmation? deleteConfirmationReportSuccessTitle:Deleting disposal confirmation deleteConfirmationReportSuccessMessage:Execute action to delete disposal confirmation disposalConfirmationDataPanelTitle:Title diff --git a/roda-ui/roda-wui/src/main/resources/config/theme/EditMultiplePermissionsDescription.html b/roda-ui/roda-wui/src/main/resources/config/theme/EditMultiplePermissionsDescription.html new file mode 100644 index 0000000000..6fd6aa3105 --- /dev/null +++ b/roda-ui/roda-wui/src/main/resources/config/theme/EditMultiplePermissionsDescription.html @@ -0,0 +1,2 @@ +

The number of intellectual entities selected exceed the maximum allowed value to calculate the common permissions. After add + or removing permissions applying those will override the previous assigned permissions.