Revision 61889
Added by Michele Artini almost 3 years ago
modules/dnet-openaireplus-workflows/branches/dismiss_repo_profiles/pom.xml | ||
---|---|---|
10 | 10 |
<groupId>eu.dnetlib</groupId> |
11 | 11 |
<artifactId>dnet-openaireplus-workflows</artifactId> |
12 | 12 |
<packaging>jar</packaging> |
13 |
<version>7.1.18-SNAPSHOT</version>
|
|
13 |
<version>7.2.0-SNAPSHOT</version>
|
|
14 | 14 |
|
15 | 15 |
<scm> |
16 | 16 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-openaireplus-workflows/trunk</developerConnection> |
modules/dnet-openaireplus-workflows/branches/dismiss_repo_profiles/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/repohi/RetrieveInterfaceInfoJobNode.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.msro.openaireplus.workflows.nodes.repohi; |
2 | 2 |
|
3 |
import java.io.StringReader; |
|
4 |
import javax.annotation.Resource; |
|
3 |
import org.springframework.beans.factory.annotation.Autowired; |
|
5 | 4 |
|
6 | 5 |
import com.googlecode.sarasvati.Arc; |
7 | 6 |
import com.googlecode.sarasvati.NodeToken; |
8 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
9 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
7 |
|
|
8 |
import eu.dnetlib.enabling.datasources.common.Api; |
|
9 |
import eu.dnetlib.enabling.datasources.common.ApiParam; |
|
10 |
import eu.dnetlib.enabling.datasources.common.Datasource; |
|
11 |
import eu.dnetlib.enabling.datasources.common.LocalDatasourceManager; |
|
12 |
import eu.dnetlib.msro.rmi.MSROException; |
|
10 | 13 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
11 | 14 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
12 |
import org.dom4j.Document; |
|
13 |
import org.dom4j.Node; |
|
14 |
import org.dom4j.io.SAXReader; |
|
15 | 15 |
|
16 | 16 |
public class RetrieveInterfaceInfoJobNode extends SimpleJobNode { |
17 | 17 |
|
18 |
@Resource
|
|
19 |
private UniqueServiceLocator serviceLocator;
|
|
18 |
@Autowired
|
|
19 |
private LocalDatasourceManager<Datasource<?, ?>, Api<ApiParam>> dsManager;
|
|
20 | 20 |
|
21 | 21 |
@Override |
22 | 22 |
protected String execute(final NodeToken token) throws Exception { |
23 | 23 |
|
24 |
String datasourceId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ID); |
|
25 |
String interfaceID = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE); |
|
26 |
final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(datasourceId); |
|
27 |
final Document doc = new SAXReader().read(new StringReader(profile)); |
|
28 |
final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id='" + interfaceID + "']"); |
|
24 |
final String datasourceId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ID); |
|
25 |
final String interfaceID = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE); |
|
29 | 26 |
|
30 |
String contentDescription = ifcNode.valueOf("./@contentDescription"); |
|
27 |
final Api<ApiParam> api = dsManager.getApis(datasourceId) |
|
28 |
.stream() |
|
29 |
.filter(a -> a.getId().equals(interfaceID)) |
|
30 |
.findFirst() |
|
31 |
.orElseThrow(() -> new MSROException("Api not found")); |
|
32 |
|
|
33 |
final String contentDescription = api.getContentdescription(); |
|
31 | 34 |
token.getEnv().setAttribute("objectStoreContentDescription", contentDescription); |
32 | 35 |
|
33 |
final Node acProtNode = doc.selectSingleNode("//INTERFACE[@id='" + interfaceID + "']/ACCESS_PROTOCOL"); |
|
36 |
final String basePath = api.getApiParams() |
|
37 |
.stream() |
|
38 |
.filter(ap -> ap.getParam().equals("basePath")) |
|
39 |
.map(ap -> ap.getValue()) |
|
40 |
.findFirst() |
|
41 |
.orElseThrow(() -> new MSROException("Param 'basePath' not found")); |
|
34 | 42 |
|
35 |
String basePath = acProtNode.valueOf("./@basePath"); |
|
36 | 43 |
token.getEnv().setAttribute("objectStoreBasePath", basePath); |
37 | 44 |
|
38 | 45 |
return Arc.DEFAULT_ARC; |
modules/dnet-openaireplus-workflows/branches/dismiss_repo_profiles/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/repohi/UpdateOpenaireMetaWfStatusJobNode.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.msro.openaireplus.workflows.nodes.repohi; |
2 | 2 |
|
3 |
import eu.dnetlib.enabling.datasources.common.LocalDatasourceManager; |
|
4 | 3 |
import org.springframework.beans.factory.annotation.Autowired; |
5 | 4 |
|
6 |
import eu.dnetlib.enabling.datasources.LocalOpenaireDatasourceManager; |
|
7 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
8 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
5 |
import eu.dnetlib.enabling.datasources.common.LocalDatasourceManager; |
|
9 | 6 |
import eu.dnetlib.msro.workflows.nodes.repohi.UpdateMetaWfStatusJobNode; |
10 |
import org.springframework.beans.factory.annotation.Required; |
|
11 | 7 |
|
12 | 8 |
public class UpdateOpenaireMetaWfStatusJobNode extends UpdateMetaWfStatusJobNode { |
13 | 9 |
|
14 | 10 |
@Autowired |
15 |
private UniqueServiceLocator serviceLocator;
|
|
11 |
private LocalDatasourceManager<?, ?> dsManager;
|
|
16 | 12 |
|
17 |
@Autowired |
|
18 |
private LocalDatasourceManager dsManager; |
|
19 |
|
|
20 | 13 |
@Override |
21 | 14 |
protected void updateDatasource(final String dsId, final String ifaceId) throws Exception { |
22 |
|
|
23 |
final String openaireDsId = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery( |
|
24 |
"/*[.//RESOURCE_IDENTIFIER/@value = '" + dsId + "']//FIELD/value[../key='OpenAireDataSourceId']/text()"); |
|
25 |
|
|
26 |
if (openaireDsId.equals("openaire____::bootstrap")) { |
|
27 |
super.updateDatasource(dsId, ifaceId); |
|
28 |
} else { |
|
29 |
dsManager.setManaged(openaireDsId, true); |
|
30 |
dsManager.setActive(openaireDsId, ifaceId, true); |
|
15 |
if (!dsId.equals("openaire____::bootstrap")) { |
|
16 |
dsManager.setManaged(dsId, true); |
|
17 |
dsManager.setActive(dsId, ifaceId, true); |
|
31 | 18 |
} |
32 | 19 |
} |
33 | 20 |
|
34 |
|
|
35 | 21 |
} |
Also available in: Unified diff