//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) {
ClientResponse response = resource.type( MediaType.MULTIPART_FORM_DATA ).post( ClientResponse.class, form );
if ( response.getClientResponseStatus() != null && response.getClientResponseStatus().getStatusCode() == HttpStatus.SC_OK ) {
processing = false;
InputStream zipFile = response.getEntityInputStream();
String outputDir = ConfigUtils.getIntegrityPath() + File.separator + endpoint.getId();
try {
IntegrityUtil.unzipFile(zipFile, outputDir);