Minor fixes (added suppress warning on some methods)
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@139813 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a6cde11d39
commit
aec8452e7b
|
@ -85,7 +85,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
private String CKAN_TOKEN_SYS;
|
||||
private String URI_RESOLVER_URL;
|
||||
private boolean MANAGE_PRODUCT_BUTTON;
|
||||
private String validForContext;
|
||||
private String CONTEXT;
|
||||
|
||||
// ckan client
|
||||
private CkanClient client;
|
||||
|
@ -137,7 +137,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
apiKeysMap = new ConcurrentHashMap<String, CKANTokenBean>();
|
||||
|
||||
// save the context
|
||||
validForContext = scope;
|
||||
CONTEXT = scope;
|
||||
|
||||
}
|
||||
|
||||
|
@ -924,7 +924,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
if(dataset != null){
|
||||
|
||||
if(getUriResolverUrl() != null)
|
||||
url = getUrlForProduct(validForContext, EntityContext.DATASET, name);
|
||||
url = getUrlForProduct(CONTEXT, EntityContext.DATASET, name);
|
||||
|
||||
if(url == null || url.isEmpty())
|
||||
url = getPortletUrl() + "?" + URLEncoder.encode("path=/dataset/" + name, "UTF-8");
|
||||
|
@ -943,6 +943,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
* @param entityName
|
||||
* @return the url for the product
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private String getUrlForProduct(String context, EntityContext entityContext, String entityName){
|
||||
|
||||
String toReturn = null;
|
||||
|
@ -1416,19 +1417,8 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
String groupNameToCheck = UtilMethods.fromGroupTitleToName(groupNameOrId);
|
||||
|
||||
try(CloseableHttpClient httpClient = HttpClientBuilder.create().build();){
|
||||
|
||||
// TODO unfortunately it doesn't work properly.. We use the APIs
|
||||
// // the association is performed by using the sysadmi api key, since from apis only group admin can perform this operation...
|
||||
|
||||
CheckedCkanClient client = new CheckedCkanClient(CKAN_CATALOGUE_URL, CKAN_TOKEN_SYS);
|
||||
//
|
||||
// // retrieve the dataset
|
||||
// CkanDataset dataset = client.getDataset(datasetNameOrId);
|
||||
// List<CkanGroup> datasetGroups = dataset.getGroups();
|
||||
// CkanGroup destinationGroup = client.getGroup(groupNameToCheck);
|
||||
// datasetGroups.add(destinationGroup);
|
||||
//
|
||||
// // patch the dataset
|
||||
// client.patchUpdateDataset(dataset);
|
||||
|
||||
// check the group exists
|
||||
CkanGroup group = client.getGroup(groupNameToCheck);
|
||||
|
@ -1446,20 +1436,9 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
|
||||
|
||||
// parse the json and convert to java beans
|
||||
BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader((response.getEntity().getContent())));
|
||||
|
||||
String output;
|
||||
String res = "";
|
||||
while ((output = br.readLine()) != null) {
|
||||
res += output;
|
||||
}
|
||||
|
||||
if(res == "")
|
||||
throw new Exception("Unable to retrieve the package!");
|
||||
|
||||
String jsonAsString = EntityUtils.toString(response.getEntity());
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject json = (JSONObject) parser.parse(res);
|
||||
JSONObject json = (JSONObject) parser.parse(jsonAsString);
|
||||
JSONObject resultJson = (JSONObject) json.get("result");
|
||||
JSONArray groupsJson = (JSONArray)resultJson.get("groups");
|
||||
Iterator<JSONObject> it = groupsJson.iterator();
|
||||
|
@ -1520,6 +1499,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean removeDatasetFromGroup(String groupNameOrId,
|
||||
String datasetNameOrId, String apiKey) {
|
||||
|
@ -2039,6 +2019,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean removeCustomField(String productId, String key,
|
||||
String value, String apiKey) {
|
||||
|
@ -2113,6 +2094,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean removeTag(String productId, String apiKey, String tagToRemove) {
|
||||
|
||||
|
@ -2240,6 +2222,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean setGroupParent(String parentName, String groupName) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue