List of usage examples for org.apache.commons.lang StringUtils endsWith
public static boolean endsWith(String str, String suffix)
Check if a String ends with a specified suffix.
From source file:com.sfs.whichdoctor.dao.RelationshipDAOImpl.java
/** * Rebuilds the relationship index for the specified GUID. * * @param guid the guid//ww w . j a v a2s .co m * @param type the type * @return the string * * @throws WhichDoctorDaoException the which doctor dao exception */ public final String rebuildRelationships(final int guid, final String type) throws WhichDoctorDaoException { String result = ""; // Load the existing relationships for this object Collection<RelationshipBean> existingRelationships = load(guid, new BuilderBean()); Collection<RelationshipBean> updatedRelationships = new ArrayList<RelationshipBean>(); // Begin the ISB transaction */ IsbTransactionBean isbTransaction = this.isbTransactionDAO.begin(guid); if (StringUtils.equalsIgnoreCase(type, "Person")) { /* Load the person specified by the GUID */ BuilderBean loadDetails = new BuilderBean(); loadDetails.setParameter("MEMBERSHIP", true); loadDetails.setParameter("TRAINING_ROTATIONS", true); Collection<RelationshipBean> changedRelationships = new ArrayList<RelationshipBean>(); Collection<RotationBean> priorRotations = new ArrayList<RotationBean>(); PersonBean person = null; try { person = this.personDAO.loadGUID(guid, loadDetails); } catch (Exception e) { dataLogger.error("Error loading person " + guid + ": " + e.getMessage()); } if (person == null) { person = new PersonBean(); } Collection<RotationBean> rotations = person.getRotations(); if (rotations == null) { rotations = new ArrayList<RotationBean>(); } Date currentDate = Calendar.getInstance().getTime(); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, 0 - this.previousRotationLimit); final Date limitMonthsAgo = calendar.getTime(); for (RotationBean rotation : rotations) { try { /* Is this rotation currently taking place? */ if (rotation.getStartDate().compareTo(currentDate) <= 0 && rotation.getEndDate().compareTo(currentDate) >= 0) { dataLogger.debug("The rotation is taking place now"); dataLogger.debug("Rotation supervisor count: " + rotation.getSupervisors().size()); for (SupervisorBean supervisor : rotation.getSupervisors()) { RelationshipBean relationship = build(guid, supervisor.getPerson(), supervisor.getRelationshipClass(), supervisor.getRelationshipType(), rotation.getEndDate(), rotation.getGUID()); changedRelationships.add(relationship); } } else { // If not currently taking place did it end in the // time limit. If so add to prior rotations if (rotation.getEndDate().compareTo(limitMonthsAgo) > 0) { priorRotations.add(rotation); } } } catch (Exception e) { dataLogger.error( "Error processing rotation for person (" + person.getGUID() + "): " + e.getMessage()); } } // A trainee requires that all supervisor roles are satisfied Collection<RelationshipBean> supervisors = new ArrayList<RelationshipBean>(); Collection<RelationshipBean> otherRelationships = new ArrayList<RelationshipBean>(); // Divide the relationships between supervisors and others for (RelationshipBean relationship : changedRelationships) { dataLogger.debug("Relationship class: " + relationship.getRelationshipClass()); if (StringUtils.endsWith(relationship.getRelationshipClass(), "Supervisor") && StringUtils.isNotBlank(relationship.getISBMapping())) { // The relationship is a supervisor and has an ISB mapping supervisors.add(relationship); } else { dataLogger.debug("'Other' relationship processed"); otherRelationships.add(relationship); } } // Construct the full list of required supervisors Map<Integer, RelationshipBean> fullSupervisorMap = this.buildFullSupervisorMap(supervisors); if (fullSupervisorMap.size() == 0) { // No supervisors exist - try loading some from the past fullSupervisorMap = loadPriorSupervisorMap(priorRotations); } // Add the relationships from the full supervisors map for (Integer hierarchy : fullSupervisorMap.keySet()) { RelationshipBean relationship = fullSupervisorMap.get(hierarchy); updatedRelationships.add(relationship); } // Add the relationships from the other relationships collection for (RelationshipBean relationship : otherRelationships) { updatedRelationships.add(relationship); } result = update(existingRelationships, updatedRelationships); } /* Commit the ISB transaction */ this.isbTransactionDAO.commit(isbTransaction); return result; }
From source file:com.google.gdt.eclipse.designer.wizards.model.mvp.ViewComposite.java
private void validateNames() { String newViewName = viewField.getText(); // extract template {//w w w. j a va 2 s . co m if (StringUtils.endsWith(newViewName, "View")) { newViewName = StringUtils.replace(newViewName, "View", ""); } else if (StringUtils.endsWith(newViewName, "Composite")) { newViewName = StringUtils.replace(newViewName, "Composite", ""); } else if (StringUtils.endsWith(newViewName, "Frame")) { newViewName = StringUtils.replace(newViewName, "Frame", ""); } } if (StringUtils.isEmpty(oldViewName)) { placeNameField.setTextWithoutUpdate(newViewName + placeNameField.getText()); activityNameField.setTextWithoutUpdate(newViewName + activityNameField.getText()); } else { placeNameField.setTextWithoutUpdate( StringUtils.replaceOnce(placeNameField.getText(), oldViewName, newViewName)); activityNameField.setTextWithoutUpdate( StringUtils.replaceOnce(activityNameField.getText(), oldViewName, newViewName)); } oldViewName = newViewName; // enabled fields placeNameField.setEnabled(placeField.getSelection()); activityNameField.setEnabled(activityField.getSelection()); factoryField.setEnabled(activityField.getSelection()); factoryNameField.setEnabled(factoryField.isEnabled() && factoryField.getSelection()); }
From source file:com.hangum.tadpole.rdb.core.dialog.job.CreateJobDialog.java
@Override protected void buttonPressed(int buttonId) { if (buttonId == ID_CREATE_JOB) { //Excute script RequestResultDAO reqReResultDAO = new RequestResultDAO(); try {//from ww w . j av a 2 s . co m String stmt = this.textPreview.getText().trim(); if (StringUtils.isBlank(this.textScript.getText().trim())) { MessageDialog.openInformation(this.getShell(), CommonMessages.get().Information, Messages.get().CreateJobDialog_JobSelectMsg); return; } if (!StringUtils.endsWith(stmt, ";")) { stmt += ";"; } ExecuteDDLCommand.executSQL(userDB, reqReResultDAO, this.textPreview.getText().trim()); } catch (Exception e) { logger.error(e); } finally { if (PublicTadpoleDefine.SUCCESS_FAIL.F.name().equals(reqReResultDAO.getResult())) { MessageDialog.openError(this.getShell(), CommonMessages.get().Error, Messages.get().CreateJobDialog_RegException + reqReResultDAO.getMesssage() + reqReResultDAO.getException().getMessage()); } else { MessageDialog.openInformation(this.getShell(), CommonMessages.get().Information, Messages.get().CreateJobDialog_JobCompleted); this.okPressed(); } } } else if (buttonId == ID_DROP_JOB) { //Excute script RequestResultDAO reqReResultDAO = new RequestResultDAO(); try { String drop_stmp = ""; if (jobDao.getJob() <= 0) { // job_id ...?. MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, Messages.get().CreateJobDialog_DoesnotDeleteTarget); return; } else { drop_stmp = "begin sys.dbms_job.remove('" + jobDao.getJob() + "'); commit;end;"; ExecuteDDLCommand.executSQL(userDB, reqReResultDAO, drop_stmp); } } catch (Exception e) { logger.error(e); } finally { if (PublicTadpoleDefine.SUCCESS_FAIL.F.name().equals(reqReResultDAO.getResult())) { MessageDialog.openError(this.getShell(), CommonMessages.get().Error, Messages.get().CreateJobDialog_DelException + reqReResultDAO.getMesssage() + reqReResultDAO.getException().getMessage()); } else { MessageDialog.openInformation(this.getShell(), CommonMessages.get().Information, Messages.get().CreateJobDialog_JobDeleted); okPressed(); } } } else { okPressed(); } }
From source file:com.hangum.tadpole.ace.editor.core.texteditor.EditorExtension.java
/** * append text at position/*from w w w . j a va 2s .com*/ * * @param strText */ public void appendText(String strText) { try { if (!StringUtils.endsWith(StringUtils.trimToEmpty(strText), PublicTadpoleDefine.SQL_DELIMITER)) { strText += PublicTadpoleDefine.SQL_DELIMITER; } browserEvaluate(EditorFunctionService.APPEND_TEXT, strText); } catch (Exception ee) { logger.error("query text", ee); //$NON-NLS-1$ } }
From source file:com.bluexml.xforms.controller.alfresco.AlfrescoController.java
public boolean workflowIsBlueXMLDefinition(String name) { int start = name.indexOf(BLUEXML_WORKFLOW_PREFIX); int end = name.indexOf(':'); if (start == -1 || end == -1 || (end < start)) { return false; }/*from ww w . java 2 s. c om*/ String prefix = name.substring(start, end); String processName = name.substring(end + 1); return StringUtils.endsWith(prefix, processName); }
From source file:com.bluexml.xforms.controller.alfresco.AlfrescoController.java
/** * Gets the actual data type for a form. Added because read only forms are * distinguished from/*from w w w . j a va 2s . co m*/ * R/W forms using a suffix. Hence the form name in itself cannot be used to * designate the * datatype (or "form id" to be more precise). * * @param formName * @return the id of the read-write version of the form */ public String getDataTypeFromFormName(String formName) { String underlyingDataType = formName; String readOnlyFormsSuffix = getReadOnlyFormsSuffix(); if (StringUtils.endsWith(formName, readOnlyFormsSuffix)) { underlyingDataType = StringUtils.removeEnd(formName, readOnlyFormsSuffix); } return underlyingDataType; }
From source file:net.ymate.framework.core.util.WebUtils.java
/** * @param url URL?//from w w w. j ava2s .c o m * @param needStartWith ?'/' * @param needEndwith ?'/'? * @return ?URL? */ public static String fixURL(String url, boolean needStartWith, boolean needEndwith) { url = StringUtils.trimToNull(url); if (url != null) { if (needStartWith && !StringUtils.startsWith(url, "/")) { url = '/' + url; } else if (!needStartWith && StringUtils.startsWith(url, "/")) { url = StringUtils.substringAfter(url, "/"); } if (needEndwith && !StringUtils.endsWith(url, "/")) { url = url + '/'; } else if (!needEndwith && StringUtils.endsWith(url, "/")) { url = StringUtils.substringBeforeLast(url, "/"); } return url; } return ""; }
From source file:net.ymate.module.sso.impl.DefaultSSOModuleCfg.java
public DefaultSSOModuleCfg(YMP owner) { IConfigReader _moduleCfg = MapSafeConfigReader.bind(owner.getConfig().getModuleConfigs(ISSO.MODULE_NAME)); ///*from www . ja v a 2s .c o m*/ __tokenCookieName = _moduleCfg.getString(TOKEN_COOKIE_NAME, ISSO.MODULE_NAME + "_token"); // __tokenHeaderName = _moduleCfg.getString(TOKEN_HEADER_NAME, "X-ModuleSSO-Token"); // __tokenParamName = _moduleCfg.getString(TOKEN_PARAM_NAME, "token"); // __tokenMaxage = _moduleCfg.getInt(TOKEN_MAXAGE); // __tokenValidateTimeInterval = _moduleCfg.getInt(TOKEN_VALIDATE_TIME_INTERVAL); // __cacheNamePrefix = _moduleCfg.getString(CACHE_NAME_PREFIX); // __multiSessionEnabled = _moduleCfg.getBoolean(MULTI_SESSION_ENABLED); // __ipCheckEnabled = _moduleCfg.getBoolean(IP_CHECK_ENABLED); // __isClientMode = _moduleCfg.getBoolean(CLIENT_MODE); // __serviceAuthKey = _moduleCfg.getString(SERVICE_AUTH_KEY); // if (__isClientMode) { __serviceBaseUrl = StringUtils.trimToNull(_moduleCfg.getString(SERVICE_BASE_URL)); if (__serviceBaseUrl != null) { if (!StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "http://") && !StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "https://")) { throw new IllegalArgumentException("The parameter " + SERVICE_BASE_URL + " is invalid"); } else if (!StringUtils.endsWith(__serviceBaseUrl, "/")) { __serviceBaseUrl = __serviceBaseUrl + "/"; } } } // __tokenAdapter = _moduleCfg.getClassImpl(TOKEN_ADAPTER_CLASS, ISSOTokenAdapter.class); if (__tokenAdapter == null) { __tokenAdapter = new DefaultSSOTokenAdapter(); } // __tokenStorageAdapter = _moduleCfg.getClassImpl(STORAGE_ADAPTER_CLASS, ISSOTokenStorageAdapter.class); if (!__isClientMode && __tokenStorageAdapter == null) { throw new IllegalArgumentException("The parameter " + STORAGE_ADAPTER_CLASS + " is invalid"); } // if (!__isClientMode) { __tokenAttributeAdapter = _moduleCfg.getClassImpl(ATTRIBUTE_ADAPTER_CLASS, ISSOTokenAttributeAdapter.class); } }
From source file:net.ymate.module.webproxy.impl.DefaultModuleCfg.java
public DefaultModuleCfg(YMP owner) { Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(IWebProxy.MODULE_NAME); ////from www . jav a2 s.co m __serviceBaseUrl = _moduleCfgs.get("service_base_url"); if (StringUtils.isBlank(__serviceBaseUrl)) { throw new NullArgumentException("service_base_url"); } if (!StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "http://") && !StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "https://")) { throw new IllegalArgumentException("Argument service_base_url must be start with http or https"); } else if (StringUtils.endsWith(__serviceBaseUrl, "/")) { __serviceBaseUrl = StringUtils.substringBeforeLast(__serviceBaseUrl, "/"); } // __serviceRequestPrefix = StringUtils.trimToEmpty(_moduleCfgs.get("service_request_prefix")); if (StringUtils.isNotBlank(__serviceRequestPrefix) && !StringUtils.startsWith(__serviceRequestPrefix, "/")) { __serviceRequestPrefix = "/" + __serviceRequestPrefix; } // __useProxy = BlurObject.bind(_moduleCfgs.get("use_proxy")).toBooleanValue(); if (__useProxy) { Proxy.Type _proxyType = Proxy.Type .valueOf(StringUtils.defaultIfBlank(_moduleCfgs.get("proxy_type"), "HTTP").toUpperCase()); int _proxyPrort = BlurObject.bind(StringUtils.defaultIfBlank(_moduleCfgs.get("proxy_port"), "80")) .toIntValue(); String _proxyHost = _moduleCfgs.get("proxy_host"); if (StringUtils.isBlank(_proxyHost)) { throw new NullArgumentException("proxy_host"); } __proxy = new Proxy(_proxyType, new InetSocketAddress(_proxyHost, _proxyPrort)); } // __useCaches = BlurObject.bind(_moduleCfgs.get("use_caches")).toBooleanValue(); __instanceFollowRedirects = BlurObject.bind(_moduleCfgs.get("instance_follow_redirects")).toBooleanValue(); // __connectTimeout = BlurObject.bind(_moduleCfgs.get("connect_timeout")).toIntValue(); __readTimeout = BlurObject.bind(_moduleCfgs.get("read_timeout")).toIntValue(); // __transferBlackList = Arrays .asList(StringUtils.split(StringUtils.trimToEmpty(_moduleCfgs.get("transfer_blacklist")), "|")); // __transferHeaderEnabled = BlurObject.bind(_moduleCfgs.get("transfer_header_enabled")).toBooleanValue(); // if (__transferHeaderEnabled) { String[] _filters = StringUtils .split(StringUtils.lowerCase(_moduleCfgs.get("transfer_header_whitelist")), "|"); if (_filters != null && _filters.length > 0) { __transferHeaderWhiteList = Arrays.asList(_filters); } else { __transferHeaderWhiteList = Collections.emptyList(); } // _filters = StringUtils.split(StringUtils.lowerCase(_moduleCfgs.get("transfer_header_blacklist")), "|"); if (_filters != null && _filters.length > 0) { __transferHeaderBlackList = Arrays.asList(_filters); } else { __transferHeaderBlackList = Collections.emptyList(); } // _filters = StringUtils.split(StringUtils.lowerCase(_moduleCfgs.get("response_header_whitelist")), "|"); if (_filters != null && _filters.length > 0) { __responseHeaderWhiteList = Arrays.asList(_filters); } else { __responseHeaderWhiteList = Collections.emptyList(); } } else { __transferHeaderWhiteList = Collections.emptyList(); __transferHeaderBlackList = Collections.emptyList(); // __responseHeaderWhiteList = Collections.emptyList(); } }
From source file:net.ymate.module.webproxy.support.DispatchProxyFilter.java
private boolean __doMatchBlacklist(String requestMapping) { if (!__blacklist.isEmpty()) { if (__blacklist.contains(requestMapping)) { return true; } else {/*w w w .jav a 2 s . c o m*/ for (String _mapping : __blacklist) { if (StringUtils.endsWith(_mapping, "*")) { if (StringUtils.startsWith(requestMapping, StringUtils.substringBefore(_mapping, "*"))) { return true; } } } } } return false; }