Search in sources :

Example 1 with DuplicateJobException

use of net.geoprism.registry.etl.DuplicateJobException 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;
}
Also used : PublishListTypeVersionJob(net.geoprism.registry.etl.PublishListTypeVersionJob) QueryFactory(com.runwaysdk.query.QueryFactory) JobHistoryQuery(com.runwaysdk.system.scheduler.JobHistoryQuery) DuplicateJobException(net.geoprism.registry.etl.DuplicateJobException) JobHistory(com.runwaysdk.system.scheduler.JobHistory) PublishListTypeVersionJobQuery(net.geoprism.registry.etl.PublishListTypeVersionJobQuery) JsonObject(com.google.gson.JsonObject) ListTypeVersion(net.geoprism.registry.ListTypeVersion) GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) Request(com.runwaysdk.session.Request)

Aggregations

JsonObject (com.google.gson.JsonObject)1 QueryFactory (com.runwaysdk.query.QueryFactory)1 Request (com.runwaysdk.session.Request)1 JobHistory (com.runwaysdk.system.scheduler.JobHistory)1 JobHistoryQuery (com.runwaysdk.system.scheduler.JobHistoryQuery)1 ListTypeVersion (net.geoprism.registry.ListTypeVersion)1 DuplicateJobException (net.geoprism.registry.etl.DuplicateJobException)1 PublishListTypeVersionJob (net.geoprism.registry.etl.PublishListTypeVersionJob)1 PublishListTypeVersionJobQuery (net.geoprism.registry.etl.PublishListTypeVersionJobQuery)1 GlobalNotificationMessage (net.geoprism.registry.ws.GlobalNotificationMessage)1