use of cz.metacentrum.perun.cabinet.model.Author in project perun by CESNET.
the class ThanksManagerBlImpl method deleteThanks.
@Override
public void deleteThanks(PerunSession sess, Thanks thanks) throws CabinetException {
getThanksManagerDao().deleteThanks(sess, thanks);
log.debug("{} deleted.", thanks);
// recalculate thanks for all publication's authors
List<Author> authors = getAuthorshipManagerBl().getAuthorsByPublicationId(thanks.getPublicationId());
synchronized (ThanksManagerBlImpl.class) {
for (Author a : authors) {
getCabinetManagerBl().setThanksAttribute(a.getId());
}
}
}
use of cz.metacentrum.perun.cabinet.model.Author in project perun by CESNET.
the class CabinetManagerImpl method getAuthorsByPublicationId.
@Override
public List<Author> getAuthorsByPublicationId(PerunSession session, int id) throws PrivilegeException, CabinetException {
List<Author> authors = getAuthorshipManagerBl().getAuthorsByPublicationId(id);
boolean oneOfAuthors = false;
for (Author author : authors) {
if (author.getId() == session.getPerunPrincipal().getUserId()) {
oneOfAuthors = true;
break;
}
}
// Authorization
if (AuthzResolver.authorizedInternal(session, "getAuthorsByPublicationId_int_policy")) {
oneOfAuthors = true;
}
if (!oneOfAuthors) {
// not author, but check if user created publication, then he can list current authors
Publication publication = getPublicationManagerBl().getPublicationById(id);
if ((publication.getCreatedByUid() != session.getPerunPrincipal().getUserId()) && !(Objects.equals(publication.getCreatedBy(), session.getPerunPrincipal().getActor()))) {
throw new PrivilegeException("getAuthorsByPublicationId");
}
}
return authors;
}
Aggregations