List of usage examples for org.apache.commons.lang StringUtils deleteWhitespace
public static String deleteWhitespace(String str)
Deletes all whitespaces from a String as defined by Character#isWhitespace(char) .
From source file:org.sonar.plugins.csharp.dependency.results.DependencyResultParser.java
private Resource<?> getResource(String name, String version) { // try to find the project String projectKey = StringUtils.substringBefore(project.getParent().getKey(), ":") + ":" + StringUtils.deleteWhitespace(name); Resource<?> result = getProjectFromKey(project.getParent(), projectKey); // if not found in the solution, get the binary if (result == null) { Library library = new Library(name, version); library.setName(name + " " + version); result = context.getResource(library); // not already exists, save it if (result == null) { context.index(library);// w w w. ja v a 2s. c o m } result = library; } return result; }
From source file:org.sonar.scanner.scan.filesystem.CharsetValidationTest.java
private static byte[] hexToByte(String str) { String s = StringUtils.deleteWhitespace(str); int len = s.length(); byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16)); }/*from www . j a v a 2 s . com*/ return data; }
From source file:org.sonar.squid.recognizer.ContainsDetector.java
@Override public int scan(String line) { String lineWithoutWhitespaces = StringUtils.deleteWhitespace(line); int matchers = 0; for (String str : strs) { matchers += StringUtils.countMatches(lineWithoutWhitespaces, str); }/*from w ww .j av a 2 s .com*/ return matchers; }
From source file:org.webguitoolkit.ui.controls.form.ButtonBar.java
public void setButtons(String buttons) { if (StringUtils.isEmpty(buttons)) { throw new WGTException("button attribute of tag ButtonBar is not allowed to be empty"); }//from w ww. j a v a 2 s .c o m // remove any white space which might exist in the configuration string StringUtils.deleteWhitespace(buttons); setButtons(buttons.split(",")); }
From source file:org.wso2.carbon.appfactory.deployers.AbstractStratosDeployer.java
private void addToGitRepo(String fileName, File artifacts, Map metadata, String appTypeName, String serverDeploymentPath, String relativePathFragment, String tenantDomain, int tenantId) throws AppFactoryException { // subscribeOnDeployment is true or not boolean subscribeOnDeployment = Boolean.parseBoolean( DeployerUtil.getParameterValue(metadata, AppFactoryConstants.RUNTIME_SUBSCRIBE_ON_DEPLOYMENT)); String applicationId = DeployerUtil.getParameterValue(metadata, AppFactoryConstants.APPLICATION_ID); String version = DeployerUtil.getParameterValue(metadata, AppFactoryConstants.APPLICATION_VERSION); version = version.replaceAll("\\.+", AppFactoryConstants.MINUS); String gitRepoUrl = generateRepoUrl(applicationId, version, metadata, tenantId, appTypeName, subscribeOnDeployment);/*from w ww . j a v a2 s .c o m*/ String stageName = DeployerUtil.getParameterValue(metadata, AppFactoryConstants.DEPLOY_STAGE); String username = ((String[]) metadata.get("tenantUserName"))[0]; // if subscribeOnDeployment is true create a git repo per application if (subscribeOnDeployment) { if (log.isDebugEnabled()) { log.debug("SubscribeOnDeployment is true"); } SubscriptionHandler.getInstance().createSubscription(metadata, stageName, username, tenantId, applicationId + AppFactoryConstants.MINUS + version, tenantDomain); } else { if (log.isDebugEnabled()) { log.debug("SubscribeOnDeployment is false"); } } String applicationAdmin = getAdminUserName(); String defaultPassword = getAdminPassword(); // Create the temporary directory first. without this we can't proceed String path = getTempPath(tenantDomain) + File.separator + stageName + File.separator + StringUtils.deleteWhitespace(fileName).replaceAll("\\.", "_"); File tempApptypeDirectory = new File(path); synchronized (path) { log.info("====================Thread name:========" + Thread.currentThread().getName()); // <tempdir>/jaxrs, if (!tempApptypeDirectory.exists()) { if (!tempApptypeDirectory.mkdirs()) { String msg = "Unable to create temp directory : " + tempApptypeDirectory.getAbsolutePath(); handleException(msg); } } String appTypeDirectory = null; // if (serverDeploymentPath != null) { appTypeDirectory = tempApptypeDirectory.getAbsolutePath() + File.separator + serverDeploymentPath; // tempdir/<war>webapps // ,tempdir/jaggery/jaggeryapps, // //tempdir/esb/synapse-config } else { appTypeDirectory = tempApptypeDirectory.getAbsolutePath(); } String deployableFileName = null; if (StringUtils.isBlank(relativePathFragment)) { deployableFileName = appTypeDirectory + File.separator + fileName; // tempdir/webapps/myapp.war // , // tempdir/jappgeryapps/myapp.war } else { deployableFileName = appTypeDirectory + File.separator + relativePathFragment + File.separator + fileName; // <tempdir>/synapse-config/proxy-services/MyProxy.xml } if (log.isDebugEnabled()) { log.debug("Deployable file name to be git push:" + deployableFileName); } GitRepositoryClient repositoryClient = new GitRepositoryClient(new JGitAgent()); try { repositoryClient.init(applicationAdmin, defaultPassword); if (tempApptypeDirectory.isDirectory() && tempApptypeDirectory.list().length > 0) { try { FileUtils.cleanDirectory(tempApptypeDirectory); } catch (IOException e) { String msg = "Unable to clean the directory : " + tempApptypeDirectory.getAbsolutePath(); throw new AppFactoryException(msg, e); } // File[] filesToDelete = tempApptypeDirectory.listFiles(); // // if (filesToDelete != null) { // for (File fileToDelete : filesToDelete) { // try { // if (fileToDelete.isDirectory()) { // FileUtils.deleteDirectory(fileToDelete); // } else { // FileUtils.forceDelete(fileToDelete); // } // } catch (IOException e) { // String msg = "Unable to delete the file : " + fileToDelete.getAbsolutePath(); // throw new AppFactoryException(msg, e); // } // } // } repositoryClient.retireveMetadata(gitRepoUrl, false, tempApptypeDirectory); } else { // this means no files exists, so we straight away check out the // repo repositoryClient.retireveMetadata(gitRepoUrl, false, tempApptypeDirectory); } File deployableFile = new File(deployableFileName); if (!deployableFile.getParentFile().exists()) { log.debug("deployableFile.getParentFile() doesn't exist: " + deployableFile.getParentFile()); if (!deployableFile.getParentFile().mkdirs()) { String msg = "Unable to create parent path of the deployable file " + deployableFile.getAbsolutePath(); // unable to create <tempdir>/war/webapps, // <tempdir>/jaggery/jaggeryapps // or <tempdir>/esb/synapse-config/default/proxy-services handleException(msg); } } // If there is a file in repo, we delete it first if (deployableFile.exists()) { repositoryClient.delete(gitRepoUrl, deployableFile, "Removing the old file to add the new one", tempApptypeDirectory); // Checking and removing the local file if (deployableFile.exists()) { deployableFile.delete(); } // repositoryClient.checkIn(gitRepoUrl, applicationTempLocation, // "Removing the old file to add the new one"); try { deployableFile = new File(deployableFileName); // check weather directory exists. if (!deployableFile.getParentFile().isDirectory()) { log.debug("parent directory : " + deployableFile.getParentFile().getAbsolutePath() + " doesn't exits creating again"); if (!deployableFile.getParentFile().mkdirs()) { throw new IOException( "Unable to re-create " + deployableFile.getParentFile().getAbsolutePath()); } } if (artifacts.isFile()) { if (!deployableFile.createNewFile()) { throw new IOException( "unable re-create the target file : " + deployableFile.getAbsolutePath()); } if (deployableFile.canWrite()) { log.debug("Successfully re-created a writable file : " + deployableFileName); } else { String errorMsg = "re-created file is not writable: " + deployableFileName; log.error(errorMsg); throw new IOException(errorMsg); } } } catch (IOException e) { log.error("Unable to create the new file after deleting the old: " + deployableFile.getAbsolutePath(), e); throw new AppFactoryException(e); } } copyFilesToGit(artifacts, deployableFile); if (repositoryClient.add(gitRepoUrl, deployableFile, true, false, tempApptypeDirectory)) { if (repositoryClient.commitLocally("Adding the artifact to the repo", true, tempApptypeDirectory)) { if (!repositoryClient.pushLocalCommits(gitRepoUrl, AppFactoryConstants.MASTER, tempApptypeDirectory)) { String msg = "Unable to push local commits to git repo. Git repo URL : " + gitRepoUrl + "from local directory " + tempApptypeDirectory.getAbsolutePath(); handleException(msg); } } else { String msg = "Unable to commit files locally to location : " + tempApptypeDirectory.getAbsolutePath(); handleException(msg); } } else { String msg = "Unable to add file : " + deployableFile.getAbsolutePath() + " to git repo : " + gitRepoUrl; handleException(msg); } } catch (RepositoryMgtException e) { String msg = "Unable to add files to git location."; handleException(msg, e); } finally { if (tempApptypeDirectory.exists()) { try { FileUtils.cleanDirectory(tempApptypeDirectory); } catch (IOException e) { String msg = "Unable to clean the directory : " + tempApptypeDirectory.getAbsolutePath(); log.warn(msg, e); } } } } }
From source file:org.wso2.carbon.identity.workflow.impl.BPELDeployer.java
@Override public void initialize(List<Parameter> parameterList) throws WorkflowImplException { if (!validateParams(parameterList)) { throw new WorkflowRuntimeException("Workflow initialization failed, required parameter is missing"); }//w ww. j a v a 2s .c om Parameter wfNameParameter = WorkflowManagementUtil.getParameter(parameterList, WFConstant.ParameterName.WORKFLOW_NAME, WFConstant.ParameterHolder.WORKFLOW_IMPL); if (wfNameParameter != null) { processName = StringUtils.deleteWhitespace(wfNameParameter.getParamValue()); role = WorkflowManagementUtil .createWorkflowRoleName(StringUtils.deleteWhitespace(wfNameParameter.getParamValue())); } int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { tenantContext = "t/" + tenantDomain + "/"; } Parameter bpsProfileParameter = WorkflowManagementUtil.getParameter(parameterList, WFImplConstant.ParameterName.BPS_PROFILE, WFConstant.ParameterHolder.WORKFLOW_IMPL); if (bpsProfileParameter != null) { String bpsProfileName = bpsProfileParameter.getParamValue(); bpsProfile = WorkflowImplServiceDataHolder.getInstance().getWorkflowImplService() .getBPSProfile(bpsProfileName, tenantId); } htName = processName + BPELDeployer.Constants.HT_SUFFIX; generateAndDeployArtifacts(); }
From source file:org.wso2.carbon.identity.workflow.impl.RequestExecutor.java
private void callService(OMElement messagePayload) throws AxisFault { ServiceClient client = new ServiceClient(WorkflowImplServiceDataHolder.getInstance() .getConfigurationContextService().getClientConfigContext(), null); Options options = new Options(); options.setAction(WFImplConstant.DEFAULT_APPROVAL_BPEL_SOAP_ACTION); String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); String host = bpsProfile.getWorkerHostURL(); String serviceName = StringUtils.deleteWhitespace(WorkflowManagementUtil.getParameter(parameterList, WFConstant.ParameterName.WORKFLOW_NAME, WFConstant.ParameterHolder.WORKFLOW_IMPL).getParamValue()); serviceName = StringUtils.deleteWhitespace(serviceName); if (host.endsWith("/")) { host = host.substring(0, host.lastIndexOf("/")); }// ww w . j av a2 s .c o m String endpoint; if (tenantDomain != null && !tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { endpoint = host + "/services/t/" + tenantDomain + "/" + serviceName + WFConstant.TemplateConstants.SERVICE_SUFFIX; } else { endpoint = host + "/services/" + serviceName + WFConstant.TemplateConstants.SERVICE_SUFFIX; } options.setTo(new EndpointReference(endpoint)); options.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE, SOAP11Constants.SOAP_11_CONTENT_TYPE); HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator(); auth.setUsername(bpsProfile.getUsername()); auth.setPassword(bpsProfile.getPassword()); auth.setPreemptiveAuthentication(true); List<String> authSchemes = new ArrayList<>(); authSchemes.add(HttpTransportProperties.Authenticator.BASIC); auth.setAuthSchemes(authSchemes); options.setProperty(HTTPConstants.AUTHENTICATE, auth); options.setManageSession(true); client.setOptions(options); client.fireAndForget(messagePayload); }
From source file:org.wso2.carbon.identity.workflow.mgt.WorkflowManagementServiceImpl.java
@Override public void addWorkflow(Workflow workflow, List<Parameter> parameterList, int tenantId) throws WorkflowException { //TODO:Workspace Name may contain spaces , so we need to remove spaces and prepare process for that Parameter workflowNameParameter = new Parameter(workflow.getWorkflowId(), WFConstant.ParameterName.WORKFLOW_NAME, workflow.getWorkflowName(), WFConstant.ParameterName.WORKFLOW_NAME, WFConstant.ParameterHolder.WORKFLOW_IMPL); if (!parameterList.contains(workflowNameParameter)) { parameterList.add(workflowNameParameter); } else {//w ww . jav a2s . com workflowNameParameter = parameterList.get(parameterList.indexOf(workflowNameParameter)); } if (!workflowNameParameter.getParamValue().equals(workflow.getWorkflowName())) { workflowNameParameter.setParamValue(workflow.getWorkflowName()); //TODO:Since the user has changed the workflow name, we have to undeploy bpel package that is already // deployed using previous workflow name. } AbstractWorkflow abstractWorkflow = WorkflowServiceDataHolder.getInstance().getWorkflowImpls() .get(workflow.getTemplateId()).get(workflow.getWorkflowImplId()); //deploying the template abstractWorkflow.deploy(parameterList); //add workflow to the database if (workflowDAO.getWorkflow(workflow.getWorkflowId()) == null) { workflowDAO.addWorkflow(workflow, tenantId); WorkflowManagementUtil.createAppRole(StringUtils.deleteWhitespace(workflow.getWorkflowName())); } else { workflowDAO.removeWorkflowParams(workflow.getWorkflowId()); workflowDAO.updateWorkflow(workflow); } workflowDAO.addWorkflowParams(parameterList, workflow.getWorkflowId()); }
From source file:org.wso2.carbon.identity.workflow.mgt.WorkflowManagementServiceImpl.java
@Override public void removeWorkflow(String workflowId) throws WorkflowException { Workflow workflow = workflowDAO.getWorkflow(workflowId); //Deleting the role that is created for per workflow if (workflow != null) { List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance() .getWorkflowListenerList(); for (WorkflowListener workflowListener : workflowListenerList) { try { workflowListener.doPreDeleteWorkflow(workflow); } catch (WorkflowException e) { throw new WorkflowException( "Error occurred while calling doPreDeleteWorkflow in WorkflowListener ," + workflowListener.getClass().getName(), e);/*from w ww .j a va2s . c o m*/ } } WorkflowManagementUtil.deleteWorkflowRole(StringUtils.deleteWhitespace(workflow.getWorkflowName())); workflowDAO.removeWorkflowParams(workflowId); workflowDAO.removeWorkflow(workflowId); for (WorkflowListener workflowListener : workflowListenerList) { try { workflowListener.doPostDeleteWorkflow(workflow); } catch (WorkflowException e) { throw new WorkflowException( "Error occurred while calling doPreDeleteWorkflow in WorkflowListener ," + workflowListener.getClass().getName(), e); } } } }
From source file:org.xmlactions.mapping.validation.CompareElements.java
private boolean compareElementText(Element element1, Element element2) { String t1 = element1.getText(); String t2 = element2.getText(); // String t1 = element1.getStringValue(); // String t2 = element2.getStringValue(); if (isIgnoreWhitespace()) { t1 = StringUtils.deleteWhitespace(t1); t2 = StringUtils.deleteWhitespace(t2); }//from ww w.j a va2 s . c o m return t1.equals(t2); }