Revision 48139
Added by Alessia Bardi almost 7 years ago
SaveContextProfileJobNode.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.StringReader; |
4 | 4 |
import java.util.List; |
5 |
|
|
6 | 5 |
import javax.annotation.Resource; |
7 | 6 |
|
7 |
import com.googlecode.sarasvati.Arc; |
|
8 |
import com.googlecode.sarasvati.NodeToken; |
|
9 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
10 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException; |
|
11 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
12 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
13 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
8 | 14 |
import org.apache.commons.logging.Log; |
9 | 15 |
import org.apache.commons.logging.LogFactory; |
10 | 16 |
import org.dom4j.Document; |
... | ... | |
13 | 19 |
import org.dom4j.Node; |
14 | 20 |
import org.dom4j.io.SAXReader; |
15 | 21 |
|
16 |
import com.googlecode.sarasvati.Arc; |
|
17 |
import com.googlecode.sarasvati.NodeToken; |
|
18 |
|
|
19 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
20 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException; |
|
21 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
22 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
23 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
24 |
|
|
25 | 22 |
public class SaveContextProfileJobNode extends SimpleJobNode { |
26 | 23 |
|
27 | 24 |
private String contextObj; |
... | ... | |
53 | 50 |
final Document doc = reader.read(new StringReader(profile)); |
54 | 51 |
final String profId = doc.valueOf("//HEADER/RESOURCE_IDENTIFIER/@value"); |
55 | 52 |
final Element ctxElem = (Element) doc.selectSingleNode("//CONFIGURATION/context[@id='" + desc.getId() + "' and @type='" + desc.getType() + "']"); |
53 |
updateContextParams(ctxElem, desc); |
|
56 | 54 |
|
57 | 55 |
for (ContextPart cat : desc.getCategories().values()) { |
58 | 56 |
final Node catElem = ctxElem.selectSingleNode("./category[@id=\"" + cat.getId() + "\"]"); |
... | ... | |
65 | 63 |
return serviceLocator.getService(ISRegistryService.class).updateProfile(profId, doc.asXML(), "ContextDSResourceType"); |
66 | 64 |
} |
67 | 65 |
|
66 |
private void updateContextParams(final Element ctxElement, ContextDesc desc) { |
|
67 |
//removing old PARAMs |
|
68 |
List<Node> oldParams = ctxElement.selectNodes("param"); |
|
69 |
for (Node n : oldParams) { |
|
70 |
n.detach(); |
|
71 |
} |
|
72 |
//adding new params |
|
73 |
for (Element param : desc.getParamsAsElements()) { |
|
74 |
ctxElement.add(param); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
68 | 78 |
private String registerNewProfile(final ContextDesc desc) throws DocumentException, ISRegistryException { |
69 | 79 |
final SAXReader reader = new SAXReader(); |
70 | 80 |
final Document doc = reader.read(getClass().getResourceAsStream( |
Also available in: Unified diff
integrated (hopefully) all required changes from dnet40