Example usage for org.apache.commons.lang3 StringUtils EMPTY

List of usage examples for org.apache.commons.lang3 StringUtils EMPTY

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils EMPTY.

Prototype

String EMPTY

To view the source code for org.apache.commons.lang3 StringUtils EMPTY.

Click Source Link

Document

The empty String "" .

Usage

From source file:controller.AddNewEC.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from w  w  w  .j  ava2  s . c o  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    ExtenuatingCircumstance ec = new ExtenuatingCircumstance();
    if (ServletFileUpload.isMultipartContent(request)) {
        try {
            int year = 0;
            String fname = StringUtils.EMPTY;
            String title = StringUtils.EMPTY;
            String desciption = StringUtils.EMPTY;
            List<FileItem> multiparts = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
            ArrayList<FileItem> files = new ArrayList<>();
            for (FileItem item : multiparts) {
                if (item.isFormField()) {
                    if (item.getFieldName().equals("year")) {
                        year = Integer.parseInt(item.getString());
                    }
                    if (item.getFieldName().equals("title")) {
                        title = item.getString();
                    }
                    if (item.getFieldName().equals("description")) {
                        desciption = item.getString();
                    }

                } else {
                    if (StringUtils.isNotEmpty(item.getName())) {
                        files.add(item);
                    }
                }
            }

            HttpSession session = request.getSession(false);
            Account studentAccount = (Account) session.getAttribute("account");
            LocalDateTime now = WsadUtils.GetCurrentDatetime();

            // insert EC
            ec.setAcademicYear(year);
            ec.setTitle(title);
            ec.setDescription(desciption);
            ec.setProcess_status("submitted");
            ec.setSubmitted_date(now.toString());
            ec.setAccount(studentAccount.getId());

            ExtenuatingCircumstance insertedEC = new ExtenuatingCircumstanceDAO().insertEC(ec);

            //insert assigned coordinator
            Account coordinator = new AccountDAO().getCoordinator(studentAccount.getFaculty());
            insertAssignedCoordinator(coordinator, insertedEC);

            //insert evidence
            insertedEvidence(files, now, insertedEC, studentAccount);

            String mailContent = WsadUtils.buildMailContentForNewEC(insertedEC);
            SendMail.sendMail(coordinator.getEmail(), "New EC", mailContent);

        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        request.setAttribute("message", "Sorry this Servlet only handles file upload request");
    }

    request.setAttribute("resultMsg", "inserted");
    request.getRequestDispatcher("AddNewECResult.jsp").forward(request, response);
}

From source file:ch.cyberduck.core.sds.SDSMoveFeature.java

@Override
public Path move(final Path file, final Path renamed, final TransferStatus status,
        final Delete.Callback callback, final ConnectionCallback connectionCallback)
        throws BackgroundException {
    try {//  ww w . ja v  a2s.  c  o  m
        if (status.isExists()) {
            new SDSDeleteFeature(session).delete(Collections.singletonList(renamed), connectionCallback,
                    callback);
        }
        if (!new SimplePathPredicate(file.getParent()).test(renamed.getParent())) {
            // Change parent node
            new NodesApi(session.getClient()).moveNodes(StringUtils.EMPTY,
                    Long.parseLong(new SDSNodeIdProvider(session).getFileid(renamed.getParent(),
                            new DisabledListProgressListener())),
                    new MoveNodesRequest().resolutionStrategy(MoveNodesRequest.ResolutionStrategyEnum.OVERWRITE)
                            .addNodeIdsItem(Long.parseLong(new SDSNodeIdProvider(session).getFileid(file,
                                    new DisabledListProgressListener()))),
                    null);
        }
        if (!StringUtils.equals(file.getName(), renamed.getName())) {
            if (containerService.isContainer(file)) {
                new NodesApi(session.getClient()).updateRoom(StringUtils.EMPTY,
                        Long.parseLong(new SDSNodeIdProvider(session).getFileid(file,
                                new DisabledListProgressListener())),
                        new UpdateRoomRequest().name(renamed.getName()), null);
            }
            // Rename
            else if (file.isDirectory()) {
                new NodesApi(session.getClient()).updateFolder(StringUtils.EMPTY,
                        Long.parseLong(new SDSNodeIdProvider(session).getFileid(
                                new Path(renamed.getParent(), file.getName(), file.getType()),
                                new DisabledListProgressListener())),
                        new UpdateFolderRequest().name(renamed.getName()), null);
            } else {
                new NodesApi(session.getClient()).updateFile(StringUtils.EMPTY,
                        Long.parseLong(new SDSNodeIdProvider(session).getFileid(
                                new Path(renamed.getParent(), file.getName(), file.getType()),
                                new DisabledListProgressListener())),
                        new UpdateFileRequest().name(renamed.getName()), null);
            }
        }
        return new Path(renamed.getParent(), renamed.getName(), renamed.getType(),
                new PathAttributes(renamed.attributes()).withVersionId(file.attributes().getVersionId()));
    } catch (ApiException e) {
        throw new SDSExceptionMappingService().map("Cannot rename {0}", e, file);
    }
}

From source file:cpcc.core.services.DeviceTypeSelectHelpersTest.java

@Test
public void shouldReturnEmptyStringForClientValueNull() {
    String actual = encoder.toClient(null);
    assertThat(actual).isEqualTo(StringUtils.EMPTY);
}

From source file:com.sunchenbin.store.feilong.core.tools.jsonlib.processor.BigDecimalJsonValueProcessor.java

/**
 * Process./*from ww  w .jav a  2 s  .c o m*/
 *
 * @param value
 *            the value
 * @return the object
 */
private Object process(Object value) {
    if (value == null) {
        return StringUtils.EMPTY;
    }
    //??
    if (value instanceof BigDecimal) {
        if (Validator.isNullOrEmpty(numberPattern)) {
            numberPattern = NumberPattern.TWO_DECIMAL_POINTS;
        }

        Number number = (Number) value;
        return NumberUtil.toString(number, numberPattern);
    }
    return value;
}

From source file:ch.cyberduck.core.sds.triplecrypt.CryptoReadFeature.java

@Override
public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback)
        throws BackgroundException {
    try {//from  ww w  .j a v  a2  s .  co m
        final FileKey key = new NodesApi(session.getClient()).getUserFileKey(StringUtils.EMPTY, Long
                .parseLong(new SDSNodeIdProvider(session).getFileid(file, new DisabledListProgressListener())));
        final UserPrivateKey privateKey = new UserPrivateKey();
        final UserKeyPairContainer keyPairContainer = session.keyPair();
        privateKey.setPrivateKey(keyPairContainer.getPrivateKeyContainer().getPrivateKey());
        privateKey.setVersion(keyPairContainer.getPrivateKeyContainer().getVersion());
        final UserKeyPair userKeyPair = new UserKeyPair();
        userKeyPair.setUserPrivateKey(privateKey);
        final Credentials passphrase = new TripleCryptKeyPair().unlock(callback, session.getHost(),
                userKeyPair);
        final PlainFileKey plainFileKey = Crypto.decryptFileKey(
                TripleCryptConverter.toCryptoEncryptedFileKey(key), privateKey, passphrase.getPassword());
        return new CryptoInputStream(proxy.read(file, status, callback),
                Crypto.createFileDecryptionCipher(plainFileKey),
                CryptoUtils.stringToByteArray(plainFileKey.getTag()));
    } catch (ApiException e) {
        throw new SDSExceptionMappingService().map("Download {0} failed", e, file);
    } catch (CryptoException e) {
        throw new CryptoExceptionMappingService().map("Download {0} failed", e, file);
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map("Download {0} failed", e, file);
    }
}

From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.GeoJsonPointReverseArrayBolt.java

String reverseJsonArray(String src) {
    Gson gson = new Gson();
    List list = gson.fromJson(src, List.class);

    if (CollectionUtils.isEmpty(list)) {
        return StringUtils.EMPTY;
    } else {//from   w ww  . j  a v  a2 s  .  co  m
        Collections.reverse(list);
        return gson.toJson(list);
    }
}

From source file:com.cognifide.aet.job.common.datafilters.removeregexp.RemoveRegexpDataModifier.java

private String modify(String data, String regexp) throws ProcessingException {
    String result = null;/* ww w  .  j av  a  2  s . com*/
    try {
        result = data.replaceAll(regexp, StringUtils.EMPTY);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new ProcessingException(e.getMessage(), e);
    }
    return result;
}

From source file:de.micromata.genome.db.jdbc.trace.SqlLiteralArgRenderer.java

@Override
public String renderSqlArg(Object arg) {
    if (arg instanceof String) {
        // TODO replace with proper SQL escaping
        return "'" + StringUtils.replace((String) arg, "'", "''") + "'";
    }/*from   w  w  w .j a v  a  2  s  .co m*/
    if (arg instanceof Integer || arg instanceof Long || arg instanceof Short || arg instanceof Byte) {
        return Objects.toString(arg, StringUtils.EMPTY);
    }
    if (arg instanceof BigDecimal) {
        return Objects.toString(arg, StringUtils.EMPTY); // TODO
    }
    if (arg instanceof Date) {
        return '#' + sqlDateFormatter.get().format((Date) arg) + '#';
    }
    if (arg instanceof Time) {
        return '#' + sqlTimeFormatter.get().format((Time) arg) + '#';
    }
    if (arg instanceof Timestamp) {
        return '#' + sqlTimestampFormatter.get().format((Timestamp) arg) + '#';
    }
    if (arg instanceof java.util.Date) {
        return '#' + sqlTimestampFormatter.get().format((java.util.Date) arg) + '#';
    }
    // TODO andere typen unterstuetzen
    return Objects.toString(arg, StringUtils.EMPTY);
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.LevelOneActivity.java

private void setupVideoFragment() {
    final Intent intent = getIntent();
    final Bundle bundle = intent.getBundleExtra(EXTRA);
    Validate.notNull(bundle, "The bundle supplied to the activity is null.");
    final String fragmentToShow = bundle.getString(FRAGMENT_TO_SHOW, StringUtils.EMPTY);
    if (SignVideoFragment.class.getSimpleName().equals(fragmentToShow)) {
        final Parcelable sign = bundle.getParcelable(SignVideoFragment.SIGN_TO_SHOW);
        SignVideoFragment signVideoFragment = new SignVideoFragment();
        final Bundle args = new Bundle();
        args.putParcelable(SignVideoFragment.SIGN_TO_SHOW, sign);
        signVideoFragment.setArguments(args);
        setFragment(signVideoFragment, SIGN_VIDEO_TAG);
    } else {//from w ww  .  j  a  v a  2 s  .  c  o  m
        throw new IllegalArgumentException("Cannot show the fragment with name: " + fragmentToShow);
    }
}

From source file:com.github.haixing_hu.ilibrary.model.DocumentTemplate.java

/**
 * Default constructor.//from   ww  w.  j  a  va  2  s  . c  o m
 * <p>
 * This default constructor is presented for JAXB.
 */
DocumentTemplate() {
    name = StringUtils.EMPTY;
    type = DocumentType.ARTICLE;
    cslType = Type.ARTICLE;
    defaultKind = null;
    kinds = null;
    fieldGroups = null;
    variableMapping = null;
}