List of usage examples for java.lang Boolean toString
public String toString()
From source file:lh.api.showcase.server.api.lh.operations.OperationsServiceImpl.java
@Override public String getSchedules(AirportCode origin, AirportCode destination, String departureDate, Boolean directFlight) throws HttpErrorResponseException { // e.g., https://api.lufthansa.com/v1/operations/schedules/FRA/KIX/2014-11-01?directFlights=true OperationsRequestFactoryImpl reqFact = new OperationsRequestFactoryImpl(); try {//from w w w.j a va 2 s . co m URI uri = reqFact.getRequestUri((NameValuePair) new BasicNameValuePair("schedules", ""), (List<NameValuePair>) Arrays.asList( (NameValuePair) new BasicNameValuePair(origin.toString(), ""), (NameValuePair) new BasicNameValuePair(destination.toString(), ""), (NameValuePair) new BasicNameValuePair(departureDate, "")), Arrays.asList((NameValuePair) new BasicNameValuePair("directFlights", (directFlight == null) ? ("false") : (directFlight.toString().toLowerCase())))); return HttpQueryUtils.executeQuery(uri); } catch (URISyntaxException e) { logger.log(Level.SEVERE, e.getMessage()); } return null; }
From source file:org.axway.grapes.utils.client.GrapesClient.java
/** * Send a get artifacts request// www . ja va2 s.co m * * @param hasLicense * @return list of artifact * @throws GrapesCommunicationException */ public List<Artifact> getArtifacts(final Boolean hasLicense) throws GrapesCommunicationException { final Client client = getClient(); final WebResource resource = client.resource(serverURL).path(RequestUtils.getArtifactsPath()); final ClientResponse response = resource.queryParam(ServerAPI.HAS_LICENSE_PARAM, hasLicense.toString()) .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); client.destroy(); if (ClientResponse.Status.OK.getStatusCode() != response.getStatus()) { final String message = "Failed to get artifacts"; LOG.error(message + ". Http status: " + response.getStatus()); throw new GrapesCommunicationException(message, response.getStatus()); } return response.getEntity(ArtifactList.class); }
From source file:com.ilopez.jasperemail.JasperEmail.java
public void emailReport(String emailHost, final String emailUser, final String emailPass, Set<String> emailRecipients, String emailSender, String emailSubject, List<String> attachmentFileNames, Boolean smtpauth, OptionValues.SMTPType smtpenc, Integer smtpport) throws MessagingException { Logger.getLogger(JasperEmail.class.getName()).log(Level.INFO, emailHost + " " + emailUser + " " + emailPass + " " + emailSender + " " + emailSubject + " " + smtpauth + " " + smtpenc + " " + smtpport); Properties props = new Properties(); // Setup Email Settings props.setProperty("mail.smtp.host", emailHost); props.setProperty("mail.smtp.port", smtpport.toString()); props.setProperty("mail.smtp.auth", smtpauth.toString()); if (smtpenc == OptionValues.SMTPType.SSL) { // SSL settings props.put("mail.smtp.socketFactory.port", smtpport.toString()); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); } else if (smtpenc == OptionValues.SMTPType.TLS) { // TLS Settings props.put("mail.smtp.starttls.enable", "true"); } else {//from w w w. jav a 2 s . c o m // Plain } // Setup and Apply the Email Authentication Session mailSession = Session.getDefaultInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(emailUser, emailPass); } }); MimeMessage message = new MimeMessage(mailSession); message.setSubject(emailSubject); for (String emailRecipient : emailRecipients) { Address toAddress = new InternetAddress(emailRecipient); message.addRecipient(Message.RecipientType.TO, toAddress); } Address fromAddress = new InternetAddress(emailSender); message.setFrom(fromAddress); // Message text Multipart multipart = new MimeMultipart(); BodyPart textBodyPart = new MimeBodyPart(); textBodyPart.setText("Database report attached\n\n"); multipart.addBodyPart(textBodyPart); // Attachments for (String attachmentFileName : attachmentFileNames) { BodyPart attachmentBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(attachmentFileName); attachmentBodyPart.setDataHandler(new DataHandler(source)); String fileNameWithoutPath = attachmentFileName.replaceAll("^.*\\/", ""); fileNameWithoutPath = fileNameWithoutPath.replaceAll("^.*\\\\", ""); attachmentBodyPart.setFileName(fileNameWithoutPath); multipart.addBodyPart(attachmentBodyPart); } // add parts to message message.setContent(multipart); // send via SMTP Transport transport = mailSession.getTransport("smtp"); transport.connect(); transport.sendMessage(message, message.getAllRecipients()); transport.close(); }
From source file:gov.nih.nci.rembrandt.web.ajax.DynamicListHelper.java
public static String validateAliases(String commaGenes) { // Accepts a single gene, or a comma delimited list of strings Boolean allGeneSymbolsValid = true; commaGenes = commaGenes.replace(" ", ""); String validGeneSymbolStr = commaGenes; List<String> geneList = Arrays.asList(commaGenes.split(",")); try {/*from w w w. j ava 2s . com*/ Map<String, List<AllGeneAliasLookup>> validMap = DataValidator.searchGeneKeyWordList(geneList); if (validMap != null) { for (String symbol : geneList) { if (!DataValidator.isGeneSymbolFound(symbol) && DataValidator.searchGeneKeyWord(symbol) != null && DataValidator.searchGeneKeyWord(symbol).length > 1) { int startPos; if (geneList.size() > 1) { startPos = validGeneSymbolStr.indexOf(symbol) - 1; if (startPos < 0) startPos = 0; } else startPos = validGeneSymbolStr.indexOf(symbol); int endPos = startPos + symbol.length(); if ((endPos + 1) > validGeneSymbolStr.length()) { validGeneSymbolStr = validGeneSymbolStr.substring(0, startPos); } else { validGeneSymbolStr = validGeneSymbolStr.substring(0, startPos) + validGeneSymbolStr.substring(endPos + 1); } } } } } catch (Exception e) { e.printStackTrace(); } if (validGeneSymbolStr.equals(commaGenes)) { return allGeneSymbolsValid.toString(); } else { return validGeneSymbolStr + "|" + commaGenes; } }
From source file:com.sawyer.advadapters.widget.JSONAdapter.java
/** * Determines whether the provided constraint filters out the given item. Subclass to provide * you're own logic. It's incorrect to modify the adapter or the contents of the item itself. * Any alterations will lead to undefined behavior or crashes. Internally, this method is only * ever invoked from a background thread. * * @param item The Boolean item to compare against the constraint * @param constraint The constraint used to filter the item * * @return True if the item is filtered out by the given constraint. False if the item will * continue to display in the adapter./*from ww w.j a v a 2 s . c o m*/ */ protected boolean isFilteredOut(Boolean item, CharSequence constraint) { return !item.toString().equalsIgnoreCase(constraint.toString()); }
From source file:no.dusken.barweb.view.XListView.java
private Document generateXml(List<BarPerson> barPersons, Gjeng gjeng, List<Vare> varer, int lowlimit, Boolean panger) { Document dom = null;// ww w. j a v a 2 s.c o m //get an instance of factory DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { //get an instance of builder DocumentBuilder db = dbf.newDocumentBuilder(); //create an instance of DOM dom = db.newDocument(); } catch (ParserConfigurationException pce) { log.error("Error when generating x-list"); } Element root = dom.createElement("xlist"); root.setAttribute("gjeng", gjeng.getName()); SimpleDateFormat dateformat = new SimpleDateFormat("d. MMMMMMMMM yyyy - HH:mm", new Locale("no")); root.setAttribute("generated", dateformat.format((new GregorianCalendar()).getTime())); root.setAttribute("magicNumber", String.valueOf(((new Random()).nextDouble() * 1000))); root.setAttribute("panger", panger.toString()); dom.appendChild(root); Element personsEle = dom.createElement("barPersons"); for (BarPerson p : barPersons) { Element personEle = createPersonElement(p, dom, lowlimit); personsEle.appendChild(personEle); } root.appendChild(personsEle); Element vareEle = dom.createElement("varer"); for (Vare v : varer) { Element vare = createVareElement(v, dom); vareEle.appendChild(vare); } root.appendChild(vareEle); return dom; }
From source file:com.appfirst.communication.AFClient.java
/** * Change the alert status to be either active or inactive. * /*from www . j av a2 s.c o m*/ * @param url * query url * @param id * the id of the alert * @param active * Boolean value indicates whether the alert is active or not. * @return the modified Alert object. */ public Alert updateAlertStatus(String url, int id, Boolean active) { JSONObject jsonObject = new JSONObject(); HttpPut request = null; String params = String.format("?id=%d&active=%s", id, active.toString()); try { request = new HttpPut(new URI(url + params)); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } jsonObject = makeJsonObjectPutRequest(request); return new Alert(jsonObject); }
From source file:it.lufraproini.cms.servlet.Upload.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from www.j a v a2 s. c om*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs * @throws org.apache.commons.fileupload.FileUploadException * @throws java.sql.SQLException */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, FileUploadException, SQLException, Exception { /*verifica validit sessione*/ HttpSession s = SecurityLayer.checkSession(request); if (s != null) { /*DBMS*/ DataSource ds = (DataSource) getServletContext().getAttribute("datasource"); Connection connection = ds.getConnection(); /**/ CMSDataLayerImpl datalayer = new CMSDataLayerImpl(connection); String digest = ""; String html = ""; String tipo = ""; Map template_data = new HashMap(); Map info = new HashMap(); info = prendiInfo(request); //info = request.getParameterMap(); /*per prevedere l'upload di un nuovo tipo di file basta dare un valore personalizzato al submit nella form e creare un if con il flusso relativo all'oggetto da caricare nel file system e nel database*/ tipo = info.get("submit").toString(); try { //flusso immagine if (tipo.equals("immagine")) { Immagine img; Boolean thumbnail = false; html = "show_immagine.ftl.html"; digest = action_upload(request, info); img = memorizzaImmagine(info, datalayer, digest, (Long) s.getAttribute("userid")); img.setNome(SecurityLayer.stripSlashes(img.getNome()));//potrebbe causare eccezione su img null if (info.containsKey("thumbnail")) { thumbnail = creaThumbnail(img, s.getAttribute("username").toString()); } template_data.put("thumbnail", thumbnail.toString()); template_data.put("immagine", img); template_data.put("id", img.getId()); template_data.put("id_utente", 2); } //flusso css else if (tipo.equals("css")) { Css css = null; html = "show_css.ftl.html"; action_upload(request, info); css = memorizzaCss(info, datalayer); css.setDescrizione(SecurityLayer.stripSlashes(css.getDescrizione()));//potrebbe generare una nullpointerexception css.setNome(SecurityLayer.stripSlashes(css.getNome())); template_data.put("css", css); template_data.put("identifier", css.getId()); } //flusso slide else if (tipo.equals("slide")) { Slide img = null; html = "show_slide.ftl.html"; digest = action_upload(request, info); img = memorizzaSlide(info, datalayer, digest); /*visualizzazione della slide appena inserita*/ img.setDescrizione(SecurityLayer.stripSlashes(img.getDescrizione())); img.setNome(SecurityLayer.stripSlashes(img.getNome())); template_data.put("slide", img); template_data.put("id", img.getId()); } template_data.put("outline_tpl", ""); TemplateResult tr = new TemplateResult(getServletContext()); tr.activate(html, template_data, response); } catch (ErroreGrave ex) { Logger.getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex); FailureResult res = new FailureResult(getServletContext()); res.activate(ex.getMessage(), request, response); } } else { response.sendRedirect("Homepage.html"); } }
From source file:org.axway.grapes.utils.client.GrapesClient.java
/** * Post boolean flag "DO_NOT_USE" to an artifact * * @param gavc/*from ww w . j av a 2 s . com*/ * @param doNotUse * @param user * @param password * @throws GrapesCommunicationException */ public void postDoNotUseArtifact(final String gavc, final Boolean doNotUse, final String user, final String password) throws GrapesCommunicationException, AuthenticationException { final Client client = getClient(user, password); final WebResource resource = client.resource(serverURL).path(RequestUtils.getDoNotUseArtifact(gavc)); final ClientResponse response = resource.queryParam(ServerAPI.DO_NOT_USE, doNotUse.toString()) .accept(MediaType.APPLICATION_JSON).post(ClientResponse.class); client.destroy(); if (ClientResponse.Status.OK.getStatusCode() != response.getStatus()) { final String message = "Failed to post do not use artifact"; LOG.error(message + ". Http status: " + response.getStatus()); throw new GrapesCommunicationException(message, response.getStatus()); } }
From source file:org.axway.grapes.utils.client.GrapesClient.java
/** * Approve or reject a license//from w ww. j a va 2 s . c o m * * @param licenseId * @param approve * @throws GrapesCommunicationException * @throws javax.naming.AuthenticationException */ public void approveLicense(final String licenseId, final Boolean approve, final String user, final String password) throws GrapesCommunicationException, AuthenticationException { final Client client = getClient(user, password); final WebResource resource = client.resource(serverURL).path(RequestUtils.getLicensePath(licenseId)); final ClientResponse response = resource.queryParam(ServerAPI.APPROVED_PARAM, approve.toString()) .post(ClientResponse.class); client.destroy(); if (ClientResponse.Status.OK.getStatusCode() != response.getStatus()) { final String message = "Failed to approve license " + licenseId; LOG.error(message + ". Http status: " + response.getStatus()); throw new GrapesCommunicationException(message, response.getStatus()); } }