List of usage examples for java.util GregorianCalendar setTimeInMillis
public void setTimeInMillis(long millis)
From source file:org.apache.juddi.v3.tck.UDDI_141_JIRAIntegrationTest.java
/** * testing callbacks with undefined transport type with a uppercase path * this also tests the case of one user subscribing to a specific entity * via GetBusinessDetail subscription filter * * @throws Exception/* www .j a v a2 s.co m*/ */ @Test public void JIRA_596() throws Exception { Assume.assumeTrue(TckPublisher.isEnabled()); System.out.println("JIRA_596"); int port = 9000; String hostname = TckPublisher.getProperties().getProperty("bindaddress"); if (hostname == null) { hostname = InetAddress.getLocalHost().getHostName(); } // String localhostname = "localhost";//java.net.InetAddress.getLocalHost().getHostName(); TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe); //UDDISubscriptionListenerImpl impl = new UDDISubscriptionListenerImpl(); UDDISubscriptionListenerImpl.notifcationMap.clear(); UDDISubscriptionListenerImpl.notificationCount = 0; Endpoint ep = null; boolean ok = false; do { try { ep = Endpoint.publish("http://" + hostname + ":" + port + "/UDDI_CALLBACK", impl); ok = true; } catch (Exception ex) { port++; } } while (!ok); SaveBusiness sb = new SaveBusiness(); sb.setAuthInfo(authInfoJoe); BusinessEntity be = new BusinessEntity(); be.getName().add(new Name()); be.getName().get(0).setValue("Joe's callback business"); be.setBusinessServices(new BusinessServices()); BusinessService bs = new BusinessService(); bs.getName().add(new Name()); bs.getName().get(0).setValue("Joe's callback service"); bs.setBindingTemplates(new BindingTemplates()); BindingTemplate bt = new BindingTemplate(); bt.setAccessPoint(new AccessPoint()); bt.getAccessPoint().setValue("http://" + hostname + ":" + port + "/UDDI_CALLBACK"); bt.getAccessPoint().setUseType("endPoint"); //obmitted as part of the jira test case /*TModelInstanceInfo instanceInfo = new TModelInstanceInfo(); instanceInfo.setTModelKey("uddi:uddi.org:transport:http"); bt.setTModelInstanceDetails(new TModelInstanceDetails()); bt.getTModelInstanceDetails().getTModelInstanceInfo().add(instanceInfo); */ bs.getBindingTemplates().getBindingTemplate().add(bt); be.getBusinessServices().getBusinessService().add(bs); sb.getBusinessEntity().add(be); logger.info("setting up joe's callback business"); BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb); List<String> deleteme = new ArrayList<String>(); deleteme.add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); //ok Joe's callback is setup //Setup a business to subscribe to sb = new SaveBusiness(); sb.setAuthInfo(authInfoSam); be = new BusinessEntity(); be.getName().add(new Name()); be.getName().get(0).setValue("Sam's business"); sb.getBusinessEntity().add(be); logger.info("saving sam's business"); BusinessDetail saveBusiness1 = publicationSam.saveBusiness(sb); //ok Joe now needs to subscribe for Sam's business Holder<List<Subscription>> list = new Holder<List<Subscription>>(); list.value = new ArrayList<Subscription>(); Subscription s = new Subscription(); s.setBindingKey(saveBusiness.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0) .getBindingTemplates().getBindingTemplate().get(0).getBindingKey()); s.setSubscriptionFilter(new SubscriptionFilter()); s.getSubscriptionFilter().setGetBusinessDetail(new GetBusinessDetail()); s.getSubscriptionFilter().getGetBusinessDetail().getBusinessKey() .add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey()); DatatypeFactory df = DatatypeFactory.newInstance(); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.HOUR, 1); s.setExpiresAfter(df.newXMLGregorianCalendar(gcal)); s.setNotificationInterval(df.newDuration(5000)); list.value.add(s); logger.info("subscribing joe's to updates for sam's business"); subscriptionJoe.saveSubscription(authInfoJoe, list); //ok have sam change his business around. sb = new SaveBusiness(); sb.setAuthInfo(authInfoSam); be = saveBusiness1.getBusinessEntity().get(0); be.getName().get(0).setLang("en"); sb.getBusinessEntity().add(be); logger.info("altering sam's business"); publicationSam.saveBusiness(sb); logger.info("Waiting..."); int maxwait = 30000; while (maxwait > 0) { if (UDDISubscriptionListenerImpl.notifcationMap.size() > 0) { break; } Thread.sleep(1000); maxwait = maxwait - 1000; } TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe); DeleteBusinesses(deleteme, authInfoJoe, publicationJoe); deleteme.clear(); deleteme.add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey()); DeleteBusinesses(deleteme, authInfoSam, publicationSam); ep.stop(); if (UDDISubscriptionListenerImpl.notifcationMap.isEmpty()) { logger.error("no callbacks were recieved"); Assert.fail("no callbacks were recieved."); } logger.info("callback response was " + UDDISubscriptionListenerImpl.notifcationMap.get(0)); logger.info("PASS"); }
From source file:com.aerospike.examples.timeseries.TimeSeriesManipulator.java
private void retrieveResult(String[] ticker, Set<Long> dateList) throws ParseException { // TODO Auto-generated method stub Record[] records;/*from w w w . j a v a 2s . c o m*/ String pk; int size = dateList.size(); int numTickers = 0; if (ticker != null) numTickers = ticker.length; Key[] keys = new Key[size]; Long count = new Long(0); Double sum; Double startVal; Double endVal; GregorianCalendar cal = new GregorianCalendar(); // Random rand = new Random(); // long randomNum = 0; // long overallRndNum = 0 + rand.nextInt((1000000 - 0) + 1); long currTime = GregorianCalendar.getInstance().getTimeInMillis(); Key summaryKey = new Key("test", "overallsummary", currTime); String tksummKey = null; for (int j = 0; j < numTickers; j++) { boolean firstRec = false; count = new Long(0); sum = new Double(0); startVal = new Double(0); endVal = new Double(0); // randomNum = 0 + rand.nextInt((1000000 - 0) + 1); Key tsKey = null; //Key tsKey = new Key("test", "tickersummary", randomNum); for (int i = 0; i < size; i++) { Object[] dateArr = dateList.toArray(); Long token = (Long) dateArr[i]; pk = ticker[j] + token; tksummKey = ticker[j] + "Summary" + currTime; tsKey = new Key("test", "tickersummary", tksummKey); keys[i] = new Key("test", "timeseries", pk); cal.setTimeInMillis(token); String formattedDate = dateOp.dateFormatter(cal.getTime()); Record record = client.operate(wPolicy, keys[i], MapOperation.getByRank("stock", -1, MapReturnType.VALUE), MapOperation.getByRank("stock", -1, MapReturnType.INDEX), MapOperation.getByRank("stock", 0, MapReturnType.VALUE), MapOperation.getByRank("stock", 0, MapReturnType.INDEX), MapOperation.getByIndex("stock", 0, MapReturnType.VALUE), MapOperation.getByIndex("stock", -1, MapReturnType.VALUE), Operation.get("sum"), MapOperation.size("stock")); if (record != null) { ArrayList<Double> outList = (ArrayList<Double>) record.getList("stock"); sum = sum + (Double) record.getValue("sum"); Object countTemp = outList.get(6); count = count + (Long) countTemp; if (!firstRec) { startVal = outList.get(4); firstRec = true; } endVal = outList.get(5); Record recMax = client.operate(wPolicy, tsKey, MapOperation.put(mPolicy, "max", Value.get(formattedDate), Value.get(outList.get(0))), MapOperation.put(mPolicy, "min", Value.get(formattedDate), Value.get(outList.get(2)))); String maxIndex = dateOp.getTimeStamp(outList.get(1)); String minIndex = dateOp.getTimeStamp(outList.get(3)); System.out.println( "Reading Data for " + formattedDate + " with Primary Key: " + pk + "\n\t: MaxValue: " + Double.parseDouble(new DecimalFormat("##.##").format(outList.get(0))) + " Time of Day: " + maxIndex + "\n\t: MinValue: " + Double.parseDouble(new DecimalFormat("##.##").format(outList.get(2))) + " Time of Day: " + minIndex); } } summaryPrint(tsKey, sum, count, startVal, endVal, tksummKey, ticker[j]); double difference = endVal - startVal; Record recSumm = client.operate(wPolicy, summaryKey, MapOperation.put(mPolicy, "difference", Value.get(ticker[j]), Value.get(difference))); firstRec = false; } summaryPrint(count, summaryKey, currTime, numTickers); }
From source file:com.aerospike.examples.timeseries.TimeSeriesManipulator.java
public void run() throws ParseException, FileNotFoundException, IOException, InterruptedException { GregorianCalendar cal = new GregorianCalendar(); //String formattedDate = new String(); String[] tokens;//from w w w . ja v a 2s .c om String[] ticker; if (tickerList != null) { ticker = timeParser.parse(tickerList); } else { ticker = new String[0]; } long token; if (this.operation.contains("L")) { System.out.println("****************************************"); System.out.println("Loading Data"); System.out.println("****************************************"); if (this.days != null) { if (ticker != null) { for (int i = 0; i < ticker.length; i++) { this.sum = 0; try (BufferedReader br = getStocks(this.days, ticker[i])) { String line; while ((line = br.readLine()) != null) { if (line.startsWith("a")) { this.sum = 0; tokens = timeParser.parse(line); token = new Long(tokens[0].substring(1)).longValue() * 1000L; cal.setTimeInMillis(token); //formattedDate = dateOp.dateFormatter(cal.getTime()); this.updateTimeSeries(ticker[i], cal.getTime(), line); Date insertDate = dateOp.getDate(cal.getTime()); this.dateList.add(insertDate.getTime()); } else if ((!line.startsWith("EXCHANGE")) && (!line.startsWith("MARKET")) && (!line.startsWith("INTERVAL")) && (!line.startsWith("COLUMNS")) && (!line.startsWith("DATA")) && (!line.startsWith("TIMEZONE"))) { this.updateTimeSeries(ticker[i], cal.getTime(), line); } } } } } } else { try (BufferedReader br = new BufferedReader(new FileReader("stocktick.txt"))) { String line; while ((line = br.readLine()) != null) { if (line.startsWith("a")) { tokens = timeParser.parse(line); token = new Long(tokens[0].substring(1)).longValue() * 1000L; cal.setTimeInMillis(token); //formattedDate = dateOp.dateFormatter(cal.getTime()); Date insertDate = dateOp.getDate(cal.getTime()); this.updateTimeSeries(ticker[0], cal.getTime(), line); this.dateList.add(insertDate.getTime()); } else if ((!line.startsWith("EXCHANGE")) && (!line.startsWith("MARKET")) && (!line.startsWith("INTERVAL")) && (!line.startsWith("COLUMNS")) && (!line.startsWith("DATA")) && (!line.startsWith("TIMEZONE"))) { if (ticker != null) this.updateTimeSeries(ticker[0], cal.getTime(), line); } } } } System.out.println("****************************************"); System.out.println("Loading Complete"); System.out.println("****************************************"); } Calendar startCal = Calendar.getInstance(); Calendar endCal = Calendar.getInstance(); int count = 0; if (this.operation.contains("R")) { //if (this.startString.equals(null) && this.endString.equals(null)) { if (this.operation.contains("L")) { count++; this.retrieveResult(ticker, this.dateList); } else { count++; int[] startList = timeParser.getCalDate(this.startString); if (startList[0] > 0 && startList[1] > 0 && startList[2] > 0) { startCal = new GregorianCalendar(startList[2], startList[1] - 1, startList[0]); } else { System.out.println("Invalid Start Date Format. Specify as dd/MM/yyyy"); System.exit(0); } int[] endList = timeParser.getCalDate(this.endString); if (endList[0] > 0 && endList[1] > 0 && endList[2] > 0) { endCal = new GregorianCalendar(endList[2], endList[1] - 1, endList[0]); } else { System.out.println("Invalid End Date Format. Specify as dd/MM/yyyy"); System.exit(0); } if (!endCal.before(startCal)) this.retrieveResult(ticker, startCal.getTime(), endCal.getTime()); else System.out.println("Invalid Dates. Start Date is greater than End Date"); } } if (this.operation.contains("R") && count == 0) System.out.println("Invalid Operation. Use L or R"); }
From source file:org.betaconceptframework.astroboa.engine.jcr.io.Serializer.java
private String convertCalendarToXMLFormat(Calendar calendar, boolean dateTimePattern) { if (dateTimePattern) { GregorianCalendar gregCalendar = new GregorianCalendar(calendar.getTimeZone()); gregCalendar.setTimeInMillis(calendar.getTimeInMillis()); return df.newXMLGregorianCalendar(gregCalendar).toXMLFormat(); } else {// w w w . j ava2 s . com return df.newXMLGregorianCalendarDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, // Calendar.MONTH is zero based, XSD Date datatype's month field starts // with JANUARY as 1. calendar.get(Calendar.DAY_OF_MONTH), DatatypeConstants.FIELD_UNDEFINED).toXMLFormat(); } }
From source file:org.betaconceptframework.astroboa.console.jsf.edit.SimpleCmsPropertyWrapper.java
private void processUploadedFile(UploadItem uploadItem) throws IOException { String filename = null;// w ww. j a v a 2s .c o m byte[] filedata = null; GregorianCalendar lastModified; String mimeType = null; ConfigurableMimeFileTypeMap mimeTypesMap = (ConfigurableMimeFileTypeMap) JSFUtilities .getBeanFromSpringContext("mimeTypesMap"); // add the wrapper index to the list of wrappers that should be updated by the UI complexCmsPropertyEdit.setWrapperIndexesToUpdate(Collections.singleton(wrapperIndex)); SimpleCmsPropertyValueWrapper simpleCmsPropertyValueWrapper; // We should check if we add a new binary or updating an existing one if (indexOfPropertyValueToBeProcessed == -1) { // add a new value wrapper if property is defined to get multiple values or it is defined to get a single value and no value // exists yet if (isMultiple() || (!isMultiple() && getSimpleCmsPropertyValueWrappers().isEmpty())) { addNewSimpleCmsPropertyValueWrapper(); } simpleCmsPropertyValueWrapper = simpleCmsPropertyValueWrappers .get(simpleCmsPropertyValueWrappers.size() - 1); } else { simpleCmsPropertyValueWrapper = simpleCmsPropertyValueWrappers.get(indexOfPropertyValueToBeProcessed); } if (uploadItem.isTempFile()) { // if upload was set to use temp files filename = FilenameUtils.getName(uploadItem.getFileName()); filedata = FileUtils.readFileToByteArray(uploadItem.getFile()); lastModified = new GregorianCalendar(JSFUtilities.getLocale()); lastModified.setTimeInMillis(uploadItem.getFile().lastModified()); mimeType = mimeTypesMap.getContentType(filename); logger.debug("file uploaded " + filename); } else if (uploadItem.getData() != null) { // if upload was done in memory filename = uploadItem.getFileName(); filedata = uploadItem.getData(); lastModified = (GregorianCalendar) GregorianCalendar.getInstance(JSFUtilities.getLocale()); mimeType = mimeTypesMap.getContentType(filename); logger.debug("file uploaded " + filename); } if (StringUtils.isBlank(mimeType)) { mimeType = "application/octet-stream"; } if (filedata == null || filename == null) { JSFUtilities.addMessage(null, "object.edit.action.uploadFile.uploadFailed", null, FacesMessage.SEVERITY_WARN); return; } //Check if this property is the 'thumbnail' property try { byte[] thumbnailContent = null; if (simpleCmsPropertyValueWrapper.isThumbnailPropertyValueWrapper()) { //Generate thumbnail if (mimeType != null && (mimeType.equals("image/jpeg") || mimeType.equals("image/gif") || mimeType.equals("image/png") || mimeType.equals("image/x-png"))) { thumbnailContent = ImageUtils.changeAspectRatioAndResize(filedata, "image/png", 128, 0, 1.0, "TOPLEFT"); } else { JSFUtilities.addMessage(null, "object.edit.action.uploadFile.thumbnailCanBeCreatedOnlyFromJPGorPNGorGIFFiles", null, FacesMessage.SEVERITY_WARN); return; } } BinaryChannel binaryChannelValue = simpleCmsPropertyValueWrapper.getNewBinaryChannelValue(); //Copy byte[] to a new byte[] byte[] newContent = null; if (thumbnailContent == null) { newContent = new byte[filedata.length]; System.arraycopy(filedata, 0, newContent, 0, filedata.length); } else { newContent = new byte[thumbnailContent.length]; System.arraycopy(thumbnailContent, 0, newContent, 0, thumbnailContent.length); } binaryChannelValue.setContent(newContent); binaryChannelValue.setMimeType(new String(mimeType)); binaryChannelValue.setSize(filedata.length); binaryChannelValue.setSourceFilename(new String(filename)); binaryChannelValue.setModified(GregorianCalendar.getInstance(JSFUtilities.getLocale())); simpleCmsPropertyValueWrapper.setValue(binaryChannelValue); } catch (Exception e) { JSFUtilities.addMessage(null, "object.edit.action.uploadFile.uploadFailed", null, FacesMessage.SEVERITY_ERROR); logger.error("File upload failed", e); } finally { simpleCmsPropertyValueWrapper.setMimeTypeIconFilePath(null); indexOfPropertyValueToBeProcessed = -1; } }
From source file:org.apache.flink.client.web.JobsServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String action = req.getParameter(ACTION_PARAM_NAME); if (action.equals(ACTION_LIST_VALUE)) { GregorianCalendar cal = new GregorianCalendar(); File[] files = destinationDir.listFiles(); Arrays.<File>sort(files, FILE_SORTER); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType(CONTENT_TYPE_PLAIN); PrintWriter writer = resp.getWriter(); for (int i = 0; i < files.length; i++) { if (!files[i].getName().endsWith(".jar")) { continue; }//from w w w.j a v a 2s. co m JarFile jar = new JarFile(files[i]); Manifest manifest = jar.getManifest(); String assemblerClass = null; String descriptions = ""; if (manifest != null) { assemblerClass = manifest.getMainAttributes() .getValue(PackagedProgram.MANIFEST_ATTRIBUTE_ASSEMBLER_CLASS); if (assemblerClass == null) { assemblerClass = manifest.getMainAttributes() .getValue(PackagedProgram.MANIFEST_ATTRIBUTE_MAIN_CLASS); } } if (assemblerClass == null) { assemblerClass = ""; } else { String[] classes = assemblerClass.split(","); for (String c : classes) { try { String d = new PackagedProgram(files[i], c, new String[0]).getDescription(); if (d == null) { d = "No description provided."; } descriptions += "#_#" + d; } catch (ProgramInvocationException e) { descriptions += "#_#No description provided."; continue; } } assemblerClass = '\t' + assemblerClass; } cal.setTimeInMillis(files[i].lastModified()); writer.println(files[i].getName() + '\t' + (cal.get(GregorianCalendar.MONTH) + 1) + '/' + cal.get(GregorianCalendar.DAY_OF_MONTH) + '/' + cal.get(GregorianCalendar.YEAR) + ' ' + cal.get(GregorianCalendar.HOUR_OF_DAY) + ':' + cal.get(GregorianCalendar.MINUTE) + ':' + cal.get(GregorianCalendar.SECOND) + assemblerClass + descriptions); } } else if (action.equals(ACTION_DELETE_VALUE)) { String filename = req.getParameter(FILENAME_PARAM_NAME); if (filename == null || filename.length() == 0) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); } else { File f = new File(destinationDir, filename); if (!f.exists() || f.isDirectory()) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } f.delete(); resp.setStatus(HttpServletResponse.SC_OK); } } else { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }
From source file:de.tu_dortmund.ub.api.daia.DaiaOpenUrlEndpoint.java
private void provideService(HttpServletRequest request, HttpServletResponse response, String format, HashMap<String, String> latinParameters, boolean isTUintern, boolean isUBintern, boolean is52bIBA) throws IOException { String openurl = ""; try {/*from w ww.j ava 2 s. co m*/ // build openurl for (String k : latinParameters.keySet()) { // repeat input-openurl if (!k.equals("format") && !k.equals("system") && !latinParameters.get(k).equals("")) { if (latinParameters.get(k).contains("/>")) { latinParameters.put(k, latinParameters.get(k).replaceAll("/>", "")); } if (latinParameters.get(k).contains(">")) { latinParameters.put(k, latinParameters.get(k).replaceAll(">", "")); } String prefix = ""; if (!k.startsWith("rft")) { prefix = "rft."; } String value = ""; if (k.contains("title") || k.contains("au")) { value = latinParameters.get(k); } else if (k.contains("issn") && !latinParameters.get(k).equals("")) { if (latinParameters.get(k).contains("-")) { value = latinParameters.get(k); } else { value = latinParameters.get(k).subSequence(0, 4) + "-" + latinParameters.get(k).subSequence(4, 8); } } else { value = latinParameters.get(k); } openurl += "&" + prefix + k + "=" + URLEncoder.encode(value, "UTF-8"); } } this.logger.debug("\n" + "\tOpenURL-Parameter = " + this.config.getProperty("linkresolver.baseurl") + this.config.getProperty("linkresolver.parameters") + openurl); ArrayList<Document> daiaDocuments = new ArrayList<Document>(); // falls OpenURL contains isbn: Anfrage an "normalen DaiaService Endpoint String isbn = ""; if (latinParameters.get("rft.isbn") != null && !latinParameters.get("rft.isbn").equals("")) { isbn = latinParameters.get("rft.isbn"); } else if (latinParameters.get("isbn") != null && !latinParameters.get("isbn").equals("")) { isbn = latinParameters.get("isbn"); } else if (latinParameters.get("id") != null && latinParameters.get("id").contains("isbn:")) { isbn = latinParameters.get("id").split(":")[1]; } this.logger.debug("ISBN = " + isbn); if (!isbn.equals("")) { if (Lookup.lookupAll(IntegratedLibrarySystem.class).size() > 0) { // erst DAIA isbn fragen if (isbn.contains("; ")) { isbn = isbn.replaceAll("; ", ","); } String daiaUrl = "http://" + request.getServerName() + ":" + request.getServerPort() + "/daia/?id=isbn:" + isbn; this.logger.debug("daiaUrl = " + daiaUrl); CloseableHttpClient httpclient = HttpClients.createDefault(); HttpGet httpGet = new HttpGet(daiaUrl); httpGet.addHeader("Accept", "application/xml"); CloseableHttpResponse httpResponse = httpclient.execute(httpGet); try { int statusCode = httpResponse.getStatusLine().getStatusCode(); HttpEntity httpEntity = httpResponse.getEntity(); switch (statusCode) { case 200: { JAXBContext jaxbContext = JAXBContext.newInstance(Daia.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Daia daia = (Daia) unmarshaller.unmarshal(httpEntity.getContent()); if (daia.getDocument() != null) { daiaDocuments.addAll(daia.getDocument()); } break; } default: { // TODO Evaluieren: Das mssten die Flle sein, in denen E-Books in der Knowledgebase eingetragen sind if (Lookup.lookupAll(LinkResolver.class).size() > 0) { Document daiaDocument = null; LinkResolver linkResolver = Lookup.lookup(LinkResolver.class); // init Linkresolver linkResolver.init(this.config); // get items ArrayList<Document> linkresolverDocument = linkResolver.items("openurl", openurl); if (linkresolverDocument != null && linkresolverDocument.size() > 0) { daiaDocument = new Document(); daiaDocument.setId("urn:isbn:" + isbn); if (daiaDocument.getItem() == null || daiaDocument.getItem().size() == 0) { daiaDocument.setItem(linkresolverDocument.get(0).getItem()); } else { daiaDocument.getItem().addAll(linkresolverDocument.get(0).getItem()); } if (daiaDocument != null) { daiaDocuments.add(daiaDocument); } } } } } EntityUtils.consume(httpEntity); } finally { httpResponse.close(); } } } else { // Wenn JOP registriert ist if (Lookup.lookupAll(JournalOnlinePrintService.class).size() > 0) { // build OpenURL for JOP String issn = ""; if (latinParameters.get("rft.issn") != null && !latinParameters.get("rft.issn").equals("")) { issn = latinParameters.get("rft.issn"); } else if (latinParameters.get("issn") != null && !latinParameters.get("issn").equals("")) { issn = latinParameters.get("issn"); } if (latinParameters.get("rft.eissn") != null && !latinParameters.get("rft.eissn").equals("")) { issn = latinParameters.get("rft.eissn"); } else if (latinParameters.get("eissn") != null && !latinParameters.get("eissn").equals("")) { issn = latinParameters.get("eissn"); } else if (latinParameters.get("id") != null && latinParameters.get("id").contains("issn:")) { issn = latinParameters.get("id").split(":")[1]; } this.logger.debug("ISSN = " + issn); String jop_openurl = ""; for (String k : latinParameters.keySet()) { // mit rft if ((latinParameters.keySet().contains("rft.atitle") || latinParameters.keySet().contains("atitle")) && k.equals("rft.date") && !latinParameters.get(k).equals("")) { jop_openurl += "&date=" + latinParameters.get(k); } if (k.equals("rft.volume") && !latinParameters.get(k).equals("")) { jop_openurl += "&volume=" + latinParameters.get(k); } if (k.equals("rft.issue") && !latinParameters.get(k).equals("")) { jop_openurl += "&issue=" + latinParameters.get(k); } // ohne rft if ((latinParameters.keySet().contains("rft.atitle") || latinParameters.keySet().contains("atitle")) && k.equals("date") && !latinParameters.get(k).equals("")) { jop_openurl += "&date=" + latinParameters.get(k); } if (k.equals("volume") && !latinParameters.get(k).equals("")) { jop_openurl += "&volume=" + latinParameters.get(k); } if (k.equals("issue") && !latinParameters.get(k).equals("")) { jop_openurl += "&issue=" + latinParameters.get(k); } } if (!issn.equals("")) { if (issn.contains("-")) { jop_openurl += "&issn=" + issn; } else { jop_openurl += "&issn=" + issn.subSequence(0, 4) + "-" + issn.subSequence(4, 8); } } if (latinParameters.keySet().contains("rft.atitle") || latinParameters.keySet().contains("atitle")) { jop_openurl += "&genre=article"; } else { jop_openurl += "&genre=journal"; } this.logger.debug("\n" + jop_openurl + "\tOpenURL-Parameter (JOP) = " + this.config.getProperty("jop.url.openurl") + jop_openurl); if (!jop_openurl.equals("&genre=journal") && (jop_openurl.contains("&title=") || jop_openurl.contains("&issn="))) { // get data try { JournalOnlinePrintService journalOnlinePrintService = Lookup .lookup(JournalOnlinePrintService.class); // init JOP journalOnlinePrintService.init(this.config); // get items ArrayList<de.tu_dortmund.ub.api.daia.jop.model.Document> jopDocuments = journalOnlinePrintService .items("openurl", jop_openurl); if (jopDocuments != null && jopDocuments.size() > 0) { Document daiaDocument = new Document(); this.logger.debug("JOP hits: " + jopDocuments.size()); if (jopDocuments.get(0).getId() != null && jopDocuments.get(0).getHref() != null) { daiaDocument.setId(jopDocuments.get(0).getId()); daiaDocument.setHref(jopDocuments.get(0).getHref()); } else { daiaDocument.setId("urn:issn:" + issn); } // print if (jopDocuments.get(0).getItem() != null && jopDocuments.get(0).getItem().size() > 0) { daiaDocument.setItem(jopDocuments.get(0).getItem()); } // digital if (jopDocuments.get(0).isExistsDigitalItems() && Lookup.lookupAll(LinkResolver.class).size() > 0) { // TODO define a boolean variable for executing a linkresolver request // TODO auslagern! LinkResolver linkResolver = Lookup.lookup(LinkResolver.class); // init Linkresolver linkResolver.init(this.config); // get items ArrayList<Document> linkresolverDocument = linkResolver.items("openurl", openurl); if (linkresolverDocument != null && linkresolverDocument.size() > 0 && linkresolverDocument.get(0).getItem().size() >= jopDocuments.get(0) .getCountDigitlItems()) { if (daiaDocument.getItem() == null || daiaDocument.getItem().size() == 0) { daiaDocument.setItem(linkresolverDocument.get(0).getItem()); } else { daiaDocument.getItem().addAll(linkresolverDocument.get(0).getItem()); } } else { // TODO Ticket 11679 // E-Mail an katalogplus@ub.tu-dortmund.de mit Betreff-Prefix [Content] boolean isNatLic = true; if (isNatLic) { if (!issn.equals("")) { // request JOP again with only ISSN jopDocuments = journalOnlinePrintService.eonly("issn", issn); if (jopDocuments != null && jopDocuments.size() > 0) { this.logger.debug("JOP hits: " + jopDocuments.size()); if (daiaDocument.getItem() == null || daiaDocument.getItem().size() == 0) { daiaDocument.setItem(jopDocuments.get(0).getItem()); } else { if (jopDocuments.get(0).getItem() != null) { daiaDocument.getItem() .addAll(jopDocuments.get(0).getItem()); } else { // Error-E-Mail "JOP<>LinkResolver: Not an NatLic" Mailer mailer = new Mailer( this.config.getProperty("service.mailer.conf")); try { int cnt = 0; if (linkresolverDocument != null) { cnt = linkresolverDocument.get(0).getItem() .size(); } mailer.postMail( "[DAIAopenurl] JOP-Document ohne Items ", "JOP-Link " + jopDocuments.get(0) .getCountDigitlItems() + ": " + this.config.getProperty( "jop.url.openurl") + jop_openurl + ".\n"); } catch (MessagingException e) { this.logger.error(e.getMessage(), e.getCause()); this.logger.debug("[DAIAopenurl] CONTENT-ERROR"); this.logger.debug("OpenUrl: " + openurl + "\n\n\tJOP-URL: " + jop_openurl); } if (daiaDocument.getItem() == null || daiaDocument.getItem().size() == 0) { daiaDocument = null; } } } } } else { // Error-E-Mail "JOP<>LinkResolver: Not an NatLic" Mailer mailer = new Mailer( this.config.getProperty("service.mailer.conf")); try { int cnt = 0; if (linkresolverDocument != null) { cnt = linkresolverDocument.get(0).getItem().size(); } mailer.postMail( "[DAIAopenurl] JOP<>LinkResolver: NatLic without ISSN ", "Laut ZDB/EZB gibt es " + jopDocuments.get(0).getCountDigitlItems() + "-mal elektronischen Bestand (vgl. " + this.config.getProperty("jop.url.openurl") + jop_openurl + ").\n" + "Laut 360 Link aber " + cnt + "-mal (vgl. " + this.config .getProperty("linkresolver.baseurl") + this.config .getProperty("linkresolver.parameters") + openurl + ")."); } catch (MessagingException e) { this.logger.error(e.getMessage(), e.getCause()); this.logger.debug("[DAIAopenurl] CONTENT-ERROR"); this.logger.debug("OpenUrl: " + openurl + "\n\n\tJOP-URL: " + jop_openurl); } if (daiaDocument.getItem() == null || daiaDocument.getItem().size() == 0) { daiaDocument = null; } } } else { // Hier kann man nix machen! } } } if (daiaDocument != null) { daiaDocuments.add(daiaDocument); } } } catch (LinkResolverException e) { // daiaDocuments bleibt leer this.logger.error("[DaiaService OpenUrl Endpoint] Exception: " + HttpServletResponse.SC_SERVICE_UNAVAILABLE + " Service unavailable (LinkResolver)."); this.logger.error(e.getMessage(), e.getCause()); for (StackTraceElement stackTraceElement : e.getStackTrace()) { this.logger.error("\t" + stackTraceElement.toString()); } Mailer mailer = new Mailer(this.config.getProperty("service.mailer.conf")); try { mailer.postMail( "[DaiaService OpenUrl Endpoint] Exception: " + HttpServletResponse.SC_SERVICE_UNAVAILABLE + " Service unavailable (LinkResolver).", e.getMessage() + "\n" + this.config.getProperty("linkresolver.baseurl") + this.config.getProperty("linkresolver.parameters") + openurl); } catch (MessagingException e1) { this.logger.error(e1.getMessage(), e1.getCause()); } } catch (JOPException e) { // daiaDocuments bleibt leer this.logger.error("[DaiaService OpenUrl Endpoint] Exception: " + HttpServletResponse.SC_SERVICE_UNAVAILABLE + " Service unavailable (Journals Online & Print)."); this.logger.error(e.getMessage(), e.getCause()); for (StackTraceElement stackTraceElement : e.getStackTrace()) { this.logger.error("\t" + stackTraceElement.toString()); } Mailer mailer = new Mailer(this.config.getProperty("service.mailer.conf")); try { mailer.postMail( "[DaiaService OpenUrl Endpoint] Exception: " + HttpServletResponse.SC_SERVICE_UNAVAILABLE + " Service unavailable (Journals Online & Print).", e.getMessage() + "\n" + this.config.getProperty("jop.url.openurl") + jop_openurl); } catch (MessagingException e1) { this.logger.error(e1.getMessage(), e1.getCause()); } } } else { // tue nix: daiaDocuments bleibt leer } } } // Abschlusskorrektur fr ACM, IEEE und LNCS vor dem response // LNCS if (Lookup.lookupAll(LncsResolver.class).size() > 0 && Boolean.parseBoolean(this.config.getProperty("licenced.lncs"))) { if (daiaDocuments.size() > 0) { for (Document daiaDocument : daiaDocuments) { if (daiaDocument != null && daiaDocument.getId() != null && daiaDocument.getId().contains("urn:issn:03029743") && ((latinParameters.keySet().contains("id") && latinParameters.get("id").startsWith("doi:10.1007")) || (latinParameters.keySet().contains("rft.id") && latinParameters.get("rft.id").startsWith("doi:10.1145")))) { daiaDocument.setItem(null); LncsResolver lncsResolver = Lookup.lookup(LncsResolver.class); lncsResolver.init(this.config); Document lncsDocument = lncsResolver.items(latinParameters); daiaDocument.setId(lncsDocument.getId()); daiaDocument.setHref(lncsDocument.getHref()); daiaDocument.setItem(lncsDocument.getItem()); } } } } // ACM if (Lookup.lookupAll(AcmResolver.class).size() > 0 && Boolean.parseBoolean(this.config.getProperty("licenced.acm"))) { if ((latinParameters.keySet().contains("id") && latinParameters.get("id").contains("10.1145")) || (latinParameters.keySet().contains("rft.id") && latinParameters.get("rft.id").contains("10.1145"))) { if (daiaDocuments.size() > 0) { for (Document daiaDocument : daiaDocuments) { daiaDocument.setItem(null); AcmResolver acmResolver = Lookup.lookup(AcmResolver.class); acmResolver.init(this.config); Document acmDocument = acmResolver.items(latinParameters); daiaDocument.setId(acmDocument.getId()); daiaDocument.setHref(acmDocument.getHref()); if (daiaDocument.getItem() == null) { daiaDocument.setItem(acmDocument.getItem()); } else { daiaDocument.getItem().addAll(acmDocument.getItem()); } } } else { Document daiaDocument = new Document(); AcmResolver acmResolver = Lookup.lookup(AcmResolver.class); acmResolver.init(this.config); Document acmDocument = acmResolver.items(latinParameters); daiaDocument.setId(acmDocument.getId()); daiaDocument.setHref(acmDocument.getHref()); if (daiaDocument.getItem() == null) { daiaDocument.setItem(acmDocument.getItem()); } else { daiaDocument.getItem().addAll(acmDocument.getItem()); } daiaDocuments.add(daiaDocument); } } } // IEEE if (Lookup.lookupAll(IeeeResolver.class).size() > 0 && Boolean.parseBoolean(this.config.getProperty("licenced.ieee"))) { if ((latinParameters.keySet().contains("id") && latinParameters.get("id").contains("10.1109")) || (latinParameters.keySet().contains("rft.id") && latinParameters.get("rft.id").contains("10.1109"))) { if (daiaDocuments.size() > 0) { for (Document daiaDocument : daiaDocuments) { daiaDocument.setItem(null); IeeeResolver ieeeResolver = Lookup.lookup(IeeeResolver.class); ieeeResolver.init(this.config); Document ieeeDocument = ieeeResolver.items(latinParameters); daiaDocument.setId(ieeeDocument.getId()); daiaDocument.setHref(ieeeDocument.getHref()); if (daiaDocument.getItem() == null) { daiaDocument.setItem(ieeeDocument.getItem()); } else { daiaDocument.getItem().addAll(ieeeDocument.getItem()); } } } else { Document daiaDocument = new Document(); IeeeResolver ieeeResolver = Lookup.lookup(IeeeResolver.class); ieeeResolver.init(this.config); Document ieeeDocument = ieeeResolver.items(latinParameters); daiaDocument.setId(ieeeDocument.getId()); daiaDocument.setHref(ieeeDocument.getHref()); if (daiaDocument.getItem() == null) { daiaDocument.setItem(ieeeDocument.getItem()); } else { daiaDocument.getItem().addAll(ieeeDocument.getItem()); } daiaDocuments.add(daiaDocument); } } } if (daiaDocuments.size() > 0) { this.logger.debug("200 Document Found"); // TODO query footnotes from ils if configured // Ausgabe Daia daia = new Daia(); daia.setVersion(this.config.getProperty("daia.version")); daia.setSchema(this.config.getProperty("daia.schema")); GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(new Date().getTime()); try { DatatypeFactory df = DatatypeFactory.newInstance(); daia.setTimestamp(df.newXMLGregorianCalendar(gc).toString()); } catch (DatatypeConfigurationException dce) { this.logger.error("ERROR: Service unavailable.", dce.getCause()); } Institution institution = new Institution(); institution.setId(this.config.getProperty("daia.institution.id")); institution.setHref(this.config.getProperty("daia.institution.href")); institution.setContent(this.config.getProperty("daia.institution.content")); daia.setInstitution(institution); daia.setDocument(daiaDocuments); // Ausgabe if (daia.getDocument() == null || daia.getDocument().size() == 0) { // HTML-Ausgabe via XSLT if (format.equals("html")) { try { JAXBContext context = JAXBContext.newInstance(Daia.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // Write to HttpResponse StringWriter stringWriter = new StringWriter(); m.marshal(daia, stringWriter); org.jdom2.Document doc = new org.jdom2.Document(); doc.setRootElement(new Element("daia")); HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("lang", "de"); parameters.put("isTUintern", Boolean.toString(isTUintern)); parameters.put("isUBintern", Boolean.toString(isUBintern)); parameters.put("is52bIBA", Boolean.toString(is52bIBA)); parameters.put("id", "openurl:" + URLDecoder.decode(openurl, "UTF-8")); ObjectMapper mapper = new ObjectMapper(); StringWriter json = new StringWriter(); mapper.writeValue(json, daia); parameters.put("json", json.toString()); String html = htmlOutputter(doc, this.config.getProperty("linkresolver.html.xslt"), parameters); response.setContentType("text/html;charset=UTF-8"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println(html); } catch (PropertyException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering a HTML message. Message is 'Document not found'."); } catch (JAXBException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering a HTML message. Message is 'Document not found'."); } } else { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Document not found."); } } else { this.logger.debug("format = " + format); // HTML-Ausgabe via XSLT if (format.equals("html")) { try { JAXBContext context = JAXBContext.newInstance(Daia.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // Write to HttpResponse StringWriter stringWriter = new StringWriter(); m.marshal(daia, stringWriter); org.jdom2.Document doc = new SAXBuilder() .build(new StringReader(this.cleanup(stringWriter.toString()))); HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("lang", "de"); parameters.put("isTUintern", Boolean.toString(isTUintern)); parameters.put("isUBintern", Boolean.toString(isUBintern)); parameters.put("is52bIBA", Boolean.toString(is52bIBA)); parameters.put("id", "openurl:" + URLDecoder.decode(openurl, "UTF-8")); ObjectMapper mapper = new ObjectMapper(); StringWriter json = new StringWriter(); mapper.writeValue(json, daia); parameters.put("json", json.toString()); String html = htmlOutputter(doc, this.config.getProperty("linkresolver.html.xslt"), parameters); response.setContentType("text/html;charset=UTF-8"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println(html); } catch (PropertyException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering the results."); } catch (JAXBException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering the results."); } catch (JDOMException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering the results."); } catch (IOException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering the results."); } } // XML-Ausgabe mit JAXB if (format.equals("xml")) { try { JAXBContext context = JAXBContext.newInstance(Daia.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // Write to HttpResponse response.setContentType("application/xml;charset=UTF-8"); response.setStatus(HttpServletResponse.SC_OK); m.marshal(daia, response.getWriter()); } catch (PropertyException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering the results."); } catch (JAXBException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering the results."); } } // JSON-Ausgabe mit Jackson if (format.equals("json")) { ObjectMapper mapper = new ObjectMapper(); response.setContentType("application/json;charset=UTF-8"); response.setStatus(HttpServletResponse.SC_OK); mapper.writeValue(response.getWriter(), daia); } // RDF-Ausgabe mit XSLT auf XML-Ausgabe if (format.equals("rdf")) { try { JAXBContext context = JAXBContext.newInstance(Daia.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // Write to HttpResponse response.setContentType("application/xml;charset=UTF-8"); response.setStatus(HttpServletResponse.SC_OK); StringWriter xml = new StringWriter(); m.marshal(daia, xml); XMLOutputter out = new XMLOutputter(); out.output( new SAXBuilder().build(new StringReader( xmlOutputter(new SAXBuilder().build(new StringReader(xml.toString())), config.getProperty("xslt_xml2rdf"), null))), response.getWriter()); } catch (JDOMException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering the results."); } catch (PropertyException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering the results."); } catch (JAXBException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering the results."); } } } } else { this.logger.debug("404 Document Not Found + (format=" + format + ")"); if (format.equals("html")) { try { JAXBContext context = JAXBContext.newInstance(Daia.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // Write to HttpResponse org.jdom2.Document doc = new org.jdom2.Document(); doc.setRootElement(new Element("daia")); HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("lang", "de"); parameters.put("isTUintern", Boolean.toString(isTUintern)); parameters.put("isUBintern", Boolean.toString(isUBintern)); parameters.put("is52bIBA", Boolean.toString(is52bIBA)); parameters.put("id", "openurl:" + URLDecoder.decode(openurl, "UTF-8")); String html = htmlOutputter(doc, this.config.getProperty("linkresolver.html.xslt"), parameters); response.setContentType("text/html;charset=UTF-8"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println(html); } catch (PropertyException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering a HTML message. Message is 'Document not found'."); } catch (JAXBException e) { this.logger.error(e.getMessage(), e.getCause()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error: Error while rendering a HTML message. Message is 'Document not found'."); } } else { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Document not found."); } } } catch (Exception e) { this.logger.error("[DaiaService OpenUrl Endpoint] Exception: " + HttpServletResponse.SC_SERVICE_UNAVAILABLE + " Service unavailable."); this.logger.error(e.getMessage(), e.getCause()); for (StackTraceElement stackTraceElement : e.getStackTrace()) { this.logger.error("\t" + stackTraceElement.toString()); } Mailer mailer = new Mailer(this.config.getProperty("service.mailer.conf")); try { mailer.postMail("[DaiaService OpenUrl Endpoint] Exception: " + HttpServletResponse.SC_SERVICE_UNAVAILABLE + " Service unavailable.", e.getMessage() + "\n" + request.getRequestURL()); } catch (MessagingException e1) { this.logger.error(e1.getMessage(), e1.getCause()); } response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Service unavailable."); } }
From source file:hudson.model.Run.java
/** * When the build is scheduled./* w ww . ja v a 2s . c o m*/ * * @see #getStartTimeInMillis() */ @Exported public @Nonnull Calendar getTimestamp() { GregorianCalendar c = new GregorianCalendar(); c.setTimeInMillis(timestamp); return c; }
From source file:org.proteomecommons.tranche.cacheupdater.CacheUpdater.java
private String makeDate(long timestamp) { NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMinimumIntegerDigits(2);/* w w w . j a v a 2 s . c o m*/ GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(timestamp); return calendar.get(calendar.YEAR) + "/" + nf.format(calendar.get(calendar.MONTH) + 1) + "/" + nf.format(calendar.get(calendar.DAY_OF_MONTH)) + " " + nf.format(calendar.get(calendar.HOUR_OF_DAY)) + ":" + nf.format(calendar.get(calendar.MINUTE)) + ":" + nf.format(calendar.get(calendar.SECOND)); }
From source file:org.alfresco.opencmis.CMISConnector.java
@SuppressWarnings("unchecked") private List<ObjectData> createChangeEvents(long time, Map<String, Serializable> values) { List<ObjectData> result = new ArrayList<ObjectData>(); if ((values == null) || (values.size() == 0)) { return result; }/* w ww.ja v a2 s. com*/ GregorianCalendar changeTime = new GregorianCalendar(); changeTime.setTimeInMillis(time); String appPath = "/" + CMIS_CHANGELOG_AUDIT_APPLICATION + "/"; for (Entry<String, Serializable> entry : values.entrySet()) { if ((entry.getKey() == null) || (!(entry.getValue() instanceof Map))) { continue; } String path = entry.getKey(); if (!path.startsWith(appPath)) { continue; } ChangeType changeType = null; String changePath = path.substring(appPath.length()).toLowerCase(); for (ChangeType c : ChangeType.values()) { if (changePath.startsWith(c.value().toLowerCase())) { changeType = c; break; } } if (changeType == null) { continue; } Map<String, Serializable> valueMap = (Map<String, Serializable>) entry.getValue(); String objectId = (String) valueMap.get(CMISChangeLogDataExtractor.KEY_OBJECT_ID); // build object ObjectDataImpl object = new ObjectDataImpl(); result.add(object); PropertiesImpl properties = new PropertiesImpl(); object.setProperties(properties); PropertyIdImpl objectIdProperty = new PropertyIdImpl(PropertyIds.OBJECT_ID, objectId); properties.addProperty(objectIdProperty); ChangeEventInfoDataImpl changeEvent = new ChangeEventInfoDataImpl(); object.setChangeEventInfo(changeEvent); changeEvent.setChangeType(changeType); changeEvent.setChangeTime(changeTime); } return result; }