List of usage examples for org.apache.commons.lang3 StringUtils equals
public static boolean equals(final CharSequence cs1, final CharSequence cs2)
Compares two CharSequences, returning true if they represent equal sequences of characters.
null s are handled without exceptions.
From source file:com.santhoshknn.sudoku.GridExtractor.java
/** * Parses the supplied input to extract a 9x9 grid of integers substituting * the supplied x with a 0//www . j a v a 2s . c om * * @param input * @return extracted gridresponse */ public GridResponse parse(final String input) { int[][] grid = new int[9][9]; String error = null; GridResponse response = new GridResponse(); log.info("Parsing supplied input string to create sudoku grid"); // Strip whitespaces if any String sanitized = StringUtils.deleteWhitespace(input); // Fail early. Check if the length is 161 (81 + 80 commas) if (StringUtils.isBlank(sanitized) || StringUtils.length(sanitized) != GRID_SIZE) { error = INPUT_LENGTH_INVALID; } else { String[] tokens = sanitized.split(","); int row = 0, col = 0; for (int k = 0; k < 81; k++) { // tokens = 81 if (StringUtils.equals("x", tokens[k])) grid[row][col] = 0; else if (StringUtils.isNumeric(tokens[k])) { // What if the user enters a number > 9? However, accept 0 // since it could mean an empty cell int number = Integer.parseInt(tokens[k]); if (number > 9) { error = INVALID_NUMBER_ERROR + ":" + number; break; } grid[row][col] = number; } else { // Invalid character. Fail error = INVALID_CHAR_ERROR; break; } col++; if ((k + 1) % 9 == 0) { // Update row & reset column row++; col = 0; } } } if (null == error) response.setGrid(grid); else { response.setError(error); log.error(error); } return response; }
From source file:com.bitium.confluence.saml.IdpKeyManager.java
@Override public X509Certificate getCertificate(String key) { return StringUtils.equals(key, entityId) ? certificate : null; }
From source file:com.inkubator.hrm.web.reimbursement.RmbsDisbursementApprovalFormController.java
@PostConstruct @Override/* ww w . j a v a 2 s . c om*/ public void initialization() { try { super.initialization(); /** initial data for approval activity tracking */ String id = FacesUtil.getRequestParameter("execution"); selectedApprovalActivity = approvalActivityService.getEntiyByPK(Long.parseLong(id.substring(1))); isWaitingApproval = selectedApprovalActivity .getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL; isWaitingRevised = selectedApprovalActivity .getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_REVISED; isApprover = StringUtils.equals(UserInfoUtil.getUserName(), selectedApprovalActivity.getApprovedBy()); isRequester = StringUtils.equals(UserInfoUtil.getUserName(), selectedApprovalActivity.getRequestBy()); /** start binding data that needed (from json) to object */ Gson gson = JsonUtil.getHibernateEntityGsonBuilder().create(); rmbsDisbursement = gson.fromJson(selectedApprovalActivity.getPendingData(), RmbsDisbursement.class); /** relational object */ listRmbsApplications = new ArrayList<RmbsApplication>(); JsonObject jsonObject = (JsonObject) gson.fromJson(selectedApprovalActivity.getPendingData(), JsonObject.class); List<Long> listRmbsApplicationId = gson.fromJson(jsonObject.get("listRmbsApplicationId").getAsString(), new TypeToken<List<Long>>() { }.getType()); for (Long rmbsApplicationId : listRmbsApplicationId) { RmbsApplication application = rmbsApplicationService.getEntityByPkWithDetail(rmbsApplicationId); listRmbsApplications.add(application); } } catch (Exception ex) { LOGGER.error("Error", ex); } }
From source file:com.SFManagementAntTask.partner.dao.PartnerDao.java
/** * ??/*from ww w . j a v a2s.com*/ * @param sobjlist ??? */ public static List<CustomObject> describeSObjects(List<CustomObject> sobjlist) { //List<CustomObject> cobjlist = new ArrayList<CustomObject>(); List<String> sobjnamelist = new ArrayList<String>(); DescribeSObjectResult[] ressobjlist = null; List<DescribeSObjectResult> reslist = new ArrayList<DescribeSObjectResult>(); try { for (CustomObject cobj : sobjlist) { sobjnamelist.add(cobj.getName()); if (sobjnamelist.size() == 100) { ressobjlist = ConnectionUtil.connectPartner() .describeSObjects(sobjnamelist.toArray(new String[sobjnamelist.size()])); for (DescribeSObjectResult res : ressobjlist) { reslist.add(res); } sobjnamelist = new ArrayList<String>(); } } ressobjlist = ConnectionUtil.connectPartner() .describeSObjects(sobjnamelist.toArray(new String[sobjnamelist.size()])); for (DescribeSObjectResult res : ressobjlist) { reslist.add(res); } } catch (ConnectionException e) { e.printStackTrace(); } log.debug(">>> " + reslist.size()); for (DescribeSObjectResult res : reslist) { //CustomObject cobj = null; for (CustomObject cobj : sobjlist) { log.debug(">>> " + cobj.getName() + " : " + res.getName()); if (StringUtils.equals(cobj.getName(), res.getName())) { //cobj = tcobj; cobj.setName(res.getName()); cobj.setLabel(res.getLabel()); cobj.setCustom(res.isCustom()); cobj.setLabel(res.getLabel()); cobj.setName(res.getName()); cobj.setCustom(res.isCustom()); cobj.setFeedEnabled(res.isFeedEnabled()); cobj.setKeyPrefix(res.getKeyPrefix()); cobj.setLabelPlural(res.getLabelPlural()); cobj.setActivateable(res.isActivateable()); cobj.setCustom(res.isCustomSetting()); cobj.setDeprecatedAndHidden(res.isDeprecatedAndHidden()); cobj.setIdEnabled(res.isIdEnabled()); cobj.setLayoutable(res.isLayoutable()); cobj.setMergeable(res.isMergeable()); cobj.setReplicateable(res.isReplicateable()); cobj.setRetrieveable(res.isRetrieveable()); cobj.setQueryable(res.isQueryable()); cobj.setSearchable(res.isSearchable()); cobj.setTriggerable(res.isTriggerable()); cobj.setCreateable(res.isCreateable()); cobj.setUpdateable(res.isUpdateable()); cobj.setDeletable(res.isDeletable()); cobj.setUndeletable(res.isUndeletable()); for (Field field : res.getFields()) { CustomField fobj = new CustomField(); fobj.setName(field.getName()); fobj.setLabel(field.getLabel()); fobj.setPermissionable(field.getPermissionable()); fobj.setAutoNumber(field.isAutoNumber()); field.isCalculated(); fobj.setCalculatedFormula(field.getCalculatedFormula()); fobj.setCascadeDelete(field.isCascadeDelete()); fobj.setCaseSensitive(field.isCaseSensitive()); fobj.setControllerName(field.getControllerName()); fobj.setCreateable(field.isCreateable()); fobj.setCustom(field.isCustom()); fobj.setDefaultedOnCreate(field.isDefaultedOnCreate()); fobj.setDependentPicklist(field.isDependentPicklist()); fobj.setDeprecatedAndHidden(field.isDeprecatedAndHidden()); fobj.setDigits(field.getDigits()); fobj.setDisplayLocationInDecimal(field.isDisplayLocationInDecimal()); fobj.setEncrypted(field.isEncrypted()); fobj.setExternalId(field.isExternalId()); fobj.setExtraTypeInfo(field.getExtraTypeInfo()); fobj.setFilterable(field.isFilterable()); fobj.setFilteredLookupInfo(field.getFilteredLookupInfo()); fobj.setGroupable(field.isGroupable()); fobj.setHighScaleNumber(field.isHighScaleNumber()); fobj.setHtmlFormatted(field.isHtmlFormatted()); fobj.setIdLookup(field.isIdLookup()); fobj.setInlineHelpText(field.getInlineHelpText()); //string fobj.setLength(field.getLength()); // int fobj.setMask(field.getMask()); // string fobj.setMaskType(field.getMaskType()); //string fobj.setNameField(field.isNameField()); fobj.setNamePointing(field.isNamePointing()); fobj.setNillable(field.isNillable()); fobj.setPermissionable(field.isPermissionable()); fobj.setPrecision(field.getPrecision()); //int fobj.setQueryByDistance(field.isQueryByDistance()); fobj.setReferenceTargetField(field.getReferenceTargetField()); fobj.setReferenceTo(field.getReferenceTo()); fobj.setRelationshipName(field.getRelationshipName()); fobj.setRelationshipOrder(field.getRelationshipOrder()); fobj.setRestrictedDelete(field.isRestrictedDelete()); fobj.setRestrictedPicklist(field.isRestrictedPicklist()); fobj.setScale(field.getScale()); fobj.setSortable(field.isSortable()); fobj.setType("" + field.getType()); fobj.setUnique(field.isUnique()); fobj.setUpdateable(field.isUpdateable()); fobj.setWriteRequiresMasterRead(field.isWriteRequiresMasterRead()); cobj.addFields(fobj); } for (ChildRelationship crs : res.getChildRelationships()) { Relationship fobj = new Relationship(); fobj.setName(crs.getField()); fobj.setRelationshipName(crs.getRelationshipName()); fobj.setChildSObject(crs.getChildSObject()); //log.debug("getCascadeDelete:" + crs.getCascadeDelete()); //true //log.debug("getJunctionIdListName:" + crs.getJunctionIdListName()); //null //log.debug("getDeprecatedAndHidden:" + crs.getDeprecatedAndHidden()); //false //log.debug("getRestrictedDelete:" + crs.getRestrictedDelete()); //false // for (String jrt : crs.getJunctionReferenceTo()) { // log.debug("getJunctionReferenceTo:" + jrt); // } cobj.addChildRelationships(fobj); } } } } return sobjlist; }
From source file:de.micromata.genome.gwiki.web.dav.GFsResource.java
public boolean authorise(Request request, Method method, Auth auth) { if (auth == null || StringUtils.isBlank(auth.getUser()) == true) { return false; }/*from ww w. j a va 2 s . c o m*/ if (StringUtils.equals(auth.getUser(), resourceFactory.getInternalUserName()) == true) { return true; } GWikiContext ctx = GWikiContext.getCurrent(); GWikiAuthorization gauth = getAuthorization(ctx); if (gauth == null) { return false; } if (gauth.isAllowTo(ctx, GWikiAuthorizationRights.GWIKI_FSWEBDAV.name()) == false) return false; return true; }
From source file:com.hybris.mobile.lib.commerce.data.product.VariantOption.java
public String getImageThumbnailUrl() { String thumbnail = ""; if (variantOptionQualifiers != null && !variantOptionQualifiers.isEmpty()) { boolean imageFound = false; Iterator<VariantOptionQualifier> iterImages = variantOptionQualifiers.iterator(); while (iterImages.hasNext() && !imageFound) { VariantOptionQualifier variantOptionQualifier = iterImages.next(); if (variantOptionQualifier.getImage() != null && StringUtils.equals(variantOptionQualifier.getImage().getFormat(), "thumbnail")) { thumbnail = variantOptionQualifier.getImage().getUrl(); imageFound = true;//from w w w . j a v a2 s .c o m } } } return thumbnail; }
From source file:com.mirth.connect.donkey.model.message.attachment.AttachmentHandlerProperties.java
@Override public void migrate3_4_0(DonkeyElement element) { DonkeyElement classNameElement = element.getChildElement("className"); if (classNameElement != null) { String className = classNameElement.getTextContent(); if (StringUtils.equals(className, "com.mirth.connect.server.attachments.DICOMAttachmentHandler")) { classNameElement.setTextContent( "com.mirth.connect.server.attachments.dicom.DICOMAttachmentHandlerProvider"); } else if (StringUtils.equals(className, "com.mirth.connect.server.attachments.JavaScriptAttachmentHandler")) { classNameElement.setTextContent( "com.mirth.connect.server.attachments.javascript.JavaScriptAttachmentHandlerProvider"); } else if (StringUtils.equals(className, "com.mirth.connect.server.attachments.PassthruAttachmentHandler")) { classNameElement.setTextContent( "com.mirth.connect.server.attachments.passthru.PassthruAttachmentHandlerProvider"); } else if (StringUtils.equals(className, "com.mirth.connect.server.attachments.RegexAttachmentHandler")) { classNameElement.setTextContent( "com.mirth.connect.server.attachments.regex.RegexAttachmentHandlerProvider"); }/*w ww. j ava 2 s .com*/ } }
From source file:com.hybris.mobile.activity.OrderDetailActivity.java
private void handleIntent(Intent intent) { if (Hybris.isUserLoggedIn()) { if (intent.hasExtra("orderDetails")) { ((TextView) findViewById(R.id.lbl_thankYou)).setVisibility(View.VISIBLE); ((TextView) findViewById(R.id.lbl_orderConfirmation)).setVisibility(View.VISIBLE); // TODO setmOrderDetails(JsonUtils.fromJson(intent.getStringExtra("orderDetails"), CartOrder.class)); }/* w w w . j a v a2 s.c om*/ if (intent.hasExtra(DataConstants.ORDER_ID)) { setmOrderID(intent.getStringExtra(DataConstants.ORDER_ID)); } // Call from another application (QR Code) else if (StringUtils.equals(intent.getAction(), Intent.ACTION_VIEW)) { setmOrderID(RegexUtil.getOrderIdFromHybrisPattern(intent.getDataString())); } } // User not logged in, redirection to the login page else { Intent loginIntent = new Intent(this, LoginActivity.class); // Call from another application (QR Code) if (StringUtils.equals(intent.getAction(), Intent.ACTION_VIEW)) { loginIntent.putExtra(DataConstants.ORDER_ID, RegexUtil.getOrderIdFromHybrisPattern(intent.getDataString())); } loginIntent.putExtra(DataConstants.INTENT_DESTINATION, DataConstants.INTENT_ORDER_DETAILS); loginIntent.putExtras(intent); startActivity(loginIntent); } }
From source file:eu.openanalytics.rsb.security.X509AuthenticationFilter.java
@Override protected Object getPreAuthenticatedCredentials(final HttpServletRequest request) { if (!StringUtils.equals(request.getHeader(SSL_VERIFIED_HEADER), "SUCCESS")) { return null; }//w ww . ja v a 2s. c om return StringUtils.trimToNull(request.getHeader(SSL_CLIENT_DN_HEADER)); }
From source file:info.magnolia.ui.form.field.transformer.composite.SwitchableTransformer.java
@Override protected String getCompositePropertyName(String propertyName) { if (StringUtils.equals(propertyName, propertyPrefix)) { propertyName = StringUtils.EMPTY; }/* w w w. j a v a 2s . c o m*/ return super.getCompositePropertyName(propertyName); }