Java Code Examples for org.apache.http.client.methods.HttpPost#setURI()

The following examples show how to use org.apache.http.client.methods.HttpPost#setURI() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WineryConnector.java    From container with Apache License 2.0 5 votes vote down vote up
private String uploadCSARToWinery(final File file, final boolean overwrite) throws URISyntaxException, IOException {
    final MultipartEntityBuilder builder = MultipartEntityBuilder.create();

    final ContentBody fileBody = new FileBody(file);
    final ContentBody overwriteBody = new StringBody(String.valueOf(overwrite), ContentType.TEXT_PLAIN);
    final FormBodyPart filePart = FormBodyPartBuilder.create("file", fileBody).build();
    final FormBodyPart overwritePart = FormBodyPartBuilder.create("overwrite", overwriteBody).build();
    builder.addPart(filePart);
    builder.addPart(overwritePart);

    final HttpEntity entity = builder.build();

    final HttpPost wineryPost = new HttpPost();

    wineryPost.setURI(new URI(this.wineryPath));
    wineryPost.setEntity(entity);

    try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
        final CloseableHttpResponse wineryResp = httpClient.execute(wineryPost);
        String location = getHeaderValue(wineryResp, HttpHeaders.LOCATION);
        wineryResp.close();

        if (Objects.nonNull(location) && location.endsWith("/")) {
            location = location.substring(0, location.length() - 1);
        }
        return location;
    } catch (final IOException e) {
        LOG.error("Exception while uploading CSAR to the Container Repository: ", e);
        return "";
    }
}
 
Example 2
Source File: RestRequest.java    From TurkcellUpdater_android_sdk with Apache License 2.0 5 votes vote down vote up
private HttpPost createHttpPostRequest() throws Exception {
	final HttpPost result = new HttpPost();
	result.setURI(getUri());
	appendHeaders(result);
	result.setEntity(getRequestContents());
	return result;
}
 
Example 3
Source File: LDAPManager.java    From pacbot with Apache License 2.0 4 votes vote down vote up
/**
 * This method used to get the Kernel Version of an instance.
 * 
 * @param instanceId
 * @return String, if kernel version available else null
 */

public static String getQueryfromLdapElasticSearch(String instanceId,
        String ldapApi) {
    JsonParser jsonParser = new JsonParser();
    JsonArray jsonArray = new JsonArray();

    try {
        HttpClient client = HttpClientBuilder.create().build();

        URL url = new URL(ldapApi);
        URI uri = new URI(url.getProtocol(), url.getUserInfo(),
                url.getHost(), url.getPort(), url.getPath(),
                url.getQuery(), url.getRef());

        // prepare Json pay load for GET query.
        JsonObject innerJson = new JsonObject();
        JsonObject matchPhrase = new JsonObject();
        JsonObject must = new JsonObject();
        JsonObject bool = new JsonObject();
        JsonObject query = new JsonObject();

        innerJson.addProperty("instanceid", instanceId);
        matchPhrase.add("match_phrase", innerJson);
        must.add("must", matchPhrase);
        bool.add("bool", must);
        query.add("query", bool);
        StringEntity strjson = new StringEntity(query.toString());

        // Qurying the ES
        HttpPost httpPost = new HttpPost();
        httpPost.setURI(uri);
        httpPost.setEntity(strjson);
        httpPost.setHeader("Content-Type", "application/json");
        HttpResponse response = client.execute(httpPost);

        String jsonString = EntityUtils.toString(response.getEntity());
        JsonObject resultJson = (JsonObject) jsonParser.parse(jsonString);
        String hitsJsonString = resultJson.get("hits").toString();
        JsonObject hitsJson = (JsonObject) jsonParser.parse(hitsJsonString);
        jsonArray = hitsJson.getAsJsonObject().get("hits").getAsJsonArray();
        if (jsonArray.size() > 0) {
            JsonObject firstObject = (JsonObject) jsonArray.get(0);
            JsonObject sourceJson = (JsonObject) firstObject.get("_source");
            if (sourceJson != null) {
                JsonElement osVersion = sourceJson.get("os_version");
                if (osVersion != null) {
                    return getKernelVersion(osVersion);
                }
            }
        } else {
            logger.info("no records found in ElasticSearch");
        }
    } catch (MalformedURLException me) {
        logger.error(me.getMessage());
    } catch (UnsupportedEncodingException ue) {
        logger.error(ue.getMessage());
    } catch (ClientProtocolException ce) {
        logger.error(ce.getMessage());
    } catch (IOException ioe) {
        logger.error(ioe.getMessage());
    } catch (URISyntaxException use) {
        logger.error(use.getMessage());
    }

    return null;
}
 
Example 4
Source File: SpacewalkAndSatelliteManager.java    From pacbot with Apache License 2.0 4 votes vote down vote up
/**
 * This method used to get the Kernel Version of an instance.
 * 
 * @param instanceId
 * @return String, if kernel version available else null
 */

public static String getQueryfromRhnElasticSearch(String instanceId,
        String satAndSpacewalkApi) {
    JsonParser jsonParser = new JsonParser();
    JsonArray jsonArray = new JsonArray();

    try {
        HttpClient client = HttpClientBuilder.create().build();

        URL url = new URL(satAndSpacewalkApi);
        URI uri = new URI(url.getProtocol(), url.getUserInfo(),
                url.getHost(), url.getPort(), url.getPath(),
                url.getQuery(), url.getRef());

        // prepare Json pay load for GET query.
        JsonObject innerJson = new JsonObject();
        JsonObject matchPhrase = new JsonObject();
        JsonObject must = new JsonObject();
        JsonObject bool = new JsonObject();
        JsonObject query = new JsonObject();

        innerJson.addProperty("instanceid", instanceId);
        matchPhrase.add("match_phrase", innerJson);
        must.add("must", matchPhrase);
        bool.add("bool", must);
        query.add("query", bool);
        StringEntity strjson = new StringEntity(query.toString());

        // Qurying the ES
        HttpPost httpPost = new HttpPost();
        httpPost.setURI(uri);
        httpPost.setEntity(strjson);
        httpPost.setHeader("Content-Type", "application/json");
        HttpResponse response = client.execute(httpPost);

        String jsonString = EntityUtils.toString(response.getEntity());
        JsonObject resultJson = (JsonObject) jsonParser.parse(jsonString);
        String hitsJsonString = resultJson.get("hits").toString();
        JsonObject hitsJson = (JsonObject) jsonParser.parse(hitsJsonString);
        jsonArray = hitsJson.getAsJsonObject().get("hits").getAsJsonArray();
        if (jsonArray.size() > 0) {
            JsonObject firstObject = (JsonObject) jsonArray.get(0);
            JsonObject sourceJson = (JsonObject) firstObject.get("_source");
            if (sourceJson != null) {
                JsonElement osVersion = sourceJson.get("kernelid");
                if (osVersion != null) {
                    return osVersion.toString().substring(1,
                            osVersion.toString().length() - 1);
                }
            }
        } else {
            logger.info("no records found in ElasticSearch");
        }
    } catch (MalformedURLException me) {
        logger.error(me.getMessage());
    } catch (UnsupportedEncodingException ue) {
        logger.error(ue.getMessage());
    } catch (ClientProtocolException ce) {
        logger.error(ce.getMessage());
    } catch (IOException ioe) {
        logger.error(ioe.getMessage());
    } catch (URISyntaxException use) {
        logger.error(use.getMessage());
    }

    return null;
}
 
Example 5
Source File: PacmanUtils.java    From pacbot with Apache License 2.0 4 votes vote down vote up
public static boolean isGuardDutyFindingsExists(String id, String esUrl, String attribute) {
    JsonParser jsonParser = new JsonParser();

    try {
        HttpClient client = HttpClientBuilder.create().build();

        URL url = new URL(esUrl);
        URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(),
                url.getQuery(), url.getRef());

        // prepare Json pay load for GET query.
        JsonObject innerJson = new JsonObject();
        JsonObject matchPhrase = new JsonObject();
        JsonObject must = new JsonObject();
        JsonObject bool = new JsonObject();
        JsonObject query = new JsonObject();

        innerJson.addProperty(attribute, id);
        matchPhrase.add(PacmanRuleConstants.MATCH_PHRASE, innerJson);
        must.add("must", matchPhrase);
        bool.add("bool", must);
        query.add(PacmanRuleConstants.QUERY, bool);
        StringEntity strjson = new StringEntity(query.toString());

        // Qurying the ES
        HttpPost httpPost = new HttpPost();
        httpPost.setURI(uri);
        httpPost.setEntity(strjson);
        httpPost.setHeader(PacmanRuleConstants.CONTENT_TYPE, PacmanRuleConstants.APPLICATION_JSON);
        HttpResponse response = client.execute(httpPost);

        String jsonString = EntityUtils.toString(response.getEntity());
        JsonObject resultJson = (JsonObject) jsonParser.parse(jsonString);
        String hitsJsonString = resultJson.get(PacmanRuleConstants.HITS).toString();
        JsonObject hitsJson = (JsonObject) jsonParser.parse(hitsJsonString);
        if (hitsJson != null) {
            JsonElement total = hitsJson.getAsJsonObject().get(PacmanRuleConstants.TOTAL);
            if (total.getAsInt() > 0) {
                return true;
            } else {
                logger.info("no records found in ElasticSearch");
            }
        }
    } catch (Exception me) {
        logger.error(me.getMessage());
    }

    return false;
}
 
Example 6
Source File: PacmanUtils.java    From pacbot with Apache License 2.0 4 votes vote down vote up
public static Map<String, String> getSeviceLimit(String id, String accountId, String esUrl) {
    JsonParser jsonParser = new JsonParser();
    JsonArray jsonArray = new JsonArray();
    Map<String, String> data = new HashMap<>();
    try {
        HttpClient client = HttpClientBuilder.create().build();

        URL url = new URL(esUrl);
        URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(),
                url.getQuery(), url.getRef());

        // prepare Json pay load for GET query.
        JsonObject innerJson = new JsonObject();
        JsonObject innerJson1 = new JsonObject();
        JsonObject matchPhrase = new JsonObject();
        JsonObject matchPhrase1 = new JsonObject();
        JsonObject mustObj = new JsonObject();
        JsonArray mustArray = new JsonArray();
        JsonObject bool = new JsonObject();
        JsonObject query = new JsonObject();

        innerJson.addProperty(PacmanRuleConstants.CHECK_ID_KEYWORD, id);
        innerJson1.addProperty(PacmanRuleConstants.ACCOUNTID, accountId);
        matchPhrase.add("match", innerJson);
        matchPhrase1.add("match", innerJson1);
        mustArray.add(matchPhrase);
        mustArray.add(matchPhrase1);
        mustObj.add("must", mustArray);
        bool.add("bool", mustObj);
        query.add(PacmanRuleConstants.QUERY, bool);
        StringEntity strjson = new StringEntity(query.toString());

        // Qurying the ES
        HttpPost httpPost = new HttpPost();
        httpPost.setURI(uri);
        httpPost.setEntity(strjson);
        httpPost.setHeader(PacmanRuleConstants.CONTENT_TYPE, PacmanRuleConstants.APPLICATION_JSON);
        HttpResponse response = client.execute(httpPost);

        String jsonString = EntityUtils.toString(response.getEntity());
        JsonObject resultJson = (JsonObject) jsonParser.parse(jsonString);
        String hitsJsonString = resultJson.get(PacmanRuleConstants.HITS).toString();
        JsonObject hitsJson = (JsonObject) jsonParser.parse(hitsJsonString);
        jsonArray = hitsJson.getAsJsonObject().get(PacmanRuleConstants.HITS).getAsJsonArray();
        if (jsonArray.size() > 0) {

            for (int i = 0; i < jsonArray.size(); i++) {
                JsonObject firstObject = (JsonObject) jsonArray.get(i);
                JsonObject sourceJson = (JsonObject) firstObject.get(PacmanRuleConstants.SOURCE);
                if (sourceJson != null) {
                    String resourceinfo = sourceJson.get(PacmanRuleConstants.RESOURCE_INFO).getAsString();
                    JsonObject resourceinfoJson = (JsonObject) jsonParser.parse(resourceinfo);
                    String service = resourceinfoJson.get("Service").getAsString();
                    String status = resourceinfoJson.get(PacmanRuleConstants.STATUS_CAP).getAsString();
                    String cUsage = resourceinfoJson.get("Current Usage").getAsString();
                    String lAmount = resourceinfoJson.get("Limit Amount").getAsString();

                    if (cUsage != null && lAmount != null && !"null".equalsIgnoreCase(cUsage)
                            && !"null".equalsIgnoreCase(lAmount)) {
                        Double percentage = (Double.parseDouble(cUsage) / Double.parseDouble(lAmount)) * 100;
                        if (percentage >= 80 && status.equalsIgnoreCase(PacmanRuleConstants.STATUS_RED)) {
                            data.put(service, percentage.toString());
                            data.put("status_" + status, "RED");
                        } else if (percentage >= 80 && status.equalsIgnoreCase(PacmanRuleConstants.STATUS_YELLOW)) {
                            data.put(service, percentage.toString());
                        }
                    }
                }
            }
        }
    } catch (Exception me) {
        logger.error(me.getMessage());
    }

    return data;
}
 
Example 7
Source File: PacmanUtils.java    From pacbot with Apache License 2.0 4 votes vote down vote up
public static List<String> getVolumeIdFromElasticSearch(String id, String esUrl, String attributeName) {
    JsonParser jsonParser = new JsonParser();
    List<String> volList = new ArrayList<>();
    try {
        HttpClient client = HttpClientBuilder.create().build();

        URL url = new URL(esUrl);
        URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(),
                url.getQuery(), url.getRef());

        // prepare Json pay load for GET query.
        JsonObject innerJson = new JsonObject();
        JsonObject matchPhrase = new JsonObject();
        JsonObject must = new JsonObject();
        JsonObject bool = new JsonObject();
        JsonObject query = new JsonObject();

        innerJson.addProperty(attributeName, id);
        matchPhrase.add(PacmanRuleConstants.MATCH_PHRASE, innerJson);
        must.add("must", matchPhrase);
        bool.add("bool", must);
        query.add(PacmanRuleConstants.QUERY, bool);
        StringEntity strjson = new StringEntity(query.toString());

        // Qurying the ES
        HttpPost httpPost = new HttpPost();
        httpPost.setURI(uri);
        httpPost.setEntity(strjson);
        httpPost.setHeader(PacmanRuleConstants.CONTENT_TYPE, PacmanRuleConstants.APPLICATION_JSON);
        HttpResponse response = client.execute(httpPost);

        String jsonString = EntityUtils.toString(response.getEntity());
        JsonObject resultJson = (JsonObject) jsonParser.parse(jsonString);
        String hitsJsonString = resultJson.get(PacmanRuleConstants.HITS).toString();
        JsonObject hitsJson = (JsonObject) jsonParser.parse(hitsJsonString);
        JsonArray jsonArray = hitsJson.getAsJsonObject().get(PacmanRuleConstants.HITS).getAsJsonArray();
        volList = getVolumeList(jsonArray);
    } catch (Exception me) {
        logger.error(me.getMessage());
    }

    return volList;
}
 
Example 8
Source File: PacmanUtils.java    From pacbot with Apache License 2.0 4 votes vote down vote up
public static Map<String, Boolean> getQueryFromElasticSearch(String securityGroupId,
        List<String> serviceWithSgEsUrl, String esUrlParam) {
    JsonParser jsonParser = new JsonParser();
    Map<String, Boolean> instanceMap = new HashMap<>();
    String securityGroupAttribute = null;
    String servicesWithSgurl = null;
    for (String esUrl : serviceWithSgEsUrl) {
        servicesWithSgurl = esUrlParam + esUrl;
        if (esUrl.contains("ec2") || esUrl.contains("lambda") || esUrl.contains("appelb")
                || esUrl.contains("classicelb")) {
            securityGroupAttribute = PacmanRuleConstants.EC2_WITH_SECURITYGROUP_ID;
        } else {
            securityGroupAttribute = PacmanRuleConstants.SECURITYGROUP_ID_ATTRIBUTE;
        }

        try {
            HttpClient client = HttpClientBuilder.create().build();

            URL url = new URL(servicesWithSgurl);
            URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(),
                    url.getQuery(), url.getRef());

            // prepare Json pay load for GET query.
            JsonObject innerJson = new JsonObject();
            JsonObject matchPhrase = new JsonObject();
            JsonObject must = new JsonObject();
            JsonObject bool = new JsonObject();
            JsonObject query = new JsonObject();

            innerJson.addProperty(securityGroupAttribute, securityGroupId);
            matchPhrase.add(PacmanRuleConstants.MATCH_PHRASE, innerJson);
            must.add("must", matchPhrase);
            bool.add("bool", must);
            query.add(PacmanRuleConstants.QUERY, bool);
            StringEntity strjson = new StringEntity(query.toString());

            // Qurying the ES
            HttpPost httpPost = new HttpPost();
            httpPost.setURI(uri);
            httpPost.setEntity(strjson);
            httpPost.setHeader(PacmanRuleConstants.CONTENT_TYPE, PacmanRuleConstants.APPLICATION_JSON);
            HttpResponse response = client.execute(httpPost);
            instanceMap = getInstanceMap(response, jsonParser, instanceMap, esUrl);
        } catch (Exception me) {
            logger.error(me.getMessage());
        }
    }
    return instanceMap;
}
 
Example 9
Source File: PacmanUtils.java    From pacbot with Apache License 2.0 4 votes vote down vote up
private static JsonArray getAppTagInfoFromES(String appId, String esUrl, String attributeName) {
    JsonParser jsonParser = new JsonParser();
    JsonArray jsonArray = new JsonArray();
    try {
        HttpClient client = HttpClientBuilder.create().build();

        URL url = new URL(esUrl);
        URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(),
                url.getQuery(), url.getRef());
        // prepare Json pay load for GET query.
        JsonObject innerJson = new JsonObject();
        JsonObject matchPhrase = new JsonObject();
        JsonObject must = new JsonObject();
        JsonObject bool = new JsonObject();
        JsonObject query = new JsonObject();

        innerJson.addProperty(attributeName, appId);
        matchPhrase.add(PacmanRuleConstants.MATCH_PHRASE, innerJson);
        must.add("must", matchPhrase);
        bool.add("bool", must);
        query.add(PacmanRuleConstants.QUERY, bool);
        StringEntity strjson = new StringEntity(query.toString());

        // Qurying the ES
        HttpPost httpPost = new HttpPost();
        httpPost.setURI(uri);
        httpPost.setEntity(strjson);
        httpPost.setHeader(PacmanRuleConstants.CONTENT_TYPE, PacmanRuleConstants.APPLICATION_JSON);
        HttpResponse response = client.execute(httpPost);

        String jsonString = EntityUtils.toString(response.getEntity());
        JsonObject resultJson = (JsonObject) jsonParser.parse(jsonString);
        String hitsJsonString = resultJson.get(PacmanRuleConstants.HITS).toString();
        JsonObject hitsJson = (JsonObject) jsonParser.parse(hitsJsonString);
        jsonArray = hitsJson.getAsJsonObject().get(PacmanRuleConstants.HITS).getAsJsonArray();

    } catch (Exception me) {
        logger.error(me.getMessage());
    }
    return jsonArray;
}
 
Example 10
Source File: RecaptchaService.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public CaptchaResult checkCaptcha ( final HttpServletRequest request )
{
    final String key = getRecaptcheSecretKey ();
    if ( key == null )
    {
        return CaptchaResult.OK;
    }

    final String value = request.getParameter ( "g-recaptcha-response" );
    if ( value == null || value.isEmpty () )
    {
        return CaptchaResult.errorResult ( "No captcha response" );
    }

    final HttpPost post = new HttpPost ();
    post.setURI ( SITE_VERIFY_URI );

    try
    {

        final List<NameValuePair> params = new ArrayList<NameValuePair> ( 2 );
        params.add ( new BasicNameValuePair ( "secret", key ) );
        params.add ( new BasicNameValuePair ( "response", value ) );
        post.setEntity ( new UrlEncodedFormEntity ( params, "UTF-8" ) );

        try ( final CloseableHttpResponse result = this.client.execute ( post ) )
        {
            final HttpEntity ent = result.getEntity ();
            if ( ent == null )
            {
                return CaptchaResult.errorResult ( "No response from captcha service" );
            }

            try ( Reader r = new InputStreamReader ( ent.getContent (), StandardCharsets.UTF_8 ) )
            {
                final String str = CharStreams.toString ( r );

                final Gson g = makeGson ();
                final Response response = g.fromJson ( str, Response.class );

                if ( response.isSuccess () )
                {
                    return CaptchaResult.OK;
                }
                else
                {
                    return CaptchaResult.errorResult ( response.getErrorCodes () );
                }
            }
        }
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to check captcha", e );
        return CaptchaResult.exceptionResult ( e );
    }
}
 
Example 11
Source File: WineryConnector.java    From container with Apache License 2.0 4 votes vote down vote up
public QName createServiceTemplateFromXaaSPackage(final File file, final QName artifactType,
                                                  final Set<QName> nodeTypes, final QName infrastructureNodeType,
                                                  final Map<String, String> tags) throws URISyntaxException,
    IOException {
    final MultipartEntityBuilder builder = MultipartEntityBuilder.create();

    // file
    final ContentBody fileBody = new FileBody(file);
    final FormBodyPart filePart = FormBodyPartBuilder.create("file", fileBody).build();
    builder.addPart(filePart);

    // artefactType
    final ContentBody artefactTypeBody = new StringBody(artifactType.toString(), ContentType.TEXT_PLAIN);
    final FormBodyPart artefactTypePart = FormBodyPartBuilder.create("artefactType", artefactTypeBody).build();
    builder.addPart(artefactTypePart);

    // nodeTypes
    if (!nodeTypes.isEmpty()) {
        String nodeTypesAsString = "";
        for (final QName nodeType : nodeTypes) {
            nodeTypesAsString += nodeType.toString() + ",";
        }

        final ContentBody nodeTypesBody =
            new StringBody(nodeTypesAsString.substring(0, nodeTypesAsString.length() - 1), ContentType.TEXT_PLAIN);
        final FormBodyPart nodeTypesPart = FormBodyPartBuilder.create("nodeTypes", nodeTypesBody).build();
        builder.addPart(nodeTypesPart);
    }

    // infrastructureNodeType
    if (infrastructureNodeType != null) {
        final ContentBody infrastructureNodeTypeBody =
            new StringBody(infrastructureNodeType.toString(), ContentType.TEXT_PLAIN);
        final FormBodyPart infrastructureNodeTypePart =
            FormBodyPartBuilder.create("infrastructureNodeType", infrastructureNodeTypeBody).build();
        builder.addPart(infrastructureNodeTypePart);
    }

    // tags
    if (!tags.isEmpty()) {
        String tagsString = "";
        for (final String key : tags.keySet()) {
            if (tags.get(key) == null) {
                tagsString += key + ",";
            } else {
                tagsString += key + ":" + tags.get(key) + ",";
            }
        }

        final ContentBody tagsBody =
            new StringBody(tagsString.substring(0, tagsString.length() - 1), ContentType.TEXT_PLAIN);
        final FormBodyPart tagsPart = FormBodyPartBuilder.create("tags", tagsBody).build();
        builder.addPart(tagsPart);
    }

    try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
        // POST to XaaSPackager
        final HttpPost xaasPOST = new HttpPost();
        xaasPOST.setURI(new URI(this.wineryPath + "servicetemplates/"));
        xaasPOST.setEntity(builder.build());
        final CloseableHttpResponse xaasResp = httpClient.execute(xaasPOST);
        xaasResp.close();

        // create QName of the created serviceTemplate resource
        String location = getHeaderValue(xaasResp, HttpHeaders.LOCATION);

        if (location.endsWith("/")) {
            location = location.substring(0, location.length() - 1);
        }

        final String localPart = getLastPathFragment(location);
        final String namespaceDblEnc = getLastPathFragment(location.substring(0, location.lastIndexOf("/")));
        final String namespace = URLDecoder.decode(URLDecoder.decode(namespaceDblEnc));

        return new QName(namespace, localPart);
    } catch (final IOException e) {
        LOG.error("Exception while calling Xaas packager: ", e);
        return null;
    }
}