use of cz.metacentrum.perun.cabinet.strategy.PublicationSystemStrategy in project perun by CESNET.
the class PublicationSystemManagerIntegrationTest method getPublicationSystemByNamespace.
@Test
public void getPublicationSystemByNamespace() throws Exception {
System.out.println("PublicationSystemManagerIntegrationTest.getPublicationSystemByNamespace");
PublicationSystem publicationSystem = getCabinetManager().getPublicationSystemByNamespace("mu");
assertNotNull(publicationSystem);
assertTrue(Objects.equals(publicationSystem, pubSysMu));
PublicationSystemStrategy ps = (PublicationSystemStrategy) Class.forName(publicationSystem.getType()).newInstance();
assertNotNull(ps);
}
use of cz.metacentrum.perun.cabinet.strategy.PublicationSystemStrategy in project perun by CESNET.
the class PublicationSystemManagerIntegrationTest method getPublicationSystemById.
@Test
public void getPublicationSystemById() throws Exception {
System.out.println("PublicationSystemManagerIntegrationTest.getPublicationSystemById");
PublicationSystem publicationSystem = getCabinetManager().getPublicationSystemById(pubSysZcu.getId());
assertNotNull(publicationSystem);
assertTrue(Objects.equals(publicationSystem, pubSysZcu));
PublicationSystemStrategy ps = (PublicationSystemStrategy) Class.forName(publicationSystem.getType()).newInstance();
assertNotNull(ps);
}
use of cz.metacentrum.perun.cabinet.strategy.PublicationSystemStrategy in project perun by CESNET.
the class PublicationSystemManagerIntegrationTest method getPublicationSystemByName.
@Test
public void getPublicationSystemByName() throws Exception {
System.out.println("PublicationSystemManagerIntegrationTest.getPublicationSystemByName");
PublicationSystem publicationSystem = getCabinetManager().getPublicationSystemByName(pubSysZcu.getFriendlyName());
assertNotNull(publicationSystem);
assertTrue(Objects.equals(publicationSystem, pubSysZcu));
PublicationSystemStrategy ps = (PublicationSystemStrategy) Class.forName(publicationSystem.getType()).newInstance();
assertNotNull(ps);
}
use of cz.metacentrum.perun.cabinet.strategy.PublicationSystemStrategy in project perun by CESNET.
the class CabinetManagerBlImpl method findPublicationsInPubSys.
// methods --------------------------------------
public List<Publication> findPublicationsInPubSys(String authorId, int yearSince, int yearTill, PublicationSystem ps) throws CabinetException {
if (StringUtils.isBlank(authorId))
throw new CabinetException("AuthorId cannot be empty while searching for publications");
if (ps == null)
throw new CabinetException("Publication system cannot be null while searching for publications");
// authorId must be an publication system internal id i.e. UCO! not memberId, userId etc.
PublicationSystemStrategy prezentator = null;
try {
log.debug("Attempting to instantiate class [{}]...", ps.getType());
prezentator = (PublicationSystemStrategy) Class.forName(ps.getType()).newInstance();
log.debug("Class [{}] successfully created.", ps.getType());
} catch (Exception e) {
throw new CabinetException(e);
}
HttpUriRequest request = prezentator.getHttpRequest(authorId, yearSince, yearTill, ps);
HttpResponse response = prezentator.execute(request);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
throw new CabinetException("Can't contact publication system. HTTP error code: " + response.getStatusLine().getStatusCode(), ErrorCodes.HTTP_IO_EXCEPTION);
}
List<Publication> publications = prezentator.parseHttpResponse(response);
for (Publication p : publications) {
// set pub system for founded publications
p.setPublicationSystemId(ps.getId());
}
return publications;
}
Aggregations