List of usage examples for org.jfree.util Log info
public static void info(final Object message)
From source file:org.jenkinsci.plugins.GitLabSecurityRealm.java
/** * This is where the user comes back to at the end of the OpenID redirect * ping-pong./*from ww w . j a va2s .c om*/ */ public HttpResponse doFinishLogin(StaplerRequest request) throws IOException { String code = request.getParameter("code"); if (StringUtils.isBlank(code)) { Log.info("doFinishLogin: missing code."); return HttpResponses.redirectToContextRoot(); } HttpPost httpPost = new HttpPost(gitlabWebUri + "/oauth/token"); List<NameValuePair> parameters = new ArrayList<NameValuePair>(); parameters.add(new BasicNameValuePair("client_id", clientID)); parameters.add(new BasicNameValuePair("client_secret", clientSecret)); parameters.add(new BasicNameValuePair("code", code)); parameters.add(new BasicNameValuePair("grant_type", "authorization_code")); parameters.add(new BasicNameValuePair("redirect_uri", buildRedirectUrl(request))); httpPost.setEntity(new UrlEncodedFormEntity(parameters, StandardCharsets.UTF_8)); CloseableHttpClient httpclient = HttpClients.createDefault(); HttpHost proxy = getProxy(httpPost); if (proxy != null) { RequestConfig config = RequestConfig.custom().setProxy(proxy).build(); httpPost.setConfig(config); } org.apache.http.HttpResponse response = httpclient.execute(httpPost); HttpEntity entity = response.getEntity(); String content = EntityUtils.toString(entity); // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.close(); String accessToken = extractToken(content); if (StringUtils.isNotBlank(accessToken)) { // only set the access token if it exists. GitLabAuthenticationToken auth = new GitLabAuthenticationToken(accessToken, getGitlabApiUri()); SecurityContextHolder.getContext().setAuthentication(auth); GitlabUser self = auth.getMyself(); User user = User.current(); if (user != null) { user.setFullName(self.getName()); // Set email from gitlab only if empty if (!user.getProperty(Mailer.UserProperty.class).hasExplicitlyConfiguredAddress()) { user.addProperty(new Mailer.UserProperty(auth.getMyself().getEmail())); } } fireAuthenticated(new GitLabOAuthUserDetails(self, auth.getAuthorities())); } else { Log.info("Gitlab did not return an access token."); } String referer = (String) request.getSession().getAttribute(REFERER_ATTRIBUTE); if (referer != null) { return HttpResponses.redirectTo(referer); } return HttpResponses.redirectToContextRoot(); // referer should be // always there, but be // defensive }
From source file:com.pedra.core.setup.CoreSystemSetup.java
private File getProjectdataUpdateDirectory(String relativeUpdateDirectory) { if (relativeUpdateDirectory == null) { relativeUpdateDirectory = ""; }/*from w w w. j av a 2 s. com*/ String projectdataUpdateFolderProperty = Config.getString("projectdata.update.folder", "/pedracore/import/versions"); projectdataUpdateFolderProperty = projectdataUpdateFolderProperty + relativeUpdateDirectory; File projectdataUpdateFolder = null; try { projectdataUpdateFolder = new File(getClass().getResource(projectdataUpdateFolderProperty).toURI()); } catch (final URISyntaxException e) { Log.error("error finding project data update directory[" + projectdataUpdateFolderProperty + "]", e); return null; } if (!projectdataUpdateFolder.exists()) { Log.warn("project data update directory [" + projectdataUpdateFolderProperty + "] does not exist"); return null; } else if (ArrayUtils.isEmpty(projectdataUpdateFolder.listFiles())) { Log.info("Project datad update directory[" + projectdataUpdateFolderProperty + "] is empty"); } return projectdataUpdateFolder; }
From source file:gr.abiss.calipso.config.CalipsoConfigurer.java
private void configureCalipso(ConfigurableListableBeanFactory beanFactory) throws Exception { String calipsoHome = null;/*from ww w .j a v a 2 s . c o m*/ InputStream is = this.getClass().getResourceAsStream("/calipso-init.properties"); Properties props = loadProps(is); logger.info("found 'calipso-init.properties' on classpath, processing..."); calipsoHome = props.getProperty("calipso.home"); if (calipsoHome.equals("${calipso.home}")) { calipsoHome = null; } if (StringUtils.isBlank(calipsoHome)) { logger.info( "valid 'calipso.home' property not available in 'calipso-init.properties', trying system properties."); calipsoHome = System.getProperty("calipso.home"); if (StringUtils.isNotBlank(calipsoHome)) { logger.info("'calipso.home' property initialized from system properties as '" + calipsoHome + "'"); } } if (StringUtils.isBlank(calipsoHome)) { logger.info( "valid 'calipso.home' property not available in system properties, trying servlet init paramters."); calipsoHome = servletContext.getInitParameter("calipso.home"); if (StringUtils.isNotBlank(calipsoHome)) { logger.info("Servlet init parameter 'calipso.home' exists: '" + calipsoHome + "'"); } } if (StringUtils.isBlank(calipsoHome)) { calipsoHome = System.getProperty("user.home") + "/.calipso"; logger.warn("Servlet init paramter 'calipso.home' does not exist. Will use 'user.home' directory '" + calipsoHome + "'"); } if (StringUtils.isNotBlank(calipsoHome) && !calipsoHome.equals("${calipso.home}")) { logger.info( "'calipso.home' property initialized from 'calipso-init.properties' as '" + calipsoHome + "'"); } //====================================================================== FilenameFilter ff = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("messages_") && name.endsWith(".properties"); } }; //File[] messagePropsFiles = jtracInitResource.getFile().getParentFile().listFiles(ff); String locales = props.getProperty("calipso.locales", "en,el,ja"); // for(File f : messagePropsFiles) { // int endIndex = f.getName().indexOf('.'); // String localeCode = f.getName().substring(9, endIndex); // locales += "," + localeCode; // } logger.info("locales available configured are '" + locales + "'"); props.setProperty("calipso.locales", locales); //====================================================================== //====================================================================== File calipsoHomeDir = new File(calipsoHome); createIfNotExisting(calipsoHomeDir); props.setProperty("calipso.home", calipsoHomeDir.getAbsolutePath()); //====================================================================== File attachmentsFile = new File(calipsoHome + "/attachments"); createIfNotExisting(attachmentsFile); File indexesFile = new File(calipsoHome + "/indexes"); createIfNotExisting(indexesFile); //====================================================================== File propsFile = new File(calipsoHomeDir, "calipso.properties"); if (!propsFile.exists()) { logger.info("properties file does not exist, creating '" + propsFile.getPath() + "'"); propsFile.createNewFile(); OutputStream os = new FileOutputStream(propsFile); Writer out = new PrintWriter(os); try { out.write("database.driver=org.hsqldb.jdbcDriver\n"); out.write("database.url=jdbc:hsqldb:file:${calipso.home}/db/calipso\n"); out.write("database.username=sa\n"); out.write("database.password=\n"); out.write("hibernate.dialect=org.hibernate.dialect.HSQLDialect\n"); out.write("hibernate.show_sql=false\n"); // Can be used to set mysql as default, commenting out // to preserve HSQLDB as default // out.write("database.driver=com.mysql.jdbc.Driver\n"); // out.write("database.url=jdbc:mysql://localhost/calipso21\n"); // out.write("database.username=root\n"); // out.write("database.password=\n"); // out.write("hibernate.dialect=org.hibernate.dialect.MySQLDialect\n"); // out.write("hibernate.show_sql=false\n"); } finally { out.close(); os.close(); } logger.info("HSQLDB will be used. Finished creating '" + propsFile.getPath() + "'"); } else { logger.info("'calipso.properties' file exists: '" + propsFile.getPath() + "'"); } //====================================================================== String version = getClass().getPackage().getImplementationVersion(); String timestamp = "0000"; // ClassPathResource versionResource = new ClassPathResource("calipso-version.properties"); // if(versionResource.exists()) { // logger.info("found 'calipso-version.properties' on classpath, processing..."); // Properties versionProps = loadProps(versionResource.getFile()); // version = versionProps.getProperty("calipso.version"); // timestamp = versionProps.getProperty("calipso.timestamp"); // } else { // logger.info("did not find 'calipso-version.properties' on classpath"); // } props.setProperty("calipso.version", version); props.setProperty("calipso.timestamp", timestamp); /* * TODO: A better way (default value) to check the database should be used for Apache DBCP. * The current "SELECT...FROM DUAL" only works on Oracle (and MySQL). * Other databases also support "SELECT 1+1" as query * (e.g. PostgreSQL, Hypersonic 2 (H2), MySQL, etc.). */ props.setProperty("database.validationQuery", "SELECT 1 FROM DUAL"); props.setProperty("ldap.url", ""); props.setProperty("ldap.activeDirectoryDomain", ""); props.setProperty("ldap.searchBase", ""); props.setProperty("database.datasource.jndiname", ""); // set default properties that can be overridden by user if required setProperties(props); // finally set the property that spring is expecting, manually FileSystemResource fsr = new FileSystemResource(propsFile); setLocation(fsr); Log.info("Calipso configured, calling postProcessBeanFactory with:" + beanFactory); }
From source file:com.hygenics.parser.JDump.java
private void toFile() { ArrayList<String> archs = new ArrayList<String>(); List<Future<ArrayList<String>>> qfutures; Set<Callable<ArrayList<String>>> qcollect = new HashSet<Callable<ArrayList<String>>>(4); ForkJoinPool fjp = new ForkJoinPool((int) Math.ceil(Runtime.getRuntime().availableProcessors() * procnum)); int dumped = 0; if (archive) { log.info("Cleaning"); for (String k : fpaths.keySet()) { String fpath = ""; for (String ofp : fpaths.get(k).keySet()) { fpath = ofp;/*w ww. j av a 2 s. c o m*/ } if (fpath.length() > 0) { String[] barr = fpath.split("\\/"); String basefile = ""; Archiver zip = new Archiver(); for (int i = 0; i > barr.length - 1; i++) { basefile += (i == 0) ? barr[i] : "/" + barr[i]; } if (basefile.trim().length() > 0) { zip.setBasedirectory(basefile); zip.setZipDirectory(basefile + "archive.zip"); zip.setAvoidanceString(".zip|archive"); zip.setDelFiles(true); zip.run(); } } } } log.info("Dumping"); for (String table : fpaths.keySet()) { int offset = 0; if (template.checkTable(table, table.split("\\.")[0])) { if (template.getCount(table) > 0) { log.info("Dumping for " + table); // get header String select = "SELECT * FROM " + table; String fpath = null; ArrayList<String> jsons; String condition; int w = 0; int start = offset; int chunksize = (int) Math.ceil(pullsize / qnum); // get fpath for (String ofp : fpaths.get(table).keySet()) { start = fpaths.get(table).get(ofp); fpath = ofp; } // perform write if (headers != null && fpath != null) { List<String> headersList = headers.get(table); String output = null; boolean existed = true; if (addFileDate) { fpath = fpath + Calendar.getInstance().getTime().toString().trim().replaceAll(":|\\s", "") + ".txt"; } // check to see if file should be created if (!new File(fpath).exists()) { try { new File(fpath).createNewFile(); } catch (IOException e) { e.printStackTrace(); } existed = false; } // check to see if file must be recreated if (!append) { File f = new File(fpath); f.delete(); try { f.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } if (headersList != null && (append == false || existed == false)) { for (String header : headersList) { output = (output == null) ? StringEscapeUtils.unescapeXml(header) : output + delimeter + StringEscapeUtils.unescapeXml(header); } } do { // get records jsons = new ArrayList<String>(pullsize); log.info("Looking for Pages."); for (int conn = 0; conn < qnum; conn++) { // create condition condition = " WHERE " + pullid + " >= " + (start + (conn * chunksize)) + " AND " + pullid + " < " + Integer.toString(start + (chunksize * (conn + 1))); if (extracondition != null) { condition += " " + extracondition.trim(); } // get queries qcollect.add(new SplitQuery(template, (select + condition))); log.info("Fetching " + select + condition); } start += (chunksize * qnum); qfutures = fjp.invokeAll(qcollect); w = 0; while (fjp.getActiveThreadCount() > 0 && fjp.isQuiescent() == false) { w++; } log.info("Waited for " + w + " cycles"); for (Future<ArrayList<String>> f : qfutures) { try { ArrayList<String> test = f.get(); if (test != null) { if (test.size() > 0) { jsons.addAll(test); } } if (f.isDone() == false) { f.cancel(true); } f = null; } catch (Exception e) { log.warn("Encoding Error!"); e.printStackTrace(); } } qcollect = new HashSet<Callable<ArrayList<String>>>(4); qfutures = null; log.info("Finished Getting Pages"); // post records to the file try (FileWriter fw = new FileWriter(new File(fpath), true)) { // get and write headers if (jsons.size() > 0) { fw.write(output + "\n"); // write data for (String json : jsons) { output = null; JsonObject jo = JsonObject.readFrom(json); if (jo.size() >= headersList.size()) {// allows // trimming // of // table // to // key // aspects output = null; for (String key : headers.get(table)) { if (jo.get(key.toLowerCase()) != null) { String data = StringEscapeUtils .unescapeXml(jo.get(key.toLowerCase()).asString()); if (replacementPattern != null) { data = data.replaceAll(replacementPattern, ""); data = data.replace(delimeter, delimreplace); } output = (output == null) ? data.replaceAll("[^\u0020-\u0070 ]+", "") : output + delimeter + data.replaceAll("[^\u0020-\u0070 ]+", ""); } else { output += delimeter; } } if (output != null && output.trim().length() > headersList.size()) { fw.write(output + "\n"); } } else { if (jsons.size() == 0) { Log.info( "Number of Headers and Keys from Json Array and Headers List Impossible to Match"); try { throw new MismatchException( "Number of Headers: " + headersList.size() + " && Number of Keys: " + jo.size()); } catch (MismatchException e) { e.printStackTrace(); } } } output = null; } } else { log.info("EOF FOUND! No New Records in This Iteration....Stopping."); } } catch (IOException e) { e.printStackTrace(); } } while (jsons.size() > 0); } else { try { throw new NullPointerException( "No Headers Input to Class. Please Create the Requisite Map."); } catch (NullPointerException e) { e.printStackTrace(); } } dumped += 1; } else { try { throw new NoDataException("No Data Found in Table " + table); } catch (NoDataException e) { e.printStackTrace(); } } } else { log.info("Missing Table " + table); try { throw new NullPointerException("Table " + table + " Does Not Exist!!!"); } catch (NullPointerException e) { e.printStackTrace(); } } } // end LOOP if (!fjp.isShutdown()) { fjp.shutdownNow(); } if (dumped == 0) { log.error("No Data Found in Any Table"); System.exit(-1); } }
From source file:org.jenkinsci.plugins.GithubSecurityRealm.java
/** * This is where the user comes back to at the end of the OpenID redirect * ping-pong./* w w w .ja va 2 s. c om*/ */ public HttpResponse doFinishLogin(StaplerRequest request) throws IOException { String code = request.getParameter("code"); if (code == null || code.trim().length() == 0) { Log.info("doFinishLogin: missing code."); return HttpResponses.redirectToContextRoot(); } Log.info("test"); HttpPost httpost = new HttpPost(githubWebUri + "/login/oauth/access_token?" + "client_id=" + clientID + "&" + "client_secret=" + clientSecret + "&" + "code=" + code); CloseableHttpClient httpclient = HttpClients.createDefault(); HttpHost proxy = getProxy(httpost); if (proxy != null) { httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } org.apache.http.HttpResponse response = httpclient.execute(httpost); HttpEntity entity = response.getEntity(); String content = EntityUtils.toString(entity); // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); String accessToken = extractToken(content); if (accessToken != null && accessToken.trim().length() > 0) { // only set the access token if it exists. GithubAuthenticationToken auth = new GithubAuthenticationToken(accessToken, getGithubApiUri()); SecurityContextHolder.getContext().setAuthentication(auth); GHMyself self = auth.getMyself(); User u = User.current(); u.setFullName(self.getName()); // Set email from github only if empty if (!u.getProperty(Mailer.UserProperty.class).hasExplicitlyConfiguredAddress()) { if (hasScope("user") || hasScope("user:email")) { String primary_email = null; for (GHEmail e : self.getEmails2()) { if (e.isPrimary()) { primary_email = e.getEmail(); } } if (primary_email != null) { u.addProperty(new Mailer.UserProperty(primary_email)); } } else { u.addProperty(new Mailer.UserProperty(auth.getGitHub().getMyself().getEmail())); } } fireAuthenticated(new GithubOAuthUserDetails(self, auth.getAuthorities())); } else { Log.info("Github did not return an access token."); } String referer = (String) request.getSession().getAttribute(REFERER_ATTRIBUTE); if (referer != null) return HttpResponses.redirectTo(referer); return HttpResponses.redirectToContextRoot(); // referer should be always there, but be defensive }
From source file:com.hygenics.parser.JDumpWithReference.java
private void toFile() { List<Future<ArrayList<String>>> qfutures; Set<Callable<ArrayList<String>>> qcollect = new HashSet<Callable<ArrayList<String>>>(4); ForkJoinPool fjp = new ForkJoinPool((int) Math.ceil(Runtime.getRuntime().availableProcessors() * procnum)); int dumped = 0; if (archive) { log.info("Cleaning"); for (String k : fpaths.keySet()) { String fpath = ""; for (String ofp : fpaths.get(k).keySet()) { fpath = ofp;/*from ww w. j a v a2 s. c om*/ } if (fpath.length() > 0) { String[] barr = fpath.split("\\/"); String basefile = ""; Archiver zip = new Archiver(); for (int i = 0; i > barr.length - 1; i++) { basefile += (i == 0) ? barr[i] : "/" + barr[i]; } if (basefile.trim().length() > 0) { zip.setBasedirectory(basefile); zip.setZipDirectory(basefile + "archive.zip"); zip.setAvoidanceString(".zip|archive"); zip.setDelFiles(true); zip.run(); } } } } log.info("Dumping"); for (String table : fpaths.keySet()) { int offset = 0; if (template.checkTable(this.baseschema + "." + table, this.baseschema)) { if (template.getCount(this.baseschema + "." + table) > 0) { log.info("Dumping for " + table); // get header String select = "SELECT * FROM " + this.baseschema + "." + table; String fpath = null; ArrayList<String> jsons; String condition; int w = 0; int start = offset; int chunksize = (int) Math.ceil(pullsize / qnum); // get fpath for (String ofp : fpaths.get(table).keySet()) { start = fpaths.get(table).get(ofp); fpath = ofp; } // perform write if (headers != null && fpath != null) { List<String> headersList = headers.get(table); String output = null; boolean existed = true; if (addFileDate) { fpath = fpath + Calendar.getInstance().getTime().toString().trim().replaceAll(":|\\s", "") + ".txt"; } // check to see if file should be created if (!new File(fpath).exists()) { try { new File(this.baseFilePath + fpath).createNewFile(); } catch (IOException e) { e.printStackTrace(); } existed = false; } // check to see if file must be recreated if (!append) { File f = new File(this.baseFilePath + fpath); f.delete(); try { f.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } if (headersList != null && (append == false || existed == false)) { for (String header : headersList) { output = (output == null) ? StringEscapeUtils.unescapeXml(header) : output + delimeter + StringEscapeUtils.unescapeXml(header); } } do { // get records jsons = new ArrayList<String>(pullsize); log.info("Looking for Pages."); for (int conn = 0; conn < qnum; conn++) { // create condition condition = " WHERE " + pullid + " >= " + (start + (conn * chunksize)) + " AND " + pullid + " < " + Integer.toString(start + (chunksize * (conn + 1))); if (extracondition != null) { condition += " " + extracondition.trim(); } // get queries qcollect.add(new SplitQuery(template, (select + condition))); log.info("Fetching " + select + condition); } start += (chunksize * qnum); qfutures = fjp.invokeAll(qcollect); w = 0; while (fjp.getActiveThreadCount() > 0 && fjp.isQuiescent() == false) { w++; } log.info("Waited for " + w + " cycles"); for (Future<ArrayList<String>> f : qfutures) { try { ArrayList<String> test = f.get(); if (test != null) { if (test.size() > 0) { jsons.addAll(test); } } if (f.isDone() == false) { f.cancel(true); } f = null; } catch (Exception e) { log.warn("Encoding Error!"); e.printStackTrace(); } } qcollect = new HashSet<Callable<ArrayList<String>>>(4); qfutures = null; log.info("Finished Getting Pages"); // post records to the file try (FileWriter fw = new FileWriter(new File(this.baseFilePath + fpath), true)) { // get and write headers if (jsons.size() > 0) { fw.write(output + "\n"); // write data for (String json : jsons) { output = null; JsonObject jo = JsonObject.readFrom(json); if (jo.size() >= headersList.size()) {// allows // trimming // of // table // to // key // aspects output = null; for (String key : headers.get(table)) { if (jo.get(key.toLowerCase()) != null) { String data = StringEscapeUtils .unescapeXml(jo.get(key.toLowerCase()).asString()); if (replacementPattern != null) { data = data.replaceAll(replacementPattern, ""); data = data.replace(delimeter, delimreplace); } output = (output == null) ? data.replaceAll("[^\u0020-\u007E ]+", "") : output + delimeter + data.replaceAll("[^\u0020-\u007E ]+", ""); } else { output += delimeter; } } if (output != null && output.trim().length() > headersList.size()) { fw.write(output + "\n"); } } else { if (jsons.size() == 0) { Log.info( "Number of Headers and Keys from Json Array and Headers List Impossible to Match"); try { throw new MismatchException( "Number of Headers: " + headersList.size() + " && Number of Keys: " + jo.size()); } catch (MismatchException e) { e.printStackTrace(); } } } output = null; } } else { log.info("EOF FOUND! No New Records in This Iteration....Stopping."); } } catch (IOException e) { e.printStackTrace(); } } while (jsons.size() > 0); } else { try { throw new NullPointerException( "No Headers Input to Class. Please Create the Requisite Map."); } catch (NullPointerException e) { e.printStackTrace(); } } dumped += 1; } else { try { throw new NoDataException("No Data in Table " + table); } catch (NoDataException e) { e.printStackTrace(); } } } else { log.info("Missing Table " + table); try { throw new NullPointerException("Table " + table + " Does Not Exist!!!"); } catch (NullPointerException e) { e.printStackTrace(); } } } // end LOOP if (!fjp.isShutdown()) { fjp.shutdownNow(); } if (dumped == 0) { log.error("No Data found in Any Tables"); System.exit(-1); } }
From source file:com.hp.avmon.deploy.service.DeployService.java
public String getMoTypeTree(String userId, String id, String pid, ResourceBundle bundle) { List<Map> list = new ArrayList<Map>(); String sql = null;/*from w w w . j ava 2s. co m*/ if ("businessTree".equals(pid)) { sql = String.format( "select type_id as \"id\",caption as \"text\",a.parent_id as \"pid\",'icon-'||lower(type_id) as \"iconCls\",case when b.parent_id is null then 'true' else 'false' end as \"leaf\" from TD_AVMON_MO_TYPE a left join (select parent_id from TD_AVMON_MO_TYPE group by parent_id) b on a.type_id=b.parent_id where a.parent_id='root'"); list = jdbc.queryForList(sql); int nodeCount = 0; for (Map map : list) { this.getNodeCount(map, id, bundle); } } else { if (null != id && id.length() > 0) { String parentId = id.split("\\*")[0]; String businessType = id.split("\\*")[1]; sql = String.format("select type_id as \"id\",caption as \"text\",a.parent_id as \"pid\"," + "case WHEN a.parent_id='HOST' THEN 'icon-' || upper(a.caption) else 'icon-' || lower(a.type_id) end as \"iconCls\"," + "case when b.parent_id is null then 'true' else 'false' end as \"leaf\" " + "from TD_AVMON_MO_TYPE a " + "left join (select parent_id from TD_AVMON_MO_TYPE group by parent_id) b " + "on a.type_id=b.parent_id " + "where a.parent_id='%s'", parentId); Log.info(sql); list = jdbc.queryForList(sql); for (Map map : list) { this.getNodeCount(map, businessType, bundle); } } else { Log.error("id is null"); } } return JackJson.fromObjectHasDateToJson(list); }
From source file:com.hp.avmon.deploy.service.DeployService.java
/** * ?Agent grid ?/*from ww w.j a v a 2 s .com*/ * @param request * @return * @throws Exception */ public Map findAgentGridInfo(HttpServletRequest request) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); //?? String os = request.getParameter("os") == null ? "" : request.getParameter("os"); String osVersion = request.getParameter("osVersion") == null ? "" : request.getParameter("osVersion"); String where = "where 1=1 "; if (null != os && !StringUtils.isEmpty(os)) { where = where + " and ag.os = '" + os + "' "; } if (null != osVersion && !StringUtils.isEmpty(os)) { where = where + " and ag.os_version = '" + osVersion + "' "; } String orderBy = ""; String sortBy = request.getParameter("sort"); if (sortBy != null) { JSONArray jsonArr = JSONArray.fromObject(sortBy); String sort = jsonArr.getJSONObject(0).get("property").toString(); if ("ampCount".equalsIgnoreCase(sort) || "ampCount1".equalsIgnoreCase(sort)) { sort = "amp.\"ampCount\""; } else if ("hostName".endsWith(sort)) { sort = "host.value"; } else if ("agentId".endsWith(sort)) { sort = "ag.AGENT_ID"; } else if ("agentVersion".endsWith(sort)) { sort = "ag.agent_version"; } else if ("agentStatus".endsWith(sort)) { sort = "ag.agent_status"; } else if ("lastHeartbeatTime".endsWith(sort)) { sort = "ag.last_heartbeat_time"; } else if ("osVersion".endsWith(sort)) { sort = "ag.os_version"; } else if ("moId".endsWith(sort)) { sort = "ag.mo_id"; } orderBy = " order by " + sort + " " + "DESC"; } String listSql = null; String countSql = null; listSql = SqlManager.getSql(AgentManageService.class, "getAgentGridInfo"); String finSql = listSql + where + orderBy; Log.info(finSql); List<Map<String, Object>> list = jdbc.queryForList(finSql); map.put("root", list); return map; }
From source file:org.imos.abos.netcdf.NetCDFfile.java
public String getFileName(Instrument sourceInstrument, Timestamp dataStartTime, Timestamp dataEndTime, String table, String dataType, String instrument) { //SimpleDateFormat nameFormatter = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'"); SimpleDateFormat nameFormatter = new SimpleDateFormat("yyyyMMdd"); nameFormatter.setTimeZone(tz);/*from w w w. j a v a 2s .c om*/ String filename = "ABOS_NetCDF.nc"; String deployment = mooring.getMooringID(); String mooringName = deployment.substring(0, deployment.indexOf("-")); if (instrument != null) { deployment += "-" + instrument; } if (sourceInstrument != null) { String sn = sourceInstrument.getSerialNumber().replaceAll("[()_]", "").trim(); deployment += "-" + sourceInstrument.getModel().trim() + "-" + sn; String SQL = "SELECT depth FROM mooring_attached_instruments WHERE mooring_id = " + StringUtilities.quoteString(mooring.getMooringID()) + " AND instrument_id = " + sourceInstrument.getInstrumentID(); logger.debug("SQL : " + SQL); Connection conn = Common.getConnection(); Statement proc; double depth = Double.NaN; try { proc = conn.createStatement(); proc.execute(SQL); ResultSet results = (ResultSet) proc.getResultSet(); results.next(); logger.debug("instrument lookup " + results); depth = results.getBigDecimal(1).doubleValue(); //depth = 30; logger.info("depth from database " + depth); proc.close(); } catch (SQLException ex) { java.util.logging.Logger.getLogger(AbstractDataParser.class.getName()).log(Level.SEVERE, null, ex); } deployment += "-" + String.format("%-4.0f", Math.abs(depth)).trim() + "m"; } if (mooringName.startsWith("SAZ")) { addTimeBnds = true; } if (authority.equals("IMOS")) { // IMOS_<Facility-Code>_<Data-Code>_<Start-date>_<Platform-Code>_FV<File-Version>_<Product-Type>_END-<End-date>_C-<Creation_date>_<PARTX>.nc // IMOS_ABOS-SOTS_20110803T115900Z_PULSE_FV01_PULSE-8-2011_END-20120719T214600Z_C-20130724T051434Z.nc filename = //System.getProperty("user.home") //+ "/" "data/" + authority + "_" + facility + "_" + dataType + "_" + nameFormatter.format(dataStartTime) + "_" + mooringName; if (table.startsWith("raw")) { filename += "_FV01"; } else { filename += "_FV02"; // its a data product from the processed table } filename += "_" + deployment + "_END-" + nameFormatter.format(dataEndTime) + "_C-"; filename = filename.replaceAll("\\s+", "-"); // replace any spaces with a - character filename += nameFormatter.format(new Date(System.currentTimeMillis())); Log.debug("try file name " + filename); if (multiPart) { int n = 1; String fnNext = filename + String.format("_PART%02d.nc", n); File fn = new File(fnNext); while (fn.exists()) { Log.info("File exists " + fn); n++; fnNext = filename + String.format("_PART%02d.nc", n); fn = new File(fnNext); } filename = fnNext; } else { filename += ".nc"; } } else if (authority.equals("OS")) { filename = "OS" + "_" + facility + "_" + deployment + "_D" + ".nc"; } System.out.println("Next filename " + filename); return filename; }