use of cz.metacentrum.perun.cabinet.model.PublicationSystem 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.model.PublicationSystem in project perun by CESNET.
the class PublicationSystemManagerIntegrationTest method deletePublicationSystem.
@Test
public void deletePublicationSystem() throws Exception {
System.out.println("PublicationSystemManagerIntegrationTest.deletePublicationSystem");
List<PublicationSystem> systems = getCabinetManager().getPublicationSystems();
assertNotNull(systems);
assertTrue(!systems.isEmpty());
PublicationSystem ps = systems.get(0);
getCabinetManager().deletePublicationSystem(sess, ps);
List<PublicationSystem> systems2 = getCabinetManager().getPublicationSystems();
assertNotNull(systems2);
assertTrue(!systems2.isEmpty());
assertTrue(!systems2.contains(ps));
}
use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.
the class CabinetManagerBlImpl method findExternalPublicationsOfUser.
public List<Publication> findExternalPublicationsOfUser(PerunSession sess, int userId, int yearSince, int yearTill, String pubSysNamespace) throws CabinetException, InternalErrorException {
// get PubSys
PublicationSystem ps = getPublicationSystemManagerBl().getPublicationSystemByNamespace(pubSysNamespace);
// get user
User user;
try {
user = perun.getUsersManagerBl().getUserById(sess, userId);
} catch (UserNotExistsException ex) {
throw new CabinetException("User with ID: " + userId + " doesn't exists.", ErrorCodes.PERUN_EXCEPTION, ex);
}
// result list
List<Publication> result = new ArrayList<Publication>();
// PROCESS MU PUB SYS
if (ps.getLoginNamespace().equalsIgnoreCase("mu")) {
// get UCO
List<UserExtSource> ues = perun.getUsersManagerBl().getUserExtSources(sess, user);
String authorId = "";
for (UserExtSource es : ues) {
// get login from LDAP
if (es.getExtSource().getName().equalsIgnoreCase("LDAPMU")) {
// get only UCO
authorId = es.getLogin();
break;
// get login from IDP
} else if (es.getExtSource().getName().equalsIgnoreCase("https://idp2.ics.muni.cz/idp/shibboleth")) {
// get only UCO from UCO@mail.muni.cz
authorId = es.getLogin().substring(0, es.getLogin().indexOf("@"));
break;
}
}
// check
if (authorId.isEmpty()) {
throw new CabinetException("You don't have assigned identity in Perun for MU (LDAPMU / Shibboleth IDP).", ErrorCodes.NO_IDENTITY_FOR_PUBLICATION_SYSTEM);
}
// get publications
result.addAll(findPublicationsInPubSys(authorId, yearSince, yearTill, ps));
return result;
// PROCESS ZCU 3.0 PUB SYS
} else if (ps.getLoginNamespace().equalsIgnoreCase("zcu")) {
// search is based on "lastName,firstName"
String authorId = user.getLastName() + "," + user.getFirstName();
result.addAll(findPublicationsInPubSys(authorId, yearSince, yearTill, ps));
return result;
} else {
log.error("Publication System with namespace: [{}] found but not supported for import.", pubSysNamespace);
throw new CabinetException("PubSys namespace found but not supported for import.");
}
}
use of cz.metacentrum.perun.cabinet.model.PublicationSystem in project perun by CESNET.
the class CabinetBaseIntegrationTest method beforeClass.
// test -------------------------------
@Before
public void beforeClass() throws Exception {
//do only once for all tests
if (init)
return;
// principal
PerunPrincipal pp = new PerunPrincipal("perunTests", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL);
sess = perun.getPerunSession(pp, new PerunClient());
// setup world
User user = new User();
user.setLastName("cabinetTestUser");
user.setServiceUser(false);
user = perun.getUsersManagerBl().createUser(sess, user);
USER_ID = user.getId();
User user2 = new User();
user2.setLastName("cabinetTestUser2");
user2.setServiceUser(false);
user2 = perun.getUsersManagerBl().createUser(sess, user2);
USER_ID_2 = user2.getId();
// owner
Owner owner = new Owner();
owner.setName("PubOwner");
owner.setContact("Call me");
owner.setType(OwnerType.administrative);
this.owner = perun.getOwnersManagerBl().createOwner(sess, owner);
// category
c1 = new Category(0, "patent", 3.9);
c1 = getCabinetManager().createCategory(sess, c1);
// publication systems
PublicationSystem ps = new PublicationSystem();
ps.setFriendlyName("OBD");
ps.setLoginNamespace("zcu");
ps.setUrl("http://obd.zcu.cz:6443/fcgi/verso.fpl?");
ps.setType("cz.metacentrum.perun.cabinet.strategy.impl.OBD30Strategy");
pubSysZcu = getCabinetManager().createPublicationSystem(sess, ps);
assertTrue(pubSysZcu.getId() > 0);
PublicationSystem ps2 = new PublicationSystem();
ps2.setFriendlyName("Masarykova Univerzita - Prezentátor");
ps2.setLoginNamespace("mu");
ps2.setUrl("https://is.muni.cz/auth/prezentator/index.pl");
ps2.setUsername(cabinetProperties.getProperty("perun.cabinet.mu.login"));
ps2.setPassword(cabinetProperties.getProperty("perun.cabinet.mu.password"));
ps2.setType("cz.metacentrum.perun.cabinet.strategy.impl.MUStrategy");
pubSysMu = getCabinetManager().createPublicationSystem(sess, ps2);
assertTrue(pubSysMu.getId() > 0);
// create publication
Publication p1 = new Publication();
p1.setCategoryId(c1.getId());
p1.setExternalId(666);
p1.setPublicationSystemId(ps.getId());
p1.setCreatedBy(sess.getPerunPrincipal().getActor());
p1.setCreatedDate(new Date());
p1.setTitle("Some title");
p1.setIsbn("ISBN");
p1.setMain("MAIN");
p1.setYear(2020);
p1.setRank(0.0);
p1.setLocked(false);
p1.setDoi("DOI1");
Publication p2 = new Publication();
p2.setCategoryId(c1.getId());
p2.setExternalId(333);
p2.setPublicationSystemId(ps.getId());
p2.setCreatedBy(sess.getPerunPrincipal().getActor());
p2.setCreatedDate(new Date());
p2.setTitle("Some title vol. 2");
p2.setIsbn("ISBN2");
p2.setMain("MAIN2");
p2.setYear(2025);
p2.setRank(0.0);
p2.setLocked(false);
p2.setDoi("DOI2");
publicationOne = getCabinetManager().createPublication(sess, p1);
publicationTwo = getCabinetManager().createPublication(sess, p2);
Authorship a1 = new Authorship();
a1.setCreatedBy(sess.getPerunPrincipal().getActor());
a1.setCreatedDate(new Date());
// for PUB 1
a1.setPublicationId(p1.getId());
a1.setUserId(USER_ID);
Authorship a2 = new Authorship();
a2.setCreatedBy(sess.getPerunPrincipal().getActor());
a2.setCreatedDate(new Date());
// for PUB 1
a2.setPublicationId(p1.getId());
a2.setUserId(USER_ID_2);
a1 = getCabinetManager().createAuthorship(sess, a1);
a2 = getCabinetManager().createAuthorship(sess, a2);
authorshipOne = a1;
authorshipTwo = a2;
init = true;
}
Aggregations