use of org.sagebionetworks.bridge.validators.TemplateRevisionValidator in project BridgeServer2 by Sage-Bionetworks.
the class TemplateRevisionService method createTemplateRevision.
public CreatedOnHolder createTemplateRevision(String appId, String templateGuid, TemplateRevision revision) {
checkNotNull(appId);
checkNotNull(templateGuid);
checkNotNull(revision);
DateTime createdOn = getDateTime();
String storagePath = templateGuid + "." + createdOn.getMillis();
// verify the template GUID is in the user's app.
Template template = templateDao.getTemplate(appId, templateGuid).orElseThrow(() -> new EntityNotFoundException(Template.class));
revision.setCreatedOn(createdOn);
revision.setTemplateGuid(templateGuid);
revision.setCreatedBy(getUserId());
revision.setStoragePath(storagePath);
TemplateRevisionValidator validator = new TemplateRevisionValidator(template.getTemplateType());
Validate.entityThrowingException(validator, revision);
templateRevisionDao.createTemplateRevision(revision);
return new CreatedOnHolder(createdOn);
}
Aggregations