From 8dec1aa19dc75c8ccf5fcfd4259cfdeec86a1dad Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 5 Aug 2022 13:11:01 +0200 Subject: [PATCH] Added getProjectByID --- .../ConvertToDataValueObjectModel.java | 7 +++--- .../geoportal/ProjectsCaller.java | 22 +++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java index 8e73365..51dd2f1 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java +++ b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java @@ -1,6 +1,5 @@ package org.gcube.application.geoportalcommon; -import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -575,10 +574,10 @@ public class ConvertToDataValueObjectModel { LOG.debug("toJSON called"); try { - if (theObj instanceof Serializable) { +// if (theObj instanceof Serializable) { return org.gcube.application.geoportal.client.utils.Serialization.write(theObj); - } - throw new Exception("The input object is not serializable"); +// } +// throw new Exception("The input object is not serializable"); } catch (Exception e) { LOG.warn("Error on deserializing: ", e); diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java index 224b662..620d29a 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java @@ -91,10 +91,11 @@ public class ProjectsCaller { * @throws RemoteException the remote exception * @throws FileNotFoundException the file not found exception * @throws JsonProcessingException the json processing exception - * @throws InvalidRequestException + * @throws InvalidRequestException the invalid request exception */ public Project registerFileSet(String profileID, Project project, File theFile, String parentPath, String fieldName, - String fieldDefinition) throws RemoteException, FileNotFoundException, JsonProcessingException, InvalidRequestException { + String fieldDefinition) + throws RemoteException, FileNotFoundException, JsonProcessingException, InvalidRequestException { LOG.info( "registerFileSet called with [profileID={}, projectID={}, theFile={}, parentPath={}, fieldName={}, fieldDefinition={}", parentPath, project.getId(), theFile, parentPath, fieldName, fieldDefinition); @@ -128,10 +129,27 @@ public class ProjectsCaller { listProjects.add(prg); } + LOG.info("returning %d {}", listProjects.size(), Project.class.getName()); return listProjects; } + /** + * Gets the project by ID. + * + * @param profileID the profile ID + * @param projectID the project ID + * @return the project by ID + * @throws Exception the exception + */ + public Project getProjectByID(String profileID, String projectID) throws Exception { + LOG.info("getProjectByID called for profileID: {}, projectID: {}", profileID, projectID); + Projects client = (Projects) getClient(profileID); + Project project = client.getById(projectID); + LOG.info("returning project {}", project != null ? project.getId() : null); + return project; + } + /** * Gets the configuration. *