manager thread and groups thread cannot run concurrently... ckan loses some information

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@134797 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-11-25 13:35:00 +00:00
parent fb2fbee11a
commit 00b2442632
5 changed files with 23 additions and 13 deletions

View File

@ -239,7 +239,14 @@ public class GrsfPublisherFisheryService {
// manage time series
logger.info("Launching thread for time series handling");
new ManageTimeSeriesThread(record, id, username, catalogue, ScopeProvider.instance.get()).start();
ManageTimeSeriesThread threadFiles = new ManageTimeSeriesThread(record, futureName, username, catalogue, ScopeProvider.instance.get());
// wait this one to finish
threadFiles.start();
logger.info("Waiting time series thread to die..");
threadFiles.join();
logger.debug("Ok, it died");
if(!groups.isEmpty()){
logger.info("Launching thread for association to the list of groups " + groups);

View File

@ -228,7 +228,14 @@ public class GrsfPublisherStockService {
// manage time series
logger.info("Launching thread for time series handling");
new ManageTimeSeriesThread(record, id, username, catalogue, ScopeProvider.instance.get()).start();
ManageTimeSeriesThread threadFiles = new ManageTimeSeriesThread(record, futureName, username, catalogue, ScopeProvider.instance.get());
// wait this one to finish
threadFiles.start();
logger.info("Waiting time series thread to die..");
threadFiles.join();
logger.debug("Ok, it died");
if(!groups.isEmpty()){
logger.info("Launching thread for association to the list of groups " + groups);

View File

@ -437,7 +437,7 @@ public abstract class HelperMethods {
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
public static void manageTimeSeries(Common record, String packageId, String username, DataCatalogue catalogue, String context) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException{
public static void manageTimeSeries(Common record, String packageName, String username, DataCatalogue catalogue, String context) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException{
if(record == null)
throw new IllegalArgumentException("The given record is null!!");
@ -466,7 +466,7 @@ public abstract class HelperMethods {
// upload this file on ckan
eu.trentorise.opendata.jackan.model.CkanResource res = catalogue.uploadResourceFile(
csvFile,
packageId,
packageName,
catalogue.getApiKeyFromUsername(username),
resourceToAttachName,
customAnnotation.key() + " time series for this product");

View File

@ -46,7 +46,7 @@ public class AssociationToGroupThread extends Thread {
// retrieve the role to be assigned according the one the user has into the organization of the dataset
RolesCkanGroupOrOrg role = RolesCkanGroupOrOrg.valueOf(catalogue.getRoleOfUserInOrganization(username, organizationId, catalogue.getApiKeyFromUsername(username)).toUpperCase());
if(!role.equals(RolesCkanGroupOrOrg.ADMIN))
role = RolesCkanGroupOrOrg.MEMBER; // decrease the role to member if it is not an admin
@ -56,16 +56,12 @@ public class AssociationToGroupThread extends Thread {
boolean assigned = catalogue.checkRoleIntoGroup(username, groupTitle, role);
if(!assigned){
logger.warn("The user " + username + " has not enough privileges to associate the dataset into group OR the group doesn't exist" + groupTitle);
continue;
}
else{
boolean putIntoGroup = catalogue.assignDatasetToGroup(groupTitle, datasetId, userApiKey);
logger.info("Was product put into group " + groupTitle + "? " + putIntoGroup);
}
}
logger.info("The Association Group thread ended correctly");

View File

@ -19,7 +19,7 @@ public class ManageTimeSeriesThread extends Thread{
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ManageTimeSeriesThread.class);
private Common record;
private String packageId;
private String packageName;
private String username;
private DataCatalogue catalogue;
private String context;
@ -31,11 +31,11 @@ public class ManageTimeSeriesThread extends Thread{
* @param catalogue
* @param context
*/
public ManageTimeSeriesThread(Common record, String packageId,
public ManageTimeSeriesThread(Common record, String packageName,
String username, DataCatalogue catalogue, String context) {
super();
this.record = record;
this.packageId = packageId;
this.packageName = packageName;
this.username = username;
this.catalogue = catalogue;
this.context = context;
@ -47,7 +47,7 @@ public class ManageTimeSeriesThread extends Thread{
public void run() {
logger.info("Time series manager thread started");
try {
HelperMethods.manageTimeSeries(record, packageId, username, catalogue, context);
HelperMethods.manageTimeSeries(record, packageName, username, catalogue, context);
logger.info("The time series manager thread ended correctly");
} catch (IllegalAccessException | IllegalArgumentException
| InvocationTargetException | IntrospectionException e) {