Example usage for java.util.regex Pattern matches

List of usage examples for java.util.regex Pattern matches

Introduction

In this page you can find the example usage for java.util.regex Pattern matches.

Prototype

public static boolean matches(String regex, CharSequence input) 

Source Link

Document

Compiles the given regular expression and attempts to match the given input against it.

Usage

From source file:jp.primecloud.auto.service.impl.LoadBalancerServiceImpl.java

/**
 * {@inheritDoc}//from  w w w.j  a v a2 s  . c  o m
 */
@Override
public Long createAwsLoadBalancer(Long farmNo, String loadBalancerName, String comment, Long platformNo,
        Long componentNo, boolean internal) {
    // ?
    if (farmNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "farmNo");
    }
    if (loadBalancerName == null || loadBalancerName.length() == 0) {
        throw new AutoApplicationException("ECOMMON-000003", "loadBalancerName");
    }
    if (platformNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "platformNo");
    }
    if (componentNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "componentNo");
    }

    // ??
    if (!Pattern.matches("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", loadBalancerName)) {
        throw new AutoApplicationException("ECOMMON-000012", "loadBalancerName");
    }

    // TODO: ??

    // ??
    Platform platform = platformDao.read(platformNo);
    if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType()) == false) {
        throw new AutoApplicationException("ESERVICE-000606", platformNo);
    }

    // ??
    Image image = null;
    List<Image> images = imageDao.readAll();
    for (Image image2 : images) {
        if (image2.getPlatformNo().equals(platformNo.longValue())
                && PCCConstant.IMAGE_NAME_ELB.equals(image2.getImageName())) {
            image = image2;
            break;
        }
    }
    if (image == null) {
        // aws?????
        throw new AutoApplicationException("ESERVICE-000631", platformNo);
    }

    // ??????
    LoadBalancer checkLoadBalancer = loadBalancerDao.readByFarmNoAndLoadBalancerName(farmNo, loadBalancerName);
    if (checkLoadBalancer != null) {
        // ????????
        throw new AutoApplicationException("ESERVICE-000601", loadBalancerName);
    }

    // ????
    Instance checkInstance = instanceDao.readByFarmNoAndInstanceName(farmNo, loadBalancerName);
    if (checkInstance != null) {
        // ???????
        throw new AutoApplicationException("ESERVICE-000626", loadBalancerName);
    }

    // ??
    Farm farm = farmDao.read(farmNo);
    if (farm == null) {
        throw new AutoApplicationException("ESERVICE-000602", farmNo);
    }

    // ????
    long countComponent = componentDao.countByComponentNo(componentNo);
    if (countComponent == 0) {
        // ???????
        throw new AutoApplicationException("ESERVICE-000607", componentNo);
    }

    //AWS???
    AwsCertificate awsCertificate = awsCertificateDao.read(farm.getUserNo(), platformNo);

    //?()??
    PlatformAws platformAws = platformAwsDao.read(platformNo);
    String subnetId = null;
    String availabilityZone = null;
    if (platformAws.getVpc() && StringUtils.isNotEmpty(awsCertificate.getDefLbSubnet())) {
        //VPC ?? ?(?)???
        List<String> defLbSubnets = new ArrayList<String>();
        for (String lbSubnet : awsCertificate.getDefLbSubnet().split(",")) {
            defLbSubnets.add(lbSubnet.trim());
        }
        List<String> zones = new ArrayList<String>();
        StringBuffer subnetBuffer = new StringBuffer();
        StringBuffer zoneBuffer = new StringBuffer();
        List<SubnetDto> subnetDtos = iaasDescribeService.getSubnets(farm.getUserNo(), platformNo,
                platformAws.getVpcId());
        for (SubnetDto subnetDto : subnetDtos) {
            if (defLbSubnets.contains(subnetDto.getSubnetId())
                    && zones.contains(subnetDto.getZoneid()) == false) {
                subnetBuffer.append(
                        subnetBuffer.length() > 0 ? "," + subnetDto.getSubnetId() : subnetDto.getSubnetId());
                zoneBuffer
                        .append(zoneBuffer.length() > 0 ? "," + subnetDto.getZoneid() : subnetDto.getZoneid());
                zones.add(subnetDto.getZoneid());
            }
        }
        //??
        subnetId = subnetBuffer.toString();
        availabilityZone = zoneBuffer.toString();
    }

    //??
    String groupName = null;
    if (platformAws.getVpc()) {
        //VPC??
        List<SecurityGroupDto> securityGroupDtos = iaasDescribeService.getSecurityGroups(farm.getUserNo(),
                platformNo, platformAws.getVpcId());
        for (SecurityGroupDto securityGroupDto : securityGroupDtos) {
            if ("default".equals(securityGroupDto.getGroupName())) {
                //default?????default?
                groupName = securityGroupDto.getGroupName();
                break;
            }
        }
        if (groupName == null && securityGroupDtos.size() > 0) {
            //default????1
            groupName = securityGroupDtos.get(0).getGroupName();
        }
    }

    // ???
    LoadBalancer loadBalancer = new LoadBalancer();
    loadBalancer.setFarmNo(farmNo);
    loadBalancer.setLoadBalancerName(loadBalancerName);
    loadBalancer.setComment(comment);
    loadBalancer.setFqdn(loadBalancerName + "." + farm.getDomainName());
    loadBalancer.setPlatformNo(platformNo);
    loadBalancer.setType(PCCConstant.LOAD_BALANCER_ELB);
    loadBalancer.setEnabled(false);
    loadBalancer.setStatus(LoadBalancerStatus.STOPPED.toString());
    loadBalancer.setComponentNo(componentNo);
    loadBalancerDao.create(loadBalancer);

    Long loadBalancerNo = loadBalancer.getLoadBalancerNo();

    // AWS???
    AwsLoadBalancer awsLoadBalancer = new AwsLoadBalancer();
    awsLoadBalancer.setLoadBalancerNo(loadBalancerNo);
    awsLoadBalancer.setName(loadBalancerName + "-" + loadBalancerNo);
    awsLoadBalancer.setDnsName(null);
    awsLoadBalancer.setSubnetId(subnetId);
    awsLoadBalancer.setSecurityGroups(groupName);
    awsLoadBalancer.setAvailabilityZone(availabilityZone);
    awsLoadBalancer.setInternal(internal);
    awsLoadBalancerDao.create(awsLoadBalancer);

    // ???
    createDefaultHealthCheck(loadBalancer);

    // ??
    createDefaultAutoScalingConf(loadBalancer);

    // ??
    registerInstances(loadBalancer);

    // ??
    Boolean useZabbix = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useZabbix"));
    if (BooleanUtils.isTrue(useZabbix)) {
        elbZabbixHostProcess.createElbHostgroup(loadBalancerNo);
    }

    // 
    eventLogger.log(EventLogLevel.INFO, farmNo, farm.getFarmName(), null, null, null, null,
            "LoadBalancerCreate", null, null,
            new Object[] { loadBalancerName, platform.getPlatformName(), PCCConstant.LOAD_BALANCER_ELB });

    return loadBalancerNo;
}

From source file:eu.eidas.node.auth.connector.AUCONNECTORSAML.java

private void checkIdentifierFormat(IAuthenticationResponse authnResponse) throws InternalErrorEIDASException {
    String patterEidentifier = "^[A-Z]{2}/[A-Z]{2}/[A-Za-z0-9+/=\r\n]+$";
    if (authnResponse.getAttributes() != null) {
        ImmutableSet personIdentifier = authnResponse.getAttributes().getAttributeValuesByNameUri(
                EidasSpec.Definitions.PERSON_IDENTIFIER.getNameUri().toASCIIString());
        if (personIdentifier != null && !personIdentifier.isEmpty()) {
            if (!Pattern.matches(patterEidentifier,
                    ((StringAttributeValue) personIdentifier.iterator().next()).getValue())) {
                throw new InternalErrorEIDASException(EidasErrorKey.COLLEAGUE_RESP_INVALID_SAML.errorCode(),
                        "Person Identifier has an invalid format.");
            }/*w  w  w . j a v a  2 s  . c  om*/
        }
        ImmutableSet legalPersonIdentifier = authnResponse.getAttributes().getAttributeValuesByNameUri(
                EidasSpec.Definitions.LEGAL_PERSON_IDENTIFIER.getNameUri().toASCIIString());
        if (legalPersonIdentifier != null && !legalPersonIdentifier.isEmpty()) {
            if (!Pattern.matches(patterEidentifier,
                    ((StringAttributeValue) legalPersonIdentifier.iterator().next()).getValue())) {
                throw new InternalErrorEIDASException(EidasErrorKey.COLLEAGUE_RESP_INVALID_SAML.errorCode(),
                        "Legal person Identifier has an invalid format.");
            }

        }
    }

}

From source file:com.microfocus.application.automation.tools.octane.configuration.JobConfigurationProxy.java

@JavaScriptMethod
public JSONObject searchReleases(String term, String instanceId, long workspaceId) {
    int defaultSize = 5;
    JSONObject ret = new JSONObject();
    OctaneClient octaneClient = OctaneSDK.getClientByInstanceId(instanceId);

    try {/*  w  ww .ja  v  a2s  . c  om*/

        ResponseEntityList releasePagedList = queryReleasesByName(octaneClient, term, workspaceId, defaultSize);
        List<Entity> releases = releasePagedList.getData();
        boolean moreResults = releasePagedList.getTotalCount() > releases.size();

        JSONArray retArray = new JSONArray();
        if (moreResults) {
            retArray.add(createMoreResultsJson());
        }

        String quotedTerm = Pattern.quote(term.toLowerCase());
        if (Pattern.matches(".*" + quotedTerm + ".*", NOT_SPECIFIED.toLowerCase())) {
            JSONObject notSpecifiedItemJson = new JSONObject();
            notSpecifiedItemJson.put("id", -1);
            notSpecifiedItemJson.put("text", NOT_SPECIFIED);
            retArray.add(notSpecifiedItemJson);
        }

        for (Entity release : releases) {
            JSONObject relJson = new JSONObject();
            relJson.put("id", release.getId());
            relJson.put("text", release.getName());
            retArray.add(relJson);
        }
        ret.put("results", retArray);

    } catch (Exception e) {
        logger.warn("Failed to retrieve releases", e);
        return error("Unable to retrieve releases");
    }

    return ret;
}

From source file:org.dasein.cloud.aws.storage.S3Method.java

private boolean isValidDomainName(String bucket) {
    return (bucket != null && Pattern.matches("^[a-z0-9](-*[a-z0-9]){2,62}$", bucket));
}

From source file:com.microsoft.azure.management.resources.DeploymentOperationsImpl.java

/**
* Create a named template deployment using a template.
*
* @param resourceGroupName Required. The name of the resource group. The
* name is case insensitive.//from w  w  w  . java2s . c  o m
* @param deploymentName Required. The name of the deployment.
* @param parameters Required. Additional parameters supplied to the
* operation.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @throws URISyntaxException Thrown if there was an error parsing a URI in
* the response.
* @return Template deployment operation create result.
*/
@Override
public DeploymentOperationsCreateResult createOrUpdate(String resourceGroupName, String deploymentName,
        Deployment parameters) throws IOException, ServiceException, URISyntaxException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (resourceGroupName != null && resourceGroupName.length() > 1000) {
        throw new IllegalArgumentException("resourceGroupName");
    }
    if (Pattern.matches("^[-\\w\\._]+$", resourceGroupName) == false) {
        throw new IllegalArgumentException("resourceGroupName");
    }
    if (deploymentName == null) {
        throw new NullPointerException("deploymentName");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getProperties() != null) {
        if (parameters.getProperties().getParametersLink() != null) {
            if (parameters.getProperties().getParametersLink().getUri() == null) {
                throw new NullPointerException("parameters.Properties.ParametersLink.Uri");
            }
        }
        if (parameters.getProperties().getTemplateLink() != null) {
            if (parameters.getProperties().getTemplateLink().getUri() == null) {
                throw new NullPointerException("parameters.Properties.TemplateLink.Uri");
            }
        }
    }

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        tracingParameters.put("resourceGroupName", resourceGroupName);
        tracingParameters.put("deploymentName", deploymentName);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "createOrUpdateAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/subscriptions/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/resourcegroups/";
    url = url + URLEncoder.encode(resourceGroupName, "UTF-8");
    url = url + "/deployments/";
    url = url + URLEncoder.encode(deploymentName, "UTF-8");
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2014-04-01-preview");
    if (queryParameters.size() > 0) {
        url = url + "?" + CollectionStringBuilder.join(queryParameters, "&");
    }
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    HttpPut httpRequest = new HttpPut(url);

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/json; charset=utf-8");

    // Serialize Request
    String requestContent = null;
    JsonNode requestDoc = null;

    ObjectMapper objectMapper = new ObjectMapper();
    ObjectNode deploymentValue = objectMapper.createObjectNode();
    requestDoc = deploymentValue;

    if (parameters.getProperties() != null) {
        ObjectNode propertiesValue = objectMapper.createObjectNode();
        ((ObjectNode) deploymentValue).put("properties", propertiesValue);

        if (parameters.getProperties().getTemplate() != null) {
            ((ObjectNode) propertiesValue).put("template",
                    objectMapper.readTree(parameters.getProperties().getTemplate()));
        }

        if (parameters.getProperties().getTemplateLink() != null) {
            ObjectNode templateLinkValue = objectMapper.createObjectNode();
            ((ObjectNode) propertiesValue).put("templateLink", templateLinkValue);

            ((ObjectNode) templateLinkValue).put("uri",
                    parameters.getProperties().getTemplateLink().getUri().toString());

            if (parameters.getProperties().getTemplateLink().getContentVersion() != null) {
                ((ObjectNode) templateLinkValue).put("contentVersion",
                        parameters.getProperties().getTemplateLink().getContentVersion());
            }
        }

        if (parameters.getProperties().getParameters() != null) {
            ((ObjectNode) propertiesValue).put("parameters",
                    objectMapper.readTree(parameters.getProperties().getParameters()));
        }

        if (parameters.getProperties().getParametersLink() != null) {
            ObjectNode parametersLinkValue = objectMapper.createObjectNode();
            ((ObjectNode) propertiesValue).put("parametersLink", parametersLinkValue);

            ((ObjectNode) parametersLinkValue).put("uri",
                    parameters.getProperties().getParametersLink().getUri().toString());

            if (parameters.getProperties().getParametersLink().getContentVersion() != null) {
                ((ObjectNode) parametersLinkValue).put("contentVersion",
                        parameters.getProperties().getParametersLink().getContentVersion());
            }
        }

        if (parameters.getProperties().getMode() != null) {
            ((ObjectNode) propertiesValue).put("mode", parameters.getProperties().getMode().toString());
        }
    }

    StringWriter stringWriter = new StringWriter();
    objectMapper.writeValue(stringWriter, requestDoc);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/json; charset=utf-8");

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED) {
            ServiceException ex = ServiceException.createFromJson(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        DeploymentOperationsCreateResult result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new DeploymentOperationsCreateResult();
            JsonNode responseDoc = null;
            String responseDocContent = IOUtils.toString(responseContent);
            if (responseDocContent == null == false && responseDocContent.length() > 0) {
                responseDoc = objectMapper.readTree(responseDocContent);
            }

            if (responseDoc != null && responseDoc instanceof NullNode == false) {
                DeploymentExtended deploymentInstance = new DeploymentExtended();
                result.setDeployment(deploymentInstance);

                JsonNode idValue = responseDoc.get("id");
                if (idValue != null && idValue instanceof NullNode == false) {
                    String idInstance;
                    idInstance = idValue.getTextValue();
                    deploymentInstance.setId(idInstance);
                }

                JsonNode nameValue = responseDoc.get("name");
                if (nameValue != null && nameValue instanceof NullNode == false) {
                    String nameInstance;
                    nameInstance = nameValue.getTextValue();
                    deploymentInstance.setName(nameInstance);
                }

                JsonNode propertiesValue2 = responseDoc.get("properties");
                if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) {
                    DeploymentPropertiesExtended propertiesInstance = new DeploymentPropertiesExtended();
                    deploymentInstance.setProperties(propertiesInstance);

                    JsonNode provisioningStateValue = propertiesValue2.get("provisioningState");
                    if (provisioningStateValue != null && provisioningStateValue instanceof NullNode == false) {
                        String provisioningStateInstance;
                        provisioningStateInstance = provisioningStateValue.getTextValue();
                        propertiesInstance.setProvisioningState(provisioningStateInstance);
                    }

                    JsonNode correlationIdValue = propertiesValue2.get("correlationId");
                    if (correlationIdValue != null && correlationIdValue instanceof NullNode == false) {
                        String correlationIdInstance;
                        correlationIdInstance = correlationIdValue.getTextValue();
                        propertiesInstance.setCorrelationId(correlationIdInstance);
                    }

                    JsonNode timestampValue = propertiesValue2.get("timestamp");
                    if (timestampValue != null && timestampValue instanceof NullNode == false) {
                        Calendar timestampInstance;
                        timestampInstance = DatatypeConverter.parseDateTime(timestampValue.getTextValue());
                        propertiesInstance.setTimestamp(timestampInstance);
                    }

                    JsonNode outputsValue = propertiesValue2.get("outputs");
                    if (outputsValue != null && outputsValue instanceof NullNode == false) {
                        String outputsInstance;
                        outputsInstance = outputsValue.getTextValue();
                        propertiesInstance.setOutputs(outputsInstance);
                    }

                    JsonNode providersArray = propertiesValue2.get("providers");
                    if (providersArray != null && providersArray instanceof NullNode == false) {
                        for (JsonNode providersValue : ((ArrayNode) providersArray)) {
                            Provider providerInstance = new Provider();
                            propertiesInstance.getProviders().add(providerInstance);

                            JsonNode idValue2 = providersValue.get("id");
                            if (idValue2 != null && idValue2 instanceof NullNode == false) {
                                String idInstance2;
                                idInstance2 = idValue2.getTextValue();
                                providerInstance.setId(idInstance2);
                            }

                            JsonNode namespaceValue = providersValue.get("namespace");
                            if (namespaceValue != null && namespaceValue instanceof NullNode == false) {
                                String namespaceInstance;
                                namespaceInstance = namespaceValue.getTextValue();
                                providerInstance.setNamespace(namespaceInstance);
                            }

                            JsonNode registrationStateValue = providersValue.get("registrationState");
                            if (registrationStateValue != null
                                    && registrationStateValue instanceof NullNode == false) {
                                String registrationStateInstance;
                                registrationStateInstance = registrationStateValue.getTextValue();
                                providerInstance.setRegistrationState(registrationStateInstance);
                            }

                            JsonNode resourceTypesArray = providersValue.get("resourceTypes");
                            if (resourceTypesArray != null && resourceTypesArray instanceof NullNode == false) {
                                for (JsonNode resourceTypesValue : ((ArrayNode) resourceTypesArray)) {
                                    ProviderResourceType providerResourceTypeInstance = new ProviderResourceType();
                                    providerInstance.getResourceTypes().add(providerResourceTypeInstance);

                                    JsonNode resourceTypeValue = resourceTypesValue.get("resourceType");
                                    if (resourceTypeValue != null
                                            && resourceTypeValue instanceof NullNode == false) {
                                        String resourceTypeInstance;
                                        resourceTypeInstance = resourceTypeValue.getTextValue();
                                        providerResourceTypeInstance.setName(resourceTypeInstance);
                                    }

                                    JsonNode locationsArray = resourceTypesValue.get("locations");
                                    if (locationsArray != null && locationsArray instanceof NullNode == false) {
                                        for (JsonNode locationsValue : ((ArrayNode) locationsArray)) {
                                            providerResourceTypeInstance.getLocations()
                                                    .add(locationsValue.getTextValue());
                                        }
                                    }

                                    JsonNode apiVersionsArray = resourceTypesValue.get("apiVersions");
                                    if (apiVersionsArray != null
                                            && apiVersionsArray instanceof NullNode == false) {
                                        for (JsonNode apiVersionsValue : ((ArrayNode) apiVersionsArray)) {
                                            providerResourceTypeInstance.getApiVersions()
                                                    .add(apiVersionsValue.getTextValue());
                                        }
                                    }

                                    JsonNode propertiesSequenceElement = ((JsonNode) resourceTypesValue
                                            .get("properties"));
                                    if (propertiesSequenceElement != null
                                            && propertiesSequenceElement instanceof NullNode == false) {
                                        Iterator<Map.Entry<String, JsonNode>> itr = propertiesSequenceElement
                                                .getFields();
                                        while (itr.hasNext()) {
                                            Map.Entry<String, JsonNode> property = itr.next();
                                            String propertiesKey = property.getKey();
                                            String propertiesValue3 = property.getValue().getTextValue();
                                            providerResourceTypeInstance.getProperties().put(propertiesKey,
                                                    propertiesValue3);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    JsonNode dependenciesArray = propertiesValue2.get("dependencies");
                    if (dependenciesArray != null && dependenciesArray instanceof NullNode == false) {
                        for (JsonNode dependenciesValue : ((ArrayNode) dependenciesArray)) {
                            Dependency dependencyInstance = new Dependency();
                            propertiesInstance.getDependencies().add(dependencyInstance);

                            JsonNode dependsOnArray = dependenciesValue.get("dependsOn");
                            if (dependsOnArray != null && dependsOnArray instanceof NullNode == false) {
                                for (JsonNode dependsOnValue : ((ArrayNode) dependsOnArray)) {
                                    BasicDependency basicDependencyInstance = new BasicDependency();
                                    dependencyInstance.getDependsOn().add(basicDependencyInstance);

                                    JsonNode idValue3 = dependsOnValue.get("id");
                                    if (idValue3 != null && idValue3 instanceof NullNode == false) {
                                        String idInstance3;
                                        idInstance3 = idValue3.getTextValue();
                                        basicDependencyInstance.setId(idInstance3);
                                    }

                                    JsonNode resourceTypeValue2 = dependsOnValue.get("resourceType");
                                    if (resourceTypeValue2 != null
                                            && resourceTypeValue2 instanceof NullNode == false) {
                                        String resourceTypeInstance2;
                                        resourceTypeInstance2 = resourceTypeValue2.getTextValue();
                                        basicDependencyInstance.setResourceType(resourceTypeInstance2);
                                    }

                                    JsonNode resourceNameValue = dependsOnValue.get("resourceName");
                                    if (resourceNameValue != null
                                            && resourceNameValue instanceof NullNode == false) {
                                        String resourceNameInstance;
                                        resourceNameInstance = resourceNameValue.getTextValue();
                                        basicDependencyInstance.setResourceName(resourceNameInstance);
                                    }
                                }
                            }

                            JsonNode idValue4 = dependenciesValue.get("id");
                            if (idValue4 != null && idValue4 instanceof NullNode == false) {
                                String idInstance4;
                                idInstance4 = idValue4.getTextValue();
                                dependencyInstance.setId(idInstance4);
                            }

                            JsonNode resourceTypeValue3 = dependenciesValue.get("resourceType");
                            if (resourceTypeValue3 != null && resourceTypeValue3 instanceof NullNode == false) {
                                String resourceTypeInstance3;
                                resourceTypeInstance3 = resourceTypeValue3.getTextValue();
                                dependencyInstance.setResourceType(resourceTypeInstance3);
                            }

                            JsonNode resourceNameValue2 = dependenciesValue.get("resourceName");
                            if (resourceNameValue2 != null && resourceNameValue2 instanceof NullNode == false) {
                                String resourceNameInstance2;
                                resourceNameInstance2 = resourceNameValue2.getTextValue();
                                dependencyInstance.setResourceName(resourceNameInstance2);
                            }
                        }
                    }

                    JsonNode templateValue = propertiesValue2.get("template");
                    if (templateValue != null && templateValue instanceof NullNode == false) {
                        String templateInstance;
                        templateInstance = templateValue.getTextValue();
                        propertiesInstance.setTemplate(templateInstance);
                    }

                    JsonNode templateLinkValue2 = propertiesValue2.get("templateLink");
                    if (templateLinkValue2 != null && templateLinkValue2 instanceof NullNode == false) {
                        TemplateLink templateLinkInstance = new TemplateLink();
                        propertiesInstance.setTemplateLink(templateLinkInstance);

                        JsonNode uriValue = templateLinkValue2.get("uri");
                        if (uriValue != null && uriValue instanceof NullNode == false) {
                            URI uriInstance;
                            uriInstance = new URI(uriValue.getTextValue());
                            templateLinkInstance.setUri(uriInstance);
                        }

                        JsonNode contentVersionValue = templateLinkValue2.get("contentVersion");
                        if (contentVersionValue != null && contentVersionValue instanceof NullNode == false) {
                            String contentVersionInstance;
                            contentVersionInstance = contentVersionValue.getTextValue();
                            templateLinkInstance.setContentVersion(contentVersionInstance);
                        }
                    }

                    JsonNode parametersValue = propertiesValue2.get("parameters");
                    if (parametersValue != null && parametersValue instanceof NullNode == false) {
                        String parametersInstance;
                        parametersInstance = parametersValue.getTextValue();
                        propertiesInstance.setParameters(parametersInstance);
                    }

                    JsonNode parametersLinkValue2 = propertiesValue2.get("parametersLink");
                    if (parametersLinkValue2 != null && parametersLinkValue2 instanceof NullNode == false) {
                        ParametersLink parametersLinkInstance = new ParametersLink();
                        propertiesInstance.setParametersLink(parametersLinkInstance);

                        JsonNode uriValue2 = parametersLinkValue2.get("uri");
                        if (uriValue2 != null && uriValue2 instanceof NullNode == false) {
                            URI uriInstance2;
                            uriInstance2 = new URI(uriValue2.getTextValue());
                            parametersLinkInstance.setUri(uriInstance2);
                        }

                        JsonNode contentVersionValue2 = parametersLinkValue2.get("contentVersion");
                        if (contentVersionValue2 != null && contentVersionValue2 instanceof NullNode == false) {
                            String contentVersionInstance2;
                            contentVersionInstance2 = contentVersionValue2.getTextValue();
                            parametersLinkInstance.setContentVersion(contentVersionInstance2);
                        }
                    }

                    JsonNode modeValue = propertiesValue2.get("mode");
                    if (modeValue != null && modeValue instanceof NullNode == false) {
                        DeploymentMode modeInstance;
                        modeInstance = Enum.valueOf(DeploymentMode.class, modeValue.getTextValue());
                        propertiesInstance.setMode(modeInstance);
                    }
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

From source file:net.spfbl.spf.SPF.java

/**
 * Verifica se o whois  um mecanismo all vlido.
 *
 * @param token o whois a ser verificado.
 * @return verdadeiro se o whois  um mecanismo all vlido.
 *///w  w w  .  ja va  2  s.  c o  m
private static boolean isMechanismAll(String token) {
    return Pattern.matches("^(\\+|-|~|\\?)?all$", token.toLowerCase());
}

From source file:net.spfbl.spf.SPF.java

/**
 * Verifica se o whois  um mecanismo ip4 vlido.
 *
 * @param token o whois a ser verificado.
 * @return verdadeiro se o whois  um mecanismo ip4 vlido.
 *//*from  w  ww.  j  a va  2s .  co  m*/
private static boolean isMechanismIPv4(String token) {
    return Pattern.matches(
            "^((\\+|-|~|\\?)?ipv?4?:)?" + "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}"
                    + "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])" + "(/[0-9]{1,2})?" + "$",
            token.toLowerCase());
}

From source file:com.fiorano.openesb.application.application.Route.java

/**
 * Converts to new DMI/*from  w  ww  .  j ava 2  s.co  m*/
 * @param that old Route DMI
 */
public void convert(com.fiorano.openesb.application.aps.Route that) {

    name = that.getRouteGUID();
    if (!Pattern.matches("([a-zA-Z0-9_]+)", name)) {
        StringBuffer nameBuff = new StringBuffer(name);
        for (int i = 0; i < nameBuff.length(); i++) {
            if (!Pattern.matches("([a-zA-Z0-9_]+)", String.valueOf(nameBuff.charAt(i)))) {
                nameBuff.setCharAt(i, '_');
            }
        }
        name = nameBuff.toString();
    }

    sourceServiceInstance = that.getSrcServInst();
    sourcePortInstance = that.getSrcPortName();

    targetServiceInstance = that.getTrgtServInst();
    targetPortInstance = that.getTrgtPortName();

    shortDescription = that.getShortDescription();
    longDescription = that.getLongDescription();
    durable = that.isDurable();

    if (!StringUtils.isEmpty(that.getTransformationXSL())
            || !StringUtils.isEmpty(that.getMessageTransformationXSL())) {
        messageTransformation = new MessageTransformation();
        messageTransformation.convert(that);
    }
    Iterator iter = that.getSelectors().entrySet().iterator();
    while (iter.hasNext()) {
        Map.Entry entry = (Map.Entry) iter.next();
        String type = (String) entry.getKey();
        if (com.fiorano.openesb.application.aps.Route.JMS_SELECTOR.equalsIgnoreCase(type))
            selectors.put(SELECTOR_JMS, entry.getValue());
        else if (com.fiorano.openesb.application.aps.Route.SENDER_SELECTOR.equalsIgnoreCase(type))
            selectors.put(SELECTOR_SENDER, entry.getValue());
        else {
            XPathSelector selector = new XPathSelector();
            if (entry.getValue() instanceof XPathDmi)
                selector.convert((XPathDmi) entry.getValue());
            else
                selector.setXPath((String) entry.getValue());
            selectors.put(com.fiorano.openesb.application.aps.Route.APP_CONTEXT_XPATH.equalsIgnoreCase(type)
                    ? SELECTOR_APPLICATION_CONTEXT
                    : SELECTOR_BODY, selector);
        }
    }
}

From source file:com.enonic.vertical.adminweb.handlers.xmlbuilders.SimpleContentXMLBuilder.java

private String[] getFormItemsByRegexp(String regex, ExtendedMap formItems) {

    int count = 0;
    for (Object key : formItems.keySet()) {
        String keyStr = (String) key;
        if (Pattern.matches(regex, keyStr)) {
            count++;//from   w ww  .  ja  v  a2 s .c om
        }

    }

    String[] entries = new String[count];

    for (Object key : formItems.keySet()) {
        String keyStr = (String) key;
        if (Pattern.matches(regex, keyStr)) {
            int index = formItems.getInt(keyStr + ":index");
            entries[index] = keyStr;
        }

    }

    return entries;

}

From source file:net.spfbl.spf.SPF.java

/**
 * Verifica se o whois  um mecanismo ip6 vlido.
 *
 * @param token o whois a ser verificado.
 * @return verdadeiro se o whois  um mecanismo ip6 vlido.
 *///from  ww  w . j  a  va 2  s  .  co m
private static boolean isMechanismIPv6(String token) {
    return Pattern.matches("^((\\+|-|~|\\?)?ipv?6?:)?" + "((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|"
            + "(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|" + "((25[0-5]|2[0-4]d|1dd|[1-9]?d)"
            + "(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|"
            + "(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:" + "((25[0-5]|2[0-4]d|1dd|[1-9]?d)"
            + "(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|"
            + "(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|"
            + "((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)"
            + "(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|"
            + "(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|"
            + "((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)"
            + "(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|"
            + "(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|"
            + "((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)"
            + "(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|"
            + "(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|"
            + "((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)"
            + "(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|" + "(:(((:[0-9A-Fa-f]{1,4}){1,7})|"
            + "((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)"
            + "(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))" + "(%.+)?(\\/[0-9]{1,3})?" + "$", token);
}