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

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

Introduction

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

Prototype

public static String defaultString(String str) 

Source Link

Document

Returns either the passed in String, or if the String is null, an empty String ("").

Usage

From source file:com.bibisco.manager.CharacterManager.java

public static CharacterInfoQuestionsDTO loadCharacterInfoQuestions(
        CharacterInfoQuestions pCharacterInfoQuestions, Integer lIntIdCharacter) {

    CharacterInfoQuestionsDTO lCharacterInfoQuestionsDTO;

    mLog.debug("Start loadCharacterInfo(CharacterInfoQuestions, Integer)");

    SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject();
    SqlSession lSqlSession = lSqlSessionFactory.openSession();
    try {/*from w w w .  ja  v  a 2  s. co m*/

        CharactersMapper lCharactersMapper = lSqlSession.getMapper(CharactersMapper.class);
        CharactersWithBLOBs lCharacters = lCharactersMapper.selectByPrimaryKey(lIntIdCharacter.longValue());

        lCharacterInfoQuestionsDTO = new CharacterInfoQuestionsDTO();
        lCharacterInfoQuestionsDTO.setId(lIntIdCharacter);
        lCharacterInfoQuestionsDTO.setCharacterInfoQuestions(pCharacterInfoQuestions);

        switch (pCharacterInfoQuestions) {

        case BEHAVIORS:
            lCharacterInfoQuestionsDTO.setFreeText(lCharacters.getBehaviorsFreeText());
            lCharacterInfoQuestionsDTO
                    .setTaskStatus(TaskStatus.getTaskStatusFromValue(lCharacters.getBehaviorsTaskStatus()));
            lCharacterInfoQuestionsDTO
                    .setInterviewMode(lCharacters.getBehaviorsInterview().equals("Y") ? true : false);
            break;

        case IDEAS:
            lCharacterInfoQuestionsDTO.setFreeText(lCharacters.getIdeasFreeText());
            lCharacterInfoQuestionsDTO
                    .setTaskStatus(TaskStatus.getTaskStatusFromValue(lCharacters.getIdeasTaskStatus()));
            lCharacterInfoQuestionsDTO
                    .setInterviewMode(lCharacters.getIdeasInterview().equals("Y") ? true : false);
            break;

        case PERSONAL_DATA:
            lCharacterInfoQuestionsDTO.setFreeText(lCharacters.getPersonalDataFreeText());
            lCharacterInfoQuestionsDTO
                    .setTaskStatus(TaskStatus.getTaskStatusFromValue(lCharacters.getPersonalDataTaskStatus()));
            lCharacterInfoQuestionsDTO
                    .setInterviewMode(lCharacters.getPersonalDataInterview().equals("Y") ? true : false);
            break;

        case PHYSIONOMY:
            lCharacterInfoQuestionsDTO.setFreeText(lCharacters.getPhysionomyFreeText());
            lCharacterInfoQuestionsDTO
                    .setTaskStatus(TaskStatus.getTaskStatusFromValue(lCharacters.getPhysionomyTaskStatus()));
            lCharacterInfoQuestionsDTO
                    .setInterviewMode(lCharacters.getPhysionomyInterview().equals("Y") ? true : false);
            break;

        case PSYCHOLOGY:
            lCharacterInfoQuestionsDTO.setFreeText(lCharacters.getPsychologyFreeText());
            lCharacterInfoQuestionsDTO
                    .setTaskStatus(TaskStatus.getTaskStatusFromValue(lCharacters.getPsychologyTaskStatus()));
            lCharacterInfoQuestionsDTO
                    .setInterviewMode(lCharacters.getPsychologyInterview().equals("Y") ? true : false);
            break;

        case SOCIOLOGY:
            lCharacterInfoQuestionsDTO.setFreeText(lCharacters.getSociologyFreeText());
            lCharacterInfoQuestionsDTO
                    .setTaskStatus(TaskStatus.getTaskStatusFromValue(lCharacters.getSociologyTaskStatus()));
            lCharacterInfoQuestionsDTO
                    .setInterviewMode(lCharacters.getSociologyInterview().equals("Y") ? true : false);
            break;
        default:
            break;
        }

        // get answers
        CharacterInfosExample lCharacterInfosExample = new CharacterInfosExample();
        lCharacterInfosExample.createCriteria().andCharacterInfoTypeEqualTo(pCharacterInfoQuestions.name())
                .andIdCharacterEqualTo(lCharacters.getIdCharacter().intValue());
        lCharacterInfosExample.setOrderByClause("question");

        CharacterInfosMapper lCharacterInfosMapper = lSqlSession.getMapper(CharacterInfosMapper.class);
        List<CharacterInfos> lListCharacterInfos = lCharacterInfosMapper
                .selectByExampleWithBLOBs(lCharacterInfosExample);

        List<String> lListAnswers = new ArrayList<String>();
        for (CharacterInfos lCharacterInfos : lListCharacterInfos) {
            lListAnswers.add(StringUtils.defaultString(lCharacterInfos.getInfo()));
        }
        lCharacterInfoQuestionsDTO.setAnswerList(lListAnswers);

    } catch (Throwable t) {
        mLog.error(t);
        throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION);
    } finally {
        lSqlSession.close();
    }

    mLog.debug("End loadCharacterInfo(CharacterInfoQuestions, Integer)");

    return lCharacterInfoQuestionsDTO;
}

From source file:com.redhat.rhn.manager.rhnpackage.PackageManager.java

/**
 * Compares an evr to another evr.//from w  w w  .j  av  a2  s .  co  m
 * @param epoch1 Epoch 1
 * @param version1 Version 1
 * @param release1 Release 1
 * @param epoch2 Epoch 2
 * @param version2 Version 2
 * @param release2 Release 2
 * @return Returns 1 if EVR1 > EVR2, -1 if EVR1 < EVR2, and 0 if EVR1 == EVR2.
 */
public static int verCmp(String epoch1, String version1, String release1, String epoch2, String version2,
        String release2) {

    // Compare the Epochs
    int c = compareEpochs(epoch1, epoch2);
    if (c != 0) {
        return c;
    }

    // Compare the Versions
    RpmVersionComparator cmp = new RpmVersionComparator();
    c = cmp.compare(StringUtils.defaultString(version1), StringUtils.defaultString(version2));
    if (c != 0) {
        return c;
    }

    // Compare the Releases
    return cmp.compare(StringUtils.defaultString(release1), StringUtils.defaultString(release2));
}

From source file:jenkins.scm.impl.subversion.SubversionSCMSource.java

/**
 * Split a comma separated set of includes/excludes into a set of strings.
 *
 * @param cludes a comma separated set of includes/excludes.
 * @return a set of strings.// w  w w  .  ja  v  a2  s. c  o  m
 */
@NonNull
static SortedSet<String> splitCludes(@CheckForNull String cludes) {
    TreeSet<String> result = new TreeSet<String>();
    StringTokenizer tokenizer = new StringTokenizer(StringUtils.defaultString(cludes), ",");
    while (tokenizer.hasMoreTokens()) {
        String clude = tokenizer.nextToken().trim();
        if (StringUtils.isNotEmpty(clude)) {
            result.add(clude.trim());
        }
    }
    return result;
}

From source file:com.haulmont.cuba.gui.app.core.categories.AttributeEditor.java

protected void fillAttributeCode() {
    CategoryAttribute attribute = getItem();
    if (StringUtils.isBlank(attribute.getCode()) && StringUtils.isNotBlank(attribute.getName())) {
        String categoryName = StringUtils.EMPTY;
        if (attribute.getCategory() != null) {
            categoryName = StringUtils.defaultString(attribute.getCategory().getName());
        }//  w w w  .ja v a2 s  . co  m
        attribute.setCode(StringUtils.deleteWhitespace(categoryName + attribute.getName()));
    }
}

From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelImportServiceImpl.java

/**
 * Imports the subscribed users for the specified {@code buildingBlock}.
 * //from w  ww .  j av a2s .  c  o  m
 * @param buildingBlock the building block to subcribe users for
 * @param relations the relation field values containing field names associated with the value
 * @param locale the import locale
 */
private void importSubscribedUsers(BuildingBlock buildingBlock, Map<String, CellValueHolder> relations,
        Locale locale) {
    CellValueHolder subscribedUserCellValueHolder = relations
            .get(MessageAccess.getStringOrNull(Constants.SUBSCRIBED_USERS, locale));
    String subscribedUsersContent = "";
    if (subscribedUserCellValueHolder == null) {
        return;
    }
    subscribedUsersContent = subscribedUserCellValueHolder.getAttributeValue();

    String subscribedUserNames = StringUtils.defaultString(subscribedUsersContent);
    String[] subscribedUsersLogins = ExcelImportUtilities.getSplittedArray(subscribedUserNames,
            ExcelSheet.IN_LINE_SEPARATOR.trim());

    Set<String> validLoginNames = Sets.newHashSet();
    for (String login : subscribedUsersLogins) {
        if (StringUtils.isNotEmpty(login)) {
            validLoginNames.add(login);
        }
    }

    Set<User> subscribedUsers = this.loadOrCreateUsers(validLoginNames);
    buildingBlock.getSubscribedUsers().clear();
    buildingBlock.getSubscribedUsers().addAll(subscribedUsers);
}

From source file:fr.paris.lutece.plugins.directory.modules.pdfproducer.web.PDFProducerJspBean.java

/**
 * Modify a configuration// w w w. j  ava2 s.c  om
 * @param request request
 * @return a message to confirm and redirect to manage page
 */
public String doModifyConfigProducer(HttpServletRequest request) {
    String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY);

    if (!isAuthorized(strIdDirectory)) {
        return AdminMessageService.getMessageUrl(request, Messages.USER_ACCESS_DENIED, AdminMessage.TYPE_STOP);
    }

    String strIdConfigProducer = request.getParameter(PARAMETER_ID_CONFIG_PRODUCER);
    String strCheckPageConfig = request.getParameter(PARAMETER_CHECK_PAGE_CONFIG);
    String[] listStrIdEntry = request.getParameterValues(PARAMETER_CONFIG_ENTRY);
    String strIdEntryFileName = request.getParameter(PARAMETER_ID_ENTRY_FILE_NAME);
    String strNameConfig = request.getParameter(PARAMETER_CREATECONFIG_NAME);
    String strExtractNotEmpty = request.getParameter(PARAMETER_EXTRACT_NOT_EMPTY);

    String strTypeConfigFileName = request.getParameter(PARAMETER_TYPE_CONFIG_FILE_NAME);
    String strTextFileName = request.getParameter(PARAMETER_TEXT_FILE_NAME);

    if (StringUtils.isNotEmpty(strTextFileName)) {
        strTextFileName = PDFUtils.doPurgeNameFile(strTextFileName);
    }

    List<Integer> listIdEntry = new ArrayList<Integer>();

    if (listStrIdEntry != null) {
        for (int i = 0; i < listStrIdEntry.length; i++) {
            if (StringUtils.isNotBlank(listStrIdEntry[i]) && StringUtils.isNumeric(listStrIdEntry[i])) {
                listIdEntry.add(Integer.valueOf(listStrIdEntry[i]));
            }
        }
    }

    checkEntryGroup(listIdEntry);

    UrlItem url = new UrlItem(JSP_MODIFY_CONFIG_PRODUCER);
    url.addParameter(PARAMETER_ID_DIRECTORY, strIdDirectory);
    url.addParameter(PARAMETER_TYPE_CONFIG_FILE_NAME, strTypeConfigFileName);
    url.addParameter(PARAMETER_TEXT_FILE_NAME, strTextFileName);
    url.addParameter(PARAMETER_EXTRACT_NOT_EMPTY, StringUtils.defaultString(strExtractNotEmpty));

    if (request.getParameterMap().containsKey(PARAMETER_CREATECONFIG_SAVE)) {
        url.addParameter(PARAMETER_ID_CONFIG_PRODUCER, strIdConfigProducer);
        url.addParameter(PARAMETER_CHECK_PAGE_CONFIG, strCheckPageConfig);

        if (!listIdEntry.isEmpty()) {
            for (Integer idEntry : listIdEntry) {
                url.addParameter(PARAMETER_CONFIG_ENTRY, String.valueOf(idEntry));
            }
        }

        if (StringUtils.isBlank(strNameConfig)) {
            url.addParameter(PARAMETER_ID_ENTRY_FILE_NAME, strIdEntryFileName);

            return AdminMessageService.getMessageUrl(request, MESSAGE_NAME_CONFIG_MISSED, url.getUrl(),
                    AdminMessage.TYPE_ERROR);
        } else if (StringUtils.isBlank(strIdEntryFileName) && strIdEntryFileName.equals(DEFAULT_VALUE)) {
            url.addParameter(PARAMETER_CREATECONFIG_NAME, strIdEntryFileName);

            return AdminMessageService.getMessageUrl(request, MESSAGE_ENTRY_FILE_NAME_MISSED, url.getUrl(),
                    AdminMessage.TYPE_ERROR);
        } else {
            url = new UrlItem(JSP_MANAGE_CONFIG_PRODUCER);
            url.addParameter(PARAMETER_ID_DIRECTORY, strIdDirectory);

            ConfigProducer configProducer = new ConfigProducer();
            configProducer.setName(strNameConfig);
            configProducer.setIdProducerConfig(DirectoryUtils.convertStringToInt(strIdConfigProducer));
            configProducer.setIdEntryFileName(DirectoryUtils.convertStringToInt(strIdEntryFileName));
            configProducer.setIdDirectory(DirectoryUtils.convertStringToInt(strIdDirectory));
            configProducer.setType(TYPE_CONFIG_PDF);
            configProducer.setTextFileName(strTextFileName);
            configProducer.setTypeConfigFileName(strTypeConfigFileName);

            if (StringUtils.isNotBlank(strExtractNotEmpty)) {
                configProducer.setExtractNotFilled(false);
            } else {
                configProducer.setExtractNotFilled(true);
            }

            _manageConfigProducerService.modifyProducerConfig(getPlugin(), configProducer, listIdEntry);
        }

        return AdminMessageService.getMessageUrl(request, MESSAGE_ADD_NEW_CONFIG, url.getUrl(),
                AdminMessage.TYPE_INFO);
    } else if (request.getParameterMap().containsKey(PARAMETER_CREATECONFIG_CANCEL)) {
        url = new UrlItem(JSP_MANAGE_CONFIG_PRODUCER);
        url.addParameter(PARAMETER_ID_DIRECTORY, strIdDirectory);

        return AdminMessageService.getMessageUrl(request, MESSAGE_CANCEL_CREATE, url.getUrl(),
                AdminMessage.TYPE_INFO);
    } else {
        url = new UrlItem(JSP_MODIFY_CONFIG_PRODUCER_BIS);
        url.addParameter(PARAMETER_CHECK_PAGE_CONFIG, strCheckPageConfig);
        url.addParameter(PARAMETER_ID_CONFIG_PRODUCER, strIdConfigProducer);

        return doCheckAll(url, strIdDirectory, listIdEntry, strNameConfig, strIdEntryFileName, strTextFileName,
                strTypeConfigFileName);
    }
}

From source file:gtu._work.ui.ObnfInsertCreaterUI.java

private void addFieldBtnAction() {
    String dbField = dbFieldText.getText();
    String dbvalue = StringUtils.defaultString(dbValue.getText());
    if (StringUtils.isBlank(dbField)) {
        JCommonUtil._jOptionPane_showMessageDialog_error("dbField");
        return;/*from   www .j a  v  a2 s. c o  m*/
    }
    DefaultListModel dbFieldListModel = (DefaultListModel) dbFieldList.getModel();
    boolean doUpdate = false;
    for (Enumeration<?> enu = dbFieldListModel.elements(); enu.hasMoreElements();) {
        KeyValue kv = (KeyValue) enu.nextElement();
        if (kv.getKey().equalsIgnoreCase(dbField) && kv.pk == pkCheckBox.isSelected()) {
            kv.value = dbvalue;
            doUpdate = true;
            JCommonUtil._jOptionPane_showMessageDialog_info(":" + kv);
            break;
        }
    }
    if (!doUpdate) {
        KeyValue kv = new KeyValue();
        kv.key = dbField;
        kv.value = dbvalue;
        kv.pk = pkCheckBox.isSelected();
        dbFieldListModel.addElement(kv);
        JCommonUtil._jOptionPane_showMessageDialog_info(":" + kv);
    }
}

From source file:mitm.application.djigzo.ws.impl.CAWSImpl.java

@Override
@StartTransaction//  ww w  . jav  a 2s .c o m
public void sendCertificates(SendCertificatesDTO parameters) throws WebServiceCheckedException {
    try {
        if (parameters == null) {
            throw new WebServiceCheckedException("parameters is missing");
        }

        if (parameters.getThumbprints() == null || parameters.getThumbprints().size() == 0) {
            throw new WebServiceCheckedException("Thumbprints are missing");
        }

        if (StringUtils.isBlank(parameters.getPassword())) {
            throw new WebServiceCheckedException("password is missing");
        }

        if (StringUtils.isBlank(parameters.getSender())) {
            throw new WebServiceCheckedException("Sender is missing");
        }

        if (parameters.isSendSMS() && StringUtils.isBlank(parameters.getPhoneNumber())) {
            throw new WebServiceCheckedException("Phone number is missing");
        }

        if (StringUtils.isBlank(parameters.getRecipient())) {
            throw new WebServiceCheckedException("Recipient is missing");
        }

        String normalizedRecipient = EmailAddressUtils.canonicalizeAndValidate(parameters.getRecipient(), true);

        if (normalizedRecipient == null) {
            throw new WebServiceCheckedException("Recipient is not a valid email address.");
        }

        InternetAddress recipient = new InternetAddress(normalizedRecipient);

        List<X509Certificate> certificates = getCertificates(parameters.getThumbprints());

        if (certificates.size() == 0) {
            throw new WebServiceCheckedException("No certificates found.");
        }

        for (X509Certificate certificate : certificates) {
            if (!parameters.isAllowCA()) {
                if (X509CertificateInspector.isCA(certificate)) {
                    throw new NotAllowedWebServiceCheckedException("Sending a CA certificate is not allowed.");
                }
            }

            if (!parameters.isAllowEmailMismatch()) {
                X509CertificateInspector inspector = new X509CertificateInspector(certificate);

                if (!EmailAddressUtils.containsEmail(normalizedRecipient, inspector.getEmail())) {
                    throw new NotAllowedWebServiceCheckedException(
                            "Recipient email address does not match " + "certificate(s) email address(es).");
                }
            }
        }

        ByteArrayOutputStream pfxStream = new ByteArrayOutputStream();

        keyAndCertificateWorkflow.getPFX(certificates, parameters.getPassword().toCharArray(), pfxStream);

        TemplateProperties templateProperties = globalPreferencesManager.getGlobalUserPreferences()
                .getProperties().getTemplateProperties();

        PFXMailBuilder mailBuilder = new PFXMailBuilder(templateProperties.getMailPFXTemplate(),
                templateBuilder);

        String phoneNumber = StringUtils.defaultString(parameters.getPhoneNumber());
        String anonymizedPhoneNumber = MiscStringUtils.replaceLastChars(phoneNumber, anonymizedDigits, "*");
        String pfxID = createPFXId();

        mailBuilder.setFrom(new InternetAddress(parameters.getSender()));
        mailBuilder.setRecipient(recipient);

        /*
         * Set additional properties which can be used in the message template
         */
        mailBuilder.addProperty("password", parameters.getPassword());
        mailBuilder.addProperty("sendSMS", parameters.isSendSMS());
        mailBuilder.addProperty("phoneNumber", phoneNumber);
        mailBuilder.addProperty("phoneNumberAnonymized", anonymizedPhoneNumber);
        mailBuilder.addProperty("id", pfxID);

        mailBuilder.setPFX(pfxStream.toByteArray());

        MimeMessage message = mailBuilder.createMessage();

        mailTransport.sendMessage(message, recipient);

        if (parameters.isSendSMS()) {
            PFXSMSBuilder smsBuilder = new PFXSMSBuilder(templateProperties.getSMSPFXPasswordTemplate(),
                    templateBuilder);

            smsBuilder.setPassword(parameters.getPassword());
            smsBuilder.addProperty("id", pfxID);

            SMS sms = new SMSImpl(parameters.getPhoneNumber(), smsBuilder.createSMS(), null);

            smsGateway.sendSMS(sms);
        }
    } catch (NotAllowedWebServiceCheckedException e) {
        logger.warn("Action now allowed. Message: " + e.getMessage());

        throw e;
    } catch (Exception e) {
        logger.error("sendCertificates failed.", e);

        throw new WebServiceCheckedException(ExceptionUtils.getRootCauseMessage(e));
    }
}

From source file:fr.paris.lutece.plugins.directory.modules.pdfproducer.utils.PDFUtils.java

/**
 * Build the fields in a single paragraph.
 * @param listRecordFields the list of record fields
 * @param entry the entry/*from  w  ww  .  j a va  2s  .  c o m*/
 * @param locale the locale
 * @param phraseEntry the phrase entry
 * @param paragraphEntry the paragraph entry
 * @param bExtractNotFilledField if true, extract empty fields, false
 * @throws DocumentException exception if there is an error
 */
private static void builFieldsInSinglePhrase(List<RecordField> listRecordFields, IEntry entry, Locale locale,
        Phrase phraseEntry, Paragraph paragraphEntry, Boolean bExtractNotFilledField) throws DocumentException {
    RecordField recordField = listRecordFields.get(0);
    Chunk chunkEntryValue = null;
    Font fontEntryValue = new Font(
            DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_NAME)),
            DirectoryUtils
                    .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_SIZE_ENTRY_VALUE)),
            DirectoryUtils
                    .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_STYLE_ENTRY_VALUE)));

    if (entry instanceof fr.paris.lutece.plugins.directory.business.EntryTypeDownloadUrl) {
        if (StringUtils.isNotBlank(recordField.getFileName())) {
            chunkEntryValue = new Chunk(recordField.getFileName());
        } else {
            chunkEntryValue = new Chunk(StringUtils.EMPTY);
        }
    } else if (entry instanceof fr.paris.lutece.plugins.directory.business.EntryTypeGeolocation) {
        for (RecordField recordFieldGeo : listRecordFields) {
            if ((recordFieldGeo.getField() != null)
                    && EntryTypeGeolocation.CONSTANT_ADDRESS.equals(recordFieldGeo.getField().getTitle())) {
                chunkEntryValue = new Chunk(
                        entry.convertRecordFieldValueToString(recordFieldGeo, locale, false, false),
                        fontEntryValue);
            }
        }
    } else if (entry instanceof fr.paris.lutece.plugins.directory.business.EntryTypeCheckBox
            || entry instanceof fr.paris.lutece.plugins.directory.business.EntryTypeSelect
            || entry instanceof fr.paris.lutece.plugins.directory.business.EntryTypeRadioButton) {
        chunkEntryValue = new Chunk(entry.convertRecordFieldTitleToString(recordField, locale, false),
                fontEntryValue);
    } else if (entry instanceof fr.paris.lutece.plugins.directory.business.EntryTypeFile
            || entry instanceof fr.paris.lutece.plugins.directory.business.EntryTypeImg) {
        String strFileName = StringUtils.EMPTY;

        if ((recordField.getFile() != null) && StringUtils.isNotBlank(recordField.getFile().getTitle())) {
            // The thumbnails and big thumbnails should not be displayed
            if (!((StringUtils.isNotBlank(recordField.getValue())
                    && recordField.getValue().startsWith(FIELD_THUMBNAIL))
                    || (StringUtils.isNotBlank(recordField.getValue())
                            && recordField.getValue().startsWith(FIELD_BIG_THUMBNAIL)))) {
                strFileName = recordField.getFile().getTitle();
            }
        }

        chunkEntryValue = new Chunk(strFileName, fontEntryValue);
    } else if (entry instanceof fr.paris.lutece.plugins.directory.business.EntryTypeRichText) {
        String strValue = entry.convertRecordFieldValueToString(recordField, locale, false, false);
        strValue = StringUtils.defaultString(HtmlUtils.htmlUnescape(strValue)).replaceAll("<[^>]*>", "");
        chunkEntryValue = new Chunk(strValue, fontEntryValue);
    } else {
        chunkEntryValue = new Chunk(entry.convertRecordFieldValueToString(recordField, locale, false, false),
                fontEntryValue);
    }

    if (chunkEntryValue != null) {
        if (bExtractNotFilledField
                || (!bExtractNotFilledField && StringUtils.isNotBlank(chunkEntryValue.getContent()))) {
            phraseEntry.add(chunkEntryValue);
            paragraphEntry.add(phraseEntry);
        }
    }
}

From source file:com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.java

private void retrievePullRequests(final BitbucketSCMSourceRequest request)
        throws IOException, InterruptedException {
    final String fullName = repoOwner + "/" + repository;

    class Skip extends IOException {
    }/*from   w w  w  . j  a  va2s.  co  m*/

    final BitbucketApi originBitbucket = buildBitbucketClient();
    if (request.isSkipPublicPRs() && !originBitbucket.isPrivate()) {
        request.listener().getLogger().printf("Skipping pull requests for %s (public repository)%n", fullName);
        return;
    }

    request.listener().getLogger().printf("Looking up %s for pull requests%n", fullName);
    final Set<String> livePRs = new HashSet<>();
    int count = 0;
    Map<Boolean, Set<ChangeRequestCheckoutStrategy>> strategies = request.getPRStrategies();
    for (final BitbucketPullRequest pull : request.getPullRequests()) {
        String originalBranchName = pull.getSource().getBranch().getName();
        request.listener().getLogger().printf("Checking PR-%s from %s and branch %s%n", pull.getId(),
                pull.getSource().getRepository().getFullName(), originalBranchName);
        boolean fork = !fullName.equalsIgnoreCase(pull.getSource().getRepository().getFullName());
        String pullRepoOwner = pull.getSource().getRepository().getOwnerName();
        String pullRepository = pull.getSource().getRepository().getRepositoryName();
        final BitbucketApi pullBitbucket = fork && originBitbucket instanceof BitbucketCloudApiClient
                ? BitbucketApiFactory.newInstance(getServerUrl(), authenticator(), pullRepoOwner,
                        pullRepository)
                : originBitbucket;
        count++;
        livePRs.add(pull.getId());
        getPullRequestTitleCache().put(pull.getId(), StringUtils.defaultString(pull.getTitle()));
        getPullRequestContributorCache().put(pull.getId(),
                // TODO get more details on the author
                new ContributorMetadataAction(pull.getAuthorLogin(), null, pull.getAuthorEmail()));
        try {
            // We store resolved hashes here so to avoid resolving the commits multiple times
            for (final ChangeRequestCheckoutStrategy strategy : strategies.get(fork)) {
                String branchName = "PR-" + pull.getId();
                if (strategies.get(fork).size() > 1) {
                    branchName = "PR-" + pull.getId() + "-" + strategy.name().toLowerCase(Locale.ENGLISH);
                }
                PullRequestSCMHead head;
                if (originBitbucket instanceof BitbucketCloudApiClient) {
                    head = new PullRequestSCMHead( //
                            branchName, //
                            pullRepoOwner, //
                            pullRepository, //
                            repositoryType, //
                            originalBranchName, //
                            pull, //
                            originOf(pullRepoOwner, pullRepository), //
                            strategy);
                } else {
                    head = new PullRequestSCMHead( //
                            branchName, //
                            repoOwner, //
                            repository, //
                            repositoryType, //
                            originalBranchName, //
                            pull, //
                            originOf(pullRepoOwner, pullRepository), //
                            strategy);
                }
                if (request.process(head, //
                        () -> {
                            // use branch instead of commit to postpone closure initialisation
                            return new BranchHeadCommit(pull.getSource().getBranch());
                        }, //
                        new BitbucketProbeFactory<>(pullBitbucket, request), //
                        new BitbucketRevisionFactory<BitbucketCommit>(pullBitbucket) {
                            @NonNull
                            @Override
                            public SCMRevision create(@NonNull SCMHead head,
                                    @Nullable BitbucketCommit sourceCommit)
                                    throws IOException, InterruptedException {
                                try {
                                    // use branch instead of commit to postpone closure initialisation
                                    BranchHeadCommit targetCommit = new BranchHeadCommit(
                                            pull.getDestination().getBranch());
                                    return super.create(head, sourceCommit, targetCommit);
                                } catch (BitbucketRequestException e) {
                                    if (originBitbucket instanceof BitbucketCloudApiClient) {
                                        if (e.getHttpCode() == 403) {
                                            request.listener().getLogger().printf( //
                                                    "Skipping %s because of %s%n", //
                                                    pull.getId(), //
                                                    HyperlinkNote.encodeTo("https://bitbucket.org/site/master" //
                                                            + "/issues/5814/reify-pull-requests-by-making-them-a-ref", //
                                                            "a permission issue accessing pull requests from forks"));
                                            throw new Skip();
                                        }
                                    }
                                    // https://bitbucket.org/site/master/issues/5814/reify-pull-requests-by-making-them-a-ref
                                    e.printStackTrace(request.listener().getLogger());
                                    if (e.getHttpCode() == 403) {
                                        // the credentials do not have permission, so we should not observe the
                                        // PR ever the PR is dead to us, so this is the one case where we can
                                        // squash the exception.
                                        throw new Skip();
                                    }
                                    throw e;
                                }
                            }
                        }, //
                        new CriteriaWitness(request))) {
                    request.listener().getLogger() //
                            .format("%n  %d pull requests were processed (query completed)%n", count);
                    return;
                }
            }
        } catch (Skip e) {
            request.listener().getLogger().println("Do not have permission to view PR from "
                    + pull.getSource().getRepository().getFullName() + " and branch " + originalBranchName);
            continue;
        }
    }
    request.listener().getLogger().format("%n  %d pull requests were processed%n", count);
    getPullRequestTitleCache().keySet().retainAll(livePRs);
    getPullRequestContributorCache().keySet().retainAll(livePRs);
}