Revision 57102
Added by Enrico Ottonello over 4 years ago
modules/dnet-modular-uis/branches/saxonHE-SOLR772/deploy.info | ||
---|---|---|
1 |
{ |
|
2 |
"type_source": "SVN", |
|
3 |
"goal": "package -U source:jar", |
|
4 |
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet50/modules/dnet-modular-uis/branches/saxonHE", |
|
5 |
"deploy_repository": "dnet5-snapshots", |
|
6 |
"version": "5", |
|
7 |
"mail": "alessia.bardi@isti.cnr.it", |
|
8 |
"deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet5-snapshots", |
|
9 |
"name": "dnet-modular-uis-saxonHE" |
|
10 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/test/java/eu/dnetlib/functionality/modular/ui/users/SimpleSSOAuthorizationManagerTest.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.users; |
|
2 |
|
|
3 |
import static org.junit.Assert.*; |
|
4 |
|
|
5 |
import org.junit.Before; |
|
6 |
import org.junit.Test; |
|
7 |
import org.springframework.core.io.ClassPathResource; |
|
8 |
|
|
9 |
public class SimpleSSOAuthorizationManagerTest { |
|
10 |
|
|
11 |
private final static String PAYLOAD = "{\"uid\":\"michele.artini\",\"fullname\":\"Michele Artini\",\"email\":\"michele.artini@isti.cnr.it\"}"; |
|
12 |
private final static String SIGNATURE = "89f7a05d39d7a1e6489506c0a27f6087cf4ca0c7f0298c29d61464f5522be146363e8ad63312cc3d7fdcf5b5f1ff7b26e64ed1009b52b6562deebbd267dc6f49e25714f54a8cd2936db6b15e27e9dfc7ab762728d33449e8734101265bbb8b70e5efe2845d5ae2da6e43f25ab75e531fa6cc15e31497bb344b1cca6d687ecf2501c407316423c3eecbe98df43a0721b63f3a1a07fc1e7d75855cc6dc9dce18817b008d60fb4b225d462755d5671fdd01d3c7b08d5d039524e45a78a808377a3cc44b13c0c8e314aa1893e88cd32120e8beeacf5df8412c8228c1e8aa046a159ea1d6a36de160456f32001e23978b1b2d15490a07943d95a56d9dfd0f7bc6b4c6"; |
|
13 |
|
|
14 |
private SimpleSSOAuthorizationManager manager = new SimpleSSOAuthorizationManager(); |
|
15 |
|
|
16 |
|
|
17 |
@Before |
|
18 |
public void setup() throws Exception { |
|
19 |
manager.setPubKeyAlgo("RSA"); |
|
20 |
manager.setPubKeyFile(new ClassPathResource("/eu/dnetlib/functionality/modular/ui/users/pubkey.der")); |
|
21 |
manager.setSignatureAlgo("SHA1withRSA"); |
|
22 |
manager.init(); |
|
23 |
} |
|
24 |
@Test |
|
25 |
public void testIsValidMessage() { |
|
26 |
assertTrue(manager.isValidMessage(PAYLOAD, SIGNATURE)); |
|
27 |
assertFalse(manager.isValidMessage(PAYLOAD.toLowerCase(), SIGNATURE)); |
|
28 |
assertFalse(manager.isValidMessage(PAYLOAD + "123", SIGNATURE)); |
|
29 |
assertFalse(manager.isValidMessage(PAYLOAD, SIGNATURE + "123")); |
|
30 |
assertFalse(manager.isValidMessage(PAYLOAD + PAYLOAD, SIGNATURE)); |
|
31 |
assertFalse(manager.isValidMessage("aaa", "aaa")); |
|
32 |
assertFalse(manager.isValidMessage(null, SIGNATURE)); |
|
33 |
assertFalse(manager.isValidMessage(PAYLOAD, null)); |
|
34 |
assertFalse(manager.isValidMessage("", SIGNATURE)); |
|
35 |
assertFalse(manager.isValidMessage(PAYLOAD, "")); |
|
36 |
assertFalse(manager.isValidMessage(null, "")); |
|
37 |
assertFalse(manager.isValidMessage("", null)); |
|
38 |
assertFalse(manager.isValidMessage("", "")); |
|
39 |
assertFalse(manager.isValidMessage(null, null)); |
|
40 |
} |
|
41 |
|
|
42 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/test/java/eu/dnetlib/functionality/modular/ui/repositories/DatasourceTest.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.repositories; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
|
|
5 |
import com.google.gson.Gson; |
|
6 |
import eu.dnetlib.rmi.datasource.DatasourceDesc; |
|
7 |
import org.junit.Assert; |
|
8 |
import org.junit.Test; |
|
9 |
|
|
10 |
/** |
|
11 |
* Created by Alessia Bardi on 11/05/2017. |
|
12 |
* |
|
13 |
* @author Alessia Bardi |
|
14 |
*/ |
|
15 |
public class DatasourceTest { |
|
16 |
|
|
17 |
String repoJson = "{\"latitude\":\"0.0\",\"longitude\":\"0.0\",\"timezone\":\"0.0\",\"id\":\"parthenos___::ehri\",\"officialName\":\"European Holocaust Research Infrastructure\",\"englishName\":\"European Holocaust Research Infrastructure\",\"organization\":\"EHRI\",\"datasourceClass\":\"dnet:repository\",\"websiteUrl\":\"https://www.ehri-project.eu/\",\"contactEmail\":\"charles.riondet@inria.fr\",\"countryCode\":\"EU\",\"namespacePrefix\":\"ehri________\"}"; |
|
18 |
|
|
19 |
@Test |
|
20 |
public void testGsonParse(){ |
|
21 |
final DatasourceDesc ds = new Gson().fromJson(repoJson, DatasourceDesc.class); |
|
22 |
ds.setDateOfCollection(new Date()); |
|
23 |
|
|
24 |
Assert.assertNotNull(ds); |
|
25 |
|
|
26 |
System.out.println(ds); |
|
27 |
} |
|
28 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/InfoController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.lang.management.ManagementFactory; |
|
5 |
import java.lang.management.RuntimeMXBean; |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.Collections; |
|
8 |
import java.util.Comparator; |
|
9 |
import java.util.HashMap; |
|
10 |
import java.util.List; |
|
11 |
import java.util.Map; |
|
12 |
import java.util.Map.Entry; |
|
13 |
|
|
14 |
import javax.servlet.http.HttpServletRequest; |
|
15 |
import javax.servlet.http.HttpServletResponse; |
|
16 |
|
|
17 |
import org.apache.commons.logging.Log; |
|
18 |
import org.apache.commons.logging.LogFactory; |
|
19 |
import org.apache.maven.model.Model; |
|
20 |
import org.apache.maven.model.Parent; |
|
21 |
import org.apache.maven.model.io.xpp3.MavenXpp3Reader; |
|
22 |
import org.springframework.beans.factory.annotation.Required; |
|
23 |
import org.springframework.context.ResourceLoaderAware; |
|
24 |
import org.springframework.core.io.Resource; |
|
25 |
import org.springframework.core.io.ResourceLoader; |
|
26 |
import org.springframework.core.io.support.ResourcePatternUtils; |
|
27 |
import org.springframework.ui.ModelMap; |
|
28 |
|
|
29 |
import com.google.common.collect.Lists; |
|
30 |
import com.google.common.collect.Maps; |
|
31 |
|
|
32 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
33 |
import eu.dnetlib.miscutils.datetime.HumanTime; |
|
34 |
|
|
35 |
public class InfoController extends ModuleEntryPoint implements ResourceLoaderAware { |
|
36 |
|
|
37 |
private String hostname; |
|
38 |
private String port; |
|
39 |
private String context; |
|
40 |
|
|
41 |
private ResourceLoader resourceLoader; |
|
42 |
|
|
43 |
private static final Log log = LogFactory.getLog(InfoController.class); |
|
44 |
|
|
45 |
@Override |
|
46 |
protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception { |
|
47 |
final RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean(); |
|
48 |
|
|
49 |
final Map<String, Map<String, String>> info = Maps.newLinkedHashMap(); |
|
50 |
info.put("General", getGeneralInfo(mxbean)); |
|
51 |
info.put("JVM", getJvmInfo(mxbean)); |
|
52 |
info.put("Libraries and arguments", getLibInfo(mxbean)); |
|
53 |
info.put("System properties", getSysInfo(mxbean)); |
|
54 |
|
|
55 |
map.addAttribute("info", info); |
|
56 |
map.addAttribute("modules", getModules()); |
|
57 |
|
|
58 |
} |
|
59 |
|
|
60 |
@SuppressWarnings("unchecked") |
|
61 |
private List<Map<String, Object>> getModules() throws IOException { |
|
62 |
final Map<String, Map<String, Map<String, Object>>> modules = Maps.newLinkedHashMap(); |
|
63 |
|
|
64 |
final MavenXpp3Reader reader = new MavenXpp3Reader(); |
|
65 |
for (Resource res : ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources("classpath*:/META-INF/**/pom.xml")) { |
|
66 |
try { |
|
67 |
final Model model = reader.read(res.getInputStream()); |
|
68 |
|
|
69 |
final String name = model.getArtifactId(); |
|
70 |
|
|
71 |
String groupId = model.getGroupId(); |
|
72 |
for (Parent parent = model.getParent(); groupId == null && model.getParent() != null; parent = model.getParent()) { |
|
73 |
groupId = parent.getGroupId(); |
|
74 |
} |
|
75 |
|
|
76 |
String version = model.getVersion(); |
|
77 |
for (Parent parent = model.getParent(); version == null && model.getParent() != null; parent = model.getParent()) { |
|
78 |
version = parent.getVersion(); |
|
79 |
} |
|
80 |
|
|
81 |
if (!modules.containsKey(groupId)) { |
|
82 |
modules.put(groupId, new HashMap<String, Map<String, Object>>()); |
|
83 |
} |
|
84 |
if (!modules.get(groupId).containsKey(name)) { |
|
85 |
final Map<String, Object> map = Maps.newHashMap(); |
|
86 |
map.put("group", groupId); |
|
87 |
map.put("name", name); |
|
88 |
map.put("files", new ArrayList<String>()); |
|
89 |
map.put("versions", new ArrayList<String>()); |
|
90 |
modules.get(groupId).put(name, map); |
|
91 |
} else { |
|
92 |
// Artifact already found |
|
93 |
modules.get(groupId).get(name).put("warning", "1"); |
|
94 |
} |
|
95 |
((List<String>) modules.get(groupId).get(name).get("versions")).add(version); |
|
96 |
((List<String>) modules.get(groupId).get(name).get("files")).add(res.getURI().toString()); |
|
97 |
} catch (Exception e) { |
|
98 |
log.error("Error evaluating pom: " + res.getURI()); |
|
99 |
log.debug("-- ERROR --", e); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
final List<Map<String, Object>> list = Lists.newArrayList(); |
|
104 |
for (Entry<String, Map<String, Map<String, Object>>> e : modules.entrySet()) { |
|
105 |
for (Entry<String, Map<String, Object>> e1 : e.getValue().entrySet()) { |
|
106 |
list.add(e1.getValue()); |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
Collections.sort(list, new Comparator<Map<String, Object>>() { |
|
111 |
|
|
112 |
@Override |
|
113 |
public int compare(final Map<String, Object> o1, final Map<String, Object> o2) { |
|
114 |
if (o1.get("group").equals(o2.get("group"))) { |
|
115 |
return o1.get("name").toString().compareTo(o2.get("name").toString()); |
|
116 |
} else { |
|
117 |
return o1.get("group").toString().compareTo(o2.get("group").toString()); |
|
118 |
} |
|
119 |
} |
|
120 |
}); |
|
121 |
|
|
122 |
return list; |
|
123 |
} |
|
124 |
|
|
125 |
private Map<String, String> getSysInfo(final RuntimeMXBean mxbean) { |
|
126 |
return mxbean.getSystemProperties(); |
|
127 |
} |
|
128 |
|
|
129 |
private Map<String, String> getGeneralInfo(final RuntimeMXBean mxbean) { |
|
130 |
final Map<String, String> genInfo = Maps.newLinkedHashMap(); |
|
131 |
genInfo.put("Hostname", hostname); |
|
132 |
genInfo.put("Port", port); |
|
133 |
genInfo.put("Context", context); |
|
134 |
genInfo.put("Uptime", HumanTime.exactly(mxbean.getUptime())); |
|
135 |
genInfo.put("Start Time", DateUtils.calculate_ISO8601(mxbean.getStartTime())); |
|
136 |
return genInfo; |
|
137 |
} |
|
138 |
|
|
139 |
private Map<String, String> getJvmInfo(final RuntimeMXBean mxbean) { |
|
140 |
final Map<String, String> jvmInfo = Maps.newLinkedHashMap(); |
|
141 |
jvmInfo.put("JVM Name", mxbean.getVmName()); |
|
142 |
jvmInfo.put("JVM Vendor", mxbean.getVmVendor()); |
|
143 |
jvmInfo.put("JVM Version", mxbean.getVmVersion()); |
|
144 |
jvmInfo.put("JVM Spec Name", mxbean.getSpecName()); |
|
145 |
jvmInfo.put("JVM Spec Vendor", mxbean.getSpecVendor()); |
|
146 |
jvmInfo.put("JVM Spec Version", mxbean.getSpecVersion()); |
|
147 |
jvmInfo.put("Running JVM Name", mxbean.getName()); |
|
148 |
jvmInfo.put("Management Spec Version", mxbean.getManagementSpecVersion()); |
|
149 |
return jvmInfo; |
|
150 |
} |
|
151 |
|
|
152 |
private Map<String, String> getLibInfo(final RuntimeMXBean mxbean) { |
|
153 |
final Map<String, String> libInfo = Maps.newLinkedHashMap(); |
|
154 |
libInfo.put("Classpath", mxbean.getClassPath().replaceAll(":", " : ")); |
|
155 |
libInfo.put("Boot ClassPath", mxbean.getBootClassPath().replaceAll(":", " : ")); |
|
156 |
libInfo.put("Input arguments", mxbean.getInputArguments().toString()); |
|
157 |
libInfo.put("Library Path", mxbean.getLibraryPath().replaceAll(":", " : ")); |
|
158 |
return libInfo; |
|
159 |
} |
|
160 |
|
|
161 |
public String getHostname() { |
|
162 |
return hostname; |
|
163 |
} |
|
164 |
|
|
165 |
@Required |
|
166 |
public void setHostname(final String hostname) { |
|
167 |
this.hostname = hostname; |
|
168 |
} |
|
169 |
|
|
170 |
public String getPort() { |
|
171 |
return port; |
|
172 |
} |
|
173 |
|
|
174 |
@Required |
|
175 |
public void setPort(final String port) { |
|
176 |
this.port = port; |
|
177 |
} |
|
178 |
|
|
179 |
public String getContext() { |
|
180 |
return context; |
|
181 |
} |
|
182 |
|
|
183 |
@Required |
|
184 |
public void setContext(final String context) { |
|
185 |
this.context = context; |
|
186 |
} |
|
187 |
|
|
188 |
@Override |
|
189 |
public void setResourceLoader(final ResourceLoader resourceLoader) { |
|
190 |
this.resourceLoader = resourceLoader; |
|
191 |
} |
|
192 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/model/Term.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.vocabularies.model; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
public class Term implements Comparable<Term> { |
|
7 |
private String englishName; |
|
8 |
private String nativeName; |
|
9 |
private String encoding; |
|
10 |
private String code; |
|
11 |
private List<Synonym> synonyms = new ArrayList<Synonym>(); |
|
12 |
private List<Relation> relations = new ArrayList<Relation>(); |
|
13 |
|
|
14 |
public Term() {} |
|
15 |
|
|
16 |
public Term(String englishName, String nativeName, String encoding, |
|
17 |
String code, List<Synonym> synonyms, List<Relation> relations) { |
|
18 |
super(); |
|
19 |
this.englishName = englishName; |
|
20 |
this.nativeName = nativeName; |
|
21 |
this.encoding = encoding; |
|
22 |
this.code = code; |
|
23 |
this.synonyms = synonyms; |
|
24 |
this.relations = relations; |
|
25 |
} |
|
26 |
|
|
27 |
public String getEnglishName() { |
|
28 |
return englishName; |
|
29 |
} |
|
30 |
|
|
31 |
public void setEnglishName(String englishName) { |
|
32 |
this.englishName = englishName; |
|
33 |
} |
|
34 |
|
|
35 |
public String getNativeName() { |
|
36 |
return nativeName; |
|
37 |
} |
|
38 |
|
|
39 |
public void setNativeName(String nativeName) { |
|
40 |
this.nativeName = nativeName; |
|
41 |
} |
|
42 |
|
|
43 |
public String getEncoding() { |
|
44 |
return encoding; |
|
45 |
} |
|
46 |
|
|
47 |
public void setEncoding(String encoding) { |
|
48 |
this.encoding = encoding; |
|
49 |
} |
|
50 |
|
|
51 |
public String getCode() { |
|
52 |
return code; |
|
53 |
} |
|
54 |
|
|
55 |
public void setCode(String code) { |
|
56 |
this.code = code; |
|
57 |
} |
|
58 |
|
|
59 |
public List<Synonym> getSynonyms() { |
|
60 |
return synonyms; |
|
61 |
} |
|
62 |
|
|
63 |
public void setSynonyms(List<Synonym> synonyms) { |
|
64 |
this.synonyms = synonyms; |
|
65 |
} |
|
66 |
|
|
67 |
public List<Relation> getRelations() { |
|
68 |
return relations; |
|
69 |
} |
|
70 |
|
|
71 |
public void setRelations(List<Relation> relations) { |
|
72 |
this.relations = relations; |
|
73 |
} |
|
74 |
|
|
75 |
@Override |
|
76 |
public int compareTo(Term o) { |
|
77 |
return englishName.compareTo(o.getEnglishName()); |
|
78 |
} |
|
79 |
|
|
80 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/model/Vocabulary.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.vocabularies.model; |
|
2 |
|
|
3 |
public class Vocabulary implements Comparable<Vocabulary> { |
|
4 |
private String id; |
|
5 |
private String name; |
|
6 |
private String description; |
|
7 |
private String code; |
|
8 |
|
|
9 |
public Vocabulary() {} |
|
10 |
|
|
11 |
public Vocabulary(String id, String name, String description, String code) { |
|
12 |
super(); |
|
13 |
this.id = id; |
|
14 |
this.name = name; |
|
15 |
this.description = description; |
|
16 |
this.code = code; |
|
17 |
} |
|
18 |
|
|
19 |
public String getId() { |
|
20 |
return id; |
|
21 |
} |
|
22 |
|
|
23 |
public void setId(String id) { |
|
24 |
this.id = id; |
|
25 |
} |
|
26 |
|
|
27 |
public String getName() { |
|
28 |
return name; |
|
29 |
} |
|
30 |
|
|
31 |
public void setName(String name) { |
|
32 |
this.name = name; |
|
33 |
} |
|
34 |
|
|
35 |
public String getDescription() { |
|
36 |
return description; |
|
37 |
} |
|
38 |
|
|
39 |
public void setDescription(String description) { |
|
40 |
this.description = description; |
|
41 |
} |
|
42 |
|
|
43 |
public String getCode() { |
|
44 |
return code; |
|
45 |
} |
|
46 |
|
|
47 |
public void setCode(String code) { |
|
48 |
this.code = code; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public int compareTo(Vocabulary o) { |
|
53 |
return name.compareTo(o.getName()); |
|
54 |
} |
|
55 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/model/Synonym.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.vocabularies.model; |
|
2 |
|
|
3 |
public class Synonym implements Comparable<Synonym> { |
|
4 |
private String term; |
|
5 |
private String encoding; |
|
6 |
|
|
7 |
public Synonym() {} |
|
8 |
|
|
9 |
public Synonym(String term, String encoding) { |
|
10 |
super(); |
|
11 |
this.term = term; |
|
12 |
this.encoding = encoding; |
|
13 |
} |
|
14 |
|
|
15 |
public String getTerm() { |
|
16 |
return term; |
|
17 |
} |
|
18 |
|
|
19 |
public void setTerm(String term) { |
|
20 |
this.term = term; |
|
21 |
} |
|
22 |
|
|
23 |
public String getEncoding() { |
|
24 |
return encoding; |
|
25 |
} |
|
26 |
|
|
27 |
public void setEncoding(String encoding) { |
|
28 |
this.encoding = encoding; |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
public int compareTo(Synonym o) { |
|
33 |
return term.compareTo(o.getTerm()); |
|
34 |
} |
|
35 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/model/Relation.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.vocabularies.model; |
|
2 |
|
|
3 |
public class Relation implements Comparable<Relation> { |
|
4 |
|
|
5 |
private String type; |
|
6 |
private String code; |
|
7 |
|
|
8 |
public Relation() {} |
|
9 |
|
|
10 |
public Relation(final String type, final String code) { |
|
11 |
super(); |
|
12 |
this.type = type; |
|
13 |
this.code = code; |
|
14 |
} |
|
15 |
|
|
16 |
public String getType() { |
|
17 |
return type; |
|
18 |
} |
|
19 |
|
|
20 |
public void setType(final String type) { |
|
21 |
this.type = type; |
|
22 |
} |
|
23 |
|
|
24 |
@Override |
|
25 |
public int compareTo(final Relation o) { |
|
26 |
return code.compareTo(o.getCode()); |
|
27 |
} |
|
28 |
|
|
29 |
public String getCode() { |
|
30 |
return code; |
|
31 |
} |
|
32 |
|
|
33 |
public void setCode(final String code) { |
|
34 |
this.code = code; |
|
35 |
} |
|
36 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/persistence/RegistryServiceVocabularyDAO.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.vocabularies.persistence; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Collections; |
|
7 |
import java.util.List; |
|
8 |
import java.util.Map; |
|
9 |
|
|
10 |
import com.google.common.collect.Lists; |
|
11 |
import com.google.common.collect.Maps; |
|
12 |
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Relation; |
|
13 |
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Synonym; |
|
14 |
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Term; |
|
15 |
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Vocabulary; |
|
16 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
17 |
import eu.dnetlib.rmi.enabling.*; |
|
18 |
import org.antlr.stringtemplate.StringTemplate; |
|
19 |
import org.apache.commons.io.IOUtils; |
|
20 |
import org.apache.commons.lang3.StringEscapeUtils; |
|
21 |
import org.dom4j.Document; |
|
22 |
import org.dom4j.DocumentException; |
|
23 |
import org.dom4j.Element; |
|
24 |
import org.dom4j.io.SAXReader; |
|
25 |
|
|
26 |
public class RegistryServiceVocabularyDAO extends VocabularyDAO { |
|
27 |
|
|
28 |
@Override |
|
29 |
public List<Vocabulary> getVocabularies() throws VocabularyException { |
|
30 |
try { |
|
31 |
final String query = |
|
32 |
"for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType') order by $x//VOCABULARY_NAME " |
|
33 |
+ "return concat ($x//RESOURCE_IDENTIFIER/@value,' §§§ ',$x//VOCABULARY_NAME,' §§§ ',$x//VOCABULARY_DESCRIPTION,' §§§ ',$x//VOCABULARY_NAME/@code)"; |
|
34 |
|
|
35 |
final List<Vocabulary> vocabularies = Lists.transform(this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query), |
|
36 |
s -> { |
|
37 |
final String[] tokens = s.split("§§§"); |
|
38 |
return new Vocabulary(tokens[0].trim(), tokens[1].trim(), tokens[2].trim(), tokens[3].trim()); |
|
39 |
}); |
|
40 |
return vocabularies; |
|
41 |
} catch (final ISLookUpException e) { |
|
42 |
throw new VocabularyException(e); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public List<Term> getTerms(final String vocabularyId) throws VocabularyException { |
|
48 |
try { |
|
49 |
final String profile = this.serviceLocator.getService(ISLookUpService.class).getResourceProfile(vocabularyId); |
|
50 |
final Document doc = new SAXReader().read(new StringReader(profile)); |
|
51 |
final Map<String, Term> terms = Maps.newHashMap(); |
|
52 |
|
|
53 |
for (final Object t : doc.selectNodes("//TERM")) { |
|
54 |
final Element termNode = (Element) t; |
|
55 |
final String code = termNode.valueOf("@code"); |
|
56 |
|
|
57 |
if (!terms.containsKey(code)) { |
|
58 |
final Term term = new Term(); |
|
59 |
term.setEnglishName(termNode.valueOf("@english_name")); |
|
60 |
term.setNativeName(termNode.valueOf("@native_name")); |
|
61 |
term.setEncoding(termNode.valueOf("@encoding")); |
|
62 |
term.setCode(code); |
|
63 |
term.setSynonyms(new ArrayList<Synonym>()); |
|
64 |
term.setRelations(new ArrayList<Relation>()); |
|
65 |
terms.put(code, term); |
|
66 |
} |
|
67 |
final Term term = terms.get(code); |
|
68 |
|
|
69 |
for (final Object s : termNode.selectNodes(".//SYNONYM")) { |
|
70 |
final Element synNode = (Element) s; |
|
71 |
final Synonym syn = new Synonym(); |
|
72 |
syn.setTerm(synNode.valueOf("@term")); |
|
73 |
syn.setEncoding(synNode.valueOf("@encoding")); |
|
74 |
term.getSynonyms().add(syn); |
|
75 |
} |
|
76 |
|
|
77 |
for (final Object r : termNode.selectNodes(".//RELATION")) { |
|
78 |
final Element relNode = (Element) r; |
|
79 |
final Relation rel = new Relation(); |
|
80 |
rel.setCode(relNode.valueOf("@code")); |
|
81 |
rel.setType(relNode.valueOf("@type")); |
|
82 |
term.getRelations().add(rel); |
|
83 |
} |
|
84 |
|
|
85 |
Collections.sort(term.getSynonyms()); |
|
86 |
Collections.sort(term.getRelations()); |
|
87 |
} |
|
88 |
|
|
89 |
final List<Term> list = Lists.newArrayList(terms.values()); |
|
90 |
Collections.sort(list); |
|
91 |
|
|
92 |
return list; |
|
93 |
} catch (final ISLookUpDocumentNotFoundException e) { |
|
94 |
throw new VocabularyException(e); |
|
95 |
} catch (final ISLookUpException e) { |
|
96 |
throw new VocabularyException(e); |
|
97 |
} catch (final DocumentException e) { |
|
98 |
throw new VocabularyException(e); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public void commitTerms(final List<Term> terms, final String vocabularyId) throws VocabularyException { |
|
104 |
try { |
|
105 |
// prepare terms for XML |
|
106 |
for (final Term t : terms) { |
|
107 |
t.setCode(StringEscapeUtils.escapeXml11(t.getCode())); |
|
108 |
t.setEncoding(StringEscapeUtils.escapeXml11(t.getEncoding())); |
|
109 |
t.setEnglishName(StringEscapeUtils.escapeXml11(t.getEnglishName())); |
|
110 |
t.setNativeName(StringEscapeUtils.escapeXml11(t.getNativeName())); |
|
111 |
for (final Synonym s : t.getSynonyms()) { |
|
112 |
s.setEncoding(StringEscapeUtils.escapeXml11(s.getEncoding())); |
|
113 |
s.setTerm(StringEscapeUtils.escapeXml11(s.getTerm())); |
|
114 |
} |
|
115 |
for (final Relation r : t.getRelations()) { |
|
116 |
r.setType(StringEscapeUtils.escapeXml11(r.getType())); |
|
117 |
r.setCode(StringEscapeUtils.escapeXml11(r.getCode())); |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
final StringTemplate st = |
|
122 |
new StringTemplate(IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/templates/terms.xml.st"))); |
|
123 |
st.setAttribute("terms", terms); |
|
124 |
this.serviceLocator.getService(ISRegistryService.class).updateProfileNode(vocabularyId, "//TERMS", st.toString()); |
|
125 |
} catch (final IOException e) { |
|
126 |
throw new VocabularyException(e); |
|
127 |
} catch (final ISRegistryException e) { |
|
128 |
throw new VocabularyException(e); |
|
129 |
} |
|
130 |
|
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public void commitVocabularyInfo(final Vocabulary voc, final String vocabularyId) throws VocabularyException { |
|
135 |
try { |
|
136 |
String xml = "<VOCABULARY_DESCRIPTION>{desc}</VOCABULARY_DESCRIPTION>"; |
|
137 |
xml = xml.replace("{desc}", StringEscapeUtils.escapeXml11(voc.getDescription())); |
|
138 |
this.serviceLocator.getService(ISRegistryService.class).updateProfileNode(vocabularyId, "//VOCABULARY_DESCRIPTION", xml); |
|
139 |
} catch (final ISRegistryException e) { |
|
140 |
throw new VocabularyException(e); |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
@Override |
|
145 |
public String createVocabulary(final Vocabulary voc) throws VocabularyException { |
|
146 |
try { |
|
147 |
final StringTemplate st = new StringTemplate( |
|
148 |
IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/templates/vocabulary.xml.st"))); |
|
149 |
st.setAttribute("name", voc.getName()); |
|
150 |
st.setAttribute("description", voc.getDescription()); |
|
151 |
st.setAttribute("code", voc.getCode()); |
|
152 |
st.setAttribute("date", DateUtils.now_ISO8601()); |
|
153 |
final String newVocabularyId = this.serviceLocator.getService(ISRegistryService.class).registerProfile(st.toString()); |
|
154 |
|
|
155 |
return newVocabularyId; |
|
156 |
} catch (final IOException e) { |
|
157 |
throw new VocabularyException(e); |
|
158 |
} catch (final ISRegistryException e) { |
|
159 |
throw new VocabularyException(e); |
|
160 |
} |
|
161 |
} |
|
162 |
|
|
163 |
@Override |
|
164 |
public void dropVocabulary(final String vocabularyId) throws VocabularyException { |
|
165 |
try { |
|
166 |
this.serviceLocator.getService(ISRegistryService.class).deleteProfile(vocabularyId); |
|
167 |
} catch (final ISRegistryDocumentNotFoundException e) { |
|
168 |
throw new VocabularyException(e); |
|
169 |
} catch (final ISRegistryException e) { |
|
170 |
throw new VocabularyException(e); |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/persistence/VocabularyException.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.vocabularies.persistence; |
|
2 |
|
|
3 |
|
|
4 |
public class VocabularyException extends Exception { |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
*/ |
|
9 |
private static final long serialVersionUID = 1L; |
|
10 |
|
|
11 |
Exception exception; |
|
12 |
|
|
13 |
public VocabularyException(final Exception e) { |
|
14 |
this.exception = e; |
|
15 |
} |
|
16 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/persistence/VocabularyDAO.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.vocabularies.persistence; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
6 |
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Term; |
|
7 |
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Vocabulary; |
|
8 |
import org.springframework.beans.factory.annotation.Autowired; |
|
9 |
|
|
10 |
public abstract class VocabularyDAO { |
|
11 |
|
|
12 |
@Autowired |
|
13 |
protected UniqueServiceLocator serviceLocator; |
|
14 |
|
|
15 |
public abstract List<Vocabulary> getVocabularies() throws VocabularyException; |
|
16 |
|
|
17 |
public abstract List<Term> getTerms(final String vocabularyId) throws VocabularyException; |
|
18 |
|
|
19 |
public abstract void commitTerms(final List<Term> terms, final String vocabularyId) throws VocabularyException; |
|
20 |
|
|
21 |
public abstract void commitVocabularyInfo(final Vocabulary voc, final String vocabularyId) throws VocabularyException; |
|
22 |
|
|
23 |
public abstract String createVocabulary(final Vocabulary voc) throws VocabularyException; |
|
24 |
|
|
25 |
public abstract void dropVocabulary(final String vocabularyId) throws VocabularyException; |
|
26 |
|
|
27 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/controllers/EntryPointController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.vocabularies.controllers; |
|
2 |
|
|
3 |
import javax.servlet.http.HttpServletRequest; |
|
4 |
import javax.servlet.http.HttpServletResponse; |
|
5 |
|
|
6 |
import org.apache.commons.io.IOUtils; |
|
7 |
import org.springframework.ui.ModelMap; |
|
8 |
|
|
9 |
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint; |
|
10 |
|
|
11 |
public class EntryPointController extends ModuleEntryPoint { |
|
12 |
|
|
13 |
@Override |
|
14 |
protected void initialize(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws Exception { |
|
15 |
map.addAttribute("validRelations", IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/ui/term_relations.json"))); |
|
16 |
} |
|
17 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/controllers/VocabulariesController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.vocabularies.controllers; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import javax.annotation.Resource; |
|
6 |
|
|
7 |
import org.apache.commons.logging.Log; |
|
8 |
import org.apache.commons.logging.LogFactory; |
|
9 |
import org.springframework.stereotype.Controller; |
|
10 |
import org.springframework.web.bind.annotation.RequestBody; |
|
11 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
12 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
13 |
import org.springframework.web.bind.annotation.RequestParam; |
|
14 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
15 |
|
|
16 |
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Term; |
|
17 |
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Vocabulary; |
|
18 |
import eu.dnetlib.functionality.modular.ui.vocabularies.persistence.VocabularyDAO; |
|
19 |
import eu.dnetlib.functionality.modular.ui.vocabularies.persistence.VocabularyException; |
|
20 |
|
|
21 |
/** |
|
22 |
* Web controller for the UI |
|
23 |
* |
|
24 |
* @author Andrea Mannocci |
|
25 |
*/ |
|
26 |
@Controller |
|
27 |
public class VocabulariesController extends VocabularyDAO { |
|
28 |
|
|
29 |
private static final Log log = LogFactory.getLog(VocabulariesController.class); |
|
30 |
|
|
31 |
@Resource(name = "vocabularyDao") |
|
32 |
private VocabularyDAO dao; |
|
33 |
|
|
34 |
/** |
|
35 |
* Returns all vocabularies serialized in json. Invoked by angularJS |
|
36 |
*/ |
|
37 |
@Override |
|
38 |
@RequestMapping("/ui/vocabularies.json") |
|
39 |
public @ResponseBody List<Vocabulary> getVocabularies() throws VocabularyException { |
|
40 |
log.info("vocabularies.json"); |
|
41 |
return dao.getVocabularies(); |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* Returns all terms and their synonyms belonging to a vocabulary. Invoked by AngularJS |
|
46 |
*/ |
|
47 |
@Override |
|
48 |
@RequestMapping("/ui/terms.json") |
|
49 |
public @ResponseBody List<Term> getTerms(@RequestParam(value = "vocabularyId", required = true) final String vocabularyId) throws VocabularyException { |
|
50 |
log.info("terms.json?vocabularyId=" + vocabularyId); |
|
51 |
return dao.getTerms(vocabularyId); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
@RequestMapping(value = "/ui/commitVocabulary", method = RequestMethod.POST) |
|
56 |
public @ResponseBody void commitTerms(@RequestBody(required = true) final List<Term> terms, |
|
57 |
@RequestParam(value = "vocabularyId", required = true) final String vocabularyId) throws VocabularyException { |
|
58 |
log.info("committing vocabulary id = " + vocabularyId); |
|
59 |
dao.commitTerms(terms, vocabularyId); |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
@RequestMapping(value = "/ui/commitVocabularyInfo", method = RequestMethod.POST) |
|
64 |
public @ResponseBody void commitVocabularyInfo(@RequestBody(required = true) final Vocabulary voc, |
|
65 |
@RequestParam(value = "vocabularyId", required = true) final String vocabularyId) throws VocabularyException { |
|
66 |
log.info("committing vocabulary info id = " + vocabularyId); |
|
67 |
dao.commitVocabularyInfo(voc, vocabularyId); |
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
@RequestMapping(value = "/ui/createVocabulary", method = RequestMethod.POST) |
|
72 |
public @ResponseBody String createVocabulary(@RequestBody(required = true) final Vocabulary voc) throws VocabularyException { |
|
73 |
log.info("create vocabulary"); |
|
74 |
String vocId = dao.createVocabulary(voc); |
|
75 |
return vocId; |
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
@RequestMapping(value = "/ui/dropVocabulary", method = RequestMethod.GET) |
|
80 |
public @ResponseBody void dropVocabulary(@RequestParam(value = "vocabularyId", required = true) final String vocabularyId) throws VocabularyException { |
|
81 |
log.info("delete vocabulary id=" + vocabularyId); |
|
82 |
dao.dropVocabulary(vocabularyId); |
|
83 |
} |
|
84 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/DnetLogController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.Enumeration; |
|
5 |
|
|
6 |
import javax.servlet.http.HttpServletRequest; |
|
7 |
import javax.servlet.http.HttpServletResponse; |
|
8 |
|
|
9 |
import org.apache.log4j.FileAppender; |
|
10 |
import org.apache.log4j.LogManager; |
|
11 |
import org.apache.log4j.Logger; |
|
12 |
import org.springframework.ui.ModelMap; |
|
13 |
|
|
14 |
public class DnetLogController extends ModuleEntryPoint { |
|
15 |
|
|
16 |
@Override |
|
17 |
protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception { |
|
18 |
map.addAttribute("logFile", getLogFileName()); |
|
19 |
} |
|
20 |
|
|
21 |
public static String getLogFileName() { |
|
22 |
final Logger logger = LogManager.getRootLogger(); |
|
23 |
final Enumeration<?> appenders = logger.getAllAppenders(); |
|
24 |
while (appenders.hasMoreElements()) { |
|
25 |
final Object app = appenders.nextElement(); |
|
26 |
if (app instanceof FileAppender) { return new File(((FileAppender) app).getFile()).getAbsolutePath(); } |
|
27 |
} |
|
28 |
return ""; |
|
29 |
} |
|
30 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/EntryPointsAggregator.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui; |
|
2 |
|
|
3 |
import java.util.*; |
|
4 |
|
|
5 |
import com.google.common.collect.Sets; |
|
6 |
import eu.dnetlib.functionality.modular.ui.users.AccessLimited; |
|
7 |
import eu.dnetlib.functionality.modular.ui.users.PermissionLevel; |
|
8 |
import eu.dnetlib.functionality.modular.ui.users.User; |
|
9 |
import org.springframework.beans.factory.annotation.Autowired; |
|
10 |
|
|
11 |
public class EntryPointsAggregator { |
|
12 |
|
|
13 |
@Autowired(required=false) |
|
14 |
private List<ModuleEntryPoint> entryPoints = new ArrayList<>(); |
|
15 |
|
|
16 |
@Autowired(required=false) |
|
17 |
private List<AbstractMenu> otherMenus = new ArrayList<>(); |
|
18 |
|
|
19 |
public List<ModuleEntryPoint> getEntryPoints() { |
|
20 |
return entryPoints; |
|
21 |
} |
|
22 |
|
|
23 |
public void setEntryPoints(List<ModuleEntryPoint> entryPoints) { |
|
24 |
this.entryPoints = entryPoints; |
|
25 |
} |
|
26 |
|
|
27 |
public List<AbstractMenu> getMenus(User user) { |
|
28 |
final Map<String, ModulesMenu> map = new HashMap<>(); |
|
29 |
|
|
30 |
for (ModuleEntryPoint entry : entryPoints) { |
|
31 |
if (entry.isValidMenuEntry() && verifyAuthorization(entry, user)) { |
|
32 |
final String group = entry.getGroup(); |
|
33 |
if (!map.containsKey(group)) { |
|
34 |
map.put(group, new ModulesMenu(group)); |
|
35 |
} |
|
36 |
map.get(group).addEntry(entry); |
|
37 |
} |
|
38 |
} |
|
39 |
final List<AbstractMenu> items = new ArrayList<>(); |
|
40 |
|
|
41 |
for (AbstractMenu menu : otherMenus) { |
|
42 |
if (menu instanceof AccessLimited) { |
|
43 |
if (verifyAuthorization((AccessLimited) menu, user) && menu.getEntries().size() > 0) { |
|
44 |
items.add(menu); |
|
45 |
} |
|
46 |
} else if (menu.getEntries().size() > 0) { |
|
47 |
items.add(menu); |
|
48 |
} |
|
49 |
} |
|
50 |
|
|
51 |
for (ModulesMenu item : map.values()) { |
|
52 |
item.complete(); |
|
53 |
items.add(item); |
|
54 |
} |
|
55 |
|
|
56 |
Collections.sort(items); |
|
57 |
return items; |
|
58 |
} |
|
59 |
|
|
60 |
private boolean verifyAuthorization(AccessLimited entry, User user) { |
|
61 |
if (user.getPermissionLevels().contains(PermissionLevel.SUPER_ADMIN)) return true; |
|
62 |
return (Sets.intersection(user.getPermissionLevels(), entry.getPermissionLevels()).size() > 0); |
|
63 |
} |
|
64 |
|
|
65 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/UsersInternalController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.Collections; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
import java.util.Set; |
|
8 |
|
|
9 |
import javax.annotation.Resource; |
|
10 |
import javax.servlet.http.HttpServletResponse; |
|
11 |
|
|
12 |
import org.apache.commons.logging.Log; |
|
13 |
import org.apache.commons.logging.LogFactory; |
|
14 |
import org.springframework.stereotype.Controller; |
|
15 |
import org.springframework.web.bind.annotation.RequestBody; |
|
16 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
17 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
18 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
19 |
|
|
20 |
import com.google.common.collect.Lists; |
|
21 |
import com.google.common.collect.Maps; |
|
22 |
|
|
23 |
import eu.dnetlib.functionality.modular.ui.users.AuthorizationDAO; |
|
24 |
import eu.dnetlib.functionality.modular.ui.users.PermissionLevel; |
|
25 |
import eu.dnetlib.functionality.modular.ui.users.User; |
|
26 |
|
|
27 |
@Controller |
|
28 |
public class UsersInternalController { |
|
29 |
|
|
30 |
@Resource(name="modularUiAuthorizationDao") |
|
31 |
private AuthorizationDAO dao; |
|
32 |
|
|
33 |
private static final Log log = LogFactory.getLog(UsersInternalController.class); |
|
34 |
|
|
35 |
@RequestMapping(value = "/ui/users.get") |
|
36 |
public @ResponseBody List<User> listUsers(HttpServletResponse response) throws IOException { |
|
37 |
final List<User> list = Lists.newArrayList(); |
|
38 |
for (Map.Entry<String, Set<PermissionLevel>> e : dao.getPermissionLevels().entrySet()) { |
|
39 |
final User user = new User(e.getKey()); |
|
40 |
user.setPermissionLevels(e.getValue()); |
|
41 |
list.add(user); |
|
42 |
} |
|
43 |
Collections.sort(list); |
|
44 |
|
|
45 |
return list; |
|
46 |
} |
|
47 |
|
|
48 |
@RequestMapping(value = "/ui/saveusers.do", method=RequestMethod.POST) |
|
49 |
public @ResponseBody boolean updateUsers(@RequestBody final List<User> users) { |
|
50 |
|
|
51 |
log.info("Saving " + users.size() + " user(s)"); |
|
52 |
final Map<String, Set<PermissionLevel>> map = Maps.newHashMap(); |
|
53 |
for (User u : users) { |
|
54 |
map.put(u.getId(), u.getPermissionLevels()); |
|
55 |
} |
|
56 |
dao.updatePermissionLevels(map); |
|
57 |
return true; |
|
58 |
} |
|
59 |
|
|
60 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/ContainerPropertiesController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
import java.util.Map.Entry; |
|
8 |
import java.util.Properties; |
|
9 |
|
|
10 |
import javax.servlet.http.HttpServletRequest; |
|
11 |
import javax.servlet.http.HttpServletResponse; |
|
12 |
|
|
13 |
import org.apache.commons.logging.Log; |
|
14 |
import org.apache.commons.logging.LogFactory; |
|
15 |
import org.springframework.beans.factory.annotation.Autowired; |
|
16 |
import org.springframework.core.io.Resource; |
|
17 |
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
|
18 |
import org.springframework.core.io.support.ResourcePatternResolver; |
|
19 |
import org.springframework.ui.ModelMap; |
|
20 |
|
|
21 |
import com.google.common.collect.Maps; |
|
22 |
|
|
23 |
import eu.dnetlib.conf.PropertyFetcher; |
|
24 |
import eu.dnetlib.conf.WebappContextPropertyLocationFactory; |
|
25 |
|
|
26 |
/** |
|
27 |
* Modular UI that displays collected properties and shows winning ones. |
|
28 |
* |
|
29 |
* @author Andrea Mannocci |
|
30 |
*/ |
|
31 |
public class ContainerPropertiesController extends ModuleEntryPoint { |
|
32 |
|
|
33 |
private static final Log log = LogFactory.getLog(ContainerPropertiesController.class); |
|
34 |
|
|
35 |
private final ResourcePatternResolver pathResolver = new PathMatchingResourcePatternResolver(); |
|
36 |
|
|
37 |
@Autowired |
|
38 |
private PropertyFetcher propertyFetcher; |
|
39 |
|
|
40 |
private Properties propertyFetcherProps; |
|
41 |
|
|
42 |
@Autowired |
|
43 |
private WebappContextPropertyLocationFactory propertyLocations; |
|
44 |
|
|
45 |
@Override |
|
46 |
protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception { |
|
47 |
this.propertyFetcherProps = this.propertyFetcher.getProps(); |
|
48 |
map.addAttribute("properties", fetchProperties()); |
|
49 |
} |
|
50 |
|
|
51 |
private Map<String, List<PropertyInfo>> fetchProperties() throws IOException { |
|
52 |
final Map<String, List<PropertyInfo>> propertiesMap = Maps.newTreeMap(); |
|
53 |
|
|
54 |
// cycle over all property locations know to dnet |
|
55 |
for (final String location : this.propertyLocations.getLocations()) { |
|
56 |
log.debug(String.format("Loading properties from %s", location)); |
|
57 |
// loop over all *.properties files matching the location |
|
58 |
for (final Resource propertyFile : this.pathResolver.getResources(location)) { |
|
59 |
final Properties properties = new Properties(); |
|
60 |
log.debug(String.format("URL: %s", propertyFile.getURL())); |
|
61 |
properties.load(propertyFile.getInputStream()); |
|
62 |
|
|
63 |
// loop over all properties set within a property file file |
|
64 |
for (final Entry<Object, Object> property : properties.entrySet()) { |
|
65 |
List<PropertyInfo> propertyInfoList; |
|
66 |
if (propertiesMap.containsKey(property.getKey())) { |
|
67 |
propertyInfoList = propertiesMap.get(property.getKey()); |
|
68 |
} else { |
|
69 |
propertyInfoList = new ArrayList<>(); |
|
70 |
} |
|
71 |
|
|
72 |
propertyInfoList.add(new PropertyInfo((String) property.getValue(), propertyFile.getFilename(), |
|
73 |
isWinning((String) property.getKey(), (String) property.getValue()))); |
|
74 |
propertiesMap.put((String) property.getKey(), propertyInfoList); |
|
75 |
} |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
// Scans the Map just created for properties overridden externally (e.g. by Tomcat) |
|
80 |
/* |
|
81 |
* for (String property : propertiesMap.keySet()) { List<PropertyInfo> propertyInfoList = propertiesMap.get(property); boolean |
|
82 |
* isOverridden = true; for (PropertyInfo propInfo : propertyInfoList) { // Checks for a checker if (propInfo.isChecked) { |
|
83 |
* isOverridden = false; } } |
|
84 |
* |
|
85 |
* // If none of the pairs has been checked, then the property has been overridden externally. if (isOverridden && |
|
86 |
* propertyFetcherProps.getProperty(property) != null) { // Adds the current property value (which is the override) as the current |
|
87 |
* one. propertyInfoList.add(new PropertyInfo(propertyFetcherProps.getProperty(property), "Overridden externally", true)); |
|
88 |
* propertiesMap.put(property, propertyInfoList); } } |
|
89 |
*/ |
|
90 |
|
|
91 |
return propertiesMap; |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Checks whether a given property-value is the one currently in use. |
|
96 |
* |
|
97 |
* @param property |
|
98 |
* The property key |
|
99 |
* @param value |
|
100 |
* The property value |
|
101 |
* @return true/false |
|
102 |
*/ |
|
103 |
private Boolean isWinning(final String property, final String value) { |
|
104 |
final String winningPropertyValue = this.propertyFetcherProps.getProperty(property); |
|
105 |
return value.equals(winningPropertyValue); |
|
106 |
} |
|
107 |
|
|
108 |
private class PropertyInfo { |
|
109 |
|
|
110 |
String value; |
|
111 |
String sourcePropertyFile; |
|
112 |
Boolean isChecked; |
|
113 |
|
|
114 |
public PropertyInfo(final String value, final String sourcePropertyFile, final Boolean isChecked) { |
|
115 |
this.value = value; |
|
116 |
this.sourcePropertyFile = sourcePropertyFile; |
|
117 |
this.isChecked = isChecked; |
|
118 |
} |
|
119 |
|
|
120 |
public String getValue() { |
|
121 |
return this.value; |
|
122 |
} |
|
123 |
|
|
124 |
public String getSourcePropertyFile() { |
|
125 |
return this.sourcePropertyFile; |
|
126 |
} |
|
127 |
|
|
128 |
public Boolean getIsChecked() { |
|
129 |
return this.isChecked; |
|
130 |
} |
|
131 |
} |
|
132 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/DnetLogAjaxController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.Enumeration; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.annotation.PostConstruct; |
|
8 |
|
|
9 |
import org.apache.commons.logging.Log; |
|
10 |
import org.apache.commons.logging.LogFactory; |
|
11 |
import org.apache.log4j.Level; |
|
12 |
import org.apache.log4j.LogManager; |
|
13 |
import org.apache.log4j.Logger; |
|
14 |
import org.springframework.stereotype.Controller; |
|
15 |
import org.springframework.web.bind.annotation.PathVariable; |
|
16 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
17 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
18 |
|
|
19 |
import eu.dnetlib.functionality.modular.ui.utils.LogLine; |
|
20 |
import eu.dnetlib.functionality.modular.ui.utils.LogUiAppender; |
|
21 |
|
|
22 |
@Controller |
|
23 |
public class DnetLogAjaxController extends AbstractAjaxController { |
|
24 |
|
|
25 |
private LogUiAppender appender; |
|
26 |
|
|
27 |
private static final Log log = LogFactory.getLog(DnetLogAjaxController.class); |
|
28 |
|
|
29 |
@PostConstruct |
|
30 |
void init() throws IOException { |
|
31 |
this.appender = findLogUiAppender(); |
|
32 |
} |
|
33 |
|
|
34 |
private LogUiAppender findLogUiAppender() { |
|
35 |
final Logger logger = LogManager.getRootLogger(); |
|
36 |
final Enumeration<?> appenders = logger.getAllAppenders(); |
|
37 |
while (appenders.hasMoreElements()) { |
|
38 |
final Object app = appenders.nextElement(); |
|
39 |
if (app instanceof LogUiAppender) { |
|
40 |
log.info("An istance of LogUiAppender is already registered in log4j configuration."); |
|
41 |
return (LogUiAppender) app; |
|
42 |
} |
|
43 |
} |
|
44 |
|
|
45 |
final LogUiAppender app = new LogUiAppender(); |
|
46 |
LogManager.getRootLogger().addAppender(app); |
|
47 |
|
|
48 |
log.info("A new LogUiAppender has been registered in log4j configuration."); |
|
49 |
|
|
50 |
return app; |
|
51 |
} |
|
52 |
|
|
53 |
@RequestMapping(value = "/ui/log/tail/{n}") |
|
54 |
public @ResponseBody List<LogLine> tail_N(@PathVariable(value = "n") final int n) throws Exception { |
|
55 |
return this.appender.tail_N(n); |
|
56 |
} |
|
57 |
|
|
58 |
@RequestMapping(value = "/ui/log/continue/{after}") |
|
59 |
public @ResponseBody List<LogLine> tail_continue(@PathVariable(value = "after") final int after) throws Exception { |
|
60 |
return tail_continue(after, 0); |
|
61 |
} |
|
62 |
|
|
63 |
private List<LogLine> tail_continue(final int after, final int recursionLevel) throws Exception { |
|
64 |
final List<LogLine> res = this.appender.tail_continue(after); |
|
65 |
if (res.isEmpty() && recursionLevel < 10) { |
|
66 |
Thread.sleep(10000); |
|
67 |
return tail_continue(after, recursionLevel + 1); |
|
68 |
} else { |
|
69 |
return res; |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
@RequestMapping(value = "/ui/log/level/{level}/{resource}") |
|
74 |
public @ResponseBody boolean updateLogLevel(@PathVariable(value = "level") final String level, @PathVariable(value = "resource") final String resource) |
|
75 |
throws Exception { |
|
76 |
if (resource != null && level != null) { |
|
77 |
LogManager.getLogger(resource).setLevel(Level.toLevel(level)); |
|
78 |
} |
|
79 |
return true; |
|
80 |
} |
|
81 |
|
|
82 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/UsersController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import javax.servlet.http.HttpServletRequest; |
|
7 |
import javax.servlet.http.HttpServletResponse; |
|
8 |
|
|
9 |
import org.springframework.ui.ModelMap; |
|
10 |
|
|
11 |
import com.google.common.collect.Lists; |
|
12 |
import com.google.common.collect.Maps; |
|
13 |
|
|
14 |
import eu.dnetlib.functionality.modular.ui.users.PermissionLevel; |
|
15 |
|
|
16 |
public class UsersController extends ModuleEntryPoint { |
|
17 |
|
|
18 |
private List<Map<String, String>> listAvailableLevels = Lists.newArrayList();; |
|
19 |
|
|
20 |
@Override |
|
21 |
protected void initialize(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws Exception { |
|
22 |
map.addAttribute("availableLevels", listPermissionLevels()); |
|
23 |
} |
|
24 |
|
|
25 |
private List<Map<String, String>> listPermissionLevels() { |
|
26 |
if (listAvailableLevels.isEmpty()) { |
|
27 |
for (PermissionLevel level : PermissionLevel.values()) { |
|
28 |
final Map<String, String> map = Maps.newHashMap(); |
|
29 |
map.put("level", level.toString()); |
|
30 |
map.put("label", level.getLabel()); |
|
31 |
map.put("details", level.getDetails()); |
|
32 |
listAvailableLevels.add(map); |
|
33 |
} |
|
34 |
} |
|
35 |
return listAvailableLevels; |
|
36 |
} |
|
37 |
|
|
38 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/controllers/RepoApisEntryPointController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.repositories.controllers; |
|
2 |
|
|
3 |
import javax.servlet.http.HttpServletRequest; |
|
4 |
import javax.servlet.http.HttpServletResponse; |
|
5 |
|
|
6 |
import com.google.gson.Gson; |
|
7 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
8 |
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint; |
|
9 |
import eu.dnetlib.functionality.modular.ui.repositories.util.RepoUIUtils; |
|
10 |
import eu.dnetlib.rmi.datasource.DatasourceManagerService; |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
import org.springframework.beans.factory.annotation.Required; |
|
13 |
import org.springframework.ui.ModelMap; |
|
14 |
|
|
15 |
public class RepoApisEntryPointController extends ModuleEntryPoint { |
|
16 |
|
|
17 |
@Autowired |
|
18 |
private UniqueServiceLocator serviceLocator; |
|
19 |
|
|
20 |
@Autowired |
|
21 |
private RepoUIUtils repoUIUtils; |
|
22 |
|
|
23 |
private String compatibilityLevelsVocabulary; |
|
24 |
|
|
25 |
@Override |
|
26 |
protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception { |
|
27 |
final Gson gson = new Gson(); |
|
28 |
map.addAttribute("compatibilityLevels", gson.toJson(this.repoUIUtils.fetchVocabularyTerms(getCompatibilityLevelsVocabulary()))); |
|
29 |
map.addAttribute("browseFields", gson.toJson(this.serviceLocator.getService(DatasourceManagerService.class).listBrowsableFields())); |
|
30 |
} |
|
31 |
|
|
32 |
public String getCompatibilityLevelsVocabulary() { |
|
33 |
return this.compatibilityLevelsVocabulary; |
|
34 |
} |
|
35 |
|
|
36 |
@Required |
|
37 |
public void setCompatibilityLevelsVocabulary(final String compatibilityLevelsVocabulary) { |
|
38 |
this.compatibilityLevelsVocabulary = compatibilityLevelsVocabulary; |
|
39 |
} |
|
40 |
|
|
41 |
} |
modules/dnet-modular-uis/branches/saxonHE-SOLR772/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/controllers/RepoInternalController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.repositories.controllers; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Map; |
|
6 |
import javax.annotation.Resource; |
|
7 |
|
|
8 |
import com.google.gson.Gson; |
|
9 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
10 |
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController; |
|
11 |
import eu.dnetlib.functionality.modular.ui.repositories.util.RepoUIUtils; |
|
12 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.sections.WorkflowSectionGrouper; |
|
13 |
import eu.dnetlib.msro.workflows.procs.WorkflowExecutor; |
|
14 |
import eu.dnetlib.rmi.data.CollectorService; |
|
15 |
import eu.dnetlib.rmi.data.CollectorServiceException; |
|
16 |
import eu.dnetlib.rmi.data.ProtocolParameterValue; |
|
17 |
import eu.dnetlib.rmi.datasource.*; |
|
18 |
import net.sf.ehcache.Cache; |
|
19 |
import net.sf.ehcache.Element; |
|
20 |
import org.apache.commons.lang3.StringUtils; |
|
21 |
import org.apache.commons.logging.Log; |
|
22 |
import org.apache.commons.logging.LogFactory; |
|
23 |
import org.springframework.beans.factory.annotation.Autowired; |
|
24 |
import org.springframework.stereotype.Controller; |
|
25 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
26 |
import org.springframework.web.bind.annotation.RequestParam; |
|
27 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
28 |
|
|
29 |
@Controller |
|
30 |
public class RepoInternalController extends AbstractAjaxController { |
|
31 |
|
|
32 |
private static final Log log = LogFactory.getLog(RepoInternalController.class); |
|
33 |
@Autowired |
|
34 |
private UniqueServiceLocator serviceLocator; |
|
35 |
@Autowired |
|
36 |
private WorkflowSectionGrouper workflowSectionGrouper; |
|
37 |
@Autowired |
|
38 |
private WorkflowExecutor workflowExecutor; |
|
39 |
@Autowired |
|
40 |
private RepoUIUtils repoUIUtils; |
|
41 |
@Resource(name = "repoUIJsonCache") |
|
42 |
private Cache repoUIJsonCache; |
|
43 |
|
|
44 |
@RequestMapping(value = "/ui/browseRepoField.do") |
|
45 |
public @ResponseBody List<BrowseTerm> browseRepoField(@RequestParam(value = "field", required = true) final String field) throws Exception { |
|
46 |
return this.serviceLocator.getService(DatasourceManagerService.class).browseField(field); |
|
47 |
} |
|
48 |
|
|
49 |
@SuppressWarnings("unchecked") |
|
50 |
@RequestMapping(value = "/ui/listApis.do") |
|
51 |
public @ResponseBody List<SearchInterfacesEntry> listApis( |
|
52 |
@RequestParam(value = "param", required = true) final String param, |
|
53 |
@RequestParam(value = "value", required = true) final String value, |
|
54 |
@RequestParam(value = "refresh", required = false) final String refresh) throws Exception { |
|
55 |
|
|
56 |
final String cacheKey = "list@@@" + param + "@@@" + value; |
|
57 |
|
|
58 |
final Element elem = this.repoUIJsonCache.get(cacheKey); |
|
59 |
|
|
60 |
if (elem != null && refresh == null) { |
|
61 |
return (List<SearchInterfacesEntry>) elem.getObjectValue(); |
|
62 |
} else { |
|
63 |
log.info("Refreshing " + cacheKey + " cache..."); |
|
64 |
final List<SearchInterfacesEntry> list = this.serviceLocator.getService(DatasourceManagerService.class).searchInterface(param, value); |
|
65 |
this.repoUIJsonCache.put(new Element(cacheKey, list)); |
|
66 |
return list; |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
@RequestMapping(value = "/ui/listRepositories.map") |
|
71 |
public @ResponseBody List<RepositoryMapEntry> listRepositories_asMap() throws Exception { |
|
72 |
return this.serviceLocator.getService(DatasourceManagerService.class).getRepositoryMap(); |
|
73 |
} |
|
74 |
|
|
75 |
@RequestMapping(value = "/ui/listRepositories.json") |
|
76 |
public @ResponseBody List<SimpleDatasourceDesc> listRepositories(@RequestParam(value = "type", required = true) final String type) throws Exception { |
|
77 |
return this.serviceLocator.getService(DatasourceManagerService.class).simpleListDatasourcesByType(type); |
|
78 |
} |
|
79 |
|
|
80 |
@SuppressWarnings("unchecked") |
|
81 |
@RequestMapping("/ui/repo/repoApi.update") |
|
82 |
public @ResponseBody boolean updateRepoApi( |
|
83 |
@RequestParam(value = "id", required = true) final String repoId, |
|
84 |
@RequestParam(value = "iface", required = true) final String ifaceId, |
|
85 |
@RequestParam(value = "accessParams", required = true) final String accessParamsJson) throws Exception { |
|
86 |
if (!StringUtils.isEmpty(accessParamsJson)) { |
|
87 |
this.serviceLocator.getService(DatasourceManagerService.class).bulkUpdateApiAccessParams(repoId, ifaceId, |
|
88 |
new Gson().fromJson(accessParamsJson, Map.class)); |
|
89 |
} |
|
90 |
return true; |
|
91 |
} |
|
92 |
|
|
93 |
@RequestMapping("/ui/repo/repoApiCompliance.update") |
|
94 |
public @ResponseBody boolean updateRepoApiCompliance(@RequestParam(value = "id", required = true) final String repoId, |
|
95 |
@RequestParam(value = "iface", required = true) final String ifaceId, |
|
96 |
@RequestParam(value = "compliance", required = true) final String compliance) throws Exception { |
|
97 |
|
|
98 |
log.debug("SET COMPLIANCE TO " + compliance); |
|
99 |
|
|
100 |
this.serviceLocator.getService(DatasourceManagerService.class).overrideCompliance(repoId, ifaceId, compliance); |
|
101 |
|
|
102 |
this.repoUIJsonCache.removeAll(); |
|
103 |
|
|
104 |
return true; |
|
105 |
} |
|
106 |
|
|
107 |
@RequestMapping("/ui/repo/repoApiCompliance.reset") |
|
108 |
public @ResponseBody boolean resetRepoApiCompliance(@RequestParam(value = "id", required = true) final String repoId, |
|
109 |
@RequestParam(value = "iface", required = true) final String ifaceId) throws Exception { |
|
110 |
|
|
111 |
log.debug("RESET COMPLIANCE"); |
|
112 |
|
|
113 |
this.serviceLocator.getService(DatasourceManagerService.class).overrideCompliance(repoId, ifaceId, null); |
|
114 |
|
|
115 |
this.repoUIJsonCache.removeAll(); |
|
116 |
|
|
117 |
return true; |
|
118 |
} |
|
119 |
|
|
120 |
@RequestMapping("/ui/repoApi.new") |
|
121 |
public @ResponseBody boolean addRepoApi(@RequestParam(value = "repoId", required = true) final String repoId, |
|
122 |
@RequestParam(value = "iface", required = true) final String ifaceJson) throws DatasourceManagerServiceException { |
|
123 |
final IfaceDesc iface = new Gson().fromJson(ifaceJson, IfaceDesc.class); |
|
124 |
|
|
125 |
log.info("Adding interface " + iface.getId() + " to repository " + repoId); |
|
126 |
|
|
127 |
final DatasourceManagerService dsManager = this.serviceLocator.getService(DatasourceManagerService.class); |
|
128 |
return dsManager.addInterface(repoId, iface); |
|
129 |
} |
|
130 |
|
|
131 |
@RequestMapping("/ui/repo.new") |
|
132 |
public @ResponseBody boolean addRepoApi(@RequestParam(value = "repo", required = true) final String repoJson) throws DatasourceManagerServiceException { |
|
133 |
final DatasourceDesc ds = new Gson().fromJson(repoJson, DatasourceDesc.class); |
|
134 |
ds.setDateOfCollection(new Date()); |
|
135 |
|
|
136 |
//This logic has been embedded when converting DatasourceDesc into a datasource XML profile in class eu.dnetlib.enabling.datasources.DatasourceDescToProfile |
|
137 |
// if (StringUtils.isBlank(ds.getEnglishName())) { |
|
138 |
// ds.setEnglishName(ds.getOfficialName()); |
|
139 |
// } |
|
140 |
|
|
141 |
log.info("Adding datasource " + ds.getId() + " - name " + ds.getOfficialName()); |
|
142 |
|
|
143 |
final DatasourceManagerService dsManager = this.serviceLocator.getService(DatasourceManagerService.class); |
|
144 |
|
|
145 |
return dsManager.addDatasource(ds); |
|
146 |
} |
|
147 |
|
|
148 |
@RequestMapping("/ui/listValidValuesForParam.do") |
|
149 |
public @ResponseBody List<ProtocolParameterValue> listValidValuesForParam( |
|
150 |
@RequestParam(value = "protocol", required = true) final String protocol, |
|
151 |
@RequestParam(value = "param", required = true) final String param, |
Also available in: Unified diff
branch for solr 772