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);
}
Aggregations