List of usage examples for org.apache.commons.lang StringUtils EMPTY
String EMPTY
To view the source code for org.apache.commons.lang StringUtils EMPTY.
Click Source Link
""
. From source file:com.mirth.connect.server.util.DICOMUtil.java
public static String mergeHeaderAttachments(MessageObject message, List<Attachment> attachments) throws SerializerException { try {/*from www . ja va 2s. c o m*/ List<byte[]> images = new ArrayList<byte[]>(); for (Attachment attachment : attachments) { images.add(Base64.decodeBase64(attachment.getData())); } byte[] headerBytes; if (message.getEncodedDataProtocol().equals(MessageObject.Protocol.DICOM) && message.getEncodedData() != null) { headerBytes = Base64.decodeBase64(message.getEncodedData().getBytes()); } else if (message.getRawDataProtocol().equals(MessageObject.Protocol.DICOM) && message.getRawData() != null) { headerBytes = Base64.decodeBase64(message.getRawData().getBytes()); } else { return StringUtils.EMPTY; } return mergeHeaderPixelData(headerBytes, images); } catch (IOException e) { throw new SerializerException(e); } }
From source file:jenkins.plugins.coverity.CoverityTool.CovEmitJavaCommandTest.java
@Test public void doesNotExecute_WithoutJavaWarFiles() throws IOException, InterruptedException { InvocationAssistance invocationAssistance = new InvocationAssistanceBuilder().build(); CoverityPublisher publisher = new CoverityPublisherBuilder().withInvocationAssistance(invocationAssistance) .build();// w ww.ja v a2 s .com Command covEmitJavaCommand = new CovEmitJavaCommand(build, launcher, listener, publisher, StringUtils.EMPTY, envVars, false); covEmitJavaCommand.runCommand(); verifyNumberOfExecutedCommands(0); }
From source file:com.sugaronrest.restapicalls.ModuleInfoExt.java
/** * Gets modules linked information./*w ww . j a v a 2 s. co m*/ * * @param linkedModules The module linked info list. * @return Dictionary map of linked modules. */ private static Map<String, List<String>> getLinkedInfo(Map<Object, List<String>> linkedModules) throws Exception { if ((linkedModules == null) || (linkedModules.size() == 0)) { return null; } Map<String, List<String>> jsonLinkedInfo = new HashMap<String, List<String>>(); for (Map.Entry<Object, List<String>> entry : linkedModules.entrySet()) { Object key = entry.getKey(); List<String> jsonPropertyNames = entry.getValue(); ModuleInfo linkedModuleInfo = null; String jsonModuleName = StringUtils.EMPTY; if (key instanceof String) { linkedModuleInfo = ModuleInfo.create(null, key.toString()); if (linkedModuleInfo != null) { if ((jsonPropertyNames == null) || (jsonPropertyNames.size() == 0)) { jsonPropertyNames = linkedModuleInfo.getJsonPropertyNames(); } jsonModuleName = linkedModuleInfo.jsonName; } if (!StringUtils.isNotBlank(jsonModuleName)) { jsonModuleName = ModuleMapper.getInstance().getTablename(key.toString()); } } else if (key instanceof Type) { // This key is a class type (e.g Accounts.class) linkedModuleInfo = ModuleInfo.create((Type) key, null); if (linkedModuleInfo != null) { if ((jsonPropertyNames == null) || (jsonPropertyNames.size() == 0)) { jsonPropertyNames = linkedModuleInfo.getJsonPropertyNames(); } jsonModuleName = linkedModuleInfo.jsonName; } if (!StringUtils.isNotBlank(jsonModuleName)) { String className = ModuleInfo.getClassName((Type) key); jsonModuleName = ModuleMapper.getInstance().getTablename(className); } } else { continue; } jsonLinkedInfo.put(jsonModuleName, jsonPropertyNames); } return jsonLinkedInfo; }
From source file:com.amalto.core.load.LoadParserTest.java
public void testArgs() { ParserTestCallback callback = new ParserTestCallback(); try {/*from w w w . j a va2s.co m*/ LoadParser.parse(null, null, null); } catch (IllegalArgumentException e) { assertEquals("Input stream cannot be null", e.getMessage()); } try { LoadParser.parse(new ByteArrayInputStream(StringUtils.EMPTY.getBytes()), null, callback); } catch (IllegalArgumentException e) { assertEquals("Configuration cannot be null", e.getMessage()); } try { LoadParser.Configuration config = new LoadParser.Configuration("root", new String[] { null }, false, "clusterName", "modelName", idGenerator); LoadParser.parse(new ByteArrayInputStream(StringUtils.EMPTY.getBytes()), config, null); } catch (IllegalArgumentException e) { assertEquals("LoadParser callback cannot be null", e.getMessage()); } }
From source file:com.fengduo.bee.commons.velocity.Widget.java
public String toString() { try {//from w w w. jav a2 s. c o m return this.buildContent(this.uri.toString()); } catch (Exception e) { logger.warn("Widget toString:", e); return StringUtils.EMPTY; } }
From source file:de.hybris.platform.acceleratorfacades.device.impl.DefaultDeviceDetectionFacade.java
@Override public void initializeRequest(final HttpServletRequest request) { // Only initialise the detected device once per session if (getCurrentDetectedDevice() == null || "true".equals(request.getParameter("clear"))) { // Detect the device in the current request final DeviceData deviceData = getRequestDeviceDataConverter().convert(request); setCurrentDetectedDevice(deviceData); // Map the detected device to a UiExperienceLevel final UiExperienceData uiExperienceData = getDeviceDataUiExperienceDataConverter().convert(deviceData); final List<String> supportedUiExperienceLevels = Arrays.asList(StringUtils.split(getSiteConfigService() .getString(DEVICE_DETECTION_UIEXPERIENCE_LEVEL_SUPPORTED, StringUtils.EMPTY), ",")); if (uiExperienceData != null && uiExperienceData.getLevel() != null && (supportedUiExperienceLevels.isEmpty() || supportedUiExperienceLevels.contains(uiExperienceData.getLevel().getCode()))) { getUiExperienceService().setDetectedUiExperienceLevel(uiExperienceData.getLevel()); } else {/*from w ww. ja v a2s. co m*/ // Default to DESKTOP experience or the first supportUi UiExperienceLevel defaultExperience = UiExperienceLevel.DESKTOP; try { if (!supportedUiExperienceLevels.isEmpty()) { defaultExperience = UiExperienceLevel.valueOf(supportedUiExperienceLevels.get(0)); } } catch (IllegalArgumentException e) { LOG.warn(String.format("Invalid UiExperienceLevel enum %s will default to 'Desktop'", supportedUiExperienceLevels.isEmpty() ? "" : supportedUiExperienceLevels.get(0))); } getUiExperienceService().setDetectedUiExperienceLevel(defaultExperience); } if (LOG.isDebugEnabled()) { final UserModel userModel = (UserModel) getSessionService() .getAttribute(UserConstants.USER_SESSION_ATTR_KEY); final String userUid = (userModel != null) ? userModel.getUid() : "<null>"; LOG.debug("Detected device [" + deviceData.getId() + "] User Agent [" + deviceData.getUserAgent() + "] Mobile [" + deviceData.getMobileBrowser() + "] Session user [" + userUid + "]"); } } }
From source file:com.amalto.core.history.UniqueIdTransformer.java
private void _addIds(org.w3c.dom.Document document, Element element, Stack<Integer> levels) { NamedNodeMap attributes = element.getAttributes(); Attr id = document.createAttribute(ID_ATTRIBUTE_NAME); int thisElementId = levels.pop() + 1; StringBuilder builder;/* www. ja va 2 s. c om*/ { builder = new StringBuilder(); for (Integer level : levels) { builder.append(level); } } String prefix = builder.toString().isEmpty() ? StringUtils.EMPTY : builder.toString() + '-'; id.setValue(prefix + element.getNodeName() + '-' + thisElementId); attributes.setNamedItem(id); levels.push(thisElementId); { levels.push(0); NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { Element child = (Element) children.item(i); _addIds(document, child, levels); } } levels.pop(); } }
From source file:com.envision.envservice.rest.UserCasePriseResource.java
@POST @Path("/cancel/{caseId}") @Produces(MediaType.APPLICATION_JSON)/* w w w .j a va2s . c om*/ public Response cancelPrise(@PathParam("caseId") int caseId) throws Exception { HttpStatus status = HttpStatus.ACCEPTED; String response = StringUtils.EMPTY; userCasePriseService.cancelPrise(caseId); return Response.status(status.value()).entity(response).build(); }
From source file:com.excilys.ebi.bank.web.controller.account.operations.OperationsTableConverter.java
@Override public OperationsTable convert(Page<Operation> source) { /*// w w w . j av a 2 s. c o m * For the brave souls who get this far: You are the chosen ones, the * valiant knights of programming who toil away, without rest, fixing * our most awful code. To you, true saviors, kings of men, I say this: * never gonna give you up, never gonna let you down, never gonna run * around and desert you. Never gonna make you cry, never gonna say * goodbye. Never gonna tell a lie and hurt you. */ OperationsTable table = new OperationsTable(); table.setNumber(source.getNumber()); table.setNumberOfElements(source.getNumberOfElements()); table.setSize(source.getSize()); table.setTotalElements(source.getTotalElements()); table.setTotalPages(source.getTotalPages()); table.setHasContent(source.hasContent()); table.setHasNextPage(source.hasNextPage()); table.setHasPreviousPage(source.hasPreviousPage()); table.setFirstPage(source.isFirstPage()); table.setLastPage(source.isLastPage()); table.setStartIndex(source.getTotalElements() > 0 ? source.getSize() * source.getNumber() + 1 : 0); table.setPageIndex(source.getTotalElements() > 0 ? source.getNumber() + 1 : 0); table.setEndIndex(source.getSize() * source.getNumber() + source.getNumberOfElements()); for (Operation operation : source.getContent()) { OperationsLine line = new OperationsLine(); line.setAmount(operation.getAmount()); line.setDate(operation.getDate().toString("MM/dd/yyyy")); line.setName(operation.getName()); line.setStatus(operation.getStatus().getId()); table.getLines().add(line); } for (int i = 0; i < source.getSize() - source.getNumberOfElements(); i++) { table.getEmptyLines().add(StringUtils.EMPTY); } return table; }
From source file:com.amalto.core.storage.record.ViewSearchResultsWriter.java
private void processValue(Writer out, FieldMetadata fieldMetadata, Object value) throws IOException { if (value == null) { throw new IllegalArgumentException("Not supposed to write null values to XML."); //$NON-NLS-1$ }/*from w w w. ja v a2 s . com*/ if (delegator.hide(fieldMetadata)) { out.append(StringUtils.EMPTY); return; } String stringValue; TypeMetadata type = fieldMetadata.getType(); if (fieldMetadata instanceof SimpleTypeFieldMetadata) { type = MetadataUtils.getSuperConcreteType(type); } if (Types.DATE.equals(type.getName())) { synchronized (DateConstant.DATE_FORMAT) { stringValue = (DateConstant.DATE_FORMAT).format(value); } } else if (Types.DATETIME.equals(type.getName())) { synchronized (DateTimeConstant.DATE_FORMAT) { stringValue = (DateTimeConstant.DATE_FORMAT).format(value); } } else if (Types.TIME.equals(type.getName())) { synchronized (TimeConstant.TIME_FORMAT) { stringValue = (TimeConstant.TIME_FORMAT).format(value); } } else if (value instanceof Object[]) { StringBuilder valueAsString = new StringBuilder(); CompoundFieldMetadata compoundFields = (CompoundFieldMetadata) ((ReferenceFieldMetadata) fieldMetadata) .getReferencedField(); int i = 0; for (Object current : ((Object[]) value)) { valueAsString.append('[') .append(StorageMetadataUtils.toString(current, compoundFields.getFields()[i++])) .append(']'); } stringValue = valueAsString.toString(); } else { stringValue = String.valueOf(value); } if (fieldMetadata instanceof ReferenceFieldMetadata) { if (value instanceof DataRecord) { // TODO Replace with MetadataUtils.toString() DataRecord referencedRecord = (DataRecord) value; StringBuilder fkValueAsString = new StringBuilder(); for (FieldMetadata keyField : referencedRecord.getType().getKeyFields()) { fkValueAsString.append('[').append(referencedRecord.get(keyField)).append(']'); } stringValue = fkValueAsString.toString(); } else { if (!stringValue.startsWith("[")) { //$NON-NLS-1$ stringValue = "[" + StorageMetadataUtils.toString(value, //$NON-NLS-1$ ((ReferenceFieldMetadata) fieldMetadata).getReferencedField()) + ']'; } } } if (fieldMetadata instanceof AliasedFieldMetadata && ((AliasedFieldMetadata) fieldMetadata).getAliasedField() instanceof ReferenceFieldMetadata) { if (!stringValue.startsWith("[")) { //$NON-NLS-1$ stringValue = "[" + StorageMetadataUtils.toString(value, //$NON-NLS-1$ ((ReferenceFieldMetadata) ((AliasedFieldMetadata) fieldMetadata).getAliasedField()) .getReferencedField()) + ']'; } } out.append(StringEscapeUtils.escapeXml(stringValue)); }