Changed the way the url of the product is generated (now it is no longer encrypted). The list of ids of products in a group is now returned (there is no longer the limit of the ckan api)
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@141264 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bf3d0675ce
commit
516c2b4697
|
@ -3,6 +3,9 @@
|
|||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<dependent-module archiveName="ckan-util-library-2.1.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="context-root" value="grsf-publisher-ws"/>
|
||||
<property name="java-output-path" value="/grsf-publisher-ws/target/classes"/>
|
||||
</wb-module>
|
||||
|
|
|
@ -237,7 +237,7 @@ public class GrsfPublisherFisheryService {
|
|||
logger.info("Product created! Id is " + id);
|
||||
responseBean.setId(id);
|
||||
status = Status.CREATED;
|
||||
String productUrl = catalogue.getUrlFromDatasetIdOrName(id);
|
||||
String productUrl = catalogue.getUnencryptedUrlFromDatasetIdOrName(futureName);
|
||||
responseBean.setProductUrl(productUrl);
|
||||
responseBean.setKbUuid(record.getUuid());
|
||||
|
||||
|
@ -388,23 +388,16 @@ public class GrsfPublisherFisheryService {
|
|||
|
||||
DataCatalogue catalogue = HelperMethods.getDataCatalogueRunningInstance(context);
|
||||
if(catalogue == null){
|
||||
|
||||
status = Status.INTERNAL_SERVER_ERROR;
|
||||
throw new Exception("There was a problem while serving your request");
|
||||
|
||||
}
|
||||
|
||||
List<CkanDataset> datasets = catalogue.getProductsInGroup(source + "-" + "fishery");
|
||||
|
||||
for (CkanDataset ckanDataset : datasets) {
|
||||
datasetsIds.add(ckanDataset.getId());
|
||||
}
|
||||
|
||||
datasetsIds = HelperMethods.getProductsInGroup(source + "-" + "fishery", catalogue);
|
||||
responseBean.setResult(datasetsIds);
|
||||
responseBean.setSuccess(true);
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("Failed to delete this ", e);
|
||||
logger.error("Failed to fetch this list of ids ", e);
|
||||
status = Status.INTERNAL_SERVER_ERROR;
|
||||
responseBean.setSuccess(false);
|
||||
responseBean.setMessage(e.getMessage());
|
||||
|
@ -447,7 +440,7 @@ public class GrsfPublisherFisheryService {
|
|||
if(customFields.containsKey(PRODUCT_URL_FIELD_KEY))
|
||||
result.put("url", customFields.get(PRODUCT_URL_FIELD_KEY));
|
||||
else
|
||||
result.put("url", catalogue.getUrlFromDatasetIdOrName(dataset.getId()));
|
||||
result.put("url", catalogue.getUnencryptedUrlFromDatasetIdOrName(dataset.getId()));
|
||||
|
||||
responseBean.setResult(result);
|
||||
responseBean.setSuccess(true);
|
||||
|
|
|
@ -227,7 +227,7 @@ public class GrsfPublisherStockService {
|
|||
logger.info("Product created! Id is " + id);
|
||||
responseBean.setId(id);
|
||||
status = Status.CREATED;
|
||||
String productUrl = catalogue.getUrlFromDatasetIdOrName(id);
|
||||
String productUrl = catalogue.getUnencryptedUrlFromDatasetIdOrName(futureName);
|
||||
responseBean.setProductUrl(productUrl);
|
||||
responseBean.setKbUuid(record.getUuid());
|
||||
|
||||
|
@ -383,17 +383,12 @@ public class GrsfPublisherStockService {
|
|||
throw new Exception("There was a problem while serving your request");
|
||||
}
|
||||
|
||||
List<CkanDataset> datasets = catalogue.getProductsInGroup(source + "-" + "stock");
|
||||
|
||||
for (CkanDataset ckanDataset : datasets) {
|
||||
datasetsIds.add(ckanDataset.getId());
|
||||
}
|
||||
|
||||
datasetsIds = HelperMethods.getProductsInGroup(source + "-" + "stock", catalogue);
|
||||
responseBean.setResult(datasetsIds);
|
||||
responseBean.setSuccess(true);
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("Failed to fetch stocks ids of source " + source, e);
|
||||
logger.error("Failed to fetch this list of ids " + source, e);
|
||||
responseBean.setSuccess(false);
|
||||
responseBean.setMessage(e.getMessage());
|
||||
}
|
||||
|
@ -436,7 +431,7 @@ public class GrsfPublisherStockService {
|
|||
if(customFields.containsKey(PRODUCT_URL_FIELD_KEY))
|
||||
result.put("url", customFields.get(PRODUCT_URL_FIELD_KEY));
|
||||
else
|
||||
result.put("url", catalogue.getUrlFromDatasetIdOrName(dataset.getId()));
|
||||
result.put("url", catalogue.getUnencryptedUrlFromDatasetIdOrName(dataset.getId()));
|
||||
|
||||
responseBean.setResult(result);
|
||||
responseBean.setSuccess(true);
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.BufferedReader;
|
|||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -448,4 +449,19 @@ public abstract class HelperMethods {
|
|||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the identifiers of the products in a given group. It doesn't use CKAN API because they would return at most 1000 ids.
|
||||
* @param string
|
||||
* @param catalogue
|
||||
* @return
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public static List<String> getProductsInGroup(String groupName,
|
||||
DataCatalogue catalogue) throws ClassNotFoundException, SQLException {
|
||||
|
||||
return catalogue.getProductsIdsInGroupOrOrg(groupName, false, 0, Integer.MAX_VALUE);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue