private void setupRankingList() { RestMessage rms = WebUtils.prepareRestTransmission("UsageStatistics/").sendGetRestMessage(); if ((rms == null) || (rms.getListEntrySets().isEmpty()) || (rms.getStatus() != RestStatusEnum.OK)) { logger.warn("received no UsageData_Ranking data "); return; } listHitOID = new ArrayList<BigDecimal>(); for (RestEntrySet res : rms.getListEntrySets()) { Iterator<String> it = res.getKeyIterator(); String key = ""; while (it.hasNext()) { key = (String) it.next(); if ("object_id".equals(key)) { listHitOID.add(new BigDecimal(res.getValue(key))); logger.info("Key" + key + ": " + res.getValue(key) + ""); } } } }
/** * @see de.dini.oanetzwerk.server.handler.AbstractKeyWordHandler#putKeyWord(java.lang.String[], * java.lang.String) */ @Override protected String putKeyWord(String[] path, String data) { BigDecimal object_id = null; String mimeformat = null; String link = null; this.rms = RestXmlCodec.decodeRestMessage(data); RestEntrySet res = this.rms.getListEntrySets().get(0); Iterator<String> it = res.getKeyIterator(); String key = ""; try { object_id = new BigDecimal(path[0]); if (object_id.intValue() < 0) { logger.error(path[0] + " is NOT a valid number for this parameter!"); this.rms = new RestMessage(RestKeyword.FullTextLinks); this.rms.setStatus(RestStatusEnum.WRONG_PARAMETER); this.rms.setStatusDescription(path[0] + " is NOT a valid number for this parameter!"); return RestXmlCodec.encodeRestMessage(this.rms); } } catch (NumberFormatException ex) { logger.error(path[0] + " is NOT a number!", ex); this.rms = new RestMessage(RestKeyword.FullTextLinks); this.rms.setStatus(RestStatusEnum.WRONG_PARAMETER); this.rms.setStatusDescription(path[0] + " is NOT a number!"); return RestXmlCodec.encodeRestMessage(this.rms); } try { while (it.hasNext()) { key = it.next(); if (logger.isDebugEnabled()) logger.debug("key = " + key); // if (key.equalsIgnoreCase ("object_id")) // object_id = new BigDecimal (res.getValue (key)); // else if (key.equalsIgnoreCase ("mimeformat")) if (key.equalsIgnoreCase("mimeformat")) mimeformat = new String(res.getValue(key)); else if (key.equalsIgnoreCase("link")) link = new String(res.getValue(key)); else continue; } } catch (NumberFormatException ex) { logger.error(res.getValue(key) + " is NOT a number!", ex); this.rms = new RestMessage(RestKeyword.FullTextLinks); this.rms.setStatusDescription(res.getValue(key) + " is NOT a number!"); return RestXmlCodec.encodeRestMessage(this.rms); } this.rms = new RestMessage(RestKeyword.FullTextLinks); DBAccessNG dbng = DBAccessNG.getInstance(super.getDataSource()); ; MultipleStatementConnection stmtconn = null; res = new RestEntrySet(); try { stmtconn = (MultipleStatementConnection) dbng.getMultipleStatementConnection(); stmtconn.loadStatement( dbng.insertIntoDB().FullTextLinks(stmtconn.connection, object_id, mimeformat, link)); this.result = stmtconn.execute(); logWarnings(); stmtconn.commit(); stmtconn.loadStatement(dbng.selectFromDB().FullTextLinks(stmtconn.connection, object_id)); this.result = stmtconn.execute(); if (this.result.getResultSet().next()) { res.addEntry( "object_id", this.result.getResultSet().getBigDecimal("object_id").toPlainString()); stmtconn.commit(); this.rms.setStatus(RestStatusEnum.OK); } else { this.rms.setStatus(RestStatusEnum.NO_OBJECT_FOUND_ERROR); this.rms.setStatusDescription("No matching WorklflowDB Entry found"); } } catch (SQLException ex) { logger.error(ex.getLocalizedMessage(), ex); this.rms.setStatus(RestStatusEnum.SQL_ERROR); this.rms.setStatusDescription(ex.getLocalizedMessage()); } catch (WrongStatementException ex) { logger.error(ex.getLocalizedMessage(), ex); this.rms.setStatus(RestStatusEnum.WRONG_STATEMENT); this.rms.setStatusDescription(ex.getLocalizedMessage()); } finally { if (stmtconn != null) { try { stmtconn.close(); stmtconn = null; } catch (SQLException ex) { logger.error(ex.getLocalizedMessage(), ex); } } this.rms.addEntrySet(res); res = null; this.result = null; dbng = null; } return RestXmlCodec.encodeRestMessage(this.rms); }