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:
parent
fb2fbee11a
commit
00b2442632
|
@ -239,7 +239,14 @@ public class GrsfPublisherFisheryService {
|
||||||
|
|
||||||
// manage time series
|
// manage time series
|
||||||
logger.info("Launching thread for time series handling");
|
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()){
|
if(!groups.isEmpty()){
|
||||||
logger.info("Launching thread for association to the list of groups " + groups);
|
logger.info("Launching thread for association to the list of groups " + groups);
|
||||||
|
|
|
@ -228,7 +228,14 @@ public class GrsfPublisherStockService {
|
||||||
|
|
||||||
// manage time series
|
// manage time series
|
||||||
logger.info("Launching thread for time series handling");
|
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()){
|
if(!groups.isEmpty()){
|
||||||
logger.info("Launching thread for association to the list of groups " + groups);
|
logger.info("Launching thread for association to the list of groups " + groups);
|
||||||
|
|
|
@ -437,7 +437,7 @@ public abstract class HelperMethods {
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* @throws IllegalAccessException
|
* @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)
|
if(record == null)
|
||||||
throw new IllegalArgumentException("The given record is null!!");
|
throw new IllegalArgumentException("The given record is null!!");
|
||||||
|
@ -466,7 +466,7 @@ public abstract class HelperMethods {
|
||||||
// upload this file on ckan
|
// upload this file on ckan
|
||||||
eu.trentorise.opendata.jackan.model.CkanResource res = catalogue.uploadResourceFile(
|
eu.trentorise.opendata.jackan.model.CkanResource res = catalogue.uploadResourceFile(
|
||||||
csvFile,
|
csvFile,
|
||||||
packageId,
|
packageName,
|
||||||
catalogue.getApiKeyFromUsername(username),
|
catalogue.getApiKeyFromUsername(username),
|
||||||
resourceToAttachName,
|
resourceToAttachName,
|
||||||
customAnnotation.key() + " time series for this product");
|
customAnnotation.key() + " time series for this product");
|
||||||
|
|
|
@ -56,16 +56,12 @@ public class AssociationToGroupThread extends Thread {
|
||||||
boolean assigned = catalogue.checkRoleIntoGroup(username, groupTitle, role);
|
boolean assigned = catalogue.checkRoleIntoGroup(username, groupTitle, role);
|
||||||
|
|
||||||
if(!assigned){
|
if(!assigned){
|
||||||
|
|
||||||
logger.warn("The user " + username + " has not enough privileges to associate the dataset into group OR the group doesn't exist" + groupTitle);
|
logger.warn("The user " + username + " has not enough privileges to associate the dataset into group OR the group doesn't exist" + groupTitle);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
||||||
boolean putIntoGroup = catalogue.assignDatasetToGroup(groupTitle, datasetId, userApiKey);
|
boolean putIntoGroup = catalogue.assignDatasetToGroup(groupTitle, datasetId, userApiKey);
|
||||||
logger.info("Was product put into group " + groupTitle + "? " + putIntoGroup);
|
logger.info("Was product put into group " + groupTitle + "? " + putIntoGroup);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info("The Association Group thread ended correctly");
|
logger.info("The Association Group thread ended correctly");
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class ManageTimeSeriesThread extends Thread{
|
||||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ManageTimeSeriesThread.class);
|
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ManageTimeSeriesThread.class);
|
||||||
|
|
||||||
private Common record;
|
private Common record;
|
||||||
private String packageId;
|
private String packageName;
|
||||||
private String username;
|
private String username;
|
||||||
private DataCatalogue catalogue;
|
private DataCatalogue catalogue;
|
||||||
private String context;
|
private String context;
|
||||||
|
@ -31,11 +31,11 @@ public class ManageTimeSeriesThread extends Thread{
|
||||||
* @param catalogue
|
* @param catalogue
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
public ManageTimeSeriesThread(Common record, String packageId,
|
public ManageTimeSeriesThread(Common record, String packageName,
|
||||||
String username, DataCatalogue catalogue, String context) {
|
String username, DataCatalogue catalogue, String context) {
|
||||||
super();
|
super();
|
||||||
this.record = record;
|
this.record = record;
|
||||||
this.packageId = packageId;
|
this.packageName = packageName;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.catalogue = catalogue;
|
this.catalogue = catalogue;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -47,7 +47,7 @@ public class ManageTimeSeriesThread extends Thread{
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.info("Time series manager thread started");
|
logger.info("Time series manager thread started");
|
||||||
try {
|
try {
|
||||||
HelperMethods.manageTimeSeries(record, packageId, username, catalogue, context);
|
HelperMethods.manageTimeSeries(record, packageName, username, catalogue, context);
|
||||||
logger.info("The time series manager thread ended correctly");
|
logger.info("The time series manager thread ended correctly");
|
||||||
} catch (IllegalAccessException | IllegalArgumentException
|
} catch (IllegalAccessException | IllegalArgumentException
|
||||||
| InvocationTargetException | IntrospectionException e) {
|
| InvocationTargetException | IntrospectionException e) {
|
||||||
|
|
Loading…
Reference in New Issue