Package com.dotcms.publisher.business

Examples of com.dotcms.publisher.business.EndpointDetail


          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);


                if(response.getClientResponseStatus().getStatusCode() == HttpStatus.SC_OK)
                {
                  detail.setStatus(PublishAuditStatus.Status.BUNDLE_SENT_SUCCESSFULLY.getCode());
                  detail.setInfo("Everything ok");
                } else {

                  if(currentStatusHistory.getNumTries()==PublisherQueueJob.MAX_NUM_TRIES) {
                    APILocator.getPushedAssetsAPI().deletePushedAssets(config.getId(), environment.getId());
                  }
                  detail.setStatus(PublishAuditStatus.Status.FAILED_TO_SENT.getCode());
                  detail.setInfo(
                      "Returned "+response.getClientResponseStatus().getStatusCode()+ " status code " +
                          "for the endpoint "+endpoint.getId()+ "with address "+endpoint.getAddress());
                  failedEnvironment |= true;

                }
              } catch(Exception e) {

                // if the bundle can't be sent after the total num of tries, delete the pushed assets for this bundle
                if(currentStatusHistory.getNumTries()==PublisherQueueJob.MAX_NUM_TRIES) {
                  APILocator.getPushedAssetsAPI().deletePushedAssets(config.getId(), environment.getId());
                }
//                hasError = true;
                detail.setStatus(PublishAuditStatus.Status.FAILED_TO_SENT.getCode());

                String error =   "An error occured for the endpoint "+ endpoint.getId() + " with address "+ endpoint.getAddress() + ".  Error: " + e.getMessage();


                detail.setInfo(error);
                failedEnvironment |= true;

                Logger.error(this.getClass(), error);
              }
View Full Code Here

TOP

Related Classes of com.dotcms.publisher.business.EndpointDetail

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.