Package com.dotcms.repackage.com.sun.jersey.api.client

Examples of com.dotcms.repackage.com.sun.jersey.api.client.Client


      ClientConfig cc = new DefaultClientConfig();

      if(Config.getStringProperty("TRUSTSTORE_PATH") != null && !Config.getStringProperty("TRUSTSTORE_PATH").trim().equals("")) {
        cc.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(tFactory.getHostnameVerifier(), tFactory.getSSLContext()));
            }
      Client client = Client.create(cc);

      //Updating audit table
      currentStatusHistory = pubAuditAPI.getPublishAuditStatus(config.getId()).getStatusPojo();

      currentStatusHistory.setPublishStart(new Date());
      pubAuditAPI.updatePublishAuditStatus(config.getId(), PublishAuditStatus.Status.SENDING_TO_ENDPOINTS, currentStatusHistory);
      //Increment numTries
      currentStatusHistory.addNumTries();


//          boolean hasError = false;
          int errorCounter = 0;

      for (Environment environment : environments) {
        List<PublishingEndPoint> endpoints = APILocator.getPublisherEndPointAPI().findSendingEndPointsByEnvironment(environment.getId());

        boolean failedEnvironment = false;

        if(!environment.getPushToAll()) {
          Collections.shuffle(endpoints);
          if(!endpoints.isEmpty())
            endpoints = endpoints.subList(0, 1);
        }

        for (PublishingEndPoint endpoint : endpoints) {
          EndpointDetail detail = new EndpointDetail();
              try {
                FormDataMultiPart form = new FormDataMultiPart();
                form.field("AUTH_TOKEN",
                    retriveKeyString(
                        PublicEncryptionFactory.decryptString(endpoint.getAuthKey().toString())));

                form.field("GROUP_ID", UtilMethods.isSet(endpoint.getGroupId()) ? endpoint.getGroupId() : endpoint.getId());
                Bundle b=APILocator.getBundleAPI().getBundleById(config.getId());
                form.field("BUNDLE_NAME", b.getName());
                form.field("ENDPOINT_ID", endpoint.getId());
                form.bodyPart(new FileDataBodyPart("bundle", bundle, MediaType.MULTIPART_FORM_DATA_TYPE));


                //Sending bundle to endpoint
                WebResource resource = client.resource(endpoint.toURL()+"/api/bundlePublisher/publish");

                ClientResponse response =
                    resource.type(MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);

View Full Code Here


    if(Config.getStringProperty("TRUSTSTORE_PATH") != null && !Config.getStringProperty("TRUSTSTORE_PATH").trim().equals("")) {
        clientConfig.getProperties()
        .put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(tFactory.getHostnameVerifier(), tFactory.getSSLContext()));
    }
        Client client = Client.create(clientConfig);
        WebResource webResource;

        List<PublishAuditStatus> pendingAudits = pubAuditAPI.getPendingPublishAuditStatus();

        //Foreach Bundle
        for(PublishAuditStatus pendingAudit: pendingAudits) {
          //Gets groups list
          PublishAuditHistory localHistory = pendingAudit.getStatusPojo();

          Map<String, Map<String, EndpointDetail>> endpointsMap = localHistory.getEndpointsMap();
          Map<String, EndpointDetail> endpointsGroup = null;

          Map<String, Map<String, EndpointDetail>> bufferMap = new HashMap<String, Map<String, EndpointDetail>>();
          //Foreach Group
          for(String group : endpointsMap.keySet()) {
            endpointsGroup = endpointsMap.get(group);

            //Foreach endpoint
            for(String endpointId: endpointsGroup.keySet()) {
              EndpointDetail localDetail = endpointsGroup.get(endpointId);

              if(localDetail.getStatus() != PublishAuditStatus.Status.SUCCESS.getCode() &&
                localDetail.getStatus() != PublishAuditStatus.Status.FAILED_TO_PUBLISH.getCode()) {

                PublishingEndPoint target = endpointAPI.findEndPointById(endpointId);

                if(target != null && !target.isSending()) {
                  webResource = client.resource(target.toURL()+"/api/auditPublishing");

                  try {
                    PublishAuditHistory remoteHistory =
                        PublishAuditHistory.getObjectFromString(
                        webResource
View Full Code Here

    assertTrue( success );
    assertTrue( newBundleFile.exists() );

    //Prepare the post request
    ClientConfig cc = new DefaultClientConfig();
    Client client = Client.create( cc );

    FormDataMultiPart form = new FormDataMultiPart();
    form.field( "AUTH_TOKEN", PublicEncryptionFactory.encryptString( (PublicEncryptionFactory.decryptString( receivingFromEndpoint.getAuthKey().toString() )) ) );
    form.field( "GROUP_ID", UtilMethods.isSet( receivingFromEndpoint.getGroupId() ) ? receivingFromEndpoint.getGroupId() : receivingFromEndpoint.getId() );
    form.field( "BUNDLE_NAME", bundle.getName() );
    form.field( "ENDPOINT_ID", receivingFromEndpoint.getId() );
    form.bodyPart( new FileDataBodyPart( "bundle", newBundleFile, MediaType.MULTIPART_FORM_DATA_TYPE ) );

    //Sending bundle to endpoint
    WebResource resource = client.resource( receivingFromEndpoint.toURL() + "/api/bundlePublisher/publish" );
    ClientResponse clientResponse = resource.type( MediaType.MULTIPART_FORM_DATA ).post( ClientResponse.class, form );
    //Validations
    assertEquals( clientResponse.getClientResponseStatus().getStatusCode(), HttpStatus.SC_OK );

    //Get current status dates
View Full Code Here

    /*
     * Prepare the post request
     */
    ClientConfig cc = new DefaultClientConfig();
    Client client = Client.create( cc );

    FormDataMultiPart form = new FormDataMultiPart();
    form.field( "AUTH_TOKEN", PublicEncryptionFactory.encryptString( (PublicEncryptionFactory.decryptString( receivingFromEndpoint.getAuthKey().toString() )) ) );
    form.field( "GROUP_ID", UtilMethods.isSet( receivingFromEndpoint.getGroupId() ) ? receivingFromEndpoint.getGroupId() : receivingFromEndpoint.getId() );
    form.field( "BUNDLE_NAME", bundle.getName() );
View Full Code Here

        try {

            //Setting the process status
            setStatus( request, endpointId, ProcessStatus.PROCESSING );

            final Client client = getRESTClient();

            final PublishingEndPoint endpoint = APILocator.getPublisherEndPointAPI().findEndPointById(endpointId);
            final String authToken = PushPublisher.retriveKeyString(PublicEncryptionFactory.decryptString(endpoint.getAuthKey().toString()));

            FormDataMultiPart form = new FormDataMultiPart();
            form.field("AUTH_TOKEN",authToken);

            //Sending bundle to endpoint
            String url = endpoint.toURL()+"/api/integrity/generateintegritydata/";
            com.dotcms.repackage.com.sun.jersey.api.client.WebResource resource = client.resource(url);

            ClientResponse response =
                    resource.type(MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);

            if(response.getClientResponseStatus().getStatusCode() == HttpStatus.SC_OK) {
                final String integrityDataRequestID = response.getEntity(String.class);

                Thread integrityDataRequestChecker = new Thread() {
                    public void run(){

                        FormDataMultiPart form = new FormDataMultiPart();
                        form.field("AUTH_TOKEN",authToken);
                        form.field("REQUEST_ID",integrityDataRequestID);

                        String url = endpoint.toURL()+"/api/integrity/getintegritydata/";
                        com.dotcms.repackage.com.sun.jersey.api.client.WebResource resource = client.resource(url);

                        boolean processing = true;

                        while(processing) {
View Full Code Here

                    FormDataMultiPart form = new FormDataMultiPart();
                    form.field( "AUTH_TOKEN", authToken );
                    form.field( "REQUEST_ID", integrityDataRequestId );

                    //Prepare the connection
                    Client client = getRESTClient();
                    String url = endpoint.toURL() + "/api/integrity/cancelIntegrityProcessOnEndpoint/";
                    com.dotcms.repackage.com.sun.jersey.api.client.WebResource resource = client.resource( url );

                    //Execute the call
                    ClientResponse response = resource.type( MediaType.MULTIPART_FORM_DATA ).post( ClientResponse.class, form );

                    if ( response.getClientResponseStatus().getStatusCode() == HttpStatus.SC_OK ) {
View Full Code Here

                clearStatus( request, endpointId );

            } else  if(whereToFix.equals("remote")) {
                integrityUtil.generateDataToFixZip(endpointId, IntegrityType.valueOf(type.toUpperCase()));

                final Client client = getRESTClient();

                PublishingEndPoint endpoint = APILocator.getPublisherEndPointAPI().findEndPointById(endpointId);
                String outputPath = ConfigUtils.getIntegrityPath() + File.separator + endpointId;
                File bundle = new File(outputPath + File.separator + INTEGRITY_DATA_TO_FIX_ZIP_FILE_NAME);

                FormDataMultiPart form = new FormDataMultiPart();
                form.field("AUTH_TOKEN",
                        PushPublisher.retriveKeyString(
                                PublicEncryptionFactory.decryptString(endpoint.getAuthKey().toString())));

                form.field("TYPE", type);
                form.bodyPart(new FileDataBodyPart("DATA_TO_FIX", bundle, MediaType.MULTIPART_FORM_DATA_TYPE));

                String url = endpoint.toURL()+"/api/integrity/fixconflictsfromremote/";
                com.dotcms.repackage.com.sun.jersey.api.client.WebResource resource = client.resource(url);

                ClientResponse response = resource.type(MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);

                if(response.getClientResponseStatus().getStatusCode() == HttpStatus.SC_OK) {
                    jsonResponse.put( "success", true );
View Full Code Here

        ClientConfig cc = new DefaultClientConfig();

        if(Config.getStringProperty("TRUSTSTORE_PATH") != null && !Config.getStringProperty("TRUSTSTORE_PATH").trim().equals("")) {
            cc.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(tFactory.getHostnameVerifier(), tFactory.getSSLContext()));
        }
        final Client client = Client.create(cc);
        return client;
    }
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.com.sun.jersey.api.client.Client

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.