Revision 49879
Added by Antonis Lempesis over 6 years ago
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/utils/EmailUtilsImpl.java | ||
---|---|---|
215 | 215 |
|
216 | 216 |
private void sendMail(List<String> recipients, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception { |
217 | 217 |
|
218 |
try { |
|
218 |
/* try {
|
|
219 | 219 |
if (sendToSpecial) { |
220 | 220 |
recipients.addAll(this.specialRecipients); |
221 | 221 |
} |
... | ... | |
233 | 233 |
} catch (Exception e) { |
234 | 234 |
LOGGER.error("Error sending mail to Recipients: " + recipients + " Subject: " + subject + " Message: " + message, e); |
235 | 235 |
throw new Exception(e); |
236 |
} |
|
236 |
}*/
|
|
237 | 237 |
} |
238 | 238 |
|
239 | 239 |
private String getEmailProperty(String key) { |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/services/RepositoryServiceImpl.java | ||
---|---|---|
11 | 11 |
import eu.dnetlib.repo.manager.client.services.RepositoryService; |
12 | 12 |
import eu.dnetlib.repo.manager.server.utils.EmailUtils; |
13 | 13 |
import eu.dnetlib.repo.manager.server.utils.LocalVocabularies; |
14 |
import eu.dnetlib.repo.manager.service.controllers.RepositoryApi; |
|
14 | 15 |
import eu.dnetlib.repo.manager.shared.*; |
15 | 16 |
import eu.dnetlib.repos.RepoApi; |
16 | 17 |
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader; |
... | ... | |
18 | 19 |
import org.apache.commons.lang.StringEscapeUtils; |
19 | 20 |
import org.apache.commons.lang.WordUtils; |
20 | 21 |
import org.apache.log4j.Logger; |
22 |
import org.json.JSONException; |
|
21 | 23 |
import org.springframework.beans.factory.annotation.Autowired; |
22 | 24 |
import org.springframework.beans.factory.annotation.Value; |
23 | 25 |
import org.springframework.core.ParameterizedTypeReference; |
... | ... | |
34 | 36 |
import javax.annotation.PostConstruct; |
35 | 37 |
import java.io.IOException; |
36 | 38 |
import java.io.UnsupportedEncodingException; |
37 |
import java.net.URL; |
|
38 | 39 |
import java.net.URLEncoder; |
39 | 40 |
import java.text.Normalizer; |
40 | 41 |
import java.util.*; |
41 | 42 |
import java.util.concurrent.ConcurrentHashMap; |
43 |
import java.net.URL; |
|
42 | 44 |
|
43 | 45 |
/** |
44 | 46 |
* Created by nikonas on 12/8/15. |
... | ... | |
101 | 103 |
"</noscript>\n" + |
102 | 104 |
"<!— End Piwik Code —>"); |
103 | 105 |
|
106 |
|
|
107 |
@Autowired |
|
108 |
private RepositoryApi repositoryApi; |
|
109 |
|
|
110 |
|
|
111 |
|
|
104 | 112 |
@PostConstruct |
105 | 113 |
public void init() { |
106 | 114 |
this.loadVocabularies(); |
... | ... | |
114 | 122 |
LOGGER.debug("Getting repositories of country: " + country + " with type: " + mode + " and includeUnknownCountries: " + includeUnknownCountries); |
115 | 123 |
|
116 | 124 |
Tuple<List<Repository>, List<Repository>> retTuple = new Tuple<List<Repository>, List<Repository>>(); |
117 |
List<Repository> reposList = this.repoAPI.getRepositoriesPerCountry(mode).get(country); |
|
125 |
// List<Repository> reposList = this.repoAPI.getRepositoriesPerCountry(mode).get(country); |
|
126 |
|
|
127 |
List<Repository> reposList = repositoryApi.getRepositoriesByCountry(country,mode); |
|
118 | 128 |
if (reposList == null) { |
119 | 129 |
retTuple.setFirst(new ArrayList<Repository>()); |
120 | 130 |
// if (!includeUnknownCountries) { |
... | ... | |
155 | 165 |
|
156 | 166 |
@Override |
157 | 167 |
public DatasourcesCollection getRepositoriesOfUser(String userEmail, boolean includeShared, boolean includeByOthers) throws RepositoryServiceException { |
168 |
|
|
169 |
DatasourcesCollection retDatasources = new DatasourcesCollection(); |
|
158 | 170 |
try { |
159 |
LOGGER.debug("Getting repositories of user: " + userEmail + " . IncludeShared: " + includeShared + " . IncludeByOthers: " + includeByOthers); |
|
160 |
DatasourcesCollection retDatasources = new DatasourcesCollection(); |
|
171 |
LOGGER.debug("Getting repositories of user: " + userEmail + " . IncludeShared: " |
|
172 |
+ includeShared + " . IncludeByOthers: " + includeByOthers); |
|
173 |
int page = 1; |
|
174 |
String size = "10"; |
|
175 |
List<Repository> resultSet = repositoryApi.getRepositoriesOfUser(userEmail,String.valueOf(page),size); |
|
176 |
while(resultSet.size() > 0 ){ |
|
177 |
retDatasources.getDatasourcesOfUser().addAll(resultSet); |
|
178 |
page++; |
|
179 |
resultSet = repositoryApi.getRepositoriesOfUser(userEmail,String.valueOf(page),size); |
|
180 |
} |
|
161 | 181 |
|
162 |
retDatasources.setDatasourcesOfUser(this.repoAPI.getRepositoriesOfUser(userEmail, false)); |
|
163 |
//geting Piwik Info |
|
164 |
for(Repository repository: retDatasources.getDatasourcesOfUser()) |
|
165 |
repository.setPiwikInfo(this.getPiwikSiteForRepository(repository.getId())); |
|
166 |
|
|
167 |
if (includeShared) { |
|
182 |
/* |
|
183 |
if (includeShared) { |
|
168 | 184 |
//TODO create dao to save-get shared datasourcesIDs |
169 | 185 |
List<String> sharedDatasourceIds = new ArrayList<String>(); |
170 | 186 |
retDatasources.setSharedDatasources(this.repoAPI.getReposByIds(sharedDatasourceIds)); |
... | ... | |
179 | 195 |
for(Repository repository: retDatasources.getDatasourcesOfOthers()) |
180 | 196 |
repository.setPiwikInfo(this.getPiwikSiteForRepository(repository.getId())); |
181 | 197 |
} |
182 |
|
|
183 |
return retDatasources; |
|
184 |
|
|
185 |
} catch (Exception e) { |
|
198 |
*/ |
|
199 |
} catch (JSONException e) { |
|
186 | 200 |
LOGGER.error("Error while getting repositories of user: " + userEmail + " . IncludeShared: " + includeShared + " . IncludeByOthers: " + includeByOthers, e); |
187 |
if (e instanceof RepositoryServiceException) { |
|
188 |
throw (RepositoryServiceException) e; |
|
189 |
} else { |
|
190 |
emailUtils.reportException(e); |
|
191 |
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
192 |
} |
|
201 |
emailUtils.reportException(e); |
|
202 |
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
193 | 203 |
} |
204 |
return retDatasources; |
|
194 | 205 |
} |
195 | 206 |
|
196 | 207 |
@Override |
... | ... | |
199 | 210 |
LOGGER.debug("Getting repositories(urls) of user: " + userEmail + " . IncludeShared: " + includeShared + " . IncludeByOthers: " + includeByOthers); |
200 | 211 |
List<String> retRepos = new ArrayList<String>(); |
201 | 212 |
|
202 |
retRepos.addAll(this.repoAPI.getUrlsOfRepos(userEmail, false)); |
|
203 |
|
|
213 |
int page = 1; |
|
214 |
String size = "10"; |
|
215 |
List<String> resultSet = repositoryApi.getUrlsOfUserRepos(userEmail,String.valueOf(page),size); |
|
216 |
while(resultSet.size() > 0 ){ |
|
217 |
retRepos.addAll(resultSet); |
|
218 |
page++; |
|
219 |
resultSet = repositoryApi.getUrlsOfUserRepos(userEmail,String.valueOf(page),size); |
|
220 |
} |
|
204 | 221 |
return retRepos; |
205 | 222 |
|
206 | 223 |
} catch (Exception e) { |
207 | 224 |
LOGGER.error("Error while getting repositories(urls) of user: " + userEmail + " . IncludeShared: " + includeShared + " . IncludeByOthers: " + includeByOthers, e); |
208 |
if (e instanceof RepositoryServiceException) { |
|
209 |
throw (RepositoryServiceException) e; |
|
210 |
} else { |
|
211 |
emailUtils.reportException(e); |
|
212 |
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
213 |
} |
|
225 |
emailUtils.reportException(e); |
|
226 |
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
214 | 227 |
} |
215 | 228 |
} |
216 | 229 |
|
... | ... | |
218 | 231 |
public Repository getRepository(String repoId) throws RepositoryServiceException { |
219 | 232 |
try { |
220 | 233 |
LOGGER.debug("Getting repository with id: " + repoId); |
234 |
Repository repo = repositoryApi.getRepositoryById(repoId); |
|
221 | 235 |
|
222 |
Repository repo = this.repoAPI.getRepository(repoId); |
|
223 | 236 |
if (repo != null) { |
224 | 237 |
for (RepositoryInterface iFace : repo.getInterfaces()) { |
225 | 238 |
if (!iFace.getContentDescription().equals("file::hybrid") && iFace.getAccessProtocol().equalsIgnoreCase("oai")) { |
... | ... | |
262 | 275 |
LOGGER.debug("using \"dnet:countries\" vocabulary"); |
263 | 276 |
countries.addAll(this.getVocabulary("dnet:countries").getEnglishNames()); |
264 | 277 |
} |
265 |
|
|
278 |
// countries.addAll(repositoryApi.getDnetCountries()); |
|
266 | 279 |
for (String country : countries) { |
267 | 280 |
countriesMap.put(country, WordUtils.capitalizeFully(country)); |
268 | 281 |
} |
... | ... | |
289 | 302 |
public List<Timezone> getTimezones() throws RepositoryServiceException { |
290 | 303 |
try { |
291 | 304 |
LOGGER.debug("Getting timezones from file"); |
305 |
// return repositoryApi.getTimezones(); |
|
292 | 306 |
return LocalVocabularies.timezones; |
293 | 307 |
} catch (Exception e) { |
294 | 308 |
LOGGER.error("Error while getting timezones from file", e); |
... | ... | |
302 | 316 |
public List<String> getTypologies() throws RepositoryServiceException { |
303 | 317 |
try { |
304 | 318 |
LOGGER.debug("Getting typologies from file"); |
319 |
// return repositoryApi.getTypologies(); |
|
305 | 320 |
return LocalVocabularies.typologies; |
306 | 321 |
} catch (Exception e) { |
307 | 322 |
LOGGER.error("Error while getting typologies from file", e); |
... | ... | |
312 | 327 |
|
313 | 328 |
@Override |
314 | 329 |
public Map<String, String> getDatasourceClasses(String mode) throws RepositoryServiceException { |
315 |
try { |
|
316 |
LOGGER.debug("Getting datasource classes for mode: " + mode); |
|
317 |
Map<String, String> retMap = new HashMap<String, String>(); |
|
318 |
|
|
319 |
for (Map.Entry<String, String> entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) { |
|
320 |
if (mode.equalsIgnoreCase("aggregator")) { |
|
321 |
if (entry.getKey().contains("aggregator")) |
|
322 |
retMap.put(entry.getKey(), entry.getValue()); |
|
323 |
} else if (mode.equalsIgnoreCase("journal")) { |
|
324 |
if (entry.getKey().contains("journal")) |
|
325 |
retMap.put(entry.getKey(), entry.getValue()); |
|
326 |
} else if (mode.equalsIgnoreCase("opendoar")) { |
|
327 |
if (entry.getKey().contains("pubsrepository")) |
|
328 |
retMap.put(entry.getKey(), entry.getValue()); |
|
329 |
} else if (mode.equalsIgnoreCase("re3data")) { |
|
330 |
if (entry.getKey().contains("datarepository")) |
|
331 |
retMap.put(entry.getKey(), entry.getValue()); |
|
332 |
} |
|
333 |
} |
|
334 |
return retMap; |
|
335 |
|
|
336 |
} catch (Exception e) { |
|
337 |
LOGGER.error("Error while getting datasource classes for mode: " + mode, e); |
|
338 |
emailUtils.reportException(e); |
|
339 |
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
340 |
} |
|
330 |
return repositoryApi.getDatasourceClasses(mode); |
|
341 | 331 |
} |
342 | 332 |
|
343 | 333 |
@Override |
344 | 334 |
public Map<String, String> getCompatibilityClasses(String mode) throws RepositoryServiceException { |
345 |
try { |
|
346 |
LOGGER.debug("Getting compatibility classes for mode: " + mode); |
|
347 |
Map<String, String> retMap = new HashMap<String, String>(); |
|
348 |
|
|
349 |
Map<String, String> compatibilityClasses = this.getVocabulary("dnet:compatibilityLevel").getAsMap(); |
|
350 |
boolean foundData = false; |
|
351 |
for (Map.Entry<String, String> entry : compatibilityClasses.entrySet()) { |
|
352 |
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL)) |
|
353 |
return compatibilityClasses; |
|
354 |
else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) { |
|
355 |
if (entry.getKey().matches("^openaire[1-9].0_data$")) { |
|
356 |
retMap.put(entry.getKey(), entry.getValue()); |
|
357 |
foundData = true; |
|
358 |
} |
|
359 |
} else { |
|
360 |
if (entry.getKey().matches("^openaire[1-9].0$") || entry.getKey().equals("driver")) |
|
361 |
retMap.put(entry.getKey(), entry.getValue()); |
|
362 |
} |
|
363 |
} |
|
364 |
|
|
365 |
//TODO TO BE REMOVED WHEN VOCABULARIES ARE UPDATED |
|
366 |
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA) && !foundData) |
|
367 |
retMap.put("openaire2.0_data", "OpenAIRE Data (funded, referenced datasets)"); |
|
368 |
|
|
369 |
return retMap; |
|
370 |
|
|
371 |
} catch (Exception e) { |
|
372 |
LOGGER.error("Error while getting compatibility classes for mode: " + mode, e); |
|
373 |
emailUtils.reportException(e); |
|
374 |
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
375 |
} |
|
335 |
return repositoryApi.getCompatibilityClasses(mode); |
|
376 | 336 |
} |
377 | 337 |
|
378 | 338 |
@Override |
... | ... | |
380 | 340 |
|
381 | 341 |
try { |
382 | 342 |
LOGGER.debug("Storing repository with name: " + repo.getOfficialName()); |
383 |
|
|
384 | 343 |
List<RepositoryInterface> interfacesToRegister = new ArrayList<RepositoryInterface>(); |
385 | 344 |
|
386 | 345 |
//TODO update map |
... | ... | |
410 | 369 |
repo.setNamespacePrefix(repo.getNamespacePrefix().concat("_")); |
411 | 370 |
} |
412 | 371 |
} |
413 |
|
|
414 |
this.repoAPI.storeRepository(repo, mode, interfacesToRegister); |
|
415 |
|
|
416 |
} catch (Exception e) { |
|
372 |
repositoryApi.addRepository(repo); |
|
373 |
} catch (JSONException e) { |
|
417 | 374 |
LOGGER.error("Error while Storing repository with name: " + repo.getOfficialName(), e); |
418 |
if (e instanceof RepositoryServiceException) { |
|
419 |
throw (RepositoryServiceException) e; |
|
420 |
} else { |
|
421 |
emailUtils.reportException(e); |
|
422 |
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
423 |
} |
|
375 |
emailUtils.reportException(e); |
|
376 |
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
424 | 377 |
} |
425 | 378 |
} |
426 | 379 |
|
... | ... | |
428 | 381 |
public void updateRepositoryInformation(Repository repo) throws RepositoryServiceException { |
429 | 382 |
try { |
430 | 383 |
LOGGER.debug("Updating information of repo: " + repo.getOfficialName()); |
431 |
this.repoAPI.updateRepositoryInformation(repo); |
|
432 | 384 |
|
385 |
//TODO SOS, check old API |
|
386 |
|
|
387 |
//this.repoAPI.updateRepositoryInformation(repo); |
|
388 |
repositoryApi.updateEnglishName(repo.getId(),repo.getEnglishName()); |
|
389 |
repositoryApi.updateLatitude(repo.getId(), String.valueOf(repo.getLatitude())); |
|
390 |
repositoryApi.updateLongitude(repo.getId(), String.valueOf(repo.getLongitude())); |
|
391 |
repositoryApi.updateOfficialName(repo.getId(),repo.getOfficialName()); |
|
433 | 392 |
} catch (Exception e) { |
434 | 393 |
LOGGER.error("Error while updating information of repo: " + repo.getOfficialName(), e); |
435 | 394 |
if (e instanceof RepositoryServiceException) { |
... | ... | |
466 | 425 |
try { |
467 | 426 |
LOGGER.debug("inserting interface with id: " + iFace.getId()); |
468 | 427 |
RepositoryInterface retIface = null; |
469 |
retIface = this.repoAPI.insertRepositoryInterfaceWithoutChecks(repoId, iFace, datatype); |
|
428 |
//retIface = this.repoAPI.insertRepositoryInterfaceWithoutChecks(repoId, iFace, datatype); |
|
429 |
|
|
430 |
Repository e = this.getRepository(repoId); |
|
431 |
iFace.setContentDescription("metadata"); |
|
432 |
iFace.setCompliance("UNKNOWN"); |
|
433 |
if(e.getDatasourceClass() == null) { |
|
434 |
if(datatype.equalsIgnoreCase("journal")) { |
|
435 |
iFace.setTypology("pubsrepository::journal"); |
|
436 |
} else if(datatype.equalsIgnoreCase("aggregator")) { |
|
437 |
iFace.setTypology("aggregator::pubsrepository::unknown"); |
|
438 |
} else { |
|
439 |
iFace.setTypology("pubsrepository::unknown"); |
|
440 |
} |
|
441 |
} else { |
|
442 |
iFace.setTypology(e.getDatasourceClass()); |
|
443 |
} |
|
444 |
|
|
445 |
if(datatype.equals("re3data")) { |
|
446 |
iFace.setAccessFormat("oai_datacite"); |
|
447 |
} else { |
|
448 |
iFace.setAccessFormat("oai_dc"); |
|
449 |
} |
|
450 |
|
|
451 |
iFace.setAccessProtocol("oai"); |
|
452 |
iFace.setRemovable(true); |
|
453 |
iFace.setMetadataIdentifierPath("//*[local-name()=\'header\']/*[local-name()=\'identifier\']"); |
|
454 |
iFace.setId("api_________::" + repoId + "::" + UUID.randomUUID().toString().substring(0, 8)); |
|
455 |
if(iFace.getAccessSet().isEmpty()) { |
|
456 |
LOGGER.debug("set is empty: " + iFace.getAccessSet()); |
|
457 |
iFace.removeAccessSet(); |
|
458 |
} |
|
459 |
|
|
460 |
retIface = repositoryApi.addRepositoryInterface(iFace); |
|
470 | 461 |
retIface.setComplianceName(this.getComplianceName(retIface.getCompliance())); |
462 |
|
|
471 | 463 |
return retIface; |
472 | 464 |
|
473 | 465 |
} catch (Exception e) { |
... | ... | |
492 | 484 |
public void deleteInterfaces(String repoId, List<RepositoryInterface> iFaces, String datatype) throws RepositoryServiceException { |
493 | 485 |
try { |
494 | 486 |
LOGGER.debug("deleting interfaces of repo: " + repoId); |
495 |
this.repoAPI.deleteRepositoryInterfacesWithoutChecks(repoId, iFaces, datatype); |
|
487 |
//this.repoAPI.deleteRepositoryInterfacesWithoutChecks(repoId, iFaces, datatype);
|
|
496 | 488 |
|
489 |
for(RepositoryInterface iFace : iFaces) { |
|
490 |
LOGGER.info("deleting repository interface with url/set/id: " + iFace.getBaseUrl() + "/" |
|
491 |
+ iFace.getAccessSet() + "/" + iFace.getId()); |
|
492 |
repositoryApi.deleteRepositoryInterface(iFace.getId()); |
|
493 |
} |
|
494 |
|
|
497 | 495 |
} catch (Exception e) { |
498 | 496 |
LOGGER.error("deleting interfaces of repo: " + repoId, e); |
499 | 497 |
if (e instanceof RepositoryServiceException) { |
... | ... | |
578 | 576 |
@Override |
579 | 577 |
public PiwikInfo getPiwikSiteForRepository(String repoId) throws RepositoryServiceException { |
580 | 578 |
try { |
579 |
LOGGER.debug("Repo id -> " + repoId); |
|
581 | 580 |
return this.piwikDAO.getPiwikSiteForRepo(repoId); |
582 | 581 |
} catch (EmptyResultDataAccessException e) { |
583 | 582 |
return null; |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/services/BrokerServiceImpl.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.repo.manager.server.services; |
2 | 2 |
|
3 |
import com.fasterxml.jackson.core.JsonProcessingException; |
|
4 |
import com.fasterxml.jackson.databind.ObjectMapper; |
|
3 | 5 |
import eu.dnetlib.domain.data.Repository; |
4 | 6 |
import eu.dnetlib.gwt.server.service.SpringGwtRemoteServiceServlet; |
5 | 7 |
import eu.dnetlib.repo.manager.client.services.BrokerService; |
8 |
import eu.dnetlib.repo.manager.service.controllers.BrokerApi; |
|
9 |
import eu.dnetlib.repo.manager.service.controllers.RepositoryApi; |
|
6 | 10 |
import eu.dnetlib.repo.manager.shared.BrokerException; |
7 | 11 |
import eu.dnetlib.repo.manager.shared.RepositoryServiceException; |
8 | 12 |
import eu.dnetlib.repo.manager.shared.Tuple; |
9 | 13 |
import eu.dnetlib.repo.manager.shared.broker.*; |
10 | 14 |
import eu.dnetlib.repos.RepoApi; |
11 | 15 |
import org.apache.log4j.Logger; |
16 |
import org.json.JSONArray; |
|
17 |
import org.json.JSONException; |
|
18 |
import org.json.JSONObject; |
|
12 | 19 |
import org.springframework.beans.factory.annotation.Autowired; |
13 | 20 |
import org.springframework.beans.factory.annotation.Value; |
14 | 21 |
import org.springframework.core.ParameterizedTypeReference; |
... | ... | |
25 | 32 |
|
26 | 33 |
import javax.servlet.ServletConfig; |
27 | 34 |
import javax.servlet.ServletException; |
35 |
import java.io.IOException; |
|
28 | 36 |
import java.util.*; |
29 | 37 |
|
30 | 38 |
/** |
... | ... | |
40 | 48 |
@Autowired |
41 | 49 |
private RepoApi repoAPI; |
42 | 50 |
|
51 |
|
|
52 |
@Autowired |
|
53 |
private RepositoryApi repositoryApi; |
|
54 |
@Autowired |
|
55 |
private BrokerApi brokerApi; |
|
56 |
|
|
57 |
|
|
43 | 58 |
@Override |
44 | 59 |
public void init(ServletConfig config) throws ServletException { |
45 | 60 |
super.init(config); |
... | ... | |
59 | 74 |
*/ |
60 | 75 |
@Override |
61 | 76 |
public List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException { |
62 |
final String service = "/topicsForDatasource"; |
|
63 |
|
|
64 |
//build the uri params |
|
65 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service) |
|
66 |
.queryParam("ds", datasourceName); |
|
67 |
|
|
68 |
//create new template engine |
|
69 |
RestTemplate template = new RestTemplate(); |
|
70 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
71 |
ResponseEntity<List<BrowseEntry>> resp; |
|
72 |
try { |
|
73 |
//communicate with endpoint |
|
74 |
resp = template.exchange( |
|
75 |
builder.build().encode().toUri(), |
|
76 |
HttpMethod.GET, |
|
77 |
null, |
|
78 |
new ParameterizedTypeReference<List<BrowseEntry>>() { |
|
79 |
}); |
|
80 |
} catch (RestClientException e) { |
|
81 |
throw new BrokerException(e); |
|
82 |
} |
|
83 |
|
|
84 |
return resp.getBody(); |
|
77 |
return brokerApi.getTopicsForDatasource(datasourceName); |
|
85 | 78 |
} |
86 | 79 |
|
87 | 80 |
/** |
... | ... | |
92 | 85 |
* @throws BrokerException containing the error code from the server |
93 | 86 |
*/ |
94 | 87 |
@Override |
95 |
public EventsPage showEvents(String datasourceName, String topic, long page) throws BrokerException { |
|
96 |
final String service = "/showEvents"; |
|
97 |
|
|
98 |
//build the uri params |
|
99 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service) |
|
100 |
.queryParam("ds", datasourceName) |
|
101 |
.queryParam("topic", topic) |
|
102 |
.queryParam("page", page); |
|
103 |
|
|
104 |
//create new template engine |
|
105 |
RestTemplate template = new RestTemplate(); |
|
106 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
107 |
ResponseEntity<EventsPage> resp; |
|
88 |
public EventsPage showEvents(String datasourceName, String topic, long page) throws BrokerException{ |
|
89 |
JSONObject params = new JSONObject(); |
|
108 | 90 |
try { |
109 |
//communicate with endpoint |
|
110 |
resp = template.exchange( |
|
111 |
builder.build().encode().toUri(), |
|
112 |
HttpMethod.GET, |
|
113 |
null, |
|
114 |
new ParameterizedTypeReference<EventsPage>() { |
|
115 |
}); |
|
116 |
} catch (RestClientException e) { |
|
117 |
throw new BrokerException(e); |
|
91 |
params.put("datasourceName",datasourceName); |
|
92 |
params.put("topic",topic); |
|
93 |
params.put("page",String.valueOf(page)); |
|
94 |
return brokerApi.showEvents(params.toString()); |
|
95 |
} catch (JSONException e) { |
|
96 |
LOGGER.debug("Error on show events",e); |
|
118 | 97 |
} |
119 |
return resp.getBody();
|
|
98 |
return null;
|
|
120 | 99 |
} |
121 | 100 |
|
122 | 101 |
/** |
... | ... | |
128 | 107 |
*/ |
129 | 108 |
@Override |
130 | 109 |
public EventsPage advancedShowEvents(AdvQueryObject advQueryObject, long page, long pageSize) throws BrokerException { |
131 |
final String service = "/events/{page}/{pageSize}"; |
|
132 | 110 |
|
133 |
// URI (URL) parameters |
|
134 |
Map<String, Long> uriParams = new HashMap<>(); |
|
135 |
uriParams.put("page", page); |
|
136 |
uriParams.put("pageSize", pageSize); |
|
137 |
|
|
138 |
//build the uri params |
|
139 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service); |
|
140 |
|
|
141 |
//Header info |
|
142 |
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); |
|
143 |
headers.add("Content-Type", "application/json"); |
|
144 |
|
|
145 |
advQueryObject.setPage(page); |
|
146 |
|
|
147 |
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, headers); |
|
148 |
|
|
149 |
//create new template engine |
|
150 |
RestTemplate template = new RestTemplate(); |
|
151 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
152 |
ResponseEntity<EventsPage> resp; |
|
111 |
JSONObject jsonObject = new JSONObject(); |
|
153 | 112 |
try { |
154 |
//communicate with endpoint |
|
155 |
resp = template.exchange( |
|
156 |
builder.buildAndExpand(uriParams).encode().toUri(), |
|
157 |
HttpMethod.POST, |
|
158 |
entity, |
|
159 |
new ParameterizedTypeReference<EventsPage>() { |
|
160 |
} |
|
161 |
); |
|
162 |
} catch (RestClientException e) { |
|
163 |
throw new BrokerException(e); |
|
113 |
jsonObject.put("page",String.valueOf(page)); |
|
114 |
jsonObject.put("pagesize",String.valueOf(pageSize)); |
|
115 |
ObjectMapper mapper = new ObjectMapper(); |
|
116 |
String json_advQueryObject = mapper.writeValueAsString(advQueryObject); |
|
117 |
jsonObject.put("advQueryObject",json_advQueryObject); |
|
118 |
return brokerApi.advancedShowEvents(jsonObject.toString()); |
|
119 |
} catch (Exception e) { |
|
120 |
LOGGER.debug("Error on advanced show events",e); |
|
164 | 121 |
} |
165 |
return resp.getBody();
|
|
122 |
return null;
|
|
166 | 123 |
} |
167 | 124 |
|
168 | 125 |
@Override |
169 |
public DatasourcesBroker getDatasourcesOfUser(String userEmail, boolean includeShared, boolean includeByOthers) throws BrokerException { |
|
126 |
public DatasourcesBroker getDatasourcesOfUser(String userEmail, boolean includeShared, boolean includeByOthers) |
|
127 |
throws BrokerException { |
|
128 |
|
|
129 |
/*JSONObject params = new JSONObject(); |
|
130 |
try { |
|
131 |
params.put("userEmail",userEmail); |
|
132 |
params.put("includeShared",includeShared); |
|
133 |
params.put("includeByOthers",includeByOthers); |
|
134 |
return brokerApi.getDatasourcesOfUser(params.toString()); |
|
135 |
} catch (JSONException e) { |
|
136 |
LOGGER.debug("Error on get datasources of user",e); |
|
137 |
} |
|
138 |
return null;*/ |
|
170 | 139 |
DatasourcesBroker ret = new DatasourcesBroker(); |
171 | 140 |
try { |
172 | 141 |
LOGGER.debug("In getDatasourcesOfUser"); |
... | ... | |
197 | 166 |
|
198 | 167 |
@Override |
199 | 168 |
public Map<String, List<SimpleSubscriptionDesc>> getSubscriptionsOfUser(String userEmail) throws BrokerException { |
200 |
final String service = "/subscriptions"; |
|
201 |
|
|
202 |
//build the uri params |
|
203 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service) |
|
204 |
.queryParam("email", userEmail); |
|
205 |
|
|
206 |
//create new template engine |
|
207 |
RestTemplate template = new RestTemplate(); |
|
208 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
209 |
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp; |
|
210 |
try { |
|
211 |
//communicate with endpoint |
|
212 |
resp = template.exchange( |
|
213 |
builder.build().encode().toUri(), |
|
214 |
HttpMethod.GET, |
|
215 |
null, |
|
216 |
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() { |
|
217 |
}); |
|
218 |
} catch (RestClientException e) { |
|
219 |
throw new BrokerException(e); |
|
220 |
} |
|
221 |
|
|
222 |
return resp.getBody(); |
|
169 |
return brokerApi.getSubscriptionsOfUser(userEmail); |
|
223 | 170 |
} |
224 | 171 |
|
225 | 172 |
@Override |
226 | 173 |
public Subscription subscribe(OpenaireSubscription obj) throws BrokerException { |
227 |
final String service = "/subscribe"; |
|
228 |
|
|
229 |
//build the uri params |
|
230 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service); |
|
231 |
|
|
232 |
//Header info |
|
233 |
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); |
|
234 |
headers.add("Content-Type", "application/json"); |
|
235 |
HttpEntity<OpenaireSubscription> entity = new HttpEntity<>(obj, headers); |
|
236 |
|
|
237 |
//create new template engine |
|
238 |
RestTemplate template = new RestTemplate(); |
|
239 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
240 |
ResponseEntity<Subscription> resp; |
|
241 |
try { |
|
242 |
//communicate with endpoint |
|
243 |
resp = template.exchange( |
|
244 |
builder.build().encode().toUri(), |
|
245 |
HttpMethod.POST, |
|
246 |
entity, |
|
247 |
new ParameterizedTypeReference<Subscription>() { |
|
248 |
}); |
|
249 |
} catch (RestClientException e) { |
|
250 |
throw new BrokerException(e); |
|
251 |
} |
|
252 |
|
|
253 |
return resp.getBody(); |
|
174 |
return brokerApi.subscribe(obj); |
|
254 | 175 |
} |
255 | 176 |
|
256 | 177 |
@Override |
257 | 178 |
public void unsubscribe(String subscriptionId) throws BrokerException { |
258 |
final String service = "/subscriptions/" + subscriptionId; |
|
259 |
|
|
260 |
//build the uri params |
|
261 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service); |
|
262 |
|
|
263 |
//create new template engine |
|
264 |
RestTemplate template = new RestTemplate(); |
|
265 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
266 |
try { |
|
267 |
//communicate with endpoint |
|
268 |
template.exchange( |
|
269 |
builder.build().encode().toUri(), |
|
270 |
HttpMethod.DELETE, |
|
271 |
null, |
|
272 |
new ParameterizedTypeReference<Void>() { |
|
273 |
}); |
|
274 |
} catch (RestClientException e) { |
|
275 |
throw new BrokerException(e); |
|
276 |
} |
|
179 |
brokerApi.unsubscribe(subscriptionId); |
|
277 | 180 |
} |
278 | 181 |
|
279 | 182 |
@Override |
280 | 183 |
public Subscription getSubscription(String subscriptionId) throws BrokerException { |
281 |
final String service = "/subscriptions/" + subscriptionId; |
|
282 |
|
|
283 |
//build the uri params |
|
284 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service); |
|
285 |
|
|
286 |
//create new template engine |
|
287 |
RestTemplate template = new RestTemplate(); |
|
288 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
289 |
ResponseEntity<Subscription> resp; |
|
290 |
try { |
|
291 |
//communicate with endpoint |
|
292 |
resp = template.exchange( |
|
293 |
builder.build().encode().toUri(), |
|
294 |
HttpMethod.GET, |
|
295 |
null, |
|
296 |
new ParameterizedTypeReference<Subscription>() { |
|
297 |
}); |
|
298 |
} catch (RestClientException e) { |
|
299 |
throw new BrokerException(e); |
|
300 |
} |
|
301 |
return resp.getBody(); |
|
184 |
return brokerApi.getSubscription(subscriptionId); |
|
302 | 185 |
} |
303 | 186 |
|
304 | 187 |
@Override |
... | ... | |
316 | 199 |
* @throws BrokerException |
317 | 200 |
*/ |
318 | 201 |
private List<Tuple<BrowseEntry, String>> getDatasourcesOfUserType(List<Repository> repositories) throws BrokerException { |
202 |
|
|
319 | 203 |
//get user entries |
320 | 204 |
LOGGER.debug("getDatasourcesOfUserType : " + repositories.size()); |
321 | 205 |
List<Tuple<BrowseEntry, String>> entries = new ArrayList<>(); |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/services/PiwikDAO.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.repo.manager.server.services; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.domain.data.PiwikInfo; |
4 |
import org.apache.commons.codec.digest.DigestUtils; |
|
4 |
import eu.dnetlib.repo.manager.service.controllers.PiWiApi; |
|
5 |
import eu.dnetlib.utils.md5.MD5; |
|
5 | 6 |
import org.springframework.beans.factory.annotation.Autowired; |
6 | 7 |
import org.springframework.beans.factory.annotation.Qualifier; |
7 | 8 |
import org.springframework.jdbc.core.JdbcTemplate; |
... | ... | |
9 | 10 |
import org.springframework.stereotype.Component; |
10 | 11 |
|
11 | 12 |
import javax.sql.DataSource; |
13 |
import java.security.NoSuchAlgorithmException; |
|
12 | 14 |
import java.sql.ResultSet; |
13 | 15 |
import java.sql.SQLException; |
14 | 16 |
import java.sql.Types; |
... | ... | |
20 | 22 |
@Component(value = "piwikDAO") |
21 | 23 |
public class PiwikDAO { |
22 | 24 |
|
25 |
|
|
23 | 26 |
@Autowired |
24 |
@Qualifier("repomanager.dataSource") |
|
25 |
private DataSource dataSource; |
|
27 |
private PiWiApi piWiApi; |
|
26 | 28 |
|
27 |
private final static String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ?;"; |
|
28 |
|
|
29 |
private final static String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, validated, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)"; |
|
30 |
|
|
31 |
private final static String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site order by repositoryname"; |
|
32 |
|
|
33 |
private final static String VALIDATE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;"; |
|
34 |
|
|
35 |
private RowMapper<PiwikInfo> piwikRowMapper = new RowMapper<PiwikInfo>() { |
|
36 |
@Override |
|
37 |
public PiwikInfo mapRow(ResultSet rs, int i) throws SQLException { |
|
38 |
return new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"), |
|
39 |
rs.getString("siteid"), rs.getString("authenticationtoken"), rs.getTimestamp("creationdate"), rs.getString("requestorname"), rs.getString("requestoremail"), |
|
40 |
rs.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment")); |
|
41 |
} |
|
42 |
}; |
|
43 |
|
|
44 | 29 |
public PiwikInfo getPiwikSiteForRepo(String repositoryId) { |
45 |
return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITE, new String[]{repositoryId}, new int[]{Types.VARCHAR}, piwikRowMapper);
|
|
30 |
return piWiApi.getPiwikSiteForRepo(repositoryId);
|
|
46 | 31 |
} |
47 | 32 |
|
48 | 33 |
public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) { |
49 |
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); |
|
50 |
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(), |
|
51 |
piwikInfo.getRequestorEmail(), piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()}, |
|
52 |
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR}); |
|
53 |
return piwikInfo; |
|
34 |
return piWiApi.savePiwikInfo(piwikInfo); |
|
54 | 35 |
} |
55 | 36 |
|
56 | 37 |
public List<PiwikInfo> getPiwikSitesForRepos() { |
57 |
return new JdbcTemplate(dataSource).query(GET_PIWIK_SITES, piwikRowMapper);
|
|
38 |
return piWiApi.getPiwikSitesForRepos();
|
|
58 | 39 |
} |
59 | 40 |
|
60 | 41 |
public void markPiwikSiteAsValidated(String repositoryId) { |
61 |
new JdbcTemplate(dataSource).update(VALIDATE_PIWIK_SITE, new Object[] {repositoryId}, new int[] {Types.VARCHAR});
|
|
42 |
piWiApi.approvePiwikSite(repositoryId);
|
|
62 | 43 |
} |
63 | 44 |
|
64 | 45 |
private String getOpenaireId(String repositoryid) { |
65 |
|
|
66 |
if (repositoryid != null && repositoryid.contains("::")) { |
|
67 |
return repositoryid.split("::")[0] + "::" + DigestUtils.md5Hex(repositoryid.split("::")[1]); |
|
68 |
} |
|
69 |
|
|
70 |
return null; |
|
46 |
return piWiApi.getOpenaireId(repositoryid); |
|
71 | 47 |
} |
72 | 48 |
} |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/services/ValidationServiceImpl.java | ||
---|---|---|
9 | 9 |
import eu.dnetlib.repo.manager.client.services.ValidationService; |
10 | 10 |
import eu.dnetlib.repo.manager.server.utils.EmailUtils; |
11 | 11 |
import eu.dnetlib.repo.manager.server.utils.OaiTools; |
12 |
import eu.dnetlib.repo.manager.service.controllers.MonitorApi; |
|
13 |
import eu.dnetlib.repo.manager.service.controllers.ValidatorApi; |
|
12 | 14 |
import eu.dnetlib.repo.manager.shared.*; |
13 | 15 |
import gr.uoa.di.driver.util.ServiceLocator; |
14 | 16 |
import org.apache.log4j.Logger; |
17 |
import org.json.JSONException; |
|
15 | 18 |
import org.springframework.beans.factory.annotation.Autowired; |
16 | 19 |
import org.springframework.beans.factory.annotation.Value; |
17 | 20 |
import org.springframework.stereotype.Service; |
... | ... | |
39 | 42 |
|
40 | 43 |
private ServiceLocator<ValidatorService> validatorServiceLocator; |
41 | 44 |
|
42 |
private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>(); |
|
45 |
//private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
|
|
43 | 46 |
|
44 | 47 |
public void init(ServletConfig config) throws ServletException { |
45 | 48 |
|
... | ... | |
47 | 50 |
super.init(config); |
48 | 51 |
} |
49 | 52 |
|
53 |
@Autowired |
|
54 |
private ValidatorApi validatorApi; |
|
55 |
@Autowired |
|
56 |
private MonitorApi monitorApi; |
|
57 |
|
|
50 | 58 |
@PostConstruct |
51 | 59 |
public void initRulesets() { |
52 |
this.loadRulesets(); |
|
60 |
//this.loadRulesets();
|
|
53 | 61 |
} |
54 | 62 |
|
55 | 63 |
@Override |
56 | 64 |
public List<String> getSets(String baseUrl) throws ValidationServiceException { |
57 |
try { |
|
58 |
LOGGER.debug("Getting sets of repository with url: " + baseUrl); |
|
59 |
return OaiTools.getSetsOfRepo(baseUrl); |
|
60 |
} catch (Exception e) { |
|
61 |
LOGGER.error("Error while getting sets of repository with url: " + baseUrl, e); |
|
62 |
// emailUtils.reportException(e); |
|
63 |
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.NOT_VALID_SET); |
|
64 |
} |
|
65 |
return validatorApi.getSetsOfRepository(baseUrl); |
|
65 | 66 |
} |
66 | 67 |
|
67 | 68 |
@Override |
68 | 69 |
public Boolean identifyRepository(String baseUrl) throws ValidationServiceException { |
69 |
try { |
|
70 |
LOGGER.debug("Identifying repository with url: " + baseUrl); |
|
71 |
return OaiTools.identifyRepository(baseUrl); |
|
72 |
} catch (Exception e) { |
|
73 |
LOGGER.error("Error while identifying repository with url: " + baseUrl, e); |
|
74 |
// emailUtils.reportException(e); |
|
75 |
return false; |
|
76 |
// throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.NOT_VALID_BASEURL); |
|
77 |
} |
|
70 |
return validatorApi.identifyRepo(baseUrl); |
|
78 | 71 |
} |
79 | 72 |
|
80 | 73 |
@Override |
... | ... | |
96 | 89 |
|
97 | 90 |
@Override |
98 | 91 |
public List<RuleSet> getRuleSets(String validationMode) throws ValidationServiceException { |
99 |
LOGGER.info("Getting rulesets for mode: " + validationMode); |
|
100 | 92 |
try { |
101 |
if (!rulesetMap.containsKey(validationMode)) |
|
102 |
this.loadRulesets(); |
|
103 |
|
|
104 |
return this.rulesetMap.get(validationMode); |
|
93 |
return validatorApi.getRuleSets(validationMode); |
|
105 | 94 |
} catch (Exception e) { |
106 | 95 |
LOGGER.error("Error getting rulesets", e); |
107 | 96 |
emailUtils.reportException(e); |
... | ... | |
111 | 100 |
|
112 | 101 |
@Override |
113 | 102 |
public RuleSet getRuleSet(String acronym) throws ValidationServiceException { |
114 |
LOGGER.info("Getting ruleset with acronym: " + acronym); |
|
115 |
RuleSet ruleSet = null; |
|
116 |
try { |
|
117 |
for (List<RuleSet> ruleSets : this.rulesetMap.values()) { |
|
118 |
for (RuleSet rSet : ruleSets) |
|
119 |
if (rSet.getGuidelinesAcronym().equals(acronym)) { |
|
120 |
ruleSet = rSet; |
|
121 |
break; |
|
122 |
} |
|
123 |
} |
|
124 |
return ruleSet; |
|
125 |
} catch (Exception e) { |
|
126 |
LOGGER.error("Error getting ruleset", e); |
|
127 |
emailUtils.reportException(e); |
|
128 |
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR); |
|
129 |
} |
|
103 |
return validatorApi.getRuleSet(acronym); |
|
130 | 104 |
} |
131 | 105 |
|
132 | 106 |
@Override |
133 | 107 |
public void submitValidationJob(JobForValidation job) throws ValidationServiceException { |
134 | 108 |
try { |
135 |
LOGGER.info("Submitting validation job"); |
|
136 |
this.getValidationService().submitValidationJob(job); |
|
109 |
validatorApi.submitJobForValidation(job); |
|
137 | 110 |
} catch (Exception e) { |
138 | 111 |
LOGGER.error("Error while submitting validation job", e); |
139 | 112 |
emailUtils.reportException(e); |
... | ... | |
145 | 118 |
public void reSubmitValidationJob(int jobId) |
146 | 119 |
throws ValidationServiceException { |
147 | 120 |
try { |
148 |
LOGGER.info("re-Submitting validation job"); |
|
149 |
StoredJob job = this.getJobSummary(jobId, "all"); |
|
150 |
Set<Integer> contentRules = new HashSet<Integer>(); |
|
151 |
Set<Integer> usageRules = new HashSet<Integer>(); |
|
152 |
RuleSet ruleSet = this.getRuleSet(job.getDesiredCompatibilityLevel()); |
|
153 |
for (int ruleId : job.getRules()) { |
|
154 |
if (ruleSet.getContentRulesIds().contains(ruleId)) |
|
155 |
contentRules.add(ruleId); |
|
156 |
else if (ruleSet.getUsageRulesIds().contains(ruleId)) |
|
157 |
usageRules.add(ruleId); |
|
158 |
} |
|
159 |
if (!contentRules.isEmpty()) |
|
160 |
job.setSelectedContentRules(contentRules); |
|
161 |
if (!usageRules.isEmpty()) |
|
162 |
job.setSelectedUsageRules(usageRules); |
|
163 |
this.submitValidationJob(job); |
|
164 |
} catch (Exception e) { |
|
121 |
validatorApi.reSubmitJobForValidation(String.valueOf(jobId)); |
|
122 |
} catch (JSONException e) { |
|
165 | 123 |
LOGGER.error("Error while re-submitting validation job", e); |
166 | 124 |
emailUtils.reportException(e); |
167 | 125 |
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR); |
... | ... | |
171 | 129 |
@Override |
172 | 130 |
public StoredJob getJobSummary(int jobId, String groupBy) |
173 | 131 |
throws ValidationServiceException { |
132 |
|
|
174 | 133 |
try { |
175 |
LOGGER.info("getting job summary for id: " + jobId); |
|
176 |
return getValidationService().getStoredJob(jobId, groupBy); |
|
177 |
} catch (ValidatorServiceException e) { |
|
134 |
return monitorApi.getJobSummary(String.valueOf(jobId),groupBy); |
|
135 |
} catch (Exception e) { |
|
178 | 136 |
LOGGER.error("Error getting job summary for id: " + jobId, e); |
179 | 137 |
emailUtils.reportException(e); |
180 | 138 |
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR); |
... | ... | |
192 | 150 |
// else |
193 | 151 |
jobs = getValidationService().getStoredJobsNew(user, jobType, offset, limit, dateFrom, dateTo, validationStatus); |
194 | 152 |
return jobs; |
153 |
// return monitorApi.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus); |
|
195 | 154 |
} catch (Exception e) { |
196 | 155 |
LOGGER.error("Error getting jobs of user " + user, e); |
197 | 156 |
emailUtils.reportException(e); |
... | ... | |
222 | 181 |
try { |
223 | 182 |
LOGGER.debug("getting jobs of user " + user + " totalJobs included: " + includeJobsTotal); |
224 | 183 |
JobsOfUser retJobs = new JobsOfUser(); |
225 |
List<StoredJob> jobs; |
|
226 |
//TODO update after declaring roles |
|
227 |
// if (this.userOverridesRepoRegistration(user)) |
|
228 |
// jobs = getValidationService().getStoredJobs(null, jobType, offset, limit, null, null); |
|
229 |
// else |
|
230 |
retJobs.setJobs(this.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus)); |
|
231 |
if (includeJobsTotal) { |
|
232 |
retJobs.setTotalJobs(this.getJobsTotalNumberOfUser(user, jobType, null)); |
|
233 |
retJobs.setTotalJobsSuccessful(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_SUCCESSFUL)); |
|
234 |
retJobs.setTotalJobsFailed(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_FAILED)); |
|
235 |
retJobs.setTotalJobsOngoing(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_ONGOING)); |
|
236 |
} |
|
237 |
return retJobs; |
|
238 | 184 |
|
185 |
return monitorApi.getJobsOfUser(user, jobType, String.valueOf(offset), String.valueOf(limit), |
|
186 |
dateFrom, dateTo, validationStatus, String.valueOf(includeJobsTotal)); |
|
187 |
|
|
239 | 188 |
} catch (Exception e) { |
240 | 189 |
LOGGER.error("getting jobs of user " + user + " totalJobs included: " + includeJobsTotal, e); |
241 |
emailUtils.reportException(e); |
|
242 | 190 |
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR); |
243 | 191 |
} |
244 | 192 |
} |
245 | 193 |
|
246 | 194 |
private void loadRulesets() { |
247 |
try { |
|
195 |
/* try {
|
|
248 | 196 |
LOGGER.debug("loading rulesets"); |
249 | 197 |
for (RuleSet ruleSet : getValidationService().getRuleSets()) { |
250 | 198 |
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains(deployEnvironment)) { |
... | ... | |
268 | 216 |
} catch (Exception e) { |
269 | 217 |
LOGGER.error("Error getting rulesets", e); |
270 | 218 |
emailUtils.reportException(e); |
271 |
} |
|
219 |
}*/
|
|
272 | 220 |
} |
273 | 221 |
|
274 | 222 |
private ValidatorService getValidationService() { |
modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/client/services/BrokerService.java | ||
---|---|---|
4 | 4 |
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; |
5 | 5 |
import eu.dnetlib.repo.manager.shared.BrokerException; |
6 | 6 |
import eu.dnetlib.repo.manager.shared.broker.*; |
7 |
import org.json.JSONException; |
|
7 | 8 |
|
8 | 9 |
import java.util.List; |
9 | 10 |
import java.util.Map; |
modules/uoa-repository-manager-gui/trunk/src/main/resources/eu/dnetlib/repo/manager/server/config/springContext-repo-manager.xml | ||
---|---|---|
5 | 5 |
xmlns:tx="http://www.springframework.org/schema/tx" |
6 | 6 |
xmlns:task="http://www.springframework.org/schema/task" |
7 | 7 |
xmlns:aop="http://www.springframework.org/schema/aop" |
8 |
xmlns:context="http://www.springframework.org/schema/context" |
|
8 | 9 |
|
9 |
xsi:schemaLocation=" |
|
10 |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
|
10 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
|
11 | 11 |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd |
12 | 12 |
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd |
13 |
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd"> |
|
13 |
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
|
14 | 14 |
|
15 |
|
|
16 |
|
|
17 |
|
|
15 | 18 |
<task:annotation-driven executor="myExecutor" scheduler="myScheduler"/> |
16 | 19 |
<task:executor id="myExecutor" pool-size="5"/> |
17 | 20 |
<task:scheduler id="myScheduler" pool-size="10"/> |
modules/uoa-repository-manager-gui/trunk/src/main/webapp/WEB-INF/applicationContext.xml | ||
---|---|---|
31 | 31 |
<import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/> |
32 | 32 |
|
33 | 33 |
<context:component-scan base-package="eu.dnetlib.repo.manager.server"/> |
34 |
<context:component-scan base-package="eu.dnetlib.repo.manager.service.controllers"/> |
|
34 | 35 |
<!--<context:component-scan base-package="gr.uoa.di.driver"/>--> |
35 | 36 |
<context:annotation-config/> |
36 | 37 |
|
38 |
|
|
37 | 39 |
<bean class="eu.dnetlib.repo.manager.server.config.CascadingPropertyLoader" |
38 | 40 |
id="propertyLoader"> |
39 | 41 |
<property name="order" value="2"/> |
... | ... | |
52 | 54 |
|
53 | 55 |
<value>classpath*:/eu/dnetlib/repo/manager/server/email-texts.properties</value> |
54 | 56 |
|
57 |
|
|
55 | 58 |
<value>classpath*:dnet-site-wizard.properties</value> |
56 | 59 |
<value>classpath*:dnet-site-override.properties</value> |
57 | 60 |
<value>classpath*:dnet-wizard.properties</value> |
... | ... | |
60 | 63 |
<value>classpath*:dnet-validator-override.properties</value> |
61 | 64 |
<value>classpath*:dnet-site-force-override.properties</value> |
62 | 65 |
<value>classpath*:dnet-force-override.properties</value> |
66 |
|
|
67 |
<value>classpath*:/eu/**/application.properties</value> |
|
68 |
|
|
63 | 69 |
</list> |
64 | 70 |
</property> |
65 | 71 |
</bean> |
modules/uoa-repository-manager-gui/trunk/src/main/webapp/WEB-INF/log4j.properties | ||
---|---|---|
11 | 11 |
log4j.logger.eu.dnetlib.repo.manager=DEBUG |
12 | 12 |
|
13 | 13 |
log4j.appender.R=org.apache.log4j.RollingFileAppender |
14 |
log4j.appender.R.File=/var/log/dnet/repo-manager/repo-manager-gui.log
|
|
14 |
log4j.appender.R.File=/tmp/repo-manager-gui.log
|
|
15 | 15 |
log4j.appender.R.MaxFileSize=10MB |
16 | 16 |
log4j.appender.R.MaxBackupIndex=10 |
17 | 17 |
log4j.appender.R.layout=org.apache.log4j.PatternLayout |
18 | 18 |
log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n |
19 | 19 |
|
20 | 20 |
log4j.appender.S=org.apache.log4j.RollingFileAppender |
21 |
log4j.appender.S.File=/var/log/dnet/repo-manager/repo-manager-gui-spring.log
|
|
21 |
log4j.appender.S.File=/tmp/repo-manager-gui-spring.log
|
|
22 | 22 |
log4j.appender.S.MaxFileSize=10MB |
23 | 23 |
log4j.appender.S.MaxBackupIndex=10 |
24 | 24 |
log4j.appender.S.layout=org.apache.log4j.PatternLayout |
modules/uoa-repository-manager-gui/trunk/pom.xml | ||
---|---|---|
56 | 56 |
<id>spring-releases</id> |
57 | 57 |
<url>https://repo.spring.io/libs-release</url> |
58 | 58 |
</repository> |
59 |
|
|
59 | 60 |
</repositories> |
60 | 61 |
|
61 | 62 |
<dependencies> |
... | ... | |
267 | 268 |
<version>1.7.3</version> |
268 | 269 |
</dependency> |
269 | 270 |
|
271 |
|
|
272 |
<dependency> |
|
273 |
<groupId>eu.dnetlib</groupId> |
|
274 |
<artifactId>uoa-repository-manager-service</artifactId> |
|
275 |
<version>1.0.0-SNAPSHOT</version> |
|
276 |
</dependency> |
|
277 |
|
|
278 |
|
|
279 |
|
|
270 | 280 |
</dependencies> |
271 | 281 |
|
282 |
|
|
272 | 283 |
<build> |
273 | 284 |
<!-- Output classes directly into the webapp, so that IDEs and "mvn process-classes" update them in DevMode --> |
274 | 285 |
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory> |
Also available in: Unified diff
merged newAPI branch