Added getProjectByID

This commit is contained in:
Francesco Mangiacrapa 2022-08-05 13:11:01 +02:00
parent 12ec651000
commit 8dec1aa19d
2 changed files with 23 additions and 6 deletions

View File

@ -1,6 +1,5 @@
package org.gcube.application.geoportalcommon; package org.gcube.application.geoportalcommon;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -575,10 +574,10 @@ public class ConvertToDataValueObjectModel {
LOG.debug("toJSON called"); LOG.debug("toJSON called");
try { try {
if (theObj instanceof Serializable) { // if (theObj instanceof Serializable) {
return org.gcube.application.geoportal.client.utils.Serialization.write(theObj); 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) { } catch (Exception e) {
LOG.warn("Error on deserializing: ", e); LOG.warn("Error on deserializing: ", e);

View File

@ -91,10 +91,11 @@ public class ProjectsCaller {
* @throws RemoteException the remote exception * @throws RemoteException the remote exception
* @throws FileNotFoundException the file not found exception * @throws FileNotFoundException the file not found exception
* @throws JsonProcessingException the json processing 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, 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( LOG.info(
"registerFileSet called with [profileID={}, projectID={}, theFile={}, parentPath={}, fieldName={}, fieldDefinition={}", "registerFileSet called with [profileID={}, projectID={}, theFile={}, parentPath={}, fieldName={}, fieldDefinition={}",
parentPath, project.getId(), theFile, parentPath, fieldName, fieldDefinition); parentPath, project.getId(), theFile, parentPath, fieldName, fieldDefinition);
@ -128,10 +129,27 @@ public class ProjectsCaller {
listProjects.add(prg); listProjects.add(prg);
} }
LOG.info("returning %d {}", listProjects.size(), Project.class.getName()); LOG.info("returning %d {}", listProjects.size(), Project.class.getName());
return listProjects; 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<Project> client = (Projects<Project>) getClient(profileID);
Project project = client.getById(projectID);
LOG.info("returning project {}", project != null ? project.getId() : null);
return project;
}
/** /**
* Gets the configuration. * Gets the configuration.
* *