64 lines
2.1 KiB
Java
64 lines
2.1 KiB
Java
package org.gcube.application.geoportal.clients;
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import org.bson.Document;
|
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
|
import org.gcube.application.geoportal.client.utils.Serialization;
|
|
import org.gcube.application.geoportal.common.model.document.Project;
|
|
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
|
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
|
import org.gcube.application.geoportal.common.rest.Projects;
|
|
import org.gcube.application.geoportal.common.utils.FileSets;
|
|
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
|
|
|
import javax.jws.soap.SOAPBinding;
|
|
import java.io.File;
|
|
import java.io.FileNotFoundException;
|
|
import java.rmi.RemoteException;
|
|
|
|
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
|
|
|
|
public abstract class GenericUseCases extends BasicVreTests{
|
|
|
|
protected String getUCID(){ return "basic";}
|
|
|
|
protected Projects<Project> getClient(String profileID){
|
|
return projects(profileID).build();
|
|
}
|
|
|
|
|
|
|
|
protected Projects<Project> getClient(){
|
|
return getClient(getUCID());
|
|
}
|
|
|
|
public void createNew () throws RemoteException, FileNotFoundException, JsonProcessingException {
|
|
String profileID=getUCID();
|
|
|
|
String myJSON=null;
|
|
Document myDocument = Document.parse(myJSON);
|
|
|
|
Projects<Project> client = getClient(profileID);
|
|
|
|
// Create project
|
|
Project project = client.createNew(myDocument);
|
|
|
|
|
|
String parentPath = "";
|
|
String fieldName = "";
|
|
String fieldDefinition = "";
|
|
|
|
// Prepare request
|
|
RegisterFileSetRequest fsRequest = FileSets.
|
|
prepareRequest(new StorageUtils(),
|
|
parentPath,fieldName,fieldDefinition, new File(TestConcessioniModel.getBaseFolder(),"pos.shp"));
|
|
|
|
|
|
project = client.registerFileSet(project.getId(),fsRequest);
|
|
|
|
System.out.println("Resulting Project : "+project);
|
|
System.out.println("JSON Reprepsentation : "+ Serialization.write(project));
|
|
}
|
|
|
|
}
|