Examples of PublishingEndPointAPI


Examples of com.dotcms.publisher.endpoint.business.PublishingEndPointAPI

          endpoint.setEnabled(null!=request.getParameter("enabled"));
          String sending = request.getParameter("sending");
          endpoint.setSending("true".equals(sending));
          endpoint.setGroupId(request.getParameter("environmentId"));
          //Save the endpoint.
          PublishingEndPointAPI peAPI = APILocator.getPublisherEndPointAPI();
          peAPI.saveEndPoint(endpoint);



    } catch (DotDataException e) {
      Logger.info(getClass(), "Error saving EndPoint. Error Message: " +  e.getMessage());
View Full Code Here

Examples of com.dotcms.publisher.endpoint.business.PublishingEndPointAPI

      endpoint.setAuthKey(new StringBuilder(PublicEncryptionFactory.encryptString(request.getParameter("authKey"))));
      endpoint.setEnabled(null!=request.getParameter("enabled"));
      endpoint.setSending("true".equals(request.getParameter("sending")));
      endpoint.setGroupId(request.getParameter("environmentId"));
      //Update the endpoint.
      PublishingEndPointAPI peAPI = APILocator.getPublisherEndPointAPI();
      peAPI.updateEndPoint(endpoint);

    } catch (DotDataException e) {
      Logger.info(getClass(), "Error editing EndPoint. Error Message: " +  e.getMessage());
      response.getWriter().println("FAILURE: " + e.getMessage());
    }
View Full Code Here

Examples of com.dotcms.publisher.endpoint.business.PublishingEndPointAPI

    response.setContentType(CHARSET);
    Context context = VelocityUtil.getWebContext(request, response);

    HTMLPage htmlPage = (HTMLPage) APILocator.getVersionableAPI().findWorkingVersion(id, user, true);
    HTMLPageAPI htmlPageAPI = APILocator.getHTMLPageAPI();
    PublishingEndPointAPI pepAPI = APILocator.getPublisherEndPointAPI();
    List<PublishingEndPoint> receivingEndpoints = pepAPI.getReceivingEndPoints();
    // to check user has permission to write on this page
        boolean hasWritePermOverHTMLPage = permissionAPI.doesUserHavePermission( htmlPage, PERMISSION_WRITE, user );
        boolean hasPublishPermOverHTMLPage = permissionAPI.doesUserHavePermission( htmlPage, PERMISSION_PUBLISH, user );
        boolean hasRemotePublishPermOverHTMLPage = hasPublishPermOverHTMLPage && LicenseUtil.getLevel() > 199;
        boolean hasEndPoints = UtilMethods.isSet( receivingEndpoints ) && !receivingEndpoints.isEmpty();
View Full Code Here

Examples of com.dotcms.publisher.endpoint.business.PublishingEndPointAPI

        response.setContentType( CHARSET );
        Context context = VelocityUtil.getWebContext( request, response );

        HTMLPage htmlPage = (HTMLPage) APILocator.getVersionableAPI().findWorkingVersion( id, APILocator.getUserAPI().getSystemUser(), false );
        HTMLPageAPI htmlPageAPI = APILocator.getHTMLPageAPI();
        PublishingEndPointAPI pepAPI = APILocator.getPublisherEndPointAPI();
    List<PublishingEndPoint> receivingEndpoints = pepAPI.getReceivingEndPoints();
        // to check user has permission to write on this page
        boolean hasAddChildrenPermOverHTMLPage = permissionAPI.doesUserHavePermission( htmlPage, PERMISSION_CAN_ADD_CHILDREN, backendUser );
        boolean hasWritePermOverHTMLPage = permissionAPI.doesUserHavePermission( htmlPage, PERMISSION_WRITE, backendUser );
        boolean hasPublishPermOverHTMLPage = permissionAPI.doesUserHavePermission( htmlPage, PERMISSION_PUBLISH, backendUser );
        boolean hasRemotePublishPermOverHTMLPage = hasPublishPermOverHTMLPage && LicenseUtil.getLevel() > 199;
View Full Code Here

Examples of com.dotcms.publisher.endpoint.business.PublishingEndPointAPI

  @Test
  public void retry_issue5097 () throws DotSecurityException, DotDataException, IOException, JSONException, DotPublisherException, InterruptedException {

    EnvironmentAPI environmentAPI = APILocator.getEnvironmentAPI();
    ContentletAPI contentletAPI = APILocator.getContentletAPI();
    PublishingEndPointAPI publisherEndPointAPI = APILocator.getPublisherEndPointAPI();
    PublisherAPI publisherAPI = PublisherAPI.getInstance();

    HttpServletRequest req = ServletTestRunner.localRequest.get();

    Environment environment = new Environment();
    environment.setName( "TestEnvironment_" + String.valueOf( new Date().getTime() ) );
    environment.setPushToAll( false );

    //Find the roles of the admin user
    Role role = APILocator.getRoleAPI().loadRoleByKey( adminUser.getUserId() );

    //Create the permissions for the environment
    List<Permission> permissions = new ArrayList<Permission>();
    Permission p = new Permission( environment.getId(), role.getId(), PermissionAPI.PERMISSION_USE );
    permissions.add( p );

    //Create a environment
    environmentAPI.saveEnvironment( environment, permissions );

    //Now we need to create the end point
    PublishingEndPoint endpoint = new PublishingEndPoint();
    endpoint.setServerName( new StringBuilder( "TestEndPoint" + String.valueOf( new Date().getTime() ) ) );
    endpoint.setAddress( "127.0.0.1" );
    endpoint.setPort( "999" );
    endpoint.setProtocol( "http" );
    endpoint.setAuthKey( new StringBuilder( PublicEncryptionFactory.encryptString( "1111" ) ) );
    endpoint.setEnabled( true );
    endpoint.setSending( false );//TODO: Shouldn't this be true as we are creating this end point to send bundles to another server..?
    endpoint.setGroupId( environment.getId() );
    //Save the endpoint.
    publisherEndPointAPI.saveEndPoint( endpoint );

    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //++++++++++++++++++++++++++++++PUBLISH++++++++++++++++++++++++++++

    //Getting test data
    List<Contentlet> contentlets = contentletAPI.findAllContent( 0, 1 );
    //Validations
    assertNotNull( contentlets );
    assertEquals( contentlets.size(), 1 );

    //Preparing the url in order to push content
    SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
    SimpleDateFormat timeFormat = new SimpleDateFormat( "H-m" );
    String publishDate = dateFormat.format( new Date() );
    String publishTime = timeFormat.format( new Date() );

    String baseURL = "http://" + req.getServerName() + ":" + req.getServerPort() + "/DotAjaxDirector/com.dotcms.publisher.ajax.RemotePublishAjaxAction/cmd/publish/u/admin@dotcms.com/p/admin";
    String completeURL = baseURL +
        "?remotePublishDate=" + UtilMethods.encodeURIComponent( publishDate ) +
        "&remotePublishTime=" + UtilMethods.encodeURIComponent( publishTime ) +
        "&remotePublishExpireDate=" +
        "&remotePublishExpireTime=" +
        "&iWantTo=" + RemotePublishAjaxAction.DIALOG_ACTION_PUBLISH +
        "&whoToSend=" + UtilMethods.encodeURIComponent( environment.getId() ) +
        "&forcePush=false" +
        "&assetIdentifier=" + UtilMethods.encodeURIComponent( contentlets.get( 0 ).getIdentifier() );

    //Execute the call
    URL publishUrl = new URL( completeURL );
    String response = IOUtils.toString( publishUrl.openStream(), "UTF-8" );
    //Validations
    JSONObject jsonResponse = new JSONObject( response );
    assertNotNull( contentlets );
    assertEquals( jsonResponse.getInt( "errors" ), 0 );
    assertEquals( jsonResponse.getInt( "total" ), 1 );
    assertNotNull( jsonResponse.get( "bundleId" ) );

    //Now that we have a bundle id
    String bundleId = jsonResponse.getString( "bundleId" );
    //First we need to verify if this bundle is in the queue job
    List<PublishQueueElement> foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
    assertNotNull( foundBundles );
    assertTrue( !foundBundles.isEmpty() );

    /*
         Now lets wait until it finished, by the way, we are expecting it to fail to publish as the end point does not exist.
         Keep in mind the queue will try 3 times before to marked as failed to publish, so we have to wait a bit here....
     */
    int x = 0;
    do {
      Thread.sleep( 3000 );
      //Verify if it continues in the queue job
      foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
      x++;
    } while ( (foundBundles != null && !foundBundles.isEmpty()) && x < 200 );
    //At this points should not be here anymore
    foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
    assertTrue( foundBundles == null || foundBundles.isEmpty() );

    //Get the audit records related to this bundle
    PublishAuditStatus status = PublishAuditAPI.getInstance().getPublishAuditStatus( bundleId );
    //We will be able to retry failed and successfully bundles
    assertEquals( status.getStatus(), PublishAuditStatus.Status.FAILED_TO_PUBLISH ); //Remember, we are expecting this to fail

    //Get current status dates
    Date initialCreationDate = status.getCreateDate();
    Date initialUpdateDate = status.getStatusUpdated();

    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //++++++++++++++++++++++++++++++RETRY++++++++++++++++++++++++++++++
    //Now we can try the retry
    req = ServletTestRunner.localRequest.get();
    baseURL = "http://" + req.getServerName() + ":" + req.getServerPort() + "/DotAjaxDirector/com.dotcms.publisher.ajax.RemotePublishAjaxAction/cmd/retry/u/admin@dotcms.com/p/admin";
    completeURL = baseURL + "?bundlesIds=" + UtilMethods.encodeURIComponent( bundleId );

    //Execute the call
    URL retryUrl = new URL( completeURL );
    response = IOUtils.toString( retryUrl.openStream(), "UTF-8" );//We can expect something like "Bundle id: <strong>1193e3eb-3ccd-496e-8995-29a9fcc48cbd</strong> added successfully to Publishing Queue."
    //Validations
    assertNotNull( response );
    assertTrue( response.contains( bundleId ) );
    assertTrue( response.contains( "added successfully to" ) );

    //And should be back to the queue job
    foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
    assertNotNull( foundBundles );
    assertTrue( !foundBundles.isEmpty() );

    //Get current status dates
    status = PublishAuditAPI.getInstance().getPublishAuditStatus( bundleId );//Get the audit records related to this bundle
    Date latestCreationDate = status.getCreateDate();
    Date latestUpdateDate = status.getStatusUpdated();
    //Validations
    assertNotSame( initialCreationDate, latestCreationDate );
    assertNotSame( initialUpdateDate, latestUpdateDate );
    assertTrue( initialCreationDate.before( latestCreationDate ) );
    assertTrue( initialUpdateDate.before( latestUpdateDate ) );

    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //++++++++++++++++++++SIMULATE AN END POINT++++++++++++++++++++++++
    /*
         And finally lets try to simulate a end point sending directly an already created bundle file to
         the api/bundlePublisher/publish service
     */

    //Create a receiving end point
    PublishingEndPoint receivingFromEndpoint = new PublishingEndPoint();
    receivingFromEndpoint.setServerName( new StringBuilder( "TestReceivingEndPoint" + String.valueOf( new Date().getTime() ) ) );
    receivingFromEndpoint.setAddress( req.getServerName() );
    receivingFromEndpoint.setPort( String.valueOf( req.getServerPort() ) );
    receivingFromEndpoint.setProtocol( "http" );
    receivingFromEndpoint.setAuthKey( new StringBuilder( PublicEncryptionFactory.encryptString( "1111" ) ) );
    receivingFromEndpoint.setEnabled( true );
    receivingFromEndpoint.setSending( true );//TODO: Shouldn't this be false as we are creating this end point to receive bundles from another server..?
    receivingFromEndpoint.setGroupId( environment.getId() );
    //Save the endpoint.
    publisherEndPointAPI.saveEndPoint( receivingFromEndpoint );

    //Find the bundle
    Bundle bundle = APILocator.getBundleAPI().getBundleById( bundleId );
    PublisherConfig basicConfig = new PublisherConfig();
    basicConfig.setId( bundleId );
View Full Code Here

Examples of com.dotcms.publisher.endpoint.business.PublishingEndPointAPI

    /*
     * Generate test environment
     */
    //Preparing the url in order to push content
    EnvironmentAPI environmentAPI = APILocator.getEnvironmentAPI();
    PublishingEndPointAPI publisherEndPointAPI = APILocator.getPublisherEndPointAPI();
    PublisherAPI publisherAPI = PublisherAPI.getInstance();

    HttpServletRequest req = ServletTestRunner.localRequest.get();

    Environment environment = new Environment();
    environment.setName( "TestEnvironment_" + String.valueOf( new Date().getTime() ) );
    environment.setPushToAll( false );

    /*
     * Find the roles of the admin user
     */
    Role role = APILocator.getRoleAPI().loadRoleByKey( adminUser.getUserId() );

    //Create the permissions for the environment
    List<Permission> permissions = new ArrayList<Permission>();
    Permission p = new Permission( environment.getId(), role.getId(), PermissionAPI.PERMISSION_USE );
    permissions.add( p );

    /*
     * Create a environment
     */
    environmentAPI.saveEnvironment( environment, permissions );

    /*
     * Now we need to create the end point
     */
    PublishingEndPoint endpoint = new PublishingEndPoint();
    endpoint.setServerName( new StringBuilder( "TestEndPoint" + String.valueOf( new Date().getTime() ) ) );
    endpoint.setAddress( "127.0.0.1" );
    endpoint.setPort( "999" );
    endpoint.setProtocol( "http" );
    endpoint.setAuthKey( new StringBuilder( PublicEncryptionFactory.encryptString( "1111" ) ) );
    endpoint.setEnabled( true );
    endpoint.setSending( false );//TODO: Shouldn't this be true as we are creating this end point to send bundles to another server..?
    endpoint.setGroupId( environment.getId() );
    /*
     * Save the endpoint.
     */
    publisherEndPointAPI.saveEndPoint( endpoint );
    SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
    SimpleDateFormat timeFormat = new SimpleDateFormat( "H-m" );
    String publishDate = dateFormat.format( new Date() );
    String publishTime = timeFormat.format( new Date() );

    String baseURL = "http://" + req.getServerName() + ":" + req.getServerPort() + "/DotAjaxDirector/com.dotcms.publisher.ajax.RemotePublishAjaxAction/cmd/publish/u/admin@dotcms.com/p/admin";
    String completeURL = baseURL +
        "?remotePublishDate=" + UtilMethods.encodeURIComponent( publishDate ) +
        "&remotePublishTime=" + UtilMethods.encodeURIComponent( publishTime ) +
        "&remotePublishExpireDate=" +
        "&remotePublishExpireTime=" +
        "&iWantTo=" + RemotePublishAjaxAction.DIALOG_ACTION_PUBLISH +
        "&whoToSend=" + UtilMethods.encodeURIComponent( environment.getId() ) +
        "&forcePush=false" +
        "&assetIdentifier=" + UtilMethods.encodeURIComponent( folder.getInode() );

    /*
     * Execute the call
     */
    URL publishUrl = new URL( completeURL );
    String response = IOUtils.toString( publishUrl.openStream(), "UTF-8" );
    /*
     * Validations
     */
    JSONObject jsonResponse = new JSONObject( response );
    assertEquals( jsonResponse.getInt( "errors" ), 0 );
    assertEquals( jsonResponse.getInt( "total" ), 1 );
    assertNotNull( jsonResponse.get( "bundleId" ) );

    /*
     * Now that we have a bundle id
     */
    String bundleId = jsonResponse.getString( "bundleId" );
    /*
     * First we need to verify if this bundle is in the queue job
     */
    List<PublishQueueElement> foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
    assertNotNull( foundBundles );
    assertTrue( !foundBundles.isEmpty() );

    /*
     *        Now lets wait until it finished, by the way, we are expecting it to fail to publish as the end point does not exist.
     *        Keep in mind the queue will try 3 times before to marked as failed to publish, so we have to wait a bit here....
     */
    int x = 0;
    do {
      Thread.sleep( 3000 );
      /*
       * Verify if it continues in the queue job
       */
      foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
      x++;
    } while ( (foundBundles != null && !foundBundles.isEmpty()) && x < 200 );
    /*
     * At this points should not be here anymore
     */
    //foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
    //assertTrue( foundBundles == null || foundBundles.isEmpty() );

    /*
     * Get the audit records related to this bundle
     */
    PublishAuditStatus status = PublishAuditAPI.getInstance().getPublishAuditStatus( bundleId );
    /*
     * We will be able to retry failed and successfully bundles
     */
    assertEquals( status.getStatus(), PublishAuditStatus.Status.FAILED_TO_PUBLISH ); //Remember, we are expecting this to fail

    /*
     * deleting folder, pages and content, to create the receiving endpoint environment
     */
    APILocator.getContentletAPI().delete(contentlet, systemUser, false, true);
    WebAssetFactory.unPublishAsset(workinghtmlPageAsset, systemUser.getUserId(), folder);
    WebAssetFactory.archiveAsset(workinghtmlPageAsset);
    APILocator.getHTMLPageAPI().delete(workinghtmlPageAsset, systemUser, true);
    APILocator.getHTMLPageAPI().delete(workinghtmlPageAsset2, systemUser, true);
    APILocator.getFolderAPI().delete(folder, systemUser, false);
   
    Assert.assertEquals(0,MultiTreeFactory.getMultiTree(workinghtmlPageAsset).size());
    Assert.assertEquals(0,MultiTreeFactory.getMultiTree(workinghtmlPageAsset2).size());
    Assert.assertEquals(0,MultiTreeFactory.getMultiTreeByChild(contentlet.getIdentifier()).size());

    folder = APILocator.getFolderAPI().findFolderByPath(folderPath, host, systemUser, false);
    assertTrue(!UtilMethods.isSet(folder.getInode()));

    /*
     * Find the bundle
     * SIMULATE AN END POINT
     *
     * And finally lets try to simulate a end point sending directly an already created bundle file to
     * the api/bundlePublisher/publish service
     */

    /*
     * Create a receiving end point
     */
    PublishingEndPoint receivingFromEndpoint = new PublishingEndPoint();
    receivingFromEndpoint.setServerName( new StringBuilder( "TestReceivingEndPoint" + String.valueOf( new Date().getTime() ) ) );
    receivingFromEndpoint.setAddress( req.getServerName() );
    receivingFromEndpoint.setPort( String.valueOf( req.getServerPort() ) );
    receivingFromEndpoint.setProtocol( "http" );
    receivingFromEndpoint.setAuthKey( new StringBuilder( PublicEncryptionFactory.encryptString( "1111" ) ) );
    receivingFromEndpoint.setEnabled( true );
    receivingFromEndpoint.setSending( true );//TODO: Shouldn't this be false as we are creating this end point to receive bundles from another server..?
    receivingFromEndpoint.setGroupId( environment.getId() );
    /*
     * Save the endpoint.
     */
    publisherEndPointAPI.saveEndPoint( receivingFromEndpoint );

    /*
     * Find the bundle
     */
    Bundle bundle = APILocator.getBundleAPI().getBundleById( bundleId );
View Full Code Here

Examples of com.dotcms.publisher.endpoint.business.PublishingEndPointAPI

    /*
     * Generate test environment
     */
    //Preparing the url in order to push content
    EnvironmentAPI environmentAPI = APILocator.getEnvironmentAPI();
    PublishingEndPointAPI publisherEndPointAPI = APILocator.getPublisherEndPointAPI();
    PublisherAPI publisherAPI = PublisherAPI.getInstance();

    HttpServletRequest req = ServletTestRunner.localRequest.get();

    Environment environment = new Environment();
    environment.setName( "TestEnvironment_" + String.valueOf( new Date().getTime() ) );
    environment.setPushToAll( false );

    /*
     * Find the roles of the admin user
     */
    Role role = APILocator.getRoleAPI().loadRoleByKey( adminUser.getUserId() );

    //Create the permissions for the environment
    List<Permission> permissions = new ArrayList<Permission>();
    Permission p = new Permission( environment.getId(), role.getId(), PermissionAPI.PERMISSION_USE );
    permissions.add( p );

    /*
     * Create a environment
     */
    environmentAPI.saveEnvironment( environment, permissions );

    /*
     * Now we need to create the end point
     */
    PublishingEndPoint endpoint = new PublishingEndPoint();
    endpoint.setServerName( new StringBuilder( "TestEndPoint" + String.valueOf( new Date().getTime() ) ) );
    endpoint.setAddress( "127.0.0.1" );
    endpoint.setPort( "9999" );
    endpoint.setProtocol( "http" );
    endpoint.setAuthKey( new StringBuilder( PublicEncryptionFactory.encryptString( "1111" ) ) );
    endpoint.setEnabled( true );
    endpoint.setSending( false );//TODO: Shouldn't this be true as we are creating this end point to send bundles to another server..?
    endpoint.setGroupId( environment.getId() );
    /*
     * Save the endpoint.
     */
    publisherEndPointAPI.saveEndPoint( endpoint );
    SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
    SimpleDateFormat timeFormat = new SimpleDateFormat( "H-m" );
    String publishDate = dateFormat.format( new Date() );
    String publishTime = timeFormat.format( new Date() );

    String baseURL = "http://" + req.getServerName() + ":" + req.getServerPort() + "/DotAjaxDirector/com.dotcms.publisher.ajax.RemotePublishAjaxAction/cmd/publish/u/admin@dotcms.com/p/admin";
    String completeURL = baseURL +
        "?remotePublishDate=" + UtilMethods.encodeURIComponent( publishDate ) +
        "&remotePublishTime=" + UtilMethods.encodeURIComponent( publishTime ) +
        "&remotePublishExpireDate=" +
        "&remotePublishExpireTime=" +
        "&iWantTo=" + RemotePublishAjaxAction.DIALOG_ACTION_PUBLISH +
        "&whoToSend=" + UtilMethods.encodeURIComponent( environment.getId() ) +
        "&forcePush=false" +
        "&assetIdentifier=" + UtilMethods.encodeURIComponent( folder.getInode() );

    /*
     * Execute the call
     */
    URL publishUrl = new URL( completeURL );
    String response = IOUtils.toString( publishUrl.openStream(), "UTF-8" );
    /*
     * Validations
     */
    JSONObject jsonResponse = new JSONObject( response );
    assertEquals( jsonResponse.getInt( "errors" ), 0 );
    assertEquals( jsonResponse.getInt( "total" ), 1 );
    assertNotNull( jsonResponse.get( "bundleId" ) );

    /*
     * Now that we have a bundle id
     */
    String bundleId = jsonResponse.getString( "bundleId" );
    /*
     * First we need to verify if this bundle is in the queue job
     */
    List<PublishQueueElement> foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
    assertNotNull( foundBundles );
    assertTrue( !foundBundles.isEmpty() );

    /*
     *        Now lets wait until it finished, by the way, we are expecting it to fail to publish as the end point does not exist.
     *        Keep in mind the queue will try 3 times before to marked as failed to publish, so we have to wait a bit here....
     */
    int x = 0;
    do {
      Thread.sleep( 3000 );
      /*
       * Verify if it continues in the queue job
       */
      foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
      x++;
    } while ( (foundBundles != null && !foundBundles.isEmpty()) && x < 200 );
    /*
     * At this points should not be here anymore
     */


    /*
     * Get the audit records related to this bundle
     */
    PublishAuditStatus status = PublishAuditAPI.getInstance().getPublishAuditStatus( bundleId );
    /*
     * We will be able to retry failed and successfully bundles
     */
    assertEquals( status.getStatus(), PublishAuditStatus.Status.FAILED_TO_PUBLISH ); //Remember, we are expecting this to fail

    /*
     * deleting folder, pages and contents, to create the receiving endpoint environment
     */
    APILocator.getContentletAPI().delete(contentlet1, systemUser, false, true);
    APILocator.getContentletAPI().delete(contentlet2, systemUser, false, true);
    APILocator.getContentletAPI().delete(contentlet3, systemUser, false, true);
    WebAssetFactory.unPublishAsset(workinghtmlPageAsset, systemUser.getUserId(), folder);
    WebAssetFactory.archiveAsset(workinghtmlPageAsset);
    APILocator.getHTMLPageAPI().delete(workinghtmlPageAsset, systemUser, true);
    APILocator.getFolderAPI().delete(folder, systemUser, false);

    folder = APILocator.getFolderAPI().findFolderByPath(folderPath, host, systemUser, false);
    assertTrue(!UtilMethods.isSet(folder.getInode()));

    /*
     * Find the bundle
     * SIMULATE AN END POINT
     *
     * And finally lets try to simulate a end point sending directly an already created bundle file to
     * the api/bundlePublisher/publish service
     */

    /*
     * Create a receiving end point
     */
    PublishingEndPoint receivingFromEndpoint = new PublishingEndPoint();
    receivingFromEndpoint.setServerName( new StringBuilder( "TestReceivingEndPoint" + String.valueOf( new Date().getTime() ) ) );
    receivingFromEndpoint.setAddress( req.getServerName() );
    receivingFromEndpoint.setPort( String.valueOf( req.getServerPort() ) );
    receivingFromEndpoint.setProtocol( "http" );
    receivingFromEndpoint.setAuthKey( new StringBuilder( PublicEncryptionFactory.encryptString( "1111" ) ) );
    receivingFromEndpoint.setEnabled( true );
    receivingFromEndpoint.setSending( true );//TODO: Shouldn't this be false as we are creating this end point to receive bundles from another server..?
    receivingFromEndpoint.setGroupId( environment.getId() );
    /*
     * Save the endpoint.
     */
    publisherEndPointAPI.saveEndPoint( receivingFromEndpoint );

    /*
     * Find the bundle
     */
    Bundle bundle = APILocator.getBundleAPI().getBundleById( bundleId );
View Full Code Here

Examples of com.dotcms.publisher.endpoint.business.PublishingEndPointAPI

        if ( !responseResource.validate( responseMessage, "endPoint" ) ) {
            return responseResource.responseError( responseMessage.toString(), HttpStatus.SC_BAD_REQUEST );
        }

        try {
            PublishingEndPointAPI pepAPI = APILocator.getPublisherEndPointAPI();

            PublishingEndPoint pep = pepAPI.findEndPointById(endPoint);
            String environmentId = pep.getGroupId();

            //Delete the end point
            pepAPI.deleteEndPointById( endPoint );

            // if the environment is now empty, lets remove it from session
            if(pepAPI.findSendingEndPointsByEnvironment(environmentId).isEmpty()) {
              //If it was deleted successfully lets remove it from session
                if ( UtilMethods.isSet( request.getSession().getAttribute( WebKeys.SELECTED_ENVIRONMENTS ) ) ) {

                    //Get the selected environments from the session
                    List<Environment> lastSelectedEnvironments = (List<Environment>) request.getSession().getAttribute( WebKeys.SELECTED_ENVIRONMENTS );
View Full Code Here

Examples of com.dotcms.publisher.endpoint.business.PublishingEndPointAPI

            String auth_token = PublicEncryptionFactory.decryptString(auth_token_enc);
            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();
            }
View Full Code Here

Examples of com.dotcms.publisher.endpoint.business.PublishingEndPointAPI

            String auth_token = PublicEncryptionFactory.decryptString(auth_token_enc);
            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) || !UtilMethods.isSet(requestId)) {
                return Response.status(HttpStatus.SC_UNAUTHORIZED).build();
            }
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.