removed JSONException

This commit is contained in:
Francesco Mangiacrapa 2021-06-14 16:10:05 +02:00
parent 93126c0843
commit 0bf3a57b51
2 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,6 @@
package org.gcube.datacatalogue.utillibrary.server.cms;
import java.io.InvalidObjectException;
import java.net.MalformedURLException;
import java.util.List;
@ -7,7 +8,6 @@ import javax.ws.rs.WebApplicationException;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
import org.json.JSONException;
/**
* The Interface CatalogueContentModeratorSystem.
@ -42,10 +42,10 @@ public interface CatalogueContentModeratorSystem {
* @return the list items for status
* @throws WebApplicationException the web application exception
* @throws MalformedURLException the malformed URL exception
* @throws JSONException the JSON exception
* @throws InvalidObjectException the invalid object exception
*/
public List<CkanDataset> getListItemsForStatus(ItemStatus theStatus, int limit, int offset)
throws WebApplicationException, MalformedURLException, JSONException;
throws WebApplicationException, MalformedURLException, InvalidObjectException;
/**
* Approve item.
@ -70,7 +70,6 @@ public interface CatalogueContentModeratorSystem {
*/
void permanentlyDelete(String itemId);
/**
* Count list items for status.
*

View File

@ -3,6 +3,7 @@ package org.gcube.datacatalogue.utillibrary.server.cms;
import static com.google.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
@ -66,7 +67,7 @@ public class DataCatalogueCMSImpl implements CatalogueContentModeratorSystem {
*/
@Override
public List<CkanDataset> getListItemsForStatus(ItemStatus theStatus, int limit, int offset)
throws WebApplicationException, MalformedURLException, JSONException {
throws WebApplicationException, MalformedURLException, InvalidObjectException {
LOG.info("called getListItemsForStatus with [status: " + theStatus + "], [limit: " + limit + "], [offset: "
+ offset + "]");
List<CkanDataset> listDataset = null;
@ -113,7 +114,7 @@ public class DataCatalogueCMSImpl implements CatalogueContentModeratorSystem {
* @throws JSONException the JSON exception
*/
protected JSONArray getSourceArrayOfItemsForStatus(ItemStatus theStatus, int limit, int offset)
throws WebApplicationException, MalformedURLException, JSONException {
throws WebApplicationException, MalformedURLException, InvalidObjectException {
LOG.info("called getSourceArrayOfItemsForStatus with [status: " + theStatus + "], [limit: " + limit
+ "], [offset: " + offset + "]");
checkNotNull(theStatus);
@ -122,7 +123,12 @@ public class DataCatalogueCMSImpl implements CatalogueContentModeratorSystem {
String datasetNames = new Item().list(limit, offset);
if (datasetNames != null) {
LOG.debug("for status " + theStatus + " found dataset: " + datasetNames);
jsonArray = new JSONArray(datasetNames);
try {
jsonArray = new JSONArray(datasetNames);
} catch (JSONException e) {
LOG.error("error occurred reading " + datasetNames + " as JSONArray",e);
throw new InvalidObjectException(e.getMessage());
}
}
return jsonArray;