List of usage examples for org.apache.commons.lang3 StringUtils endsWithIgnoreCase
public static boolean endsWithIgnoreCase(final CharSequence str, final CharSequence suffix)
Case insensitive check if a CharSequence ends with a specified suffix.
null s are handled without exceptions.
From source file:forge.gui.ImportSourceAnalyzer.java
private void analyzeQuestDataDir(final File root) { analyzeDir(root, new Analyzer() { @Override//from w w w .j av a 2s. c om void onFile(final File file) { final String filename = file.getName(); if (StringUtils.endsWithIgnoreCase(filename, ".dat")) { final File targetFile = new File(ForgeConstants.QUEST_SAVE_DIR, lcaseExt(filename)); if (!file.equals(targetFile)) { cb.addOp(OpType.QUEST_DATA, file, targetFile); } } } }); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.java
/** * Returns a sorted map containing style elements, keyed on style element name. We use a * {@link LinkedHashMap} map so that results are deterministic and are thus testable. * * @return a sorted map containing style elements, keyed on style element name *//* w w w .j a v a 2 s. c o m*/ private Map<String, StyleElement> getStyleMap() { final String styleAttribute = jsElement_.getDomNodeOrDie().getAttribute("style"); if (styleString_ == styleAttribute) { return styleMap_; } final Map<String, StyleElement> styleMap = new LinkedHashMap<>(); if (DomElement.ATTRIBUTE_NOT_DEFINED == styleAttribute || DomElement.ATTRIBUTE_VALUE_EMPTY == styleAttribute) { styleMap_ = styleMap; styleString_ = styleAttribute; return styleMap_; } for (final String token : StringUtils.split(styleAttribute, ';')) { final int index = token.indexOf(":"); if (index != -1) { final String key = token.substring(0, index).trim().toLowerCase(Locale.ROOT); String value = token.substring(index + 1).trim(); String priority = ""; if (StringUtils.endsWithIgnoreCase(value, "!important")) { priority = PRIORITY_IMPORTANT; value = value.substring(0, value.length() - 10); value = value.trim(); } final StyleElement element = new StyleElement(key, value, priority, SelectorSpecificity.FROM_STYLE_ATTRIBUTE, getCurrentElementIndex()); styleMap.put(key, element); } } styleMap_ = styleMap; styleString_ = styleAttribute; return styleMap_; }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void sign() { if (logger.isDebugEnabled()) { logger.debug("[SIGN] activeProfile sourceFile={}, targetFile={}", activeProfile.getSourceFileFileName(), activeProfile.getTargetFileFileName()); }/*from ww w .jav a 2s . c om*/ boolean isValid = validateSign(); if (!isValid) { if (logger.isDebugEnabled()) { logger.debug("[SIGN] form not valid; returning"); } return; } final Boolean doUnsign = ckReplace.isSelected(); UnsignCommand unsignCommand = unsignCommandProvider.get(); SignCommand signCommand = signCommandProvider.get(); if (activeProfile.getArgsType() == SigningArgumentsType.FOLDER) { if (logger.isDebugEnabled()) { logger.debug("[SIGN] signing folder full of jars"); } // // Get list of source JARs // File[] sourceJars = new File(activeProfile.getSourceFileFileName()) .listFiles((d, n) -> StringUtils.endsWithIgnoreCase(n, ".jar")); // // Report if no jars to sign and exit // if (sourceJars == null || sourceJars.length == 0) { Alert alert = new Alert(Alert.AlertType.INFORMATION, "There aren't any JARs to sign in '" + activeProfile.getTargetFileFileName() + "'"); alert.setHeaderText("No JARs to Sign"); alert.showAndWait(); return; } if (logger.isDebugEnabled()) { for (File f : sourceJars) { logger.debug("[SIGN] source jar={}, filename={}", f.getAbsolutePath(), f.getName()); } } // // Confirm replace operation // if (doUnsign && !confirmReplaceExisting()) { return; } // // Confirm overwriting of files // if (!confirmOverwrite(sourceJars)) { return; } // // This number is applied to the progress bar to report a particular // iterations unit-of-work (2 operations per jar) // double unitFactor = 1.0d / (sourceJars.length * 2.0d); Task<Void> task = new Task<Void>() { @Override protected Void call() throws Exception { double accruedProgress = 0.0d; for (File sf : sourceJars) { File tf = new File(activeProfile.getTargetFileFileName(), sf.getName()); if (logger.isDebugEnabled()) { logger.debug("[SIGN] progress={}", accruedProgress); } updateMessage(""); Platform.runLater(() -> piSignProgress.setVisible(true)); updateProgress(accruedProgress, 1.0d); accruedProgress += unitFactor; if (doUnsign) { if (logger.isDebugEnabled()) { logger.debug("[SIGN] doing bulk unsign operation"); } updateTitle("Unsigning JAR"); unsignCommand.unsignJAR(Paths.get(sf.getAbsolutePath()), Paths.get(tf.getAbsolutePath()), s -> Platform.runLater( () -> txtConsole.appendText(s + System.getProperty("line.separator")))); if (isCancelled()) { return null; } } else { if (logger.isDebugEnabled()) { logger.debug("[SIGN] copying bulk for sign operation"); } updateTitle("Copying JAR"); Platform.runLater(() -> txtConsole .appendText("Copying JAR" + System.getProperty("line.separator"))); unsignCommand.copyJAR(sf.getAbsolutePath(), tf.getAbsolutePath()); } updateProgress(accruedProgress, 1.0d); accruedProgress += unitFactor; updateTitle("Signing JAR"); signCommand.signJAR(Paths.get(tf.getAbsolutePath()), Paths.get(activeProfile.getJarsignerConfigKeystore()), activeProfile.getJarsignerConfigStorepass(), activeProfile.getJarsignerConfigAlias(), activeProfile.getJarsignerConfigKeypass(), s -> Platform.runLater( () -> txtConsole.appendText(s + System.getProperty("line.separator")))); } return null; } @Override protected void succeeded() { super.succeeded(); updateProgress(1.0d, 1.0d); updateMessage("JARs signed successfully"); piSignProgress.progressProperty().unbind(); lblStatus.textProperty().unbind(); } @Override protected void failed() { super.failed(); logger.error("error unsigning and signing jar", exceptionProperty().getValue()); updateProgress(1.0d, 1.0d); updateMessage("Error signing JARs"); piSignProgress.progressProperty().unbind(); lblStatus.textProperty().unbind(); piSignProgress.setVisible(false); Alert alert = new Alert(Alert.AlertType.ERROR, exceptionProperty().getValue().getMessage()); alert.showAndWait(); } @Override protected void cancelled() { super.cancelled(); if (logger.isWarnEnabled()) { logger.warn("signing jar operation cancelled"); } updateProgress(1.0d, 1.0d); updateMessage("JARs signing cancelled"); Platform.runLater(() -> { piSignProgress.progressProperty().unbind(); lblStatus.textProperty().unbind(); piSignProgress.setVisible(false); Alert alert = new Alert(Alert.AlertType.INFORMATION, "JARs signing cancelled"); alert.showAndWait(); }); } }; piSignProgress.progressProperty().bind(task.progressProperty()); lblStatus.textProperty().bind(task.messageProperty()); new Thread(task).start(); } else { if (logger.isDebugEnabled()) { logger.debug("[SIGN] signing single JAR"); } // // #2 confirm an overwrite (if needed); factored // if (doUnsign && !confirmReplaceExisting()) { return; } else { // // #6 sign-only to a different target filename needs a copy and // possible overwrite // File tf = new File(activeProfile.getTargetFileFileName()); if (tf.exists()) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Overwrite existing file '" + tf.getName() + "'?"); alert.setHeaderText("Overwrite existing file"); Optional<ButtonType> response = alert.showAndWait(); if (!response.isPresent() || response.get() != ButtonType.OK) { if (logger.isDebugEnabled()) { logger.debug("[SIGN] overwrite file cancelled"); } return; } } } Task<Void> task = new Task<Void>() { @Override protected Void call() throws Exception { updateMessage(""); Platform.runLater(() -> piSignProgress.setVisible(true)); updateProgress(0.1d, 1.0d); if (doUnsign) { if (logger.isDebugEnabled()) { logger.debug("[SIGN] doing unsign operation"); } updateTitle("Unsigning JAR"); unsignCommand.unsignJAR(Paths.get(activeProfile.getSourceFileFileName()), Paths.get(activeProfile.getTargetFileFileName()), s -> Platform.runLater( () -> txtConsole.appendText(s + System.getProperty("line.separator")))); if (isCancelled()) { return null; } } else { // // #6 needs a copy to the target if target file doesn't // exist // if (logger.isDebugEnabled()) { logger.debug("[SIGN] copying for sign operation"); } updateTitle("Copying JAR"); Platform.runLater( () -> txtConsole.appendText("Copying JAR" + System.getProperty("line.separator"))); unsignCommand.copyJAR(activeProfile.getSourceFileFileName(), activeProfile.getTargetFileFileName()); } updateProgress(0.5d, 1.0d); updateTitle("Signing JAR"); signCommand.signJAR(Paths.get(activeProfile.getTargetFileFileName()), Paths.get(activeProfile.getJarsignerConfigKeystore()), activeProfile.getJarsignerConfigStorepass(), activeProfile.getJarsignerConfigAlias(), activeProfile.getJarsignerConfigKeypass(), s -> Platform.runLater( () -> txtConsole.appendText(s + System.getProperty("line.separator")))); return null; } @Override protected void succeeded() { super.succeeded(); updateProgress(1.0d, 1.0d); updateMessage("JAR signed successfully"); piSignProgress.progressProperty().unbind(); lblStatus.textProperty().unbind(); } @Override protected void failed() { super.failed(); logger.error("error unsigning and signing jar", exceptionProperty().getValue()); updateProgress(1.0d, 1.0d); updateMessage("Error signing JAR"); piSignProgress.progressProperty().unbind(); lblStatus.textProperty().unbind(); piSignProgress.setVisible(false); Alert alert = new Alert(Alert.AlertType.ERROR, exceptionProperty().getValue().getMessage()); alert.showAndWait(); } @Override protected void cancelled() { super.cancelled(); if (logger.isWarnEnabled()) { logger.warn("signing jar operation cancelled"); } updateProgress(1.0d, 1.0d); updateMessage("JAR signing cancelled"); piSignProgress.progressProperty().unbind(); lblStatus.textProperty().unbind(); piSignProgress.setVisible(false); Alert alert = new Alert(Alert.AlertType.INFORMATION, "JAR signing cancelled"); alert.showAndWait(); } }; piSignProgress.progressProperty().bind(task.progressProperty()); lblStatus.textProperty().bind(task.messageProperty()); new Thread(task).start(); } }
From source file:com.nridge.core.base.field.data.DataTable.java
/** * Returns one or more field rows that match the search criteria of the * parameters provided in a case insensitive manner. Each row of the * table will be examined to determine if a cell identified by name * evaluates true when the operator and value are applied to it. * <p>//ww w.j a v a 2s .c o m * <b>Note:</b> This method supports text based logical operators only. * You should use other <code>findValue()</code> methods for different * data types. * </p> * * @param aName Column name. * @param anOperator Logical operator. * @param aValue Comparison value. * * @return Array list of matching field rows or <i>null</i> if none evaluate true. */ public ArrayList<FieldRow> findValueInsensitive(String aName, Field.Operator anOperator, String aValue) { FieldRow fieldRow; String valueString; Matcher regexMatcher = null; Pattern regexPattern = null; ArrayList<FieldRow> matchingRows = new ArrayList<FieldRow>(); int rowCount = rowCount(); int colOffset = offsetByName(aName); if ((aValue != null) && (colOffset != -1) && (rowCount > 0)) { for (int row = 0; row < rowCount; row++) { fieldRow = getRow(row); valueString = fieldRow.getValue(colOffset); switch (anOperator) { case EQUAL: if (StringUtils.equalsIgnoreCase(valueString, aValue)) matchingRows.add(fieldRow); break; case NOT_EQUAL: if (!StringUtils.equalsIgnoreCase(valueString, aValue)) matchingRows.add(fieldRow); break; case CONTAINS: if (StringUtils.containsIgnoreCase(valueString, aValue)) matchingRows.add(fieldRow); break; case STARTS_WITH: if (StringUtils.startsWithIgnoreCase(valueString, aValue)) matchingRows.add(fieldRow); break; case ENDS_WITH: if (StringUtils.endsWithIgnoreCase(valueString, aValue)) matchingRows.add(fieldRow); break; case EMPTY: if (StringUtils.isEmpty(valueString)) matchingRows.add(fieldRow); break; case REGEX: // http://www.regular-expressions.info/java.html if (regexPattern == null) regexPattern = Pattern.compile(aValue, Pattern.CASE_INSENSITIVE); if (regexMatcher == null) regexMatcher = regexPattern.matcher(valueString); else regexMatcher.reset(valueString); if (regexMatcher.find()) matchingRows.add(fieldRow); break; } } } return matchingRows; }
From source file:com.google.dart.java2dart.SyntaxTranslator.java
@Override public boolean visit(org.eclipse.jdt.core.dom.NumberLiteral node) { String token = node.getToken(); if (token.contains(".") || !StringUtils.startsWithIgnoreCase(token, "0x") && (StringUtils.endsWithIgnoreCase(token, "F") || StringUtils.endsWithIgnoreCase(token, "D"))) { token = StringUtils.removeEndIgnoreCase(token, "F"); token = StringUtils.removeEndIgnoreCase(token, "D"); if (!token.contains(".")) { token += ".0"; }/*from ww w . j av a 2 s.c om*/ return done(new DoubleLiteral(token(TokenType.DOUBLE, token), 0)); } else { token = StringUtils.removeEndIgnoreCase(token, "L"); return done(new IntegerLiteral(token(TokenType.INT, token), BigInteger.valueOf(0))); } }
From source file:com.mirth.connect.client.ui.reference.ReferenceListFactory.java
private void addUserutilReferences() { populateAliases();/*from w w w .j a v a 2 s . c o m*/ if (Thread.currentThread().getContextClassLoader() instanceof URLClassLoader) { URLClassLoader classLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader(); for (URL url : classLoader.getURLs()) { String urlString = url.toString(); if (StringUtils.endsWithIgnoreCase(urlString, "userutil-sources.jar")) { addUserutilReferences(url); } } } }
From source file:com.mirth.connect.client.ui.reference.ReferenceListFactory.java
private void addUserutilReferences(URL url) { InputStream inputStream = null; try {/*w ww .j av a 2 s . c om*/ inputStream = url.openStream(); ZipInputStream zis = new ZipInputStream(inputStream); ZipEntry zipEntry; Map<String, InputStream> entryMap = new HashMap<String, InputStream>(); // Iterate through each entry in the JAR file while ((zipEntry = zis.getNextEntry()) != null) { if (!zipEntry.isDirectory() && StringUtils.endsWithIgnoreCase(zipEntry.getName(), ".java")) { entryMap.put(zipEntry.getName(), new ByteArrayInputStream(IOUtils.toByteArray(zis))); } } for (Entry<String, InputStream> entry : entryMap.entrySet()) { try { // Parse the source file CompilationUnit compilationUnit = JavaParser.parse(entry.getValue()); // Determine any runtime aliases for the class List<String> inputTextList = aliasMap .get(entry.getKey().replaceAll("\\.java$", "").replace('/', '.')); // Create and add references for the parsed source file addReferences(ClassVisitor.getReferencesByCompilationUnit(compilationUnit, inputTextList)); } catch (Exception e) { logger.error("Unable to load references from userutil entry " + entry.getKey(), e); } } } catch (Exception e) { logger.error("Error occurred while scanning for userutil references.", e); } finally { IOUtils.closeQuietly(inputStream); } }
From source file:com.sonicle.webtop.core.CoreManager.java
public List<SyncDevice> listZPushDevices() throws WTException { try {//from w w w . ja va 2s . c om ZPushManager zpush = createZPushManager(); boolean noFilter = false, domainMatch = false; String match = null; UserProfileId targetPid = getTargetProfileId(); if (RunContext.isSysAdmin()) { if (UserProfileId.isWildcardUser(targetPid)) { domainMatch = true; match = "@" + wta.getWebTopManager().getDomainInternetName(targetPid.getDomainId()); } else { match = getInternetUserId(targetPid); } } else { match = getInternetUserId(targetPid); } ArrayList<SyncDevice> devices = new ArrayList<>(); List<ZPushManager.LastsyncRecord> recs = zpush.listDevices(); for (ZPushManager.LastsyncRecord rec : recs) { if (noFilter || StringUtils.equalsIgnoreCase(rec.synchronizedUser, match) || (domainMatch && StringUtils.endsWithIgnoreCase(rec.synchronizedUser, match))) { devices.add(new SyncDevice(rec.device, rec.synchronizedUser, rec.lastSyncTime)); } } return devices; } catch (Exception ex) { logger.error("Error listing zpush devices", ex); throw new WTException(ex); } }
From source file:com.sonicle.webtop.mail.Service.java
public void processGetMessage(HttpServletRequest request, HttpServletResponse response, PrintWriter out) { MailAccount account = getAccount(request); String pfoldername = request.getParameter("folder"); String puidmessage = request.getParameter("idmessage"); String pidattach = request.getParameter("idattach"); String providername = request.getParameter("provider"); String providerid = request.getParameter("providerid"); String nopec = request.getParameter("nopec"); int idattach = 0; boolean isEditor = request.getParameter("editor") != null; boolean setSeen = ServletUtils.getBooleanParameter(request, "setseen", true); if (df == null) { df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM, environment.getProfile().getLocale()); }/*from w ww .j a v a2s.com*/ try { FolderCache mcache = null; Message m = null; IMAPMessage im = null; int recs = 0; long msguid = -1; String vheader[] = null; boolean wasseen = false; boolean isPECView = false; String sout = "{\nmessage: [\n"; if (providername == null) { account.checkStoreConnected(); mcache = account.getFolderCache(pfoldername); msguid = Long.parseLong(puidmessage); m = mcache.getMessage(msguid); im = (IMAPMessage) m; im.setPeek(us.isManualSeen()); if (m.isExpunged()) throw new MessagingException("Message " + puidmessage + " expunged"); vheader = m.getHeader("Disposition-Notification-To"); wasseen = m.isSet(Flags.Flag.SEEN); if (pidattach != null) { HTMLMailData mailData = mcache.getMailData((MimeMessage) m); Part part = mailData.getAttachmentPart(Integer.parseInt(pidattach)); m = (Message) part.getContent(); idattach = Integer.parseInt(pidattach) + 1; } else if (nopec == null && mcache.isPEC()) { String hdrs[] = m.getHeader(HDR_PEC_TRASPORTO); if (hdrs != null && hdrs.length > 0 && hdrs[0].equals("posta-certificata")) { HTMLMailData mailData = mcache.getMailData((MimeMessage) m); int parts = mailData.getAttachmentPartCount(); for (int i = 0; i < parts; ++i) { Part p = mailData.getAttachmentPart(i); if (p.isMimeType("message/rfc822")) { m = (Message) p.getContent(); idattach = i + 1; isPECView = true; break; } } } } } else { // TODO: provider get message!!!! /* WebTopService provider=wts.getServiceByName(providername); MessageContentProvider mcp=provider.getMessageContentProvider(providerid); m=new MimeMessage(session,mcp.getSource()); mcache=fcProvided; mcache.addProvidedMessage(providername, providerid, m);*/ } String messageid = getMessageID(m); String subject = m.getSubject(); if (subject == null) { subject = ""; } else { try { subject = MailUtils.decodeQString(subject); } catch (Exception exc) { } } java.util.Date d = m.getSentDate(); if (d == null) { d = m.getReceivedDate(); } if (d == null) { d = new java.util.Date(0); } String date = df.format(d).replaceAll("\\.", ":"); String fromName = ""; String fromEmail = ""; Address as[] = m.getFrom(); InternetAddress iafrom = null; if (as != null && as.length > 0) { iafrom = (InternetAddress) as[0]; fromName = iafrom.getPersonal(); fromEmail = adjustEmail(iafrom.getAddress()); if (fromName == null) { fromName = fromEmail; } } sout += "{iddata:'from',value1:'" + StringEscapeUtils.escapeEcmaScript(MailUtils.htmlescape(fromName)) + "',value2:'" + StringEscapeUtils.escapeEcmaScript(fromEmail) + "',value3:0},\n"; recs += 2; Address tos[] = m.getRecipients(RecipientType.TO); if (tos != null) { for (Address to : tos) { InternetAddress ia = (InternetAddress) to; String toName = ia.getPersonal(); String toEmail = adjustEmail(ia.getAddress()); if (toName == null) { toName = toEmail; } sout += "{iddata:'to',value1:'" + StringEscapeUtils.escapeEcmaScript(MailUtils.htmlescape(toName)) + "',value2:'" + StringEscapeUtils.escapeEcmaScript(toEmail) + "',value3:0},\n"; ++recs; } } Address ccs[] = m.getRecipients(RecipientType.CC); if (ccs != null) { for (Address cc : ccs) { InternetAddress ia = (InternetAddress) cc; String ccName = ia.getPersonal(); String ccEmail = adjustEmail(ia.getAddress()); if (ccName == null) { ccName = ccEmail; } sout += "{iddata:'cc',value1:'" + StringEscapeUtils.escapeEcmaScript(ccName) + "',value2:'" + StringEscapeUtils.escapeEcmaScript(ccEmail) + "',value3:0},\n"; ++recs; } } Address bccs[] = m.getRecipients(RecipientType.BCC); if (bccs != null) for (Address bcc : bccs) { InternetAddress ia = (InternetAddress) bcc; String bccName = ia.getPersonal(); String bccEmail = adjustEmail(ia.getAddress()); if (bccName == null) { bccName = bccEmail; } sout += "{iddata:'bcc',value1:'" + StringEscapeUtils.escapeEcmaScript(bccName) + "',value2:'" + StringEscapeUtils.escapeEcmaScript(bccEmail) + "',value3:0},\n"; ++recs; } ArrayList<String> htmlparts = null; boolean balanceTags = isPreviewBalanceTags(iafrom); if (providername == null) { htmlparts = mcache.getHTMLParts((MimeMessage) m, msguid, false, balanceTags); } else { htmlparts = mcache.getHTMLParts((MimeMessage) m, providername, providerid, balanceTags); } HTMLMailData mailData = mcache.getMailData((MimeMessage) m); ICalendarRequest ir = mailData.getICalRequest(); if (ir != null) { if (htmlparts.size() > 0) sout += "{iddata:'html',value1:'" + StringEscapeUtils.escapeEcmaScript(htmlparts.get(0)) + "',value2:'',value3:0},\n"; } else { for (String html : htmlparts) { //sout += "{iddata:'html',value1:'" + OldUtils.jsEscape(html) + "',value2:'',value3:0},\n"; sout += "{iddata:'html',value1:'" + StringEscapeUtils.escapeEcmaScript(html) + "',value2:'',value3:0},\n"; ++recs; } } /*if (!wasseen) { //if (us.isManualSeen()) { if (!setSeen) { m.setFlag(Flags.Flag.SEEN, false); } else { //if no html part, flag seen is not set if (htmlparts.size()==0) m.setFlag(Flags.Flag.SEEN, true); } }*/ if (!us.isManualSeen()) { if (htmlparts.size() == 0) m.setFlag(Flags.Flag.SEEN, true); } else { if (setSeen) m.setFlag(Flags.Flag.SEEN, true); } int acount = mailData.getAttachmentPartCount(); for (int i = 0; i < acount; ++i) { Part p = mailData.getAttachmentPart(i); String ctype = p.getContentType(); Service.logger.debug("attachment " + i + " is " + ctype); int ix = ctype.indexOf(';'); if (ix > 0) { ctype = ctype.substring(0, ix); } String cidnames[] = p.getHeader("Content-ID"); String cidname = null; if (cidnames != null && cidnames.length > 0) cidname = mcache.normalizeCidFileName(cidnames[0]); boolean isInlineable = isInlineableMime(ctype); boolean inline = ((p.getHeader("Content-Location") != null) || (cidname != null)) && isInlineable; if (inline && cidname != null) inline = mailData.isReferencedCid(cidname); if (p.getDisposition() != null && p.getDisposition().equalsIgnoreCase(Part.INLINE) && inline) { continue; } String imgname = null; boolean isCalendar = ctype.equalsIgnoreCase("text/calendar") || ctype.equalsIgnoreCase("text/icalendar"); if (isCalendar) { imgname = "resources/" + getManifest().getId() + "/laf/" + cus.getLookAndFeel() + "/ical_16.png"; } String pname = getPartName(p); try { pname = MailUtils.decodeQString(pname); } catch (Exception exc) { } if (pname == null) { ix = ctype.indexOf("/"); String fname = ctype; if (ix > 0) { fname = ctype.substring(ix + 1); } //String ext = WT.getMediaTypeExtension(ctype); //if (ext == null) { pname = fname; //} else { // pname = fname + "." + ext; //} if (isCalendar) pname += ".ics"; } else { if (isCalendar && !StringUtils.endsWithIgnoreCase(pname, ".ics")) pname += ".ics"; } int size = p.getSize(); int lines = (size / 76); int rsize = size - (lines * 2);//(p.getSize()/4)*3; String iddata = ctype.equalsIgnoreCase("message/rfc822") ? "eml" : (inline ? "inlineattach" : "attach"); boolean editable = isFileEditableInDocEditor(pname); sout += "{iddata:'" + iddata + "',value1:'" + (i + idattach) + "',value2:'" + StringEscapeUtils.escapeEcmaScript(MailUtils.htmlescape(pname)) + "',value3:" + rsize + ",value4:" + (imgname == null ? "null" : "'" + StringEscapeUtils.escapeEcmaScript(imgname) + "'") + ", editable: " + editable + " },\n"; } if (!mcache.isDrafts() && !mcache.isSent() && !mcache.isSpam() && !mcache.isTrash() && !mcache.isArchive()) { if (vheader != null && vheader[0] != null && !wasseen) { sout += "{iddata:'receipt',value1:'" + us.getReadReceiptConfirmation() + "',value2:'" + StringEscapeUtils.escapeEcmaScript(vheader[0]) + "',value3:0},\n"; } } String h = getSingleHeaderValue(m, "Sonicle-send-scheduled"); if (h != null && h.equals("true")) { java.util.Calendar scal = parseScheduleHeader(getSingleHeaderValue(m, "Sonicle-send-date"), getSingleHeaderValue(m, "Sonicle-send-time")); if (scal != null) { java.util.Date sd = scal.getTime(); String sdate = df.format(sd).replaceAll("\\.", ":"); sout += "{iddata:'scheddate',value1:'" + StringEscapeUtils.escapeEcmaScript(sdate) + "',value2:'',value3:0},\n"; } } if (ir != null) { /* ICalendarManager calMgr = (ICalendarManager)WT.getServiceManager("com.sonicle.webtop.calendar",environment.getProfileId()); if (calMgr != null) { if (ir.getMethod().equals("REPLY")) { calMgr.updateEventFromICalReply(ir.getCalendar()); //TODO: gestire lato client una notifica di avvenuto aggiornamento } else { Event evt = calMgr..getEvent(GetEventScope.PERSONAL_AND_INCOMING, false, ir.getUID()) if (evt != null) { UserProfileId pid = getEnv().getProfileId(); UserProfile.Data ud = WT.getUserData(pid); boolean iAmOrganizer = StringUtils.equalsIgnoreCase(evt.getOrganizerAddress(), ud.getEmailAddress()); boolean iAmOwner = pid.equals(calMgr.getCalendarOwner(evt.getCalendarId())); if (!iAmOrganizer && !iAmOwner) { //TODO: gestire lato client l'aggiornamento: Accetta/Rifiuta, Aggiorna e20 dopo update/request } } } } */ ICalendarManager cm = (ICalendarManager) WT.getServiceManager("com.sonicle.webtop.calendar", true, environment.getProfileId()); if (cm != null) { int eid = -1; //Event ev=cm.getEventByScope(EventScope.PERSONAL_AND_INCOMING, ir.getUID()); Event ev = null; if (ir.getMethod().equals("REPLY")) { // Previous impl. forced (forceOriginal == true) ev = cm.getEvent(GetEventScope.PERSONAL_AND_INCOMING, ir.getUID()); } else { ev = cm.getEvent(GetEventScope.PERSONAL_AND_INCOMING, ir.getUID()); } UserProfileId pid = getEnv().getProfileId(); UserProfile.Data ud = WT.getUserData(pid); if (ev != null) { InternetAddress organizer = InternetAddressUtils.toInternetAddress(ev.getOrganizer()); boolean iAmOwner = pid.equals(cm.getCalendarOwner(ev.getCalendarId())); boolean iAmOrganizer = (organizer != null) && StringUtils.equalsIgnoreCase(organizer.getAddress(), ud.getEmailAddress()); //TODO: in reply controllo se mail combacia con quella dell'attendee che risponde... //TODO: rimuovere controllo su data? dovrebbe sempre aggiornare? if (iAmOwner || iAmOrganizer) { eid = 0; //TODO: troviamo un modo per capire se la risposta si riverisce all'ultima versione dell'evento? Nuovo campo timestamp? /* DateTime dtEvt = ev.getRevisionTimestamp().withMillisOfSecond(0).withZone(DateTimeZone.UTC); DateTime dtICal = ICal4jUtils.fromICal4jDate(ir.getLastModified(), ICal4jUtils.getTimeZone(DateTimeZone.UTC)); if (dtICal.isAfter(dtEvt)) { eid = 0; } else { eid = ev.getEventId(); } */ } } sout += "{iddata:'ical',value1:'" + ir.getMethod() + "',value2:'" + ir.getUID() + "',value3:'" + eid + "'},\n"; } } sout += "{iddata:'date',value1:'" + StringEscapeUtils.escapeEcmaScript(date) + "',value2:'',value3:0},\n"; sout += "{iddata:'subject',value1:'" + StringEscapeUtils.escapeEcmaScript(MailUtils.htmlescape(subject)) + "',value2:'',value3:0},\n"; sout += "{iddata:'messageid',value1:'" + StringEscapeUtils.escapeEcmaScript(messageid) + "',value2:'',value3:0}\n"; if (providername == null && !mcache.isSpecial()) { mcache.refreshUnreads(); } long millis = System.currentTimeMillis(); sout += "\n],\n"; String svtags = getJSTagsArray(m.getFlags()); if (svtags != null) sout += "tags: " + svtags + ",\n"; if (isPECView) { sout += "pec: true,\n"; } sout += "total:" + recs + ",\nmillis:" + millis + "\n}\n"; out.println(sout); if (im != null) im.setPeek(false); // if (!wasopen) folder.close(false); } catch (Exception exc) { Service.logger.error("Exception", exc); } }
From source file:net.theblackchamber.crypto.implementations.SecureProperties.java
/** * Utility method which will determine if a requested property needs to be * decrypted. If property key ends in -encrypted and the encryption provider * is configured this method will return the decrypted property value. If * the key does not include -encrypted then the property value will be * returned.// w w w .j a v a 2 s. c o m * * @param key * @param property * @throws RuntimeCryptoException * If no encryption provider is configured. * @return */ private String attemptDecryption(String key, String property) { if (StringUtils.endsWithIgnoreCase(key, ENCRYPTED_SUFFIX)) { if (encryptionProvider == null) throw new RuntimeCryptoException("No encryption provider configured"); return encryptionProvider.decrypt(property); } else { return property; } }