Examples of PublishingEndPoint


Examples of com.dotcms.publisher.endpoint.bean.PublishingEndPoint

            //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);
View Full Code Here

Examples of com.dotcms.publisher.endpoint.bean.PublishingEndPoint

                    //Get the thread associated to this endpoint and the integrity request id
                    Thread runningThread = (Thread) session.getAttribute( "integrityThread_" + endpointId );
                    String integrityDataRequestId = (String) session.getAttribute( "integrityDataRequest_" + endpointId );

                    //Find the registered auth token in order to connect to the end point server
                    PublishingEndPoint endpoint = APILocator.getPublisherEndPointAPI().findEndPointById( endpointId );
                    String authToken = PushPublisher.retriveKeyString( PublicEncryptionFactory.decryptString( endpoint.getAuthKey().toString() ) );

                    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 );
View Full Code Here

Examples of com.dotcms.publisher.endpoint.bean.PublishingEndPoint

                remoteIP = request.getRemoteAddr();
            }

            //Search for the given end point
            PublishingEndPointAPI endpointAPI = APILocator.getPublisherEndPointAPI();
            PublishingEndPoint requesterEndPoint = endpointAPI.findEnabledSendingEndPointByAddress( remoteIP );

            //Verify the authentication token
            String auth_token = PublicEncryptionFactory.decryptString( auth_token_enc );
            if ( !BundlePublisherResource.isValidToken( auth_token, remoteIP, requesterEndPoint ) || !UtilMethods.isSet( requestId ) ) {
                return Response.status( HttpStatus.SC_UNAUTHORIZED ).build();
View Full Code Here

Examples of com.dotcms.publisher.endpoint.bean.PublishingEndPoint

            remoteIP = request.getRemoteHost();
            if(!UtilMethods.isSet(remoteIP))
                remoteIP = request.getRemoteAddr();

            PublishingEndPointAPI endpointAPI = APILocator.getPublisherEndPointAPI();
            final PublishingEndPoint requesterEndPoint = endpointAPI.findEnabledSendingEndPointByAddress(remoteIP);

            if(!BundlePublisherResource.isValidToken(auth_token, remoteIP, requesterEndPoint)) {
                return Response.status(HttpStatus.SC_UNAUTHORIZED).build();
            }

            IntegrityUtil integrityUtil = new IntegrityUtil();
            HibernateUtil.startTransaction();
            integrityUtil.fixConflicts(dataToFix, requesterEndPoint.getId(), IntegrityType.valueOf(type.toUpperCase()) );
            HibernateUtil.commitTransaction();


        } catch ( Exception e ) {
            try {
View Full Code Here

Examples of com.dotcms.publisher.endpoint.bean.PublishingEndPoint

            } 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) {
View Full Code Here

Examples of com.dotcms.publisher.endpoint.bean.PublishingEndPoint

    List<PublishingEndPoint> endPoints = new ArrayList<PublishingEndPoint>();
    DotConnect dc = new DotConnect();
    dc.setSQL(GET_END_POINTS);
    List<Map<String, Object>> res = dc.loadObjectResults();
    for(Map<String, Object> row : res){
      PublishingEndPoint endPoint = PublisherUtil.getObjectByMap(row);
      endPoints.add(endPoint);
      cache.add(endPoint);
    }
    cache.setLoaded(true);
    return endPoints;
View Full Code Here

Examples of com.dotcms.publisher.endpoint.bean.PublishingEndPoint

    DotConnect dc = new DotConnect();
    dc.setSQL(SELECT_END_POINT_BY_NAME);
    dc.addParam(name);
    List<Map<String, Object>> res = dc.loadObjectResults();
    PublishingEndPoint e = null;

    if(res!=null && !res.isEmpty()) {
      Map<String, Object> row = res.get(0);
      e = PublisherUtil.getObjectByMap(row);
    }
View Full Code Here

Examples of com.dotcms.publisher.endpoint.bean.PublishingEndPoint

    }
    return endPoints;
  }

  public synchronized PublishingEndPoint getEndPointById(String id) {
    PublishingEndPoint endPoint = null;
    try {
      endPoint = (PublishingEndPoint) cache.get(id, cacheGroup);
    }
    catch(DotCacheException e) {
      Logger.debug(this, "PublishingEndPoint cache entry not found for: " + id);
View Full Code Here

Examples of com.dotcms.publisher.endpoint.bean.PublishingEndPoint

      if(!UtilMethods.isSet(remoteIP))
        remoteIP = req.getRemoteAddr();

      HibernateUtil.startTransaction();

      PublishingEndPoint mySelf = endpointAPI.findEnabledSendingEndPointByAddress(remoteIP);

      if(!isValidToken(auth_token, remoteIP, mySelf)) {
        bundle.close();
                return responseResource.responseError( HttpStatus.SC_UNAUTHORIZED );
            }

      String bundlePath = ConfigUtils.getBundlePath()+File.separator+MY_TEMP;
      String fileName=fileDetail.getFileName();
      String bundleFolder = fileName.substring(0, fileName.indexOf(".tar.gz"));

            PublishAuditStatus status = PublishAuditAPI.getInstance().updateAuditTable( mySelf.getId(), mySelf.getId(), bundleFolder, true );

            if(bundleName.trim().length()>0) {
          // save bundle if it doesn't exists
                Bundle foundBundle = APILocator.getBundleAPI().getBundleById( bundleFolder );
                if ( foundBundle == null || foundBundle.getId() == null ) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.