Search in sources :

Example 1 with OrcidElementCantBeDeletedException

use of org.orcid.core.exception.OrcidElementCantBeDeletedException in project ORCID-Source by ORCID.

the class GroupIdRecordManagerImpl method deleteGroupIdRecord.

@Override
public void deleteGroupIdRecord(Long putCode) {
    GroupIdRecordEntity existingEntity = groupIdRecordDao.find(putCode);
    if (existingEntity != null) {
        if (groupIdRecordDao.haveAnyPeerReview(existingEntity.getGroupId())) {
            throw new OrcidElementCantBeDeletedException("Unable to delete group id because there are peer reviews associated to it");
        }
        orcidSecurityManager.checkSource(existingEntity);
        groupIdRecordDao.remove(Long.valueOf(putCode));
    } else {
        throw new GroupIdRecordNotFoundException();
    }
}
Also used : OrcidElementCantBeDeletedException(org.orcid.core.exception.OrcidElementCantBeDeletedException) GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity) GroupIdRecordNotFoundException(org.orcid.core.exception.GroupIdRecordNotFoundException)

Example 2 with OrcidElementCantBeDeletedException

use of org.orcid.core.exception.OrcidElementCantBeDeletedException in project ORCID-Source by ORCID.

the class GroupIdRecordManagerImpl method deleteGroupIdRecord.

@Override
public void deleteGroupIdRecord(Long putCode) {
    GroupIdRecordEntity existingEntity = groupIdRecordDao.find(putCode);
    if (existingEntity != null) {
        if (groupIdRecordDao.haveAnyPeerReview(existingEntity.getGroupId())) {
            throw new OrcidElementCantBeDeletedException("Unable to delete group id because there are peer reviews associated to it");
        }
        orcidSecurityManager.checkSource(existingEntity);
        groupIdRecordDao.remove(Long.valueOf(putCode));
    } else {
        throw new GroupIdRecordNotFoundException();
    }
}
Also used : OrcidElementCantBeDeletedException(org.orcid.core.exception.OrcidElementCantBeDeletedException) GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity) GroupIdRecordNotFoundException(org.orcid.core.exception.GroupIdRecordNotFoundException)

Aggregations

GroupIdRecordNotFoundException (org.orcid.core.exception.GroupIdRecordNotFoundException)2 OrcidElementCantBeDeletedException (org.orcid.core.exception.OrcidElementCantBeDeletedException)2 GroupIdRecordEntity (org.orcid.persistence.jpa.entities.GroupIdRecordEntity)2