moved to json-simple
This commit is contained in:
parent
0bf3a57b51
commit
fb3245141b
|
@ -15,8 +15,9 @@ import org.gcube.datacatalogue.utillibrary.ckan.MarshUnmarshCkanObject.METHOD;
|
|||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||
import org.gcube.gcat.client.Item;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -75,19 +76,19 @@ public class DataCatalogueCMSImpl implements CatalogueContentModeratorSystem {
|
|||
JSONArray jsonArray = getSourceArrayOfItemsForStatus(theStatus, limit, offset);
|
||||
|
||||
if (jsonArray != null) {
|
||||
int size = jsonArray.length();
|
||||
int size = jsonArray.size();
|
||||
listDataset = new ArrayList<CkanDataset>(size);
|
||||
LOG.debug("converting " + size + " dataset...");
|
||||
LOG.info("reading and converting " + size + " dataset...");
|
||||
for (int i = 0; i < size; i++) {
|
||||
String datasetName = null;
|
||||
try {
|
||||
datasetName = jsonArray.getString(i);
|
||||
LOG.trace("reading dataset: " + datasetName);
|
||||
datasetName = (String) jsonArray.get(i);
|
||||
LOG.debug("reading dataset: " + datasetName);
|
||||
String jsonValueDataset = new Item().read(datasetName);
|
||||
CkanDataset toCkanDataset = MarshUnmarshCkanObject.toCkanDataset(jsonValueDataset, METHOD.TO_READ);
|
||||
LOG.trace("converted as dataset: " + toCkanDataset);
|
||||
LOG.debug("converted as dataset: " + toCkanDataset);
|
||||
listDataset.add(toCkanDataset);
|
||||
} catch (JSONException | IOException e) {
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Error on reading/converting the dataset name: " + datasetName, e);
|
||||
}
|
||||
}
|
||||
|
@ -111,21 +112,21 @@ public class DataCatalogueCMSImpl implements CatalogueContentModeratorSystem {
|
|||
* @return the source array of items for status
|
||||
* @throws WebApplicationException the web application exception
|
||||
* @throws MalformedURLException the malformed URL exception
|
||||
* @throws JSONException the JSON exception
|
||||
*/
|
||||
protected JSONArray getSourceArrayOfItemsForStatus(ItemStatus theStatus, int limit, int offset)
|
||||
protected org.json.simple.JSONArray getSourceArrayOfItemsForStatus(ItemStatus theStatus, int limit, int offset)
|
||||
throws WebApplicationException, MalformedURLException, InvalidObjectException {
|
||||
LOG.info("called getSourceArrayOfItemsForStatus with [status: " + theStatus + "], [limit: " + limit
|
||||
+ "], [offset: " + offset + "]");
|
||||
checkNotNull(theStatus);
|
||||
// TODO MUST BE CHANGED FOR THE STATUS
|
||||
JSONArray jsonArray = null;
|
||||
org.json.simple.JSONArray jsonArray = null;
|
||||
String datasetNames = new Item().list(limit, offset);
|
||||
if (datasetNames != null) {
|
||||
LOG.debug("for status " + theStatus + " found dataset: " + datasetNames);
|
||||
JSONParser parser = new JSONParser();
|
||||
try {
|
||||
jsonArray = new JSONArray(datasetNames);
|
||||
} catch (JSONException e) {
|
||||
jsonArray = (JSONArray) parser.parse(datasetNames);
|
||||
} catch (ParseException e) {
|
||||
LOG.error("error occurred reading " + datasetNames + " as JSONArray",e);
|
||||
throw new InvalidObjectException(e.getMessage());
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class TestDataCatalogueCMS {
|
|||
private DataCatalogueFactory factory;
|
||||
private String scope = "/gcube/devsec/devVRE";
|
||||
private String testUser = "francesco.mangiacrapa";
|
||||
private String authorizationToken = "8e74a17c-92f1-405a-b591-3a6090066248-98187548";
|
||||
private String authorizationToken = "";
|
||||
|
||||
/**
|
||||
* Before.
|
||||
|
@ -57,7 +57,7 @@ public class TestDataCatalogueCMS {
|
|||
* @return the scope per url
|
||||
* @throws Exception
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void getListItemsForStatus() throws Exception {
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue