Example usage for org.apache.commons.lang StringUtils contains

List of usage examples for org.apache.commons.lang StringUtils contains

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils contains.

Prototype

public static boolean contains(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String, handling null.

Usage

From source file:hydrograph.ui.expression.editor.jar.util.BuildExpressionEditorDataSturcture.java

/**
 * Returns packages of given jar file//w ww .jav a2s  .c o  m
 * 
 * @param jarFileName
 * @return IPackageFragmentRoot
 *          packages of given jar file
 */
public IPackageFragmentRoot getIPackageFragment(String jarFileName) {
    IProject iProject = getCurrentProject();
    IJavaProject javaProject = JavaCore.create(iProject);
    try {
        if (StringUtils.equals(jarFileName, hydrograph.ui.common.util.Constants.ProjectSupport_SRC)) {
            return getSrcPackageFragment(javaProject);
        }

        IPackageFragmentRoot[] fragmentRoot = javaProject.getAllPackageFragmentRoots();
        for (IPackageFragmentRoot iPackageFragmentRoot : fragmentRoot) {
            if (StringUtils.contains(iPackageFragmentRoot.getElementName(), jarFileName))
                return iPackageFragmentRoot;
        }
    } catch (JavaModelException javaModelException) {
        LOGGER.error("Error occurred while loading engines-transform jar", javaModelException);
    } finally {
        if (javaProject != null) {
            try {
                javaProject.close();
            } catch (JavaModelException modelException) {
                LOGGER.warn("JavaModelException occurred while closing java-project" + modelException);
            }
        }
    }
    if (StringUtils.equals(jarFileName,
            ConfigFileReader.INSTANCE.getConfigurationValueFromCommon(Constants.KEY_TRANSFORMATION_JAR)))
        new CustomMessageBox(SWT.ERROR, "Error occurred while loading " + jarFileName + " file", "ERROR")
                .open();
    return null;
}

From source file:edu.ku.brc.dbsupport.MySQLDMBSUserMgr.java

@Override
public List<String> getDatabaseListForUser(final String username) {
    String[] permsArray = new String[] { "SELECT", "DELETE", "UPDATE", "INSERT", "LOCK TABLES", };
    HashSet<String> permsHash = new HashSet<String>();
    Collections.addAll(permsHash, permsArray);

    ArrayList<String> dbNames = new ArrayList<String>();
    try {/*  ww  w  . j  a v  a  2 s . c  o  m*/
        if (connection != null) {
            String userStr = String.format("'%s'@'%s'", username, hostName);
            String sql = "SHOW GRANTS";
            for (Object obj : BasicSQLUtils.querySingleCol(connection, sql)) {
                boolean isAllDBs = false;
                String data = (String) obj;
                String dbName = null;
                System.out.println("->[" + data + "]");
                if (StringUtils.contains(data, userStr)) {
                    // get database name
                    String[] toks = StringUtils.split(data, '`');
                    if (toks.length > 2) {
                        dbName = toks[1];
                    }
                } else if (StringUtils.contains(data, "ON *.* TO")) {
                    //dbNames.add(obj.toString());   
                    isAllDBs = true;
                }

                // get permissions

                String permsStr = StringUtils.substringBetween(data, "GRANT ", " ON");
                String[] pToks = StringUtils.split(permsStr, ',');

                if (pToks != null) {
                    if (pToks.length == 1 && pToks[0].equalsIgnoreCase("ALL PRIVILEGES") && isAllDBs) {
                        dbNames.addAll(getDatabaseList());

                    } else if (pToks.length >= permsHash.size()) {
                        int cnt = 0;
                        for (String p : pToks) {
                            if (permsHash.contains(p.trim())) {
                                cnt++;
                            }
                        }

                        if (cnt == permsHash.size()) {
                            if (isAllDBs) {
                                dbNames.addAll(getDatabaseList());
                                break;

                            } else if (dbName != null) {
                                dbNames.add(dbName);
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return dbNames;
}

From source file:fr.dudie.acrachilisync.tools.upgrade.IssueDescriptionReaderV1.java

/**
 * Extracts the bug stacktrace from the description.
 * //w  w w. j a  v  a2 s. co m
 * @param pDescription
 *            the issue description
 * @param pStacktraceMD5
 *            the stacktrace MD5 hash the issue is related to
 * @return the stacktrace
 * @throws IssueParseException
 *             malformed issue description
 */
private String parseStacktrace(final String pDescription, final String pStacktraceMD5)
        throws IssueParseException {

    String stacktrace = null;

    // escape braces { and } to use strings in regexp
    final String start = "<pre class=\"javastacktrace\">";
    final String qStart = Pattern.quote(start);
    final String end = "</pre>";
    final String qEnd = Pattern.quote(end);

    final Pattern p = Pattern.compile(qStart + "(.*)" + qEnd, Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
    final Matcher m = p.matcher(pDescription);

    if (m.find()) {
        stacktrace = m.group(1);
        // if a start tag or an end tag is found in the stacktrace, then there is a problem
        if (StringUtils.contains(stacktrace, start) || StringUtils.contains(stacktrace, end)) {
            throw new IssueParseException("Invalid stacktrace block");
        }
    } else {
        throw new IssueParseException("0 stacktrace block found in the description");
    }

    return stacktrace;
}

From source file:it.av.youeat.service.MessageServiceTest.java

@Test
@Ignore("page needed")
public void testSuggestNewFriend() {
    // suggesting one new friend
    Set<Eater> newFriends = new HashSet<Eater>(1);
    newFriends.add(userB);/*from w ww  .  ja v  a  2s  .c o  m*/
    dialogService.sendFriendSuggestions(userC, userB, newFriends, null);
    List<Dialog> dialogs = dialogService.getDialogs(userB, true);
    assertTrue(!dialogs.isEmpty());
    Dialog dialog = dialogs.get(0);
    assertTrue("Created null dialog", dialog != null);
    assertTrue(dialog.getSender().equals(userC));
    assertTrue(dialog.getMessages().first().getSender().equals(userC));
    assertTrue(StringUtils.contains(dialog.getMessages().first().getBody(), userB.getId()));
    assertTrue(StringUtils.contains(dialog.getMessages().first().getTitle(), userC.getFirstname()));

    // suggesting multiple new friends
    newFriends.add(userC);
    dialogService.sendFriendSuggestions(userB, userC, newFriends, null);
    dialogs = dialogService.getDialogs(userC, true);
    assertTrue(!dialogs.isEmpty());
    dialog = dialogs.get(0);
    assertTrue("Created null dialog", dialog != null);
    assertTrue(dialog.getSender().equals(userB));
    assertTrue(dialog.getMessages().first().getSender().equals(userB));
    assertTrue(StringUtils.contains(dialog.getMessages().first().getBody(), userB.getId()));
    assertTrue(StringUtils.contains(dialog.getMessages().first().getBody(), userC.getId()));

}

From source file:com.ctc.storefront.filters.cms.CMSSiteFilter.java

/**
 * Processing normal request (i.e. when user goes directly to that application - not from cmscockpit)
 * <p/>//from w w w.j a v  a2 s  .co m
 * <b>Note:</b> <br/>
 * We preparing application by setting correct:
 * <ul>
 * <li>Current Site</li>
 * <li>Current Catalog Versions</li>
 * <li>Enabled language fallback</li>
 * </ul>
 *
 * @see ContextInformationLoader#initializeSiteFromRequest(String)
 * @see ContextInformationLoader#setCatalogVersions()
 * @param httpRequest
 *           current request
 * @param httpResponse
 *           the http response
 * @throws java.io.IOException
 */
protected boolean processNormalRequest(final HttpServletRequest httpRequest,
        final HttpServletResponse httpResponse) throws IOException {
    final String queryString = httpRequest.getQueryString();
    final String currentRequestURL = httpRequest.getRequestURL().toString();

    //set current site
    CMSSiteModel cmsSiteModel = getCurrentCmsSite();
    if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM)) {
        final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/")
                + (StringUtils.isBlank(queryString) ? "" : "?" + queryString);

        cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL);
    }

    if (cmsSiteModel == null) {
        // Failed to lookup CMS site
        httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_CMS_SITE_ERROR_MESSAGE);
        return false;
    } else if (!getSiteChannelValidationStrategy().validateSiteChannel(cmsSiteModel.getChannel())) // Restrict to configured channel
    {
        // CMS site that we looked up was for an unsupported channel
        httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE);
        return false;
    }

    if (!isActiveSite(cmsSiteModel)) {
        throw new IllegalStateException(
                "Site is not active. Active flag behaviour must be implement for this project.");
    }

    getContextInformationLoader().setCatalogVersions();
    //set fall back language enabled
    setFallbackLanguage(httpRequest, Boolean.TRUE);

    return true;
}

From source file:com.razorfish.controllers.misc.StoreSessionController.java

protected String getReturnRedirectUrlForUrlEncoding(final HttpServletRequest request, final String old,
        final String current) {
    String referer = StringUtils.remove(request.getRequestURL().toString(), request.getServletPath());
    if (!StringUtils.endsWith(referer, "/")) {
        referer = referer + "/";
    }/*from   w  w  w . ja  v a 2  s . c o  m*/
    if (referer != null && !referer.isEmpty() && StringUtils.contains(referer, "/" + old + "/")) {
        return REDIRECT_PREFIX + StringUtils.replace(referer, "/" + old + "/", "/" + current + "/");
    }
    return REDIRECT_PREFIX + referer;
}

From source file:info.magnolia.templating.jsp.taglib.SearchResultSnippetTag.java

/**
 * Extract a collection of snippets from any paragraph in the given page.
 * @return a collection of Strings.// www.  ja  va  2  s . c  o m
 * @todo avoid overlapping snippets (use regexp insted of simple indexOfs)
 * @todo only extract snippets from user-configured properties
 * @todo abbreviate on whitespace and puntuation, detect start of sentences
 * @todo replace ampersand in regexp
 * @todo break methods and write junits
 */
public Collection getSnippets() {

    log.debug("collecting snippets");

    Collection snippets = new ArrayList();
    String[] searchTerms = StringUtils.split(this.query);

    try {
        Iterator<Node> iterator = NodeUtil.getNodes(this.page, NodeTypes.ContentNode.NAME).iterator();

        outer: while (iterator.hasNext()) {
            Node paragraphCollection = iterator.next();

            Iterator<Node> parIterator = NodeUtil.getNodes(paragraphCollection, NodeTypes.ContentNode.NAME)
                    .iterator();
            while (parIterator.hasNext()) {
                Node paragraph = parIterator.next();

                log.debug("Iterating on paragraph {}", paragraph);

                Iterator dataIterator = paragraph.getProperties();

                while (dataIterator.hasNext()) {
                    Property property = (Property) dataIterator.next();
                    if (property.getType() != PropertyType.BINARY) {

                        String resultString = property.getString();

                        log.debug("Iterating on property {}", property.getName());
                        log.debug("Property value is {}", resultString);

                        // a quick and buggy way to avoid configuration properties, we should allow the user to
                        // configure a list of nodeData to search for...
                        if (resultString.length() < 20) {
                            continue;
                        }

                        for (int j = 0; j < searchTerms.length; j++) {
                            String searchTerm = StringUtils.lowerCase(searchTerms[j]);

                            // exclude keywords and words with less than 2 chars
                            if (!ArrayUtils.contains(new String[] { "and", "or" }, searchTerm)
                                    && searchTerm.length() > 2) {

                                log.debug("Looking for search term [{}] in [{}]", searchTerm, resultString);

                                // first check, avoid using heavy string replaceAll operations if the search term is not
                                // there
                                if (!StringUtils.contains(resultString.toLowerCase(), searchTerm)) {
                                    continue;
                                }

                                // strips out html tags using a regexp
                                resultString = stripHtmlTags(resultString);

                                // only get first matching keyword
                                int pos = resultString.toLowerCase().indexOf(searchTerm);
                                if (pos > -1) {

                                    int posEnd = pos + searchTerm.length();
                                    int from = (pos - chars / 2);
                                    if (from < 0) {
                                        from = 0;
                                    }

                                    int to = from + chars;
                                    if (to > resultString.length()) {
                                        to = resultString.length();
                                    }

                                    StringBuffer snippet = new StringBuffer();

                                    snippet.append(StringUtils.substring(resultString, from, pos));
                                    snippet.append("<strong>");
                                    snippet.append(StringUtils.substring(resultString, pos, posEnd));
                                    snippet.append("</strong>");
                                    snippet.append(StringUtils.substring(resultString, posEnd, to));

                                    if (from > 0) {
                                        snippet.insert(0, "... ");
                                    }
                                    if (to < resultString.length()) {
                                        snippet.append("... ");
                                    }

                                    log.debug("Search term found, adding snippet {}", snippet);

                                    snippets.add(snippet);
                                    if (snippets.size() >= this.maxSnippets) {

                                        log.debug("Maximum number of snippets ({}) reached, exiting",
                                                Integer.toString(this.maxSnippets));

                                        break outer;
                                    }
                                }
                            }
                        }
                    }
                }
            }

        }
        return snippets;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return null;
    }
}

From source file:gov.nih.nci.cacis.nav.AbstractSendMail.java

/**
 * Creates MimeMessage with supplied values
 * //from   w ww.j a  va 2  s.  c  o m
 * @param to - to email address
 * @param docType - String value for the attached document type
 * @param subject - Subject for the email
 * @param instructions - email body
 * @param content - content to be sent as attachment
 * @return MimeMessage instance
 */
public MimeMessage createMessage(String to, String docType, String subject, String instructions, String content,
        String metadataXMl, String title, String indexBodyToken, String readmeToken) {
    final MimeMessage msg = mailSender.createMimeMessage();
    UUID uniqueID = UUID.randomUUID();
    tempZipFolder = new File(secEmailTempZipLocation + "/" + uniqueID);
    try {
        msg.setFrom(new InternetAddress(getFrom()));
        msg.setSubject(subject);
        msg.setSentDate(new Date());
        msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));

        // The readable part
        final MimeBodyPart mbp1 = new MimeBodyPart();
        mbp1.setText(instructions);
        mbp1.setHeader("Content-Type", "text/plain");

        // The notification
        final MimeBodyPart mbp2 = new MimeBodyPart();

        final String contentType = "application/xml; charset=UTF-8";

        String extension;

        // HL7 messages should be a txt file, otherwise xml
        if (StringUtils.contains(instructions, "HL7_V2_CLINICAL_NOTE")) {
            extension = TXT_EXT;
        } else {
            extension = XML_EXT;
        }

        final String fileName = docType + UUID.randomUUID() + extension;

        //            final DataSource ds = new AttachmentDS(fileName, content, contentType);
        //            mbp2.setDataHandler(new DataHandler(ds));

        /******** START NHIN COMPLIANCE CHANGES *****/

        boolean isTempZipFolderCreated = tempZipFolder.mkdirs();
        if (!isTempZipFolderCreated) {
            LOG.error("Error creating temp folder for NHIN zip file: " + tempZipFolder.getAbsolutePath());
            throw new ApplicationRuntimeException(
                    "Error creating temp folder for NHIN zip file: " + tempZipFolder.getAbsolutePath());
        }

        String indexFileString = FileUtils.readFileToString(new File(secEmailTempZipLocation + "/INDEX.HTM"));
        String readmeFileString = FileUtils.readFileToString(new File(secEmailTempZipLocation + "/README.TXT"));

        indexFileString = StringUtils.replace(indexFileString, "@document_title@", title);
        indexFileString = StringUtils.replace(indexFileString, "@indexBodyToken@", indexBodyToken);
        FileUtils.writeStringToFile(new File(tempZipFolder + "/INDEX.HTM"), indexFileString);

        readmeFileString = StringUtils.replace(readmeFileString, "@readmeToken@", readmeToken);
        FileUtils.writeStringToFile(new File(tempZipFolder + "/README.TXT"), readmeFileString);

        // move template files & replace tokens
        //            FileUtils.copyFileToDirectory(new File(secEmailTempZipLocation + "/INDEX.HTM"), tempZipFolder, false);
        //            FileUtils.copyFileToDirectory(new File(secEmailTempZipLocation + "/README.TXT"), tempZipFolder, false);

        // create sub-directories
        String nhinSubDirectoryPath = tempZipFolder + "/IHE_XDM/SUBSET01";
        File nhinSubDirectory = new File(nhinSubDirectoryPath);
        boolean isNhinSubDirectoryCreated = nhinSubDirectory.mkdirs();
        if (!isNhinSubDirectoryCreated) {
            LOG.error("Error creating NHIN sub-directory: " + nhinSubDirectory.getAbsolutePath());
            throw new ApplicationRuntimeException(
                    "Error creating NHIN sub-directory: " + nhinSubDirectory.getAbsolutePath());
        }
        FileOutputStream metadataStream = new FileOutputStream(
                new File(nhinSubDirectoryPath + "/METADATA.XML"));
        metadataStream.write(metadataXMl.getBytes());
        metadataStream.flush();
        metadataStream.close();
        FileOutputStream documentStream = new FileOutputStream(
                new File(nhinSubDirectoryPath + "/DOCUMENT" + extension));
        documentStream.write(content.getBytes());
        documentStream.flush();
        documentStream.close();

        String zipFile = secEmailTempZipLocation + "/" + tempZipFolder.getName() + ".ZIP";
        byte[] buffer = new byte[1024];
        //            FileOutputStream fos = new FileOutputStream(zipFile);
        //            ZipOutputStream zos = new ZipOutputStream(fos);

        List<String> fileList = generateFileList(tempZipFolder);
        ByteArrayOutputStream bout = new ByteArrayOutputStream(fileList.size());
        ZipOutputStream zos = new ZipOutputStream(bout);
        //            LOG.info("File List size: "+fileList.size());
        for (String file : fileList) {
            ZipEntry ze = new ZipEntry(file);
            zos.putNextEntry(ze);
            FileInputStream in = new FileInputStream(tempZipFolder + File.separator + file);
            int len;
            while ((len = in.read(buffer)) > 0) {
                zos.write(buffer, 0, len);
            }
            in.close();
        }
        zos.closeEntry();
        // remember close it
        zos.close();

        DataSource source = new ByteArrayDataSource(bout.toByteArray(), "application/zip");
        mbp2.setDataHandler(new DataHandler(source));
        mbp2.setFileName(docType + ".ZIP");

        /******** END NHIN COMPLIANCE CHANGES *****/

        //            mbp2.setFileName(fileName);
        //            mbp2.setHeader("Content-Type", contentType);

        final Multipart mp = new MimeMultipart();
        mp.addBodyPart(mbp1);
        mp.addBodyPart(mbp2);
        msg.setContent(mp);
        msg.setSentDate(new Date());

        //            FileUtils.deleteDirectory(tempZipFolder);
    } catch (AddressException e) {
        LOG.error("Error creating email message!");
        throw new ApplicationRuntimeException("Error creating message!", e);
    } catch (MessagingException e) {
        LOG.error("Error creating email message!");
        throw new ApplicationRuntimeException("Error creating message!", e);
    } catch (IOException e) {
        LOG.error(e.getMessage());
        throw new ApplicationRuntimeException(e.getMessage());
    } finally {
        //reset filelist contents
        fileList = new ArrayList<String>();
    }
    return msg;
}

From source file:edu.ku.brc.specify.tools.FormGenerator.java

public void generateForms() {
    SpViewSetObj viewSetObj = new SpViewSetObj();
    viewSetObj.initialize();/*from w  w  w  .  ja va 2  s. c om*/
    viewSetObj.setName("All Forms");

    SpUIViewSet viewSet = new SpUIViewSet();
    viewSet.initialize();
    viewSet.setName("All Forms");

    for (DBTableInfo ti : DBTableIdMgr.getInstance().getTables()) {
        String tName = ti.getShortClassName();

        if (tName.startsWith("Sp") || tName.startsWith("User")) {
            continue;
        }

        SpUIView view = new SpUIView();
        view.initialize();
        view.setBusinessRulesClassName(ti.getBusinessRuleName());
        view.setName(tName);
        view.setSpViewSet(viewSet);
        viewSet.getSpViews().add(view);

        SpUIAltView altViewView = new SpUIAltView();
        altViewView.initialize();
        altViewView.setName(tName + " View");
        altViewView.setDefault(true);
        altViewView.setMode(AltViewIFace.CreationMode.VIEW);

        SpUIAltView altViewEdit = new SpUIAltView();
        altViewEdit.initialize();
        altViewEdit.setName(tName + " Edit");
        altViewEdit.setDefault(true);
        altViewEdit.setMode(AltViewIFace.CreationMode.EDIT);

        view.getSpAltViews().add(altViewView);
        view.getSpAltViews().add(altViewEdit);

        SpUIViewDef viewDef = new SpUIViewDef();
        viewDef.initialize();

        viewDef.setName(tName);
        viewDef.setColDef("100px,2px,p,p:g");
        viewDef.createAutoRowDef("p", "2px");
        viewDef.setDescription("Form For " + tName);
        viewDef.setType(ViewDefIFace.ViewType.form);
        viewDef.setDataClassName(ti.getClassName());
        viewDef.setSettableName(FormHelper.DATA_OBJ_SETTER);
        viewDef.setGettableName(FormHelper.DATA_OBJ_GETTER);

        altViewView.setViewDef(viewDef);
        altViewEdit.setViewDef(viewDef);

        viewSet.getSpViewDefs().add(viewDef);
        viewDef.setSpViewSet(viewSet);

        SpUIRow row = new SpUIRow();
        row.initialize();
        viewDef.addRow(row);

        SpUICell cell = new SpUICell();
        cell.initialize();
        row.addCell(cell);

        cell.setLabel(ti.getTitle());
        cell.setTypeName("separator");

        int id = 1;
        for (DBFieldInfo fi : ti.getFields()) {
            String fName = fi.getName();
            if (fName.startsWith("text") || fName.startsWith("yesNo") || fName.startsWith("number")
                    || fName.startsWith("version") || fName.startsWith("collectionMember")
                    || fName.startsWith("timestampCreated") || fName.startsWith("timestampModified")
                    || fName.startsWith("createdByAgent") || fName.startsWith("modifiedByAgent")) {
                continue;
            }

            row = new SpUIRow();
            row.initialize();
            viewDef.addRow(row);

            // Label
            cell = new SpUICell();
            cell.initialize();
            row.addCell(cell);

            cell.setTypeName("label");
            cell.setLabelFor(Integer.toString(id));

            // Field
            cell = new SpUICell();
            cell.initialize();
            row.addCell(cell);

            cell.setTypeName("field");
            cell.setIdent(Integer.toString(id));
            cell.setName(fName);
            cell.setUiType(FormCellFieldIFace.FieldType.text);

            id++;
        }

        for (DBRelationshipInfo ri : ti.getRelationships()) {
            String rName = StringUtils.substringAfterLast(ri.getClassName(), ".");

            row = new SpUIRow();
            row.initialize();
            viewDef.addRow(row);

            if (ri.getType() == DBRelationshipInfo.RelationshipType.ManyToOne) {
                // Label
                cell = new SpUICell();
                cell.initialize();
                row.addCell(cell);

                cell.setTypeName("label");
                cell.setLabelFor(Integer.toString(id));

                // Field
                cell = new SpUICell();
                cell.initialize();
                row.addCell(cell);

                cell.setTypeName("field");
                cell.setIdent(Integer.toString(id));
                cell.setName(ri.getName());

                cell.setUiType(FormCellFieldIFace.FieldType.querycbx);

                Properties props = new Properties();
                props.put("title", rName);
                props.put("name", rName);
                cell.setProperties(props);

            } else if (ri.getType() == DBRelationshipInfo.RelationshipType.OneToMany) {
                // Separator
                cell = new SpUICell();
                cell.initialize();
                row.addCell(cell);

                cell.setLabel(ri.getTitle());
                cell.setTypeName("separator");

                // SubView or QueryCBX
                cell = new SpUICell();
                cell.initialize();
                row.addCell(cell);

                cell.setIdent(Integer.toString(id));
                cell.setTypeName("subview");
                cell.setViewName(rName);
                cell.setName(ri.getName());

                if (StringUtils.contains(rName.toLowerCase(), "attachment")) {
                    Properties props = new Properties();
                    props.put("addsearch", "true");
                    props.put("btn", "true");
                    props.put("icon", rName);
                    cell.setProperties(props);
                }
            } else if (ri.getType() == DBRelationshipInfo.RelationshipType.OneToOne) {
                System.out.println("Skipping OneToOne:   " + tName + " - " + ri.getName());

            } else if (ri.getType() == DBRelationshipInfo.RelationshipType.ManyToMany) {
                System.out.println("Skipping ManyToMany: " + tName + " - " + ri.getName());
            }
            id++;

        }

        //break;

    }

    StringBuilder sb = new StringBuilder();
    viewSet.toXML(sb);

    try {
        FileUtils.writeStringToFile(new File("allforms.views.xml"), sb.toString());
        //System.out.println(sb.toString());

    } catch (IOException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(FormGenerator.class, ex);
        ex.printStackTrace();
    }

}

From source file:com.microsoft.alm.plugin.idea.git.ui.pullrequest.PullRequestHelper.java

/**
 * Parse the exception we got when generating pull request
 * <p/>//w w w. ja v a 2 s .c  o m
 * if we have a duplicate pr on server, try locate its id and generate a link to it
 *
 * @return status and string message as a pair
 */
public Pair<PRCreateStatus, String> parseException(final Throwable t, final String sourceBranch,
        final GitRemoteBranch targetBranch, final ServerContext context, final GitHttpClient gitClient) {
    if (t == null) {
        // if there is no throwale, why are we here?
        return Pair.create(PRCreateStatus.UNKNOWN, StringUtils.EMPTY);
    }

    if ((StringUtils.contains(t.getMessage(), PR_EXISTS_EXCEPTION_NAME))
            || (StringUtils.contains(t.getMessage(), PR_EXISTS_EXCEPTION_CODE))) {
        try {
            // look for the existing PR
            final UUID repoId = context.getGitRepository().getId();
            final GitPullRequestSearchCriteria searchCriteria = new GitPullRequestSearchCriteria();
            searchCriteria.setRepositoryId(repoId);
            searchCriteria.setStatus(PullRequestStatus.ACTIVE);
            searchCriteria.setSourceRefName(getVSORefName(sourceBranch));
            searchCriteria.setTargetRefName(getVSORefName(targetBranch.getNameForRemoteOperations()));
            List<GitPullRequest> pullRequests = gitClient.getPullRequests(repoId, searchCriteria, null, 0, 1);

            if (pullRequests != null && pullRequests.size() > 0) {
                final String repositoryRemoteUrl = context.getGitRepository().getRemoteUrl();
                final String notifyMsgInHtml = getHtmlMsg(repositoryRemoteUrl,
                        pullRequests.get(0).getPullRequestId());

                return Pair.create(PRCreateStatus.DUPLICATE, notifyMsgInHtml);
            }
        } catch (Throwable innerT) {
            logger.error("Failed to retrieve existing pull request", innerT);

            // since we are making server calls, it's possible this call will fail, in that case, just return
            // the original exception, never let any exception bubble up to intellij
            return Pair.create(PRCreateStatus.FAILED, t.getMessage());
        }
    }

    return Pair.create(PRCreateStatus.FAILED, t.getMessage());
}