Revision 42528
Added by Andrea Mannocci almost 8 years ago
DatasourceDescToProfile.java | ||
---|---|---|
10 | 10 |
import org.dom4j.Element; |
11 | 11 |
|
12 | 12 |
public class DatasourceDescToProfile implements Function<DatasourceDesc, String> { |
13 |
|
|
14 | 13 |
private static final Log log = LogFactory.getLog(DatasourceDescToProfile.class); |
15 | 14 |
|
16 |
public static String convert(final DatasourceDesc ds) throws Exception { |
|
15 |
public DatasourceDescToProfile(final String environment) { |
|
16 |
this.environment = environment; |
|
17 |
} |
|
18 |
|
|
19 |
private String environment; |
|
20 |
|
|
21 |
public static String convert(final DatasourceDesc ds, String environment) throws Exception { |
|
17 | 22 |
final Element root = DocumentHelper.createElement("RESOURCE_PROFILE"); |
18 | 23 |
|
19 | 24 |
final Element header = root.addElement("HEADER"); |
... | ... | |
33 | 38 |
origId.setText(ds.getId()); |
34 | 39 |
|
35 | 40 |
conf.addElement("DATASOURCE_AGGREGATED").setText("false"); |
36 |
conf.addElement("ENVIRONMENTS"); |
|
41 |
conf.addElement("ENVIRONMENTS").addElement("ENVIRONMENT").setText(environment);
|
|
37 | 42 |
conf.addElement("TYPOLOGY").setText(ds.getTypology()); |
38 | 43 |
conf.addElement("MAX_SIZE_OF_DATASTRUCTURE").setText("0"); |
39 | 44 |
conf.addElement("AVAILABLE_DISKSPACE").setText("0"); |
... | ... | |
67 | 72 |
|
68 | 73 |
final Element status = body.addElement("STATUS"); |
69 | 74 |
status.addElement("NUMBER_OF_OBJECTS").setText("0"); |
70 |
status.addElement("LAST_UPDATE").addAttribute("value", "");
|
|
75 |
status.addElement("LAST_UPDATE").addAttribute("value", DateUtils.now_ISO8601());
|
|
71 | 76 |
|
72 | 77 |
final Element qos = body.addElement("QOS"); |
73 | 78 |
qos.addElement("AVAILABILITY").setText("0"); |
... | ... | |
89 | 94 |
@Override |
90 | 95 |
public String apply(final DatasourceDesc ds) { |
91 | 96 |
try { |
92 |
return DatasourceDescToProfile.convert(ds); |
|
97 |
return DatasourceDescToProfile.convert(ds, environment);
|
|
93 | 98 |
} catch (Exception e) { |
94 | 99 |
log.error("Error convering profile", e); |
95 | 100 |
return null; |
Also available in: Unified diff
added property dnet.datasource.environment to set default environment of datasources created via datasource manager. fixed error cause by data.