all post update/create actions have been moved to a separate thread to speed up the answer
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@152494 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c35c19434c
commit
66e1a0e3a3
|
@ -429,7 +429,7 @@ public class CommonServiceUtils {
|
|||
sourcesList.add(sourceSysType.toLowerCase());
|
||||
databaseSource += sourceSysType + " ";
|
||||
}
|
||||
|
||||
|
||||
// create the Database Source information
|
||||
customFields.put(Common.GRSF_DATABASE_SOURCE, Arrays.asList(databaseSource.trim()));
|
||||
|
||||
|
@ -508,10 +508,10 @@ public class CommonServiceUtils {
|
|||
* @throws InterruptedException
|
||||
*/
|
||||
public static void actionsPostCreateOrUpdate(
|
||||
String datasetId, String futureName, Common record, String apiKey, String username, String organization, String itemUrl,
|
||||
ResponseCreationBean responseBean, DataCatalogue catalogue,
|
||||
Map<String, String> namespaces, Set<String> groups, String context,
|
||||
String token, String futureTitle, String authorFullname, ServletContext contextServlet, boolean isUpdated, String description) throws InterruptedException {
|
||||
final String datasetId, final String futureName, final Common record, final String apiKey, final String username, final String organization, String itemUrl,
|
||||
ResponseCreationBean responseBean, final DataCatalogue catalogue,
|
||||
Map<String, String> namespaces, final Set<String> groups, final String context,
|
||||
final String token, final String futureTitle, final String authorFullname, final ServletContext contextServlet, final boolean isUpdated, String description) throws InterruptedException {
|
||||
|
||||
// on create, we need to add the item url and set the description
|
||||
if(!isUpdated){
|
||||
|
@ -531,31 +531,41 @@ public class CommonServiceUtils {
|
|||
responseBean.setItemUrl(itemUrl);
|
||||
responseBean.setKbUuid(record.getUuid());
|
||||
|
||||
// manage groups (wait thread to die: ckan doesn't support too much concurrency on same record ...)
|
||||
if(!groups.isEmpty()){
|
||||
logger.info("Launching thread for association to the list of groups " + groups);
|
||||
AssociationToGroupThread threadGroups = new AssociationToGroupThread(new ArrayList<String>(groups), datasetId, organization, username, catalogue, apiKey);
|
||||
threadGroups.start();
|
||||
logger.debug("Waiting association thread to die..");
|
||||
threadGroups.join();
|
||||
logger.debug("Ok, it died");
|
||||
}
|
||||
// it is needed...
|
||||
final String itemUrlForThread = itemUrl;
|
||||
|
||||
// manage time series as resources
|
||||
logger.info("Launching thread for time series handling");
|
||||
new ManageTimeSeriesThread(record, futureName, username, catalogue, context, token).start();
|
||||
new Thread(new Runnable() {
|
||||
|
||||
// write a post if the product has been published in grsf context
|
||||
if(!isUpdated && context.equals((String)contextServlet.getInitParameter(HelperMethods.PUBLIC_CONTEX_KEY))){
|
||||
new WritePostCatalogueManagerThread(
|
||||
context,
|
||||
token,
|
||||
futureTitle,
|
||||
itemUrl,
|
||||
false,
|
||||
new ArrayList<String>(),
|
||||
authorFullname).start();
|
||||
logger.info("Thread to write a post about the new product has been launched");
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// manage groups (wait thread to die: ckan doesn't support too much concurrency on same record ...)
|
||||
if(!groups.isEmpty()){
|
||||
logger.info("Launching thread for association to the list of groups " + groups);
|
||||
AssociationToGroupThread threadGroups = new AssociationToGroupThread(new ArrayList<String>(groups), datasetId, organization, username, catalogue, apiKey);
|
||||
threadGroups.start();
|
||||
threadGroups.join();
|
||||
}
|
||||
// manage time series as resources
|
||||
logger.info("Launching thread for time series handling");
|
||||
new ManageTimeSeriesThread(record, futureName, username, catalogue, context, token).start();
|
||||
|
||||
// write a post if the product has been published in grsf context
|
||||
if(!isUpdated && context.equals((String)contextServlet.getInitParameter(HelperMethods.PUBLIC_CONTEX_KEY))){
|
||||
new WritePostCatalogueManagerThread(
|
||||
context,
|
||||
token,
|
||||
futureTitle,
|
||||
itemUrlForThread,
|
||||
false,
|
||||
new ArrayList<String>(),
|
||||
authorFullname).start();
|
||||
logger.info("Thread to write a post about the new product has been launched");
|
||||
}
|
||||
}catch (InterruptedException e) {
|
||||
logger.error("Error", e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue