List of usage examples for com.mongodb DBObject toMap
Map toMap();
From source file:de.fhg.igd.mongomvcc.impl.MongoDBVCursor.java
License:Open Source License
@Override public Iterator<Map<String, Object>> iterator() { Iterator<DBObject> it = _delegate.iterator(); if (_filter != null) { it = new FilteringIterator<DBObject>(it, _filter); }/* ww w .java 2s . c om*/ return new TransformingIterator<DBObject, Map<String, Object>>(it) { @SuppressWarnings("unchecked") @Override protected Map<String, Object> transform(DBObject input) { if (input instanceof Map) { return (Map<String, Object>) input; } return input.toMap(); } }; }
From source file:dev.j.regere.respository.MongoIntermediatePersistedTable.java
License:Apache License
@Override public RegereRuleFlowWrapper load(String regereId, String commonIdentifier, Map<String, Object> currentEvent) { final BasicDBObject dbList = new BasicDBObject(ID, regereId + STRING_COLAN + commonIdentifier); if (logger.isDebugEnabled()) { logger.debug("loading intermediate event for key [" + dbList.get(ID) + "]"); }//from ww w . j av a2 s . c o m final DBObject dbObject = dbCollection.findOne(dbList); if (dbObject != null) { logger.info("New intermediate object found loading the object from db"); currentEvent = loadPersistedValues(currentEvent, dbObject.toMap()); } //todo store final rule passed variable and the pass re rules in mongo return new RegereRuleFlowWrapper(currentEvent, new HashSet<Integer>(10)); }
From source file:edu.emory.bmi.datacafe.mongo.MongoConnector.java
License:Open Source License
/** * Prints the cursor//from ww w . j av a 2s . co m * * @param fullDataSourceName the full data source name * @param results the DBCursor * @param addHeader Should a header with attributes be added. */ public String getCursorValues(String fullDataSourceName, DBCursor results, boolean addHeader) { String outValue = ""; while (results.hasNext()) { DBObject resultElement = results.next(); Map resultElementMap = resultElement.toMap(); Collection resultValues = resultElementMap.values(); if (addHeader) { if (outValue.trim().equals("")) { Collection resultNames = resultElementMap.keySet(); outValue += DataCafeUtil.constructStringFromCollection(resultNames); if (!(ConfigReader.getHiveServer().equals("") || (ConfigReader.getHiveServer() == null))) { //start doing the Hive Things String query = DataCafeUtil .wrapTheQuery(DataCafeUtil.constructQueryFromCollection(resultNames)); HiveConnector hiveConnector = new HiveConnector(datalakeID); hiveConnector.writeToHive(fullDataSourceName, query); } outValue += "\n"; } } String temp = DataCafeUtil.constructStringFromCollection(resultValues); outValue += temp; if (logger.isDebugEnabled()) { logger.debug(outValue); } } return outValue; }
From source file:edu.slu.action.ObjectAction.java
/** * Get annotation by objectiD. Strip all unnecessary key:value pairs before returning. * @param oid variable assigned by urlrewrite rule for /id in urlrewrite.xml * @rspond with the new annotation ID in the Location header and the new object created in the body. * @throws java.io.IOException//from w w w .j a va 2 s . c om * @throws javax.servlet.ServletException */ public void getByID() throws IOException, ServletException, Exception { request.setCharacterEncoding("UTF-8"); if (null != oid && methodApproval(request, "get")) { //find one version by objectID BasicDBObject query = new BasicDBObject(); query.append("_id", oid); DBObject myAnno = mongoDBService.findOneByExample(Constant.COLLECTION_ANNOTATION, query); if (null != myAnno) { BasicDBObject bdbo = (BasicDBObject) myAnno; JSONObject jo = JSONObject.fromObject(myAnno.toMap()); //String idForHeader = jo.getString("_id"); //The following are rerum properties that should be stripped. They should be in __rerum. jo.remove("_id"); jo.remove("addedTime"); jo.remove("originalAnnoID"); jo.remove("version"); jo.remove("permission"); jo.remove("forkFromID"); // retained for legacy v0 objects jo.remove("serverName"); jo.remove("serverIP"); // @context may not be here and shall not be added, but the response // will not be ld+json without it. try { addWebAnnotationHeaders(oid, isContainerType(jo), isLD(jo)); response.addHeader("Content-Type", "application/json; charset=utf-8"); response.addHeader("Access-Control-Allow-Origin", "*"); response.setStatus(HttpServletResponse.SC_OK); out = response.getWriter(); out.write(mapper.writer().withDefaultPrettyPrinter().writeValueAsString(jo)); } catch (IOException ex) { Logger.getLogger(ObjectAction.class.getName()).log(Level.SEVERE, null, ex); } } else { writeErrorResponse("No object found with provided id '" + oid + "'.", HttpServletResponse.SC_NOT_FOUND); } } }
From source file:edu.uniandes.yelp.recommender.MongoDBDataModel.java
/** * <p>// w w w . j a v a2s . co m * Translates the MongoDB identifier to Mahout/MongoDBDataModel's internal * identifier, if required. * </p> * <p> * If MongoDB identifiers are long datatypes, it returns the id. * </p> * <p> * This conversion is needed since Mahout uses the long datatype to feed the * recommender, and MongoDB uses 12 bytes to create its identifiers. * </p> * * @param id MongoDB identifier * @param isUser * @return String containing the translation of the external MongoDB ID to * internal long ID (mapping). * @see #fromLongToId(long) * @see <a href="http://www.mongodb.org/display/DOCS/Object%20IDs"> * Mongo Object IDs</a> */ public String fromIdToLong(String id, boolean isUser) { DBObject objectIdLong = collectionMap.findOne(new BasicDBObject("element_id", id)); if (objectIdLong != null) { Map<String, Object> idLong = (Map<String, Object>) objectIdLong.toMap(); Object value = idLong.get("long_value"); return value == null ? null : value.toString(); } else { objectIdLong = new BasicDBObject(); String longValue = Long.toString(idCounter++); objectIdLong.put("element_id", id); objectIdLong.put("long_value", longValue); collectionMap.insert(objectIdLong); //log.info("Adding Translation {}: {} long_value: {}", isUser ? "User ID" : "Item ID", id, longValue); return longValue; } }
From source file:eu.eubrazilcc.lvl.storage.mongodb.MongoDBConnector.java
License:EUPL
/** * Updates a object previously stored in a collection. * @param obj - value used to update the object * @param query - statement that is used to find the object in the collection * @param collection - collection where the object is searched *///from w w w . ja va2 s . c om public void update(final DBObject obj, final DBObject query, final String collection) { checkArgument(obj != null, "Uninitialized object"); checkArgument(isNotBlank(collection), "Uninitialized or invalid collection"); final DB db = client().getDB(CONFIG_MANAGER.getDbName()); final DBCollection dbcol = db.getCollection(collection); final BasicDBObject current = (BasicDBObject) dbcol.findOne(query); checkState(current != null, "Object not found"); dbcol.save(BasicDBObjectBuilder.start(obj.toMap()).append("_id", current.get("_id")).get()); }
From source file:eu.vital.vitalcep.restApp.alert.Alerts.java
/** * Creates a filter.//from w w w. j av a 2 s .c o m * * @param cepico * @param req * @return the filter id * @throws java.io.IOException */ @PUT @Path("createalert") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createAlert(String cepico, @Context HttpServletRequest req) throws IOException { StringBuilder ck = new StringBuilder(); Security slogin = new Security(); JSONObject credentials = new JSONObject(); Boolean token = slogin.login(req.getHeader("name"), req.getHeader("password"), false, ck); credentials.put("username", req.getHeader("name")); credentials.put("password", req.getHeader("password")); if (!token) { return Response.status(Response.Status.UNAUTHORIZED).build(); } this.cookie = ck.toString(); JSONObject jo = new JSONObject(cepico); if (!jo.has("source")) { return Response.status(Response.Status.BAD_REQUEST).build(); } MongoClient mongo = new MongoClient(new MongoClientURI(mongoURL)); MongoDatabase db = mongo.getDatabase(mongoDB); try { db.getCollection("alerts"); } catch (Exception e) { //System.out.println("Mongo is down"); mongo.close(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } finally { if (db != null) db = null; if (mongo != null) { mongo.close(); mongo = null; } } // create an empty query BasicDBObject query = new BasicDBObject(); BasicDBObject fields = new BasicDBObject().append("_id", false); fields.append("dolceSpecification", false); if (jo.has("dolceSpecification")) { //Filter oFilter = new Filter(filter); JSONObject dsjo = jo.getJSONObject("dolceSpecification"); String str = dsjo.toString();//"{\"dolceSpecification\": "+ dsjo.toString()+"}"; try { DolceSpecification ds = new DolceSpecification(str); if (ds instanceof DolceSpecification) { UUID uuid = UUID.randomUUID(); String randomUUIDString = uuid.toString(); String mqin = RandomStringUtils.randomAlphanumeric(8); String mqout = RandomStringUtils.randomAlphanumeric(8); Date NOW = new Date(); JSONArray requestArray; try { requestArray = createAlertRequests(jo.getJSONArray("source"), ds.getEvents(), getXSDDateTime(NOW)); } catch (Exception e) { return Response.status(Response.Status.BAD_REQUEST) .entity("not available getObservation Service for this sensor ").build(); } CEP cepProcess = new CEP(); if (!(cepProcess.CEPStart(CEP.CEPType.ALERT, ds, mqin, mqout, confFile, requestArray.toString(), credentials))) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } String clientName = cepProcess.fileName; if (cepProcess.PID < 1) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } DBObject dbObject = createAlertSensor(cepico, randomUUIDString, dsjo, cepProcess.id); Document doc = new Document(dbObject.toMap()); try { db.getCollection("alerts").insertOne(doc); JSONObject opState = createOperationalStateObservation(randomUUIDString); String sensorId = host + "/sensor/" + randomUUIDString; MessageProcessor_publisher Publisher_MsgProcc = new MessageProcessor_publisher(this.dmsURL, cookie, sensorId, "alertsobservations", mongoURL, mongoDB);//555 MQTT_connector_subscriper publisher = new MQTT_connector_subscriper(mqout, Publisher_MsgProcc); MqttConnectorContainer.addConnector(publisher.getClientName(), publisher); DBObject oPut = (DBObject) JSON.parse(opState.toString()); Document doc1 = new Document(oPut.toMap()); try { db.getCollection("alertsobservations").insertOne(doc1); String id = doc1.get("_id").toString(); } catch (MongoException ex) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } JSONObject aOutput = new JSONObject(); aOutput.put("id", host + "/sensor/" + randomUUIDString); return Response.status(Response.Status.OK).entity(aOutput.toString()).build(); } catch (MongoException ex) { return Response.status(Response.Status.BAD_REQUEST).build(); } } else { return Response.status(Response.Status.BAD_REQUEST).build(); } } catch (JSONException | IOException e) { return Response.status(Response.Status.BAD_REQUEST).build(); } } return Response.status(Response.Status.BAD_REQUEST).build(); }
From source file:eu.vital.vitalcep.restApp.cepRESTApi.CEPICO.java
/** * Creates a filter./* ww w . j a v a 2 s . c om*/ * * @param cepico * @param req * @return the filter id * @throws java.io.IOException */ @PUT @Path("createcepico") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createCEPICO(String cepico, @Context HttpServletRequest req) throws IOException { StringBuilder ck = new StringBuilder(); Security slogin = new Security(); JSONObject credentials = new JSONObject(); Boolean token = slogin.login(req.getHeader("name"), req.getHeader("password"), false, ck); credentials.put("username", req.getHeader("name")); credentials.put("password", req.getHeader("password")); if (!token) { return Response.status(Response.Status.UNAUTHORIZED).build(); } this.cookie = ck.toString(); JSONObject jo = new JSONObject(cepico); if (!jo.has("source")) { return Response.status(Response.Status.BAD_REQUEST).build(); } MongoClient mongo = new MongoClient(new MongoClientURI(mongoURL)); MongoDatabase db = mongo.getDatabase(mongoDB); try { db.getCollection("cepicos"); } catch (Exception e) { //System.out.println("Mongo is down"); mongo.close(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } if (jo.has("dolceSpecification")) { //Filter oFilter = new Filter(filter); JSONObject dsjo = jo.getJSONObject("dolceSpecification"); String str = dsjo.toString();//"{\"dolceSpecification\": "+ dsjo.toString()+"}"; try { DolceSpecification ds = new DolceSpecification(str); if (ds instanceof DolceSpecification) { UUID uuid = UUID.randomUUID(); String randomUUIDString = uuid.toString(); String mqin = RandomStringUtils.randomAlphanumeric(8); String mqout = RandomStringUtils.randomAlphanumeric(8); Date NOW = new Date(); JSONArray requestArray; try { requestArray = createCEPICORequests(jo.getJSONArray("source"), ds.getEvents(), getXSDDateTime(NOW)); } catch (Exception e) { mongo.close(); return Response.status(Response.Status.BAD_REQUEST) .entity("not available getObservation Service for this sensor ").build(); } CEP cepProcess = new CEP(); if (!(cepProcess.CEPStart(CEP.CEPType.CEPICO, ds, mqin, mqout, confFile, requestArray.toString(), credentials))) { mongo.close(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } if (cepProcess.PID < 1) { mongo.close(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } DBObject dbObject = createCEPSensor(cepico, randomUUIDString, dsjo, cepProcess.id); Document doc = new Document(dbObject.toMap()); try { db.getCollection("cepicos").insertOne(doc); JSONObject opState = createOperationalStateObservation(randomUUIDString); String sensorId = host + "/sensor/" + randomUUIDString; MessageProcessor_publisher Publisher_MsgProcc = new MessageProcessor_publisher(this.dmsURL, cookie, sensorId, "cepicosobservations", mongoURL, mongoDB);//555 MQTT_connector_subscriper publisher = new MQTT_connector_subscriper(mqout, Publisher_MsgProcc); MqttConnectorContainer.addConnector(publisher.getClientName(), publisher); DBObject oPut = (DBObject) JSON.parse(opState.toString()); Document doc1 = new Document(oPut.toMap()); try { db.getCollection("cepicosobservations").insertOne(doc1); String id = doc1.get("_id").toString(); } catch (MongoException ex) { mongo.close(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } JSONObject aOutput = new JSONObject(); aOutput.put("id", host + "/sensor/" + randomUUIDString); return Response.status(Response.Status.OK).entity(aOutput.toString()).build(); } catch (MongoException ex) { return Response.status(Response.Status.BAD_REQUEST).build(); } } else { mongo.close(); return Response.status(Response.Status.BAD_REQUEST).build(); } } catch (MongoException ex) { return Response.status(Response.Status.BAD_REQUEST).build(); } } else { mongo.close(); return Response.status(Response.Status.BAD_REQUEST).build(); } }
From source file:eu.vital.vitalcep.restApp.filteringApi.ContinuosFiltering.java
/** * Creates a filter.// w w w. jav a 2 s . c om * * @param filter * @param req * @return the filter id * @throws java.io.IOException */ @PUT @Path("createcontinuousfilter") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createcontinuousfilter(String filter, @Context HttpServletRequest req) throws IOException { StringBuilder ck = new StringBuilder(); Security slogin = new Security(); JSONObject credentials = new JSONObject(); Boolean token = slogin.login(req.getHeader("name"), req.getHeader("password"), false, ck); credentials.put("username", req.getHeader("name")); credentials.put("password", req.getHeader("password")); if (!token) { return Response.status(Response.Status.UNAUTHORIZED).build(); } this.cookie = ck.toString(); JSONObject jo = new JSONObject(filter); MongoClient mongo = new MongoClient(new MongoClientURI(mongoURL)); MongoDatabase db = mongo.getDatabase(mongoDB); try { db.getCollection("continuousfilters"); } catch (Exception e) { //System.out.println("Mongo is down"); db = null; if (mongo != null) { mongo.close(); mongo = null; } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } if (jo.has("dolceSpecification")) { JSONObject dsjo = jo.getJSONObject("dolceSpecification"); String str = dsjo.toString();//"{\"dolceSpecification\": "+ dsjo.toString()+"}"; try { DolceSpecification ds = new DolceSpecification(str); if (ds instanceof DolceSpecification) { UUID uuid = UUID.randomUUID(); String randomUUIDString = uuid.toString(); String mqin = RandomStringUtils.randomAlphanumeric(8); String mqout = RandomStringUtils.randomAlphanumeric(8); CEP cepProcess = new CEP(); if (!(cepProcess.CEPStart(CEP.CEPType.CONTINUOUS, ds, mqin, mqout, confFile, jo.getJSONArray("source").toString(), credentials))) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } if (cepProcess.PID < 1) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } DBObject dbObject = createCEPFilterSensor(filter, randomUUIDString, dsjo, cepProcess.id); Document doc = new Document(dbObject.toMap()); try { db.getCollection("continuousfilters").insertOne(doc); JSONObject aOutput = new JSONObject(); String sensorId = host + "/sensor/" + randomUUIDString; aOutput.put("id", sensorId); //MIGUEL MessageProcessor_publisher Publisher_MsgProcc = new MessageProcessor_publisher(this.dmsURL, this.cookie, sensorId, "continuosfiltersobservations", this.mongoURL, this.mongoDB);//555 MQTT_connector_subscriper publisher = new MQTT_connector_subscriper(mqout, Publisher_MsgProcc); MqttConnectorContainer.addConnector(publisher.getClientName(), publisher); //TODO --> DESTROY DEL CONNECTOR. // MqttConnectorContainer.deleteConnector(publisher // .getClientName()); JSONObject opState = createOperationalStateObservation(randomUUIDString); DBObject oPut = (DBObject) JSON.parse(opState.toString()); Document doc1 = new Document(oPut.toMap()); try { db.getCollection("continuosfiltersobservations").insertOne(doc1); String id = doc1.get("_id").toString(); db = null; if (mongo != null) { mongo.close(); mongo = null; } } catch (MongoException ex) { db = null; if (mongo != null) { mongo.close(); mongo = null; } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } return Response.status(Response.Status.OK).entity(aOutput.toString()).build(); } catch (MongoException ex) { db = null; if (mongo != null) { mongo.close(); mongo = null; } return Response.status(Response.Status.BAD_REQUEST).build(); } } else { return Response.status(Response.Status.BAD_REQUEST).build(); } } catch (JSONException | IOException e) { return Response.status(Response.Status.BAD_REQUEST).build(); } } return Response.status(Response.Status.BAD_REQUEST).build(); }
From source file:eu.vital.vitalcep.restApp.filteringApi.StaticFiltering.java
/** * Creates a filter./*from w w w.j a va 2 s . c o m*/ * * @param info * @return the filter id * @throws java.io.IOException */ @POST @Path("filterstaticdata") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response filterstaticdata(String info, @Context HttpServletRequest req) throws IOException, UnsupportedEncodingException, NoSuchAlgorithmException { JSONObject jo = new JSONObject(info); if (jo.has("dolceSpecification") && jo.has("data")) { // && jo.has("data") for demo MongoClient mongo = new MongoClient(new MongoClientURI(mongoURL)); MongoDatabase db = mongo.getDatabase(mongoDB); try { db.getCollection("staticdatafilters"); } catch (Exception e) { //System.out.println("Mongo is down"); db = null; if (mongo != null) { mongo.close(); mongo = null; } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } if (jo.has("dolceSpecification")) { //Filter oFilter = new Filter(filter); JSONObject dsjo = jo.getJSONObject("dolceSpecification"); String str = dsjo.toString();//"{\"dolceSpecification\": "+ dsjo.toString()+"}"; try { DolceSpecification ds = new DolceSpecification(str); if (!(ds instanceof DolceSpecification)) { return Response.status(Response.Status.BAD_REQUEST).build(); } String mqin = RandomStringUtils.randomAlphanumeric(8); String mqout = RandomStringUtils.randomAlphanumeric(8); JSONArray aData = jo.getJSONArray("data"); CEP cepProcess = new CEP(); if (!(cepProcess.CEPStart(CEP.CEPType.DATA, ds, mqin, mqout, confFile, aData.toString(), null))) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } String clientName = "collector_" + RandomStringUtils.randomAlphanumeric(4); if (cepProcess.PID < 1) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } UUID uuid = UUID.randomUUID(); String randomUUIDString = uuid.toString(); DBObject dbObject = createCEPFilterStaticSensorJsonld(info, randomUUIDString, jo, dsjo, "vital:CEPFilterStaticDataSensor"); Document doc = new Document(dbObject.toMap()); try { db.getCollection("staticdatafilters").insertOne(doc); String id = doc.get("_id").toString(); } catch (MongoException ex) { db = null; if (mongo != null) { mongo.close(); mongo = null; } return Response.status(Response.Status.BAD_REQUEST).build(); } JSONObject opState = createOperationalStateObservation(randomUUIDString); DBObject oPut = (DBObject) JSON.parse(opState.toString()); Document doc1 = new Document(oPut.toMap()); try { db.getCollection("staticdatafiltersobservations").insertOne(doc1); String id = doc1.get("_id").toString(); } catch (MongoException ex) { db = null; if (mongo != null) { mongo.close(); mongo = null; } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } ///////////////////////////////////////////////////// // creates client and messages process // MqttAllInOne oMqtt = new MqttAllInOne(); TMessageProc MsgProcc = new TMessageProc(); ///////////////////////////////////////////////////////////////////////// // PREPARING DOLCE INPUT Decoder decoder = new Decoder(); ArrayList<String> simpleEventAL = decoder.JsonldArray2DolceInput(aData); String sal = simpleEventAL.toString(); ///////////////////////////////////////////////////////////////////////////// // SENDING TO MOSQUITTO oMqtt.sendMsg(MsgProcc, clientName, simpleEventAL, mqin, mqout, false); ///////////////////////////////////////////////////////////////////////////// //RECEIVING FROM MOSQUITO ArrayList<MqttMsg> mesagges = MsgProcc.getMsgs(); ArrayList<Document> outputL; outputL = new ArrayList<>(); Encoder encoder = new Encoder(); outputL = encoder.dolceOutputList2ListDBObject(mesagges, host, randomUUIDString); String sOutput = "["; for (int i = 0; i < outputL.size(); i++) { Document element = outputL.get(i); if (i == 0) { sOutput = sOutput + element.toJson(); } sOutput = sOutput + "," + element.toJson(); } sOutput = sOutput + "]"; StringBuilder ck = new StringBuilder(); try { Security slogin = new Security(); Boolean token = slogin.login(req.getHeader("name"), req.getHeader("password"), false, ck); if (!token) { return Response.status(Response.Status.UNAUTHORIZED).build(); } cookie = ck.toString(); DMSManager oDMS = new DMSManager(dmsURL, cookie); MongoCollection<Document> collection = db.getCollection("staticdatafiltersobservations"); if (outputL.size() > 0) { collection.insertMany(outputL); if (!oDMS.pushObservations(sOutput)) { java.util.logging.Logger.getLogger(StaticFiltering.class.getName()) .log(Level.SEVERE, "couldn't save to the DMS"); } } } catch (KeyManagementException | KeyStoreException ex) { db = null; if (mongo != null) { mongo.close(); mongo = null; } java.util.logging.Logger.getLogger(MessageProcessor_publisher.class.getName()) .log(Level.SEVERE, null, ex); } //cepProcess. try { CepContainer.deleteCepProcess(cepProcess.PID); if (!cepProcess.cepDispose()) { java.util.logging.Logger.getLogger(StaticFiltering.class.getName()).log(Level.SEVERE, "couldn't terminate ucep"); } } catch (Exception e) { java.util.logging.Logger.getLogger(StaticFiltering.class.getName()).log(Level.SEVERE, null, e); } db = null; if (mongo != null) { mongo.close(); mongo = null; } return Response.status(Response.Status.OK).entity(sOutput).build(); } catch (IOException | JSONException | java.text.ParseException e) { db = null; if (mongo != null) { mongo.close(); mongo = null; } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } return Response.status(Response.Status.BAD_REQUEST).build(); } return Response.status(Response.Status.BAD_REQUEST).build(); }