List of usage examples for org.apache.commons.lang StringUtils equals
public static boolean equals(String str1, String str2)
Compares two Strings, returning true
if they are equal.
From source file:net.shopxx.plugin.weiboLogin.WeiboLoginPlugin.java
@Override public boolean verifyNotify(HttpServletRequest request) { String state = (String) request.getSession().getAttribute(STATE_ATTRIBUTE_NAME); if (StringUtils.isNotEmpty(state) && StringUtils.equals(state, request.getParameter("state")) && StringUtils.isNotEmpty(request.getParameter("code"))) { request.getSession().removeAttribute(STATE_ATTRIBUTE_NAME); PluginConfig pluginConfig = getPluginConfig(); Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("grant_type", "authorization_code"); parameterMap.put("client_id", pluginConfig.getAttribute("oauthKey")); parameterMap.put("client_secret", pluginConfig.getAttribute("oauthSecret")); parameterMap.put("redirect_uri", getNotifyUrl()); parameterMap.put("code", request.getParameter("code")); String content = WebUtils.post("https://api.weibo.com/oauth2/access_token", parameterMap); JsonNode tree = JsonUtils.toTree(content); String accessToken = tree.get("access_token").textValue(); String uid = tree.get("uid").textValue(); if (StringUtils.isNotEmpty(accessToken) && StringUtils.isNotEmpty(uid)) { request.setAttribute("accessToken", tree.get("access_token").textValue()); request.setAttribute("uid", uid); return true; }//www.ja v a2 s . c o m } return false; }
From source file:edu.northwestern.bioinformatics.studycalendar.xml.writers.AddXmlSerializer.java
@Override public StringBuffer validateElement(Change change, Element eChange) { if (change == null && eChange == null) { return new StringBuffer(""); } else if ((change == null && eChange != null) || (change != null && eChange == null)) { return new StringBuffer("either change or element is null"); }/* w w w. j a va2 s .c om*/ StringBuffer errorMessageStringBuffer = super.validateElement(change, eChange); Add add = (Add) change; if (!StringUtils.equals(StringTools.valueOf(add.getIndex()), eChange.attributeValue(INDEX))) { errorMessageStringBuffer .append(String.format("index is different. expected:%s , found (in imported document) :%s \n", add.getIndex(), eChange.attributeValue(INDEX))); return errorMessageStringBuffer; } List<Element> ePlanTreeNodes = eChange.elements(); Element ePlanTreeNode = ePlanTreeNodes.get(0); //fixme:Saurabh initialze the child also Child planTreeNode = add.getChild(); StudyCalendarXmlSerializer serializer = getChangeableXmlSerializerFactory() .createXmlSerializer(ePlanTreeNode); if (serializer instanceof AbstractPlanTreeNodeXmlSerializer) { errorMessageStringBuffer.append( ((AbstractPlanTreeNodeXmlSerializer) serializer).validateElement(planTreeNode, ePlanTreeNode)); } return errorMessageStringBuffer; }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.ExcelFileNameWidget.java
@Override protected void populateWidget() { Utils.INSTANCE.loadProperties();// w w w .j av a 2s .co m cursor = container.getContainerControl().getDisplay().getSystemCursor(SWT.CURSOR_HAND); String extension = ""; logger.trace("Populating {} textbox", textBoxConfig.getName()); String property = propertyValue; if (StringUtils.isNotBlank(property)) { int i = property.lastIndexOf('.'); if (i > 0) { extension = property.substring(i); } if ((StringUtils.equals(extension, ".xls") || StringUtils.equals(extension, ".xlsx")) || ParameterUtil.isParameter(property)) { txtDecorator.hide(); } else { txtDecorator.show(); } textBox.setText(property); Utils.INSTANCE.addMouseMoveListener(textBox, cursor); } else { textBox.setText(""); txtDecorator.show(); } }
From source file:edu.mayo.cts2.framework.core.config.RefreshableServerContext.java
@Override public void afterPropertiesSet() throws Exception { //set this to default to the context String context = this.configInitializer.getContext(); synchronized (this.mutex) { if (!this.appNameUpdated) { if (StringUtils.equals(ConfigInitializer.DEFAULT_CONTEXT, context)) { context = ""; }//from w w w. j ava 2s . c o m this.appName = context; } } }
From source file:info.archinnov.achilles.table.ThriftColumnFamilyValidator.java
public void validateCFForEntity(ColumnFamilyDefinition cfDef, EntityMeta entityMeta) { log.trace("Validating column family partition key definition for entityMeta {}", entityMeta.getClassName()); PropertyMeta idMeta = entityMeta.getIdMeta(); validatePartitionKey(cfDef, entityMeta.getTableName(), idMeta); log.trace("Validating column family composite comparator definition for entityMeta {}", entityMeta.getClassName());//w w w .ja v a 2s .c o m String comparatorType = (cfDef.getComparatorType() != null ? cfDef.getComparatorType().getTypeName() : "") + cfDef.getComparatorTypeAlias(); Validator.validateTableTrue(StringUtils.equals(comparatorType, ENTITY_COMPARATOR_TYPE_CHECK), "The column family '%s' comparator type '%s' should be '%s'", entityMeta.getTableName(), comparatorType, ENTITY_COMPARATOR_TYPE_CHECK); }
From source file:com.jaromin.alfresco.repo.content.transform.BitmapExtractorContentTransformer.java
@Override protected void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception { String sourceMimetype = reader.getMimetype(); String targetMimetype = writer.getMimetype(); if (!StringUtils.equals(MIMETYPE_PNG, targetMimetype)) { throw new IllegalArgumentException( "Transformer can only convert from/to [" + MIMETYPE_SKETCHUP + "] to [" + MIMETYPE_PNG + "]"); }//ww w.j a v a 2s . com // Write out the PNG InputStream in = reader.getContentInputStream(); OutputStream out = writer.getContentOutputStream(); try { BitmapExtractor extractor = extractors.get(sourceMimetype); if (extractor == null) { throw new IllegalArgumentException( "No extractor configured " + "for source mimetype [" + sourceMimetype + "]"); } extractor.extractBitmap(index, in, out); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } }
From source file:com.microsoft.alm.plugin.external.commands.GetWorkspaceCommand.java
/** * Parses the output of the workspaces command. * SAMPLE/*from w ww . java 2 s.c o m*/ * <?xml version="1.0" encoding="utf-8"?> * <workspaces> * <workspace name="MyNewWorkspace2" owner="username" computer="machine" comment="description" server="http://server:8080/tfs/"> * <working-folder server-item="$/TeamProject" local-item="D:\project1" type="map" depth="full"/> * </workspace> * </workspaces> */ @Override public Workspace parseOutput(final String stdout, final String stderr) { super.throwIfError(stderr); final NodeList workspaceNodeList = super.evaluateXPath(stdout, "/workspaces/workspace"); if (workspaceNodeList != null && workspaceNodeList.getLength() == 1) { final NamedNodeMap workspaceAttributes = workspaceNodeList.item(0).getAttributes(); // Get all the mappings for the workspace final NodeList mappingsNodeList = super.evaluateXPath(stdout, "/workspaces/workspace/working-folder"); final List<Workspace.Mapping> mappings = new ArrayList<Workspace.Mapping>(mappingsNodeList.getLength()); for (int i = 0; i < mappingsNodeList.getLength(); i++) { final NamedNodeMap mappingAttributes = mappingsNodeList.item(i).getAttributes(); final String localPath = getXPathAttributeValue(mappingAttributes, "local-item"); final String depth = getXPathAttributeValue(mappingAttributes, "depth"); final boolean isCloaked = !StringUtils.equals(getXPathAttributeValue(mappingAttributes, "type"), "map"); String serverPath = getXPathAttributeValue(mappingAttributes, "server-item"); if (!StringUtils.equals(depth, "full")) { // The normal way to denote one level mappings (not full mappings) is to end the server path // with a /*. This indicates that the mapping is not recursive to all subfolders. serverPath = WorkspaceHelper.getOneLevelServerPath(serverPath); } mappings.add(new Workspace.Mapping(serverPath, localPath, isCloaked)); } // Get owner name (display name may not be available String owner = getXPathAttributeValue(workspaceAttributes, "owner-display-name"); if (StringUtils.isEmpty(owner)) { owner = getXPathAttributeValue(workspaceAttributes, "owner"); } final Workspace workspace = new Workspace(getXPathAttributeValue(workspaceAttributes, "server"), getXPathAttributeValue(workspaceAttributes, "name"), getXPathAttributeValue(workspaceAttributes, "computer"), owner, getXPathAttributeValue(workspaceAttributes, "comment"), mappings); return workspace; } return null; }
From source file:com.commsen.apropos.core.Property.java
/** * Checks if given <code>property</code> is the same as the one represented by this object. * This method will return <code>true</code> if ALL fields have exactly the same values and * <code>false</code> otherwise * //w w w. j a va 2s . c om * @param property the property to compare * @return <code>true</code> if both object have exactly the same values in all fields and * <code>false</code> otherwise */ public boolean sameAs(Property property) { return StringUtils.equals(group, property.getGroup()) && StringUtils.equals(name, property.getName()) && StringUtils.equals(value, property.getValue()) && StringUtils.equals(description, property.getDescription()); }
From source file:edu.cornell.kfs.gl.businessobject.ReversionUnitOfWork.java
/** * Return true of this unit of work has the same chart of accounts code, account number, and sub account number as the passed in balance * @param balance/*w w w .ja v a 2s .c o m*/ * @return */ public boolean wouldHold(Balance balance) { return StringUtils.equals(chartOfAccountsCode, balance.getChartOfAccountsCode()) && StringUtils.equals(accountNumber, balance.getAccountNumber()) && StringUtils.equals(subAccountNumber, balance.getSubAccountNumber()); }
From source file:com.openteach.diamond.integrated.test.DemoTest.java
@Test public void test() throws Exception { // Provider//from w ww . j a v a2 s.com ServiceMetadata metadata = new ServiceMetadata(); metadata.setName("test"); metadata.setInterfaceName(DemoService.class.getName()); metadata.setVersion("0.0.1"); metadata.exportProtocol(DefaultRPCProtocol4Server.PROTOCOL, Collections.EMPTY_MAP); ServiceProviderFactory factory = new DefaultServiceProviderFactory(); ServiceProvider provider = factory.newServiceProvider(metadata, new DemoServiceImpl()); DiamondServiceFactory.getDiamondService().register(metadata, provider.getMethodInvoker()); // Consumer ServiceMetadata cmetadata = new ServiceMetadata(); cmetadata.setName("test"); cmetadata.setInterfaceName(DemoService.class.getName()); cmetadata.setVersion("0.0.1"); cmetadata.addImportPortocol(DefaultRPCProtocol4Client.PROTOCOL, new Properties()); ServiceConsumerFactory cfactory = new DefaultServiceConsumerFactory(); ServiceConsumer consumer = cfactory.newServiceConsumer(cmetadata, DiamondServiceFactory.getDiamondService(), DiamondServiceFactory.getDiamondService()); DemoService service = (DemoService) consumer.getProxy(); String result = service.service("World"); if (!StringUtils.equals(result, "Hello World")) { throw new Exception("failed"); } System.out.println(result); for (int i = 0; i < 10000; i++) { System.out.println(service.service(String.format("%d", i))); } }