Java Code Examples for org.apache.commons.lang.StringUtils.isEmpty()

The following are Jave code examples for showing how to use isEmpty() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: kaltura-ce-sakai-extension   File: KalturaAPIServiceStub.java   View Source Code Vote up 7 votes
@Override
protected KalturaMetadata updatePlaylistMetadata(String playlistId, Map<String, String> newMetadata) {
    if (StringUtils.isEmpty(playlistId)) {
        throw new IllegalArgumentException("playlist id must be set");
    }
    if (newMetadata == null) {
        newMetadata = new LinkedHashMap<String, String>();
    }
    // get existing metadata for playlist
    Map<String, String> metadata = getPlaylistMetadataFields(playlistId).get(playlistId);
    // update metadata key => value pairs with new values
    metadata.putAll(newMetadata);
    String xml = createPlaylistXmlMetadataString(metadata);
    KalturaMetadata kalturaMetadata = new KalturaMetadata();
    kalturaMetadata.xml = xml;
    return kalturaMetadata;
}
 
Example 2
Project: Ace   File: RankManager.java   View Source Code Vote up 6 votes
public static ArrayList<String> getPermissions(int id) throws SQLException{
    PreparedStatement stmt = plugin.getDb().getConnection().prepareStatement("SELECT permissions FROM ranks WHERE id = "+id+" LIMIT 1");
    ResultSet set = stmt.executeQuery();
    set.next();
    String s = set.getString("permissions");
    String[] permissions = new String[(StringUtils.isEmpty(s)?1:StringUtils.length(s)+1)];
    if(StringUtils.isNotEmpty(s)){permissions = s.split("\\s+");}
    ArrayList<String> perms = new ArrayList<>();
    perms.addAll(Arrays.asList(permissions));
    return perms;
}
 
Example 3
Project: goobi-viewer-indexer   File: MetadataHelper.java   View Source Code Vote up 6 votes
/**
 * 
 * @param pi
 * @return
 * @throws FatalIndexerException
 * @should trim identifier
 * @should apply replace rules
 * @should replace spaces with underscores
 * @should replace commas with underscores
 */
public static String applyIdentifierModifications(String pi) throws FatalIndexerException {
    if (StringUtils.isEmpty(pi)) {
        return pi;
    }
    String ret = pi.trim();
    // Apply replace rules defined for the field PI
    List<FieldConfig> configItems = Configuration.getInstance().getMetadataConfigurationManager().getConfigurationListForField(SolrConstants.PI);
    if (configItems != null && !configItems.isEmpty()) {
        Map<Object, String> replaceRules = configItems.get(0).getReplaceRules();
        if (replaceRules != null && !replaceRules.isEmpty()) {
            ret = MetadataHelper.applyReplaceRules(ret, replaceRules);
        }
    }
    ret = ret.replace(" ", "_");
    ret = ret.replace(",", "_");
    ret = ret.replace(":", "_");

    return ret;
}
 
Example 4
Project: lams   File: ImageGalleryUtils.java   View Source Code Vote up 6 votes
/**
    * Create file list from multiple form.
    *
    * @param multipleForm
    * @return
    */
   public static List<FormFile> createFileListFromMultipleForm(MultipleImagesForm multipleForm) {

List<FormFile> fileList = new ArrayList<FormFile>();
if (multipleForm.getFile1() != null && !StringUtils.isEmpty(multipleForm.getFile1().getFileName())) {
    fileList.add(multipleForm.getFile1());
}
if (multipleForm.getFile2() != null && !StringUtils.isEmpty(multipleForm.getFile2().getFileName())) {
    fileList.add(multipleForm.getFile2());
}
if (multipleForm.getFile3() != null && !StringUtils.isEmpty(multipleForm.getFile3().getFileName())) {
    fileList.add(multipleForm.getFile3());
}
if (multipleForm.getFile4() != null && !StringUtils.isEmpty(multipleForm.getFile4().getFileName())) {
    fileList.add(multipleForm.getFile4());
}
if (multipleForm.getFile5() != null && !StringUtils.isEmpty(multipleForm.getFile5().getFileName())) {
    fileList.add(multipleForm.getFile5());
}

return fileList;
   }
 
Example 5
Project: configx   File: ConfigRestService.java   View Source Code Vote up 6 votes
/**
 * 查找指定配置项的标签信息
 *
 * @param tagList
 * @param configItem
 * @return
 */
private static List<Tag> findTagList(List<Tag> tagList, BuildConfigItem configItem) {
    if (StringUtils.isEmpty(configItem.getConfigTags())) {
        return Collections.emptyList();
    }
    if (tagList == null || tagList.isEmpty()) {
        return Collections.emptyList();
    }

    List<Tag> itemTagList = new ArrayList<>();
    for (Tag tag : tagList) {
        for (String tagId : StringUtils.split(configItem.getConfigTags(), ",")) {
            if (tag.getId() == Integer.valueOf(tagId)) {
                itemTagList.add(tag);
            }
        }
    }
    return itemTagList;
}
 
Example 6
Project: bdf2   File: TabBuilder.java   View Source Code Vote up 5 votes
public void build(Object control, ViewComponent parentViewComponent) {
	TabControl tabControl = (TabControl) control;
	String id = tabControl.getId();
	ViewComponent component = this.generateViewComponent(id, TabControl.class);
	if (StringUtils.isEmpty(component.getId())) {
		component.setEnabled(false);
	}
	parentViewComponent.addChildren(component);
	List<Tab> tabs = tabControl.getTabs();
	for (Tab tab : tabs) {
		ViewComponent subViewComponent = null;
		String name = tab.getName();
		if (StringUtils.isNotEmpty(name)) {
			subViewComponent=this.generateViewComponent(name, tab.getClass());
			if(StringUtils.isNotEmpty(tab.getCaption())){
				subViewComponent.setDesc(tab.getCaption());
			}
		}else if(StringUtils.isNotEmpty(tab.getCaption())){
			subViewComponent=this.generateViewComponent(tab.getCaption(),tab.getClass());
		}
		if (subViewComponent!=null) {
			if(StringUtils.isEmpty(subViewComponent.getId())){
				subViewComponent.setEnabled(false);					
			}
			component.addChildren(subViewComponent);
		}
		if (tab instanceof ControlTab && subViewComponent!=null) {
			ControlTab controlTab = (ControlTab) tab;
			Control c = controlTab.getControl();
			for (IControlBuilder builder : builders) {
				if (builder.support(c)) {
					builder.build(c, subViewComponent);
					break;
				}
			}
		}
	}
}
 
Example 7
Project: wish-pay   File: JsonMapper.java   View Source Code Vote up 5 votes
/**
 * 反序列化POJO或简单Collection如List<String>.
 * <p/>
 * 如果JSON字符串为Null或"null"字符串, 返回Null.
 * 如果JSON字符串为"[]", 返回空集合.
 * <p/>
 * 如需反序列化复杂Collection如List<MyBean>, 请使用fromJson(String, JavaType)
 *
 * @see #fromJson(String, JavaType)
 */
public <T> T fromJson(String jsonString, Class<T> clazz) {
    if (StringUtils.isEmpty(jsonString)) {
        return null;
    }

    try {
        return mapper.readValue(jsonString, clazz);
    } catch (IOException e) {
        logger.warn("parse json string error:" + jsonString, e);
        return null;
    }
}
 
Example 8
Project: configx   File: ReleaseFormSearchForm.java   View Source Code Vote up 5 votes
public Date getDateOfRelease() {
    if (StringUtils.isEmpty(releaseDate)) {
        return null;
    }
    try {
        return DateUtils.parseDate(this.releaseDate, new String[]{"yyyy-MM-dd"});
    } catch (ParseException e) {
        return null;
    }
}
 
Example 9
Project: lams   File: ForumService.java   View Source Code Vote up 5 votes
@Override
   public Attachment uploadAttachment(FormFile uploadFile) throws PersistenceException {
if ((uploadFile == null) || StringUtils.isEmpty(uploadFile.getFileName())) {
    throw new ForumException("Could not find upload file: " + uploadFile);
}

NodeKey nodeKey = processFile(uploadFile);
Attachment file = new Attachment();
file.setFileUuid(nodeKey.getUuid());
file.setFileVersionId(nodeKey.getVersion());
file.setFileName(uploadFile.getFileName());

return file;
   }
 
Example 10
Project: bdf2   File: MenuBuilder.java   View Source Code Vote up 5 votes
public void build(Object control, ViewComponent parentViewComponent) {
	Menu menu = (Menu) control;
	String id = menu.getId();
	ViewComponent component = this.generateViewComponent(id, menu.getClass());
	if (StringUtils.isEmpty(id)) {
		component.setEnabled(false);
	}
	for (BaseMenuItem c : menu.getItems()) {
		buildBaseMenuItem(c, component);
	}
	parentViewComponent.addChildren(component);
}
 
Example 11
Project: bdf2   File: FormElementBuilder.java   View Source Code Vote up 5 votes
public void build(Object control, ViewComponent parentViewComponent) {
	FormElement element = (FormElement) control;
	String id=element.getId();
	if(StringUtils.isEmpty(id)){
		id=element.getProperty();
	}
	if(StringUtils.isEmpty(id)){
		id = element.getLabel();
	}
	if (StringUtils.isEmpty(id)) {
		ViewElement viewElement = element.getParent();
		if (viewElement instanceof AutoForm) {
			EntityDataType entityDataType = ((AutoForm) viewElement).getDataType();
			Map<String, PropertyDef> dataTypePropertyDefs = null;
			if (entityDataType != null) {
				dataTypePropertyDefs = entityDataType.getPropertyDefs();
			}
			id = getFormElementLabel(element, dataTypePropertyDefs);
		}
	}
	
	ViewComponent component =generateViewComponent(id,element.getClass());
	if (StringUtils.isEmpty(id)) {
		component.setEnabled(false);
	}
	parentViewComponent.addChildren(component);

	Control c = element.getEditor();
	for (IControlBuilder builder : builders) {
		if (builder.support(c)) {
			builder.build(c, component);
			break;
		}
	}
}
 
Example 12
Project: hadoop   File: RegistrySecurity.java   View Source Code Vote up 5 votes
/**
 * Generate a base-64 encoded digest of the idPasswordPair pair
 * @param idPasswordPair id:password
 * @return a string that can be used for authentication
 */
public String digest(String idPasswordPair) throws IOException {
  if (StringUtils.isEmpty(idPasswordPair) || !isValid(idPasswordPair)) {
    throw new IOException("Invalid id:password: " + idPasswordPair);
  }
  try {
    return DigestAuthenticationProvider.generateDigest(idPasswordPair);
  } catch (NoSuchAlgorithmException e) {
    // unlikely since it is standard to the JVM, but maybe JCE restrictions
    // could trigger it
    throw new IOException(e.toString(), e);
  }
}
 
Example 13
Project: bdf2   File: MenuBuilder.java   View Source Code Vote up 5 votes
public void build(Object control, ViewComponent parentViewComponent) {
	Menu menu = (Menu) control;
	String id = menu.getId();
	ViewComponent component = this.generateViewComponent(id, menu.getClass());
	if (StringUtils.isEmpty(id)) {
		component.setEnabled(false);
	}
	for (BaseMenuItem c : menu.getItems()) {
		buildBaseMenuItem(c, component);
	}
	parentViewComponent.addChildren(component);
}
 
Example 14
Project: bdf2   File: AbstractDao.java   View Source Code Vote up 5 votes
protected String getDataSourceName(String dataSourcename){
	if(StringUtils.isEmpty(dataSourcename)){
		String currentDatasourceName=ContextHolder.getCurrentDataSourceName();
		if(StringUtils.isNotEmpty(getModuleFixDataSourceName())){
			currentDatasourceName=getModuleFixDataSourceName();
		}
		return currentDatasourceName;
	}else{
		return dataSourcename;
	}
}
 
Example 15
Project: kaltura-ce-sakai-extension   File: KalturaAPIServiceStub.java   View Source Code Vote up 5 votes
@Override
public KalturaPlaylist getPlaylistByPlaylistId(String playlistId) {
    if (StringUtils.isEmpty(playlistId)) {
        throw new IllegalArgumentException("playlist id must be set");
    }
    KalturaPlaylist playlist = null;
    for (MediaCollection mc : mockCollections) {
        if (StringUtils.equals(mc.getId(), playlistId)) {
            playlist = makeSamplePlaylist(mc);
            break;
        }
    }
    return playlist;
}
 
Example 16
Project: canal-elasticsearch   File: TotoroBootStrap.java   View Source Code Vote up 5 votes
private int getTransThreadNum(Properties conf) {
    String numStr = conf.getProperty("totoro.cannal.trans.thread.nums");

    if (numStr == null || StringUtils.isEmpty(numStr.trim())) {
        return 3;
    }
    return Integer.valueOf(numStr);
}
 
Example 17
Project: bdf2   File: AbstractDialect.java   View Source Code Vote up 5 votes
public String generateColumnTypeSql(String columnType, String columnSize) {
	StringBuilder cType = new StringBuilder(" ");
	if (StringUtils.isEmpty(columnSize)) {
		cType.append(columnType);
	} else {
		String[] cs = columnSize.split(",");
		if (cs.length == 2) {
			cType.append(columnType + "(" + cs[0] + "," + cs[1] + ")");
		} else if (cs.length == 1) {
			cType.append(columnType + "(" + cs[0] + ")");
		}
	}
	cType.append(" ");
	return cType.toString();
}
 
Example 18
Project: Hydrograph   File: DelimiterModifyListener.java   View Source Code Vote up 5 votes
@Override
public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper, Widget... widgets) {
	final Widget[] widgetList = widgets;
	if (helper != null) {
		txtDecorator = (ControlDecoration) helper.get(HelperType.CONTROL_DECORATION);
	}
	Listener listener=new Listener() {

		@Override
		public void handleEvent(Event event) {
			
			String string=((Text)widgetList[0]).getText();
			if(event.type==SWT.Modify){ 
				if(StringUtils.isEmpty(string)){
					txtDecorator.show();
					((Text) widgetList[0]).setToolTipText(txtDecorator.getDescriptionText());
					((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204));
				}else{
					txtDecorator.hide();
					((Text) widgetList[0]).setToolTipText("");
					((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255));
				}

			}else{
				txtDecorator.hide();
				((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255));
			}
		}		
	};

	return listener;
}
 
Example 19
Project: uflo   File: AbstractParser.java   View Source Code Vote up 4 votes
protected String unescape(String str){
	if(StringUtils.isEmpty(str))return str;
	return StringTools.unescape(str);
}
 
Example 20
Project: goobi-viewer-connector   File: XMLGeneration.java   View Source Code Vote up 4 votes
/**
 * Creates LIDO records
 * 
 * @param records
 * @param totalHits
 * @param firstRow
 * @param numRows
 * @param handler
 * @param recordType "GetRecord" or "ListRecords"
 * @return
 * @throws IOException
 * @throws JDOMException
 * @throws SolrServerException
 */
private Element generateLido(List<SolrDocument> records, long totalHits, int firstRow, int numRows, RequestHandler handler, String recordType)
        throws JDOMException, IOException, SolrServerException {
    Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    Element xmlListRecords = new Element(recordType, xmlns);

    Namespace lido = Namespace.getNamespace("lido", "http://www.lido-schema.org");
    Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");

    if (records.size() < numRows) {
        numRows = records.size();
    }
    for (SolrDocument doc : records) {
        String url = new StringBuilder(DataManager.getInstance().getConfiguration().getDocumentResolverUrl()).append(doc.getFieldValue(
                SolrConstants.PI_TOPSTRUCT)).toString();
        String xml = Utils.getWebContent(url);
        if (StringUtils.isEmpty(xml)) {
            xmlListRecords.addContent(new ErrorCode().getCannotDisseminateFormat());
            continue;
        }

        org.jdom2.Document lidoFile = Utils.getDocumentFromString(xml, null);
        Element lidoRoot = lidoFile.getRootElement();
        Element newLido = new Element("lido", lido);
        newLido.addNamespaceDeclaration(xsi);
        newLido.setAttribute(new Attribute("schemaLocation", "http://www.lido-schema.org http://www.lido-schema.org/schema/v1.0/lido-v1.0.xsd",
                xsi));
        newLido.addContent(lidoRoot.cloneContent());

        Element record = new Element("record", xmlns);
        Element header = getHeader(doc, null, handler);
        record.addContent(header);
        Element metadata = new Element("metadata", xmlns);
        metadata.addContent(newLido);
        // metadata.addContent(mets_root.cloneContent());
        record.addContent(metadata);
        xmlListRecords.addContent(record);
    }

    // Create resumption token
    if (totalHits > firstRow + numRows) {
        Element resumption = createResumptionTokenAndElement(totalHits, firstRow + numRows, xmlns, handler);
        xmlListRecords.addContent(resumption);
    }

    return xmlListRecords;
}