improved code
This commit is contained in:
parent
6d00320353
commit
6fad1ba8d1
|
@ -64,8 +64,8 @@ public class CKANResource extends CKAN {
|
||||||
/* TODO Remove this code ASAP. It requires a function from Storage HUB */
|
/* TODO Remove this code ASAP. It requires a function from Storage HUB */
|
||||||
private static final String URI_RESOLVER_STORAGE_HUB_HOST_PROD = "data.d4science.org";
|
private static final String URI_RESOLVER_STORAGE_HUB_HOST_PROD = "data.d4science.org";
|
||||||
private static final String URI_RESOLVER_STORAGE_HUB_HOST_PRE = "data-pre.d4science.org";
|
private static final String URI_RESOLVER_STORAGE_HUB_HOST_PRE = "data-pre.d4science.org";
|
||||||
private static final String URI_RESOLVER_STORAGE_HUB_HOST_DEV = "data-d.d4science.org";
|
private static final String URI_RESOLVER_STORAGE_HUB_HOST_DEV = "data.dev.d4science.org";
|
||||||
|
|
||||||
public static final String URI_RESOLVER_STORAGE_HUB_HOST;
|
public static final String URI_RESOLVER_STORAGE_HUB_HOST;
|
||||||
public static final String URI_RESOLVER_STORAGE_HUB_PATH = "/shub/";
|
public static final String URI_RESOLVER_STORAGE_HUB_PATH = "/shub/";
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.gcat.workspace;
|
||||||
|
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||||
|
@ -36,8 +35,8 @@ public class CatalogueStorageHubManagement {
|
||||||
this.storageHubManagement = new StorageHubManagement();
|
this.storageHubManagement = new StorageHubManagement();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getOriginalFileName(HttpURLConnection httpURLConnection) throws ParseException {
|
protected String getOriginalFileName(HttpURLConnection httpURLConnection) throws Exception {
|
||||||
String contentDisposition = httpURLConnection.getHeaderFields().get("content-disposition").get(0);
|
String contentDisposition = httpURLConnection.getHeaderField("Content-Disposition");
|
||||||
contentDisposition = contentDisposition.replaceAll("= ", "=").replaceAll(" =", "=");
|
contentDisposition = contentDisposition.replaceAll("= ", "=").replaceAll(" =", "=");
|
||||||
ContentDisposition formDataContentDisposition = new ContentDisposition(contentDisposition);
|
ContentDisposition formDataContentDisposition = new ContentDisposition(contentDisposition);
|
||||||
return formDataContentDisposition.getFileName();
|
return formDataContentDisposition.getFileName();
|
||||||
|
@ -60,6 +59,9 @@ public class CatalogueStorageHubManagement {
|
||||||
metadata);
|
metadata);
|
||||||
mimeType = storageHubManagement.getMimeType();
|
mimeType = storageHubManagement.getMimeType();
|
||||||
return persistedURL;
|
return persistedURL;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error while trying to persists the resource", e);
|
||||||
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
applicationMode.end();
|
applicationMode.end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.gcat.ContextTest;
|
||||||
import org.gcube.gcat.utils.Constants;
|
import org.gcube.gcat.utils.Constants;
|
||||||
import org.gcube.storagehub.ApplicationMode;
|
import org.gcube.storagehub.ApplicationMode;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -46,9 +47,11 @@ public class CKANResourceTest extends ContextTest {
|
||||||
applicationMode.end();
|
applicationMode.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
@Ignore
|
||||||
|
@Test
|
||||||
public void testCopyStorageResource() throws Exception {
|
public void testCopyStorageResource() throws Exception {
|
||||||
URL url = new URL("https://goo.gl/HcUWni");
|
// ContextTest.setContextByName("/d4science.research-infrastructures.eu/D4Research/AGINFRAplusDev");
|
||||||
|
URL url = new URL("https://data.d4science.net/gS9k");
|
||||||
|
|
||||||
String itemID = UUID.randomUUID().toString();
|
String itemID = UUID.randomUUID().toString();
|
||||||
CKANResource ckanResource = new CKANResource(itemID);
|
CKANResource ckanResource = new CKANResource(itemID);
|
||||||
|
@ -58,6 +61,7 @@ public class CKANResourceTest extends ContextTest {
|
||||||
ckanResource.deleteStorageResource(finalURL, ckanResource.resourceID, ckanResource.mimeType);
|
ckanResource.deleteStorageResource(finalURL, ckanResource.resourceID, ckanResource.mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testCreate() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
Loading…
Reference in New Issue