use of net.geoprism.registry.etl.PublishListTypeVersionJob in project geoprism-registry by terraframe.
the class ListTypeService method publishVersion.
@Request(RequestType.SESSION)
public JsonObject publishVersion(String sessionId, String oid) {
ListTypeVersion version = ListTypeVersion.get(oid);
// Only a working version can be republished.
if (!version.getWorking()) {
throw new UnsupportedOperationException();
}
this.enforceReadPermissions(version.getListType());
QueryFactory factory = new QueryFactory();
PublishListTypeVersionJobQuery query = new PublishListTypeVersionJobQuery(factory);
query.WHERE(query.getVersion().EQ(version));
JobHistoryQuery q = new JobHistoryQuery(factory);
q.WHERE(q.getStatus().containsAny(AllJobStatus.NEW, AllJobStatus.QUEUED, AllJobStatus.RUNNING));
q.AND(q.job(query));
if (q.getCount() > 0) {
throw new DuplicateJobException("This version has already been queued for publishing");
}
PublishListTypeVersionJob job = new PublishListTypeVersionJob();
job.setRunAsUserId(Session.getCurrentSession().getUser().getOid());
job.setVersion(version);
job.setListType(version.getListType());
job.apply();
NotificationFacade.queue(new GlobalNotificationMessage(MessageType.PUBLISH_JOB_CHANGE, null));
final JobHistory history = job.start();
JsonObject resp = new JsonObject();
resp.addProperty("jobOid", history.getOid());
return resp;
}
Aggregations