Search in sources :

Example 1 with PublishedEntityException

use of org.sagebionetworks.bridge.exceptions.PublishedEntityException in project BridgeServer2 by Sage-Bionetworks.

the class Schedule2Service method publishSchedule.

/**
 * Publish this schedule so it can no longer be modified.
 */
public Schedule2 publishSchedule(String appId, String guid) {
    Schedule2 existing = dao.getSchedule(appId, guid).orElseThrow(() -> new EntityNotFoundException(Schedule2.class));
    CAN_EDIT_SCHEDULES.checkAndThrow(ORG_ID, existing.getOwnerId());
    if (existing.isDeleted()) {
        throw new EntityNotFoundException(Schedule2.class);
    }
    if (existing.isPublished()) {
        throw new PublishedEntityException(existing);
    }
    existing.setPublished(true);
    existing.setModifiedOn(getModifiedOn());
    studyService.updateStudyEtags(appId, guid, existing.getModifiedOn());
    return dao.updateSchedule(existing);
}
Also used : Schedule2(org.sagebionetworks.bridge.models.schedules2.Schedule2) PublishedEntityException(org.sagebionetworks.bridge.exceptions.PublishedEntityException) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException)

Aggregations

EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)1 PublishedEntityException (org.sagebionetworks.bridge.exceptions.PublishedEntityException)1 Schedule2 (org.sagebionetworks.bridge.models.schedules2.Schedule2)1