updated POM and README

This commit is contained in:
Francesco Mangiacrapa 2023-05-02 11:34:53 +02:00
parent 9d8c3dbc0a
commit 5dede1e405
6 changed files with 500 additions and 74 deletions

View File

@ -80,6 +80,8 @@
@ -183,6 +185,8 @@
@ -286,6 +290,8 @@
@ -389,6 +395,8 @@
@ -444,6 +452,8 @@
@ -466,12 +476,20 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="geoportal-data-viewer-widget-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-viewer-widget/geoportal-data-viewer-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="geoportal-data-mapper-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-mapper/geoportal-data-mapper">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="metadata-profile-form-builder-widget-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/metadata-profile-form-builder-widget/metadata-profile-form-builder-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="geoportal-data-common-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -656,6 +674,8 @@
@ -759,6 +779,8 @@
@ -862,6 +884,8 @@

View File

@ -14,6 +14,10 @@ The GeoPortal Data Entry App is an application to build the web forms for data e
* pretty-print-json v.1.1. [pretty-print-json](https://github.com/center-key/pretty-print-json) is licensed under [MIT](https://github.com/center-key/pretty-print-json/blob/main/LICENSE.txt)
* jsoneditor v.9.5.5. [jsoneditor](https://github.com/josdejong/jsoneditor) is licensed under [Apache License 2.0](https://github.com/josdejong/jsoneditor/blob/master/LICENSE)
## Architecture
<img src="https://gcube.wiki.gcube-system.org/gcube/File:GeoPortalDataEntry_Architecture.png" style="max-width:800px;" alt="GeoPortal Data-Entry - Architecture" />
## Documentation
N/A

15
pom.xml
View File

@ -128,12 +128,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>openlayer-basic-widgets</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<!-- FWS -->
<dependency>
<groupId>org.gcube.common</groupId>
@ -230,6 +224,8 @@
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- TESTS -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -242,6 +238,13 @@
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@ -89,6 +89,7 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.DocumentContext;
@ -331,8 +332,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
String filesetFieldName = filePath.getFieldName();
String filesetPath = sectionPath + "." + filesetFieldName;
// Replacing $.abc with $..abc
filesetPath = filesetPath.replaceFirst("\\.", "..");
// // Replacing $.abc with $..abc
// filesetPath = filesetPath.replaceFirst("\\.", "..");
LOG.info("Going to delete fileset path: {}", filesetPath);
try {
client.deleteFileset(profileID, projectID, filesetPath, true, true);
@ -575,7 +576,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
FileUploadedRemote remote = (FileUploadedRemote) file;
LOG.info("Uploaded file is remote: " + remote.getUrl());
InputStream in = new URL(remote.getUrl()).openStream();
output = new File(tmpDirPath, remote.getFileName());
String fileName = (remote.getFileName()==null || remote.getFileName().isEmpty())?"file_"+Random.nextInt():remote.getFileName();
output = new File(tmpDirPath, fileName);
Path outputAbsolutePath = Paths.get(output.getAbsolutePath());
Files.copy(in, outputAbsolutePath, StandardCopyOption.REPLACE_EXISTING);
LOG.info("Remote file: " + remote.getUrl() + ", copied to new file: " + output.getName());

View File

@ -0,0 +1,228 @@
package org.gcube.application;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.Properties;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.document.access.Access;
import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataentry.server.MongoServiceUtil;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadedRemote;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.client.Random;
public class Service_Tests {
private static final String GCUBE_CONFIG_PROPERTIES_FILENAME = "gcube_config.properties";
// APP Working Directory + /src/test/resources must be the location of
// gcube_config.properties
private static String gcube_config_path = String.format("%s/%s",
System.getProperty("user.dir") + "/src/test/resources", GCUBE_CONFIG_PROPERTIES_FILENAME);
private static String CONTEXT;
private static String TOKEN;
private UseCaseDescriptorCaller clientUCD = null;
private ProjectsCaller clientPrj = null;
private static String PROFILE_ID = "profiledConcessioni";
private static String PROJECT_ID = "644a66e944aad51c80409a3b";
private static String MY_LOGIN = "francesco.mangiacrapa";
public static final String JSON_$_POINTER = "$";
private static final Logger LOG = LoggerFactory.getLogger(Service_Tests.class);
/**
* Read context settings.
*/
public static void readContextSettings() {
try (InputStream input = new FileInputStream(gcube_config_path)) {
Properties prop = new Properties();
// load a properties file
prop.load(input);
CONTEXT = prop.getProperty("CONTEXT");
TOKEN = prop.getProperty("TOKEN");
// get the property value and print it out
System.out.println("CONTEXT: " + CONTEXT);
System.out.println("TOKEN: " + TOKEN);
} catch (IOException ex) {
ex.printStackTrace();
}
}
//@Before
public void init() {
readContextSettings();
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
clientPrj = GeoportalClientCaller.projects();
clientUCD = GeoportalClientCaller.useCaseDescriptors();
}
//@Test
public void deleteFileSet_ServiceTest() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
boolean ignore_errors = false;
String path = "$.abstractRelazione.filesetIta";
Project doc = clientPrj.getProjectByID(PROFILE_ID, PROJECT_ID);
JSONPathWrapper wrapper = new JSONPathWrapper(doc.getTheDocument().toJson());
List<String> matchingPaths = wrapper.getMatchingPaths(path);
LOG.info("matchingPaths is: " + matchingPaths);
String error = null;
if (matchingPaths.isEmpty()) {
error = "No Registered FileSet found at " + path;
if (!ignore_errors) {
throw new WebApplicationException(error, Response.Status.BAD_REQUEST);
}
}
if (matchingPaths.size() > 1 && !ignore_errors) {
error = "Multiple Fileset (" + matchingPaths.size() + ") matching " + path;
if (!ignore_errors)
throw new WebApplicationException(error, Response.Status.BAD_REQUEST);
}
if (error != null && ignore_errors) {
LOG.info("Error detected {}. Ignoring it and returning input doc", error);
}
List<Object> listPath = wrapper.getByPath(path);
LOG.info("List path: " + listPath);
// RegisteredFileSet fs = Serialization.convert(listPath.get(0), RegisteredFileSet.class);
// LOG.info("Going to delete {}", fs);
}
// @Test
public void registerFileSet() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
Project theProject = clientPrj.getProjectByID(PROFILE_ID, PROJECT_ID);
MongoServiceUtil mongoService = new MongoServiceUtil();
Access access = new Access();
access.setLicense("CC-BY");
access.setPolicy(AccessPolicy.OPEN);
String sectionJSONPath = "$.abstractRelazione";
String fieldName = "filesetIta";
String fieldDefinition = "$.abstractRelazione._children[?(@.filesetIta)]";
String theFileName = "Application_Profile_for_CSW_2.0-2.pdf";
String theFileURL = "https://data.dev.d4science.org/shub/E_bnN2aDJZZUMySy9peE9ScEVLNVFNWjBOZWx0cXQ2UUFkQ2E3Rjc1S29EelJIMEJGbDRoczBnbHVPWHczZTNQTw==";
FileUploadedRemote file = new FileUploadedRemote();
file.setUrl(theFileURL);
file.setFileName(theFileName);
File input = null;
File output = null;
try {
File tempDir = Files.createTempDirectory("GEOPORTAL_REPLACE_FILES_").toFile();
String tmpDirPath = tempDir.getAbsolutePath();
if (file instanceof FileUploadedRemote) {
FileUploadedRemote remote = (FileUploadedRemote) file;
LOG.info("Uploaded file is remote: " + remote.getUrl());
InputStream in = new URL(remote.getUrl()).openStream();
String fileName = (remote.getFileName() == null || remote.getFileName().isEmpty())
? "file_" + Random.nextInt()
: remote.getFileName();
LOG.info("the fileName is: " + fileName);
output = new File(tmpDirPath, fileName);
Path outputAbsolutePath = Paths.get(output.getAbsolutePath());
Files.copy(in, outputAbsolutePath, StandardCopyOption.REPLACE_EXISTING);
LOG.info("Remote file: " + remote.getUrl() + ", copied to new file: " + output.getName());
} else {
LOG.info("Uploaded file is local: " + file.getTempSystemPath());
input = new File(file.getTempSystemPath());
output = new File(tmpDirPath, file.getFileName());
copyContent(input, output);
LOG.info("Temp file: " + file.getTempSystemPath() + ", copied to new file: " + output.getName());
}
tempDir.deleteOnExit();
} catch (Exception e) {
LOG.warn("Skipping file: " + file.getFileName() + ". Error: " + e.getMessage(), e);
}
File fileset = output;
LOG.info("the fileName is: " + fileset.getName());
//mongoService.registerFileSet(theProject.getProfileID(), theProject, sectionJSONPath, fieldName, fieldDefinition, access, fileset);
}
/**
* Copy content.
*
* @param a the a
* @param b the b
* @throws Exception the exception
*/
public static void copyContent(File a, File b) throws Exception {
FileInputStream in = new FileInputStream(a);
FileOutputStream out = new FileOutputStream(b);
try {
int n;
// read() function to read the
// byte of data
while ((n = in.read()) != -1) {
// write() function to write
// the byte of data
out.write(n);
}
} finally {
if (in != null) {
// close() function to close the
// stream
in.close();
}
// close() function to close
// the stream
if (out != null) {
out.close();
}
}
LOG.debug("File Copied");
}
}

View File

@ -1,19 +1,34 @@
package org.gcube.portlets.user.geoportaldataentry;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Properties;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import org.bson.Document;
import org.gcube.application.geoportal.client.utils.Serialization;
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.document.access.Access;
import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportalcommon.ConvertToDataServiceModel;
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
@ -35,13 +50,16 @@ import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataentry.server.FileSetDataObject;
import org.gcube.portlets.user.geoportaldataentry.server.FormDataObjectToJSON;
import org.gcube.portlets.user.geoportaldataentry.server.FormDataObjectToJSON.JSONObjectOrdered;
import org.gcube.portlets.user.geoportaldataentry.server.MongoServiceUtil;
import org.gcube.portlets.user.geoportaldataentry.server.json.JsonMerge;
import org.gcube.portlets.user.geoportaldataentry.server.json.JsonMerge.MERGE_OPTION;
import org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadedRemote;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
@ -53,6 +71,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gwt.user.client.Random;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
@ -73,7 +92,7 @@ public class Complex_Tests {
private ProjectsCaller clientPrj = null;
private static String PROFILE_ID = "profiledConcessioni";
private static String PROJECT_ID = "632c633155e2947b0278c999";
private static String PROJECT_ID = "644a66e944aad51c80409a3b";
private static String MY_LOGIN = "francesco.mangiacrapa";
@ -164,7 +183,8 @@ public class Complex_Tests {
sectionPath = FormDataObjectToJSON.JSON_$_POINTER;
LOG.info("theString: {}", jsonSourceProject);
com.google.gson.JsonObject currentSectionJObject = JsonPath.parse(jsonSourceProject, configurationGSON).read(sectionPath);
com.google.gson.JsonObject currentSectionJObject = JsonPath.parse(jsonSourceProject, configurationGSON)
.read(sectionPath);
LOG.info("currentSectionJObject: {}", currentSectionJObject.toString());
LOG.info("sourceSectionObject: {}", currentSectionJObject.toString());
@ -173,7 +193,8 @@ public class Complex_Tests {
targetSectionJObject.put("titolo", "Prova REJECT abstract relazione di scavo 1");
LOG.info("targetSectionJObject: {}", targetSectionJObject.toString());
String mergedDoc = JsonMerge.merge(targetSectionJObject.toString(), currentSectionJObject.toString(), MERGE_OPTION.REPLACE);
String mergedDoc = JsonMerge.merge(targetSectionJObject.toString(), currentSectionJObject.toString(),
MERGE_OPTION.REPLACE);
LOG.info("output: {}", mergedDoc);
String newDocJson;
@ -186,7 +207,8 @@ public class Complex_Tests {
Gson gson = new Gson();
JsonObject gsonOject = gson.fromJson(mergedDoc, JsonObject.class);
// Putting the merged section into Document
DocumentContext newContextDocJson = JsonPath.parse(jsonSourceProject, configurationGSON).set(sectionPath, gsonOject);
DocumentContext newContextDocJson = JsonPath.parse(jsonSourceProject, configurationGSON).set(sectionPath,
gsonOject);
newDocJson = newContextDocJson.json().toString();
}
@ -216,7 +238,8 @@ public class Complex_Tests {
sectionPath = FormDataObjectToJSON.JSON_$_POINTER;
LOG.info("theString: {}", jsonSourceProject);
com.google.gson.JsonObject currentSectionJObject = JsonPath.parse(jsonSourceProject, configurationGSON).read(sectionPath);
com.google.gson.JsonObject currentSectionJObject = JsonPath.parse(jsonSourceProject, configurationGSON)
.read(sectionPath);
LOG.info("currentSectionJObject: {}", currentSectionJObject.toString());
LOG.info("sourceSectionObject: {}", currentSectionJObject.toString());
@ -228,16 +251,20 @@ public class Complex_Tests {
// JSONObject mergedSection = FormDataObjectToJSON.deepMerge(sourceSectionObject,
// targetSectionJObject);
String output = JsonMerge.merge(targetSectionJObject.toString(), currentSectionJObject.toString(), MERGE_OPTION.REPLACE);
String output = JsonMerge.merge(targetSectionJObject.toString(), currentSectionJObject.toString(),
MERGE_OPTION.REPLACE);
LOG.info("output: {}", output);
Gson gson = new Gson();
JsonObject gsonOject = gson.fromJson(output, JsonObject.class);
// Putting the merged section into Document
DocumentContext newContextDocJson = JsonPath.parse(jsonSourceProject, configurationGSON).set(sectionPath, gsonOject);
//DocumentContext newDocument = JsonPath.parse(jsonSourceProject, configurationGSON).set(sectionPath, new JSONObject(output));
//String newDocJson = JsonPath.parse(jsonSourceProject).set(sectionPath, new JSONObject(output)).jsonString();
DocumentContext newContextDocJson = JsonPath.parse(jsonSourceProject, configurationGSON).set(sectionPath,
gsonOject);
// DocumentContext newDocument = JsonPath.parse(jsonSourceProject,
// configurationGSON).set(sectionPath, new JSONObject(output));
// String newDocJson = JsonPath.parse(jsonSourceProject).set(sectionPath, new
// JSONObject(output)).jsonString();
String newDocJson = newContextDocJson.json().toString();
LOG.info("Going to call updateProject with document: {}", newDocJson);
@ -246,7 +273,6 @@ public class Complex_Tests {
}
// @Before
public void preloadgCubeProfilesForUCDs() {
LOG.debug("preloadgCubeProfilesForUCDs called");
@ -308,6 +334,145 @@ public class Complex_Tests {
}
}
//@Test
public void deleteFileSet_ServiceTest() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
boolean ignore_errors = false;
String path = "$.abstractRelazione.filesetIta";
Project doc = clientPrj.getProjectByID(PROFILE_ID, PROJECT_ID);
JSONPathWrapper wrapper = new JSONPathWrapper(doc.getTheDocument().toJson());
List<String> matchingPaths = wrapper.getMatchingPaths(path);
LOG.info("matchingPaths is: " + matchingPaths);
String error = null;
if (matchingPaths.isEmpty()) {
error = "No Registered FileSet found at " + path;
if (!ignore_errors) {
throw new WebApplicationException(error, Response.Status.BAD_REQUEST);
}
}
if (matchingPaths.size() > 1 && !ignore_errors) {
error = "Multiple Fileset (" + matchingPaths.size() + ") matching " + path;
if (!ignore_errors)
throw new WebApplicationException(error, Response.Status.BAD_REQUEST);
}
if (error != null && ignore_errors) {
LOG.info("Error detected {}. Ignoring it and returning input doc", error);
}
List<Object> listPath = wrapper.getByPath(path);
LOG.info("List path: "+listPath);
// RegisteredFileSet fs = Serialization.convert(listPath.get(0), RegisteredFileSet.class);
// LOG.info("Going to delete {}", fs);
}
//@Test
public void registerFileSet() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
Project theProject = clientPrj.getProjectByID(PROFILE_ID, PROJECT_ID);
MongoServiceUtil mongoService = new MongoServiceUtil();
Access access = new Access();
access.setLicense("CC-BY");
access.setPolicy(AccessPolicy.OPEN);
String sectionJSONPath = "$.abstractRelazione";
String fieldName = "filesetIta";
String fieldDefinition = "$.abstractRelazione._children[?(@.filesetIta)]";
String theFileName = "Application_Profile_for_CSW_2.0-2.pdf";
String theFileURL = "https://data.dev.d4science.org/shub/E_bnN2aDJZZUMySy9peE9ScEVLNVFNWjBOZWx0cXQ2UUFkQ2E3Rjc1S29EelJIMEJGbDRoczBnbHVPWHczZTNQTw==";
FileUploadedRemote file = new FileUploadedRemote();
file.setUrl(theFileURL);
file.setFileName(theFileName);
File input = null;
File output = null;
try {
File tempDir = Files.createTempDirectory("GEOPORTAL_REPLACE_FILES_").toFile();
String tmpDirPath = tempDir.getAbsolutePath();
if (file instanceof FileUploadedRemote) {
FileUploadedRemote remote = (FileUploadedRemote) file;
LOG.info("Uploaded file is remote: " + remote.getUrl());
InputStream in = new URL(remote.getUrl()).openStream();
String fileName = (remote.getFileName() == null || remote.getFileName().isEmpty())
? "file_" + Random.nextInt()
: remote.getFileName();
LOG.info("the fileName is: " + fileName);
output = new File(tmpDirPath, fileName);
Path outputAbsolutePath = Paths.get(output.getAbsolutePath());
Files.copy(in, outputAbsolutePath, StandardCopyOption.REPLACE_EXISTING);
LOG.info("Remote file: " + remote.getUrl() + ", copied to new file: " + output.getName());
} else {
LOG.info("Uploaded file is local: " + file.getTempSystemPath());
input = new File(file.getTempSystemPath());
output = new File(tmpDirPath, file.getFileName());
copyContent(input, output);
LOG.info("Temp file: " + file.getTempSystemPath() + ", copied to new file: " + output.getName());
}
// tempDir.deleteOnExit();
} catch (Exception e) {
LOG.warn("Skipping file: " + file.getFileName() + ". Error: " + e.getMessage(), e);
}
File fileset = output;
LOG.info("the fileName is: " + fileset.getName());
mongoService.registerFileSet(theProject.getProfileID(), theProject, sectionJSONPath, fieldName, fieldDefinition,
access, fileset);
}
/**
* Copy content.
*
* @param a the a
* @param b the b
* @throws Exception the exception
*/
public static void copyContent(File a, File b) throws Exception {
FileInputStream in = new FileInputStream(a);
FileOutputStream out = new FileOutputStream(b);
try {
int n;
// read() function to read the
// byte of data
while ((n = in.read()) != -1) {
// write() function to write
// the byte of data
out.write(n);
}
} finally {
if (in != null) {
// close() function to close the
// stream
in.close();
}
// close() function to close
// the stream
if (out != null) {
out.close();
}
}
LOG.debug("File Copied");
}
// @Test
public void testReadProjectForUCDDataEntry() {
ScopeProvider.instance.set(CONTEXT);