diff --git a/distro/changelog.xml b/distro/changelog.xml index 76230de..b449c08 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,8 @@ + + [Feature #12255] Pop-up Text improvement for the locked records + [Task #11124] Testing the GRSF management panel diff --git a/pom.xml b/pom.xml index 7b6b040..9f3f5db 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.portlets.widgets grsf-manage-widget - 1.3.2-SNAPSHOT + 1.3.3-SNAPSHOT gCube GRSF Manage widget diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java index 72652b8..0523200 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java @@ -57,13 +57,13 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS * Since it needs the scope, we need to check if it is null or not * @param discoverScope if you want to the discover the utils library in this specified scope * @return DataCatalogue object - * @throws Exception + * @throws Exception */ public DataCatalogue getCatalogue(String discoverScope) throws Exception{ String currentScope = Utils.getCurrentContext(getThreadLocalRequest(), true); DataCatalogue instance = null; try{ - String scopeInWhichDiscover = (discoverScope != null && !discoverScope.isEmpty()) ? discoverScope : currentScope; + String scopeInWhichDiscover = discoverScope != null && !discoverScope.isEmpty() ? discoverScope : currentScope; logger.debug("Discovering ckan utils library into scope " + scopeInWhichDiscover); instance = DataCatalogueFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover); }catch(Exception e){ @@ -98,7 +98,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS "http://data.d4science.org/ctlg/GRSF_Admin/uuid-of-a-connected-bean", "semantic identifier of the record", "Fishery" - )); + )); toReturn.setCurrentConnections(connectTo); // these are the "suggested connections" @@ -129,55 +129,55 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS toReturn.setSources(sources); List similarGrsfRecords = new ArrayList(); similarGrsfRecords.add(new SimilarGRSFRecord( - "uuid-similar-record-1", + "uuid-similar-record-1", "description similar record", "short name similar record 1", - "title similar record 1", + "title similar record 1", "http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-1", "semantic identifier record 1", "Stock 1" )); similarGrsfRecords.add(new SimilarGRSFRecord( - "uuid-similar-record-2", + "uuid-similar-record-2", "description similar record", "short name similar record 2", - "title similar record 2", + "title similar record 2", "http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-2", "semantic identifier record 2", "Stock 2" )); similarGrsfRecords.add(new SimilarGRSFRecord( - "uuid-similar-record-3", + "uuid-similar-record-3", "description similar record", "short name similar record 3", - "title similar record 3", + "title similar record 3", "http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-3", "semantic identifier record 3", "Stock 3" )); similarGrsfRecords.add(new SimilarGRSFRecord( - "uuid-similar-record-4", + "uuid-similar-record-4", "description similar record", "short name similar record 4", - "title similar record 4", + "title similar record 4", "http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-4", "semantic identifier record 4", "Stock 4" )); similarGrsfRecords.add(new SimilarGRSFRecord( - "uuid-similar-record-5", + "uuid-similar-record-5", "description similar record", "short name similar record 5", - "title similar record 5", + "title similar record 5", "http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-5", "semantic identifier record 5", "Stock 5" )); similarGrsfRecords.add(new SimilarGRSFRecord( - "uuid-similar-record-6", + "uuid-similar-record-6", "description similar record", "short name similar record 6", - "title similar record 6", + "title similar record 6", "http://data.d4science.org/ctlg/GRSF_Admin/uuid-similar-record-6", "semantic identifier record 6", "Stock 6" @@ -204,13 +204,13 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS String systemType = extrasAsMap.get(Constants.SYSTEM_TYPE_CUSTOM_KEY); if(systemType == null || systemType.isEmpty() || systemType.equals(Constants.SYSTEM_TYPE_FOR_SOURCES_VALUE)) - throw new NoGRSFRecordException("This is not a GRSF Record"); + throw new NoGRSFRecordException("This is not a GRSF Record"); boolean isStock = record.getExtrasAsHashMap().get(Constants.DOMAIN_CUSTOM_KEY).contains(Product_Type.STOCK.getOrigName()); // fetch map for namespaces - Map fieldsNamespacesMap = - Utils.getFieldToFieldNameSpaceMapping(httpSession, isStock ? + Map fieldsNamespacesMap = + Utils.getFieldToFieldNameSpaceMapping(httpSession, isStock ? Constants.GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_STOCK : Constants.GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_FISHERY); // get extras as pairs @@ -219,10 +219,10 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS String catalogueIdentifier = record.getId(); String description = record.getNotes(); Status status = Status.fromString(extrasWithoutNamespaces.get(Constants.STATUS_OF_THE_GRSF_RECORD_CUSTOM_KEY).get(0)); - + if(status.equals(Status.To_be_Merged) && !requestForRevertingMerge) - throw new Exception("Records under merging activities cannot be managed without explicit authorisation!"); - + throw new Exception("The record is locked due to a merge request in progress!"); + String uuidKB = extrasWithoutNamespaces.get(Constants.UUID_KB_CUSTOM_KEY).get(0); String grsfDomain = extrasWithoutNamespaces.get(Constants.DOMAIN_CUSTOM_KEY).get(0); String semanticId = extrasWithoutNamespaces.get(Constants.GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY).get(0); @@ -259,7 +259,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS logger.debug("SimilarGRSFRecords are " + similarRecords); // get connected records (and the proposed ones) - List connectedBeanUrls = + List connectedBeanUrls = extrasWithoutNamespaces.containsKey(Constants.CONNECTED_CUSTOM_KEY) ? extrasWithoutNamespaces.get(Constants.CONNECTED_CUSTOM_KEY): null; List connectedBeans = new ArrayList(0); @@ -277,11 +277,11 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS // get the connections the knowledge base suggests List suggestedConnectionsByKnowledgeBase = new ArrayList(0); - List exploitedResourcesUrls = isStock ? - (extrasWithoutNamespaces.containsKey(Constants.EXPLOITING_FISHERY_CUSTOM_KEY) ? - extrasWithoutNamespaces.get(Constants.EXPLOITING_FISHERY_CUSTOM_KEY) : null): - (extrasWithoutNamespaces.containsKey(Constants.RESOURCES_EXPLOITED_CUSTOM_KEY) ? - extrasWithoutNamespaces.get(Constants.RESOURCES_EXPLOITED_CUSTOM_KEY) : null); + List exploitedResourcesUrls = isStock ? + extrasWithoutNamespaces.containsKey(Constants.EXPLOITING_FISHERY_CUSTOM_KEY) ? + extrasWithoutNamespaces.get(Constants.EXPLOITING_FISHERY_CUSTOM_KEY) : null: + extrasWithoutNamespaces.containsKey(Constants.RESOURCES_EXPLOITED_CUSTOM_KEY) ? + extrasWithoutNamespaces.get(Constants.RESOURCES_EXPLOITED_CUSTOM_KEY) : null; if(exploitedResourcesUrls != null && !exploitedResourcesUrls.isEmpty()){ for (String exploited : exploitedResourcesUrls) { @@ -303,9 +303,9 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS // set the values toReturn = new ManageProductBean( - semanticId, catalogueIdentifier, uuidKB, grsfType, + semanticId, catalogueIdentifier, uuidKB, grsfType, grsfDomain, shortName, description, grsfName,traceabilityFlag, sdgFlag, - status, recordUrl, sources, similarRecords, + status, recordUrl, sources, similarRecords, connectedBeans, suggestedConnectionsByKnowledgeBase); } @@ -373,7 +373,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS String sessionProductKey = ScopeProvider.instance.get() + bean.getCatalogueIdentifier(); threadRequest.getSession().removeAttribute(sessionProductKey); - Utils.updateRecord(baseUrl, bean, catalogue, username, administratorFullName, threadRequest, + Utils.updateRecord(baseUrl, bean, catalogue, username, administratorFullName, threadRequest, PortalContext.getConfiguration().getCurrentGroupId(threadRequest), context, token); }catch(Exception e){ @@ -400,7 +400,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS String uuid = UUID.randomUUID().toString(); String adminInUrl = "costantino.perciante"; String adminInUrlFullName = "Costantino Perciante"; - long timestamp = System.currentTimeMillis() - 1000 * ((long)(Math.random() * 10 * 60 * 60)); + long timestamp = System.currentTimeMillis() - 1000 * (long)(Math.random() * 10 * 60 * 60); return new RevertableOperationInfo( baseUrl, fullName, usernameCurrent, uuid, adminInUrlFullName, adminInUrl, timestamp, RevertableOperations.MERGE); } @@ -440,21 +440,21 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS Map extras = dataset.getExtrasAsHashMap(); String recordUrl = extras.get(Constants.ITEM_URL_FIELD); String currentStatus = extras.get(Constants.STATUS_OF_THE_GRSF_RECORD_CUSTOM_KEY); - + // check current record status if(!currentStatus.equals(Status.To_be_Merged.getOrigName())) throw new Exception("Record '" + dataset.getTitle() + "' (" + recordUrl + ") is no longer involved in a merge operation!"); // check if it is a reviewer, than he can do what he wants (no matter the admin) if(isReviewer){ - return new RevertableOperationInfo(recordUrl, + return new RevertableOperationInfo(recordUrl, fullName, username, uuid, fullNameadminInUrl, userNameadminInUrl, decryptedUrl.getTimestamp(), decryptedUrl.getOperation()); }else{ if(!username.equals(userNameadminInUrl)) throw new Exception("You are not the editor allowed to perform this operation!"); else - return new RevertableOperationInfo(recordUrl, + return new RevertableOperationInfo(recordUrl, fullName, username, uuid, fullNameadminInUrl, userNameadminInUrl, decryptedUrl.getTimestamp(), decryptedUrl.getOperation()); } @@ -494,7 +494,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS if(baseUrl == null || baseUrl.isEmpty()) throw new Exception("Unable to discover grsf-updater service!"); - Utils.revertOperation(httpClient, baseUrl, threadRequest, rInfo, token, context, + Utils.revertOperation(httpClient, baseUrl, threadRequest, rInfo, token, context, PortalContext.getConfiguration().getCurrentGroupId(threadRequest)); } @@ -578,18 +578,18 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS if(dataset == null) throw new Exception("A record with id " + id + " doesn't exist"); - + Map extras = dataset.getExtrasAsHashMap(); String systemType = extras.get(Constants.SYSTEM_TYPE_CUSTOM_KEY); String domain = extras.get(Constants.DOMAIN_CUSTOM_KEY); String url = extras.get(Constants.ITEM_URL_FIELD); - + if(systemType.equals(Constants.SYSTEM_TYPE_FOR_SOURCES_VALUE)) throw new Exception("This record is not a GRSF record!"); - + if(!acceptedDomain.equalsIgnoreCase(domain)) throw new Exception("You are suggesting a " + domain + " record instead of a " + acceptedDomain + " record!"); - + return url; }