<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Scheduled job Call Web Script in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/scheduled-job-call-web-script/m-p/126890#M34517</link>
    <description>&lt;P&gt;Hi.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some questions. I have a scheduled job on my schedule job I need to call an API Webscript that I have. Currently,&amp;nbsp; am stuck on call API Webscript. Can someone help me to explain the best way to call API Webscript. Below is the code that i stuck.&lt;/P&gt;&lt;PRE&gt;/**
 * The Class CustomJobProcessor.&amp;lt;br/&amp;gt;
 */
public class CustomJobProcessor implements org.quartz.StatefulJob{
 
 /** The Constant LOG. */
 private static final Log LOG = LogFactory.getLog(CustomJobProcessor.class);
    
 /** The global properties. */
 private Properties globalProperties;
 
 /** The service registry. */
 private ServiceRegistry serviceRegistry;

 @Override
 public void execute(final JobExecutionContext jobCtx) throws JobExecutionException {
    System.out.println("CustomJobProcessor Started..");
    try{
      //Run as system user since this job is user independent hence
       // permission is required on repo
     AuthenticationUtil.setRunAsUserSystem();
     System.out.println("AuthenticationUtil");
     // TODO:: Put job processing logic here..
     // Get the job space where all jobs are stored 
                  // using  serviceRegistry.getFileFolderService()
                  // Read the jobs in a list as given below:
                  // List&amp;lt;FileInfo&amp;gt; fileInfoList =    fileFolderService.listFiles(jobSpaceNode);
    // Read the uniuqe id from the job property and process
    
        AuthenticationService authenticationService = this.serviceRegistry.getAuthenticationService();

        String ticket = authenticationService.getCurrentTicket();

        HttpClient client = new HttpClient();

        //String uid = recorNoNodeRef.getId();
        //String apiurl = "http://172.16.20.210:8080/alfresco/s/api/managePermissionQueryBy?nodeRef=workspace://SpacesStore/98a93306-3888-4cb2-87fa-2fafa14462d1" + "?alf_ticket=" + ticket;
        String apiurl = "http://172.16.20.210:8080/alfresco/s/api/managePermissionQueryBy?nodeRef=workspace://SpacesStore/98a93306-3888-4cb2-87fa-2fafa14462d1";
        System.out.println("Get url :::" + apiurl);
        String resultString = "";
        GetMethod getComment = new GetMethod(apiurl);
        try {
                int status = client.executeMethod(getComment);
                if (status != 200) {
                        System.out.println("Method failed: " + getComment.getStatusLine());
                }
                resultString = getComment.getResponseBodyAsString();
                 System.out.println("==== resultString ====");
                    System.out.println(resultString);
                    System.out.println("==== resultString ====");
        } catch (Exception e) {
                System.out.println("Line 1643::" + e.getMessage());
                //return "{\"error\":\"" + e.getMessage() + "\"}";
                System.out.println("error :::" + e.getMessage());
        } finally {
                getComment.releaseConnection();
        }
    
   } catch (RuntimeException excp){
      System.out.println("Exception occured while processing job" + excp);
   }
    
   System.out.println("CustomJobProcessor End!");

 }// execute end

 /**
  * Sets the global properties.
  *
  * @param globalProperties the global properties
  */
 public void setGlobalProperties(final Properties globalProperties) {
  this.globalProperties = globalProperties;
 }
 
 /**
  * Sets the service registry.
  *
  * @param serviceRegistry the service registry
  */
 public void setServiceRegistry(final ServiceRegistry serviceRegistry) {
  this.serviceRegistry = serviceRegistry;
 }
}&lt;/PRE&gt;&lt;P&gt;By error as below&lt;/P&gt;&lt;P&gt;Method failed: HTTP/1.1 401 Unauthorized&lt;BR /&gt;==== resultString ====&lt;BR /&gt;{&lt;BR /&gt;"status" :&lt;BR /&gt;{&lt;BR /&gt;"code" : 401,&lt;BR /&gt;"name" : "Unauthorized",&lt;BR /&gt;"description" : "The request requires HTTP authentication."&lt;BR /&gt;},&lt;/P&gt;&lt;P&gt;"message" : "00270000 Authentication failed for Web Script org\/alfresco\/repository\/managePermission\/managepermissionby.get",&lt;BR /&gt;"exception" : "",&lt;/P&gt;&lt;P&gt;"callstack" :&lt;BR /&gt;[&lt;/P&gt;&lt;P&gt;],&lt;/P&gt;&lt;P&gt;"server" : "Enterprise v5.2.3 (r852994b1-b12) schema 10,065",&lt;BR /&gt;"time" : "Jan 27, 2022 11:22:05 AM"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;==== resultString ====&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jan 2022 13:40:58 GMT</pubDate>
    <dc:creator>faispis</dc:creator>
    <dc:date>2022-01-26T13:40:58Z</dc:date>
    <item>
      <title>Scheduled job Call Web Script</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/scheduled-job-call-web-script/m-p/126890#M34517</link>
      <description>&lt;P&gt;Hi.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some questions. I have a scheduled job on my schedule job I need to call an API Webscript that I have. Currently,&amp;nbsp; am stuck on call API Webscript. Can someone help me to explain the best way to call API Webscript. Below is the code that i stuck.&lt;/P&gt;&lt;PRE&gt;/**
 * The Class CustomJobProcessor.&amp;lt;br/&amp;gt;
 */
public class CustomJobProcessor implements org.quartz.StatefulJob{
 
 /** The Constant LOG. */
 private static final Log LOG = LogFactory.getLog(CustomJobProcessor.class);
    
 /** The global properties. */
 private Properties globalProperties;
 
 /** The service registry. */
 private ServiceRegistry serviceRegistry;

 @Override
 public void execute(final JobExecutionContext jobCtx) throws JobExecutionException {
    System.out.println("CustomJobProcessor Started..");
    try{
      //Run as system user since this job is user independent hence
       // permission is required on repo
     AuthenticationUtil.setRunAsUserSystem();
     System.out.println("AuthenticationUtil");
     // TODO:: Put job processing logic here..
     // Get the job space where all jobs are stored 
                  // using  serviceRegistry.getFileFolderService()
                  // Read the jobs in a list as given below:
                  // List&amp;lt;FileInfo&amp;gt; fileInfoList =    fileFolderService.listFiles(jobSpaceNode);
    // Read the uniuqe id from the job property and process
    
        AuthenticationService authenticationService = this.serviceRegistry.getAuthenticationService();

        String ticket = authenticationService.getCurrentTicket();

        HttpClient client = new HttpClient();

        //String uid = recorNoNodeRef.getId();
        //String apiurl = "http://172.16.20.210:8080/alfresco/s/api/managePermissionQueryBy?nodeRef=workspace://SpacesStore/98a93306-3888-4cb2-87fa-2fafa14462d1" + "?alf_ticket=" + ticket;
        String apiurl = "http://172.16.20.210:8080/alfresco/s/api/managePermissionQueryBy?nodeRef=workspace://SpacesStore/98a93306-3888-4cb2-87fa-2fafa14462d1";
        System.out.println("Get url :::" + apiurl);
        String resultString = "";
        GetMethod getComment = new GetMethod(apiurl);
        try {
                int status = client.executeMethod(getComment);
                if (status != 200) {
                        System.out.println("Method failed: " + getComment.getStatusLine());
                }
                resultString = getComment.getResponseBodyAsString();
                 System.out.println("==== resultString ====");
                    System.out.println(resultString);
                    System.out.println("==== resultString ====");
        } catch (Exception e) {
                System.out.println("Line 1643::" + e.getMessage());
                //return "{\"error\":\"" + e.getMessage() + "\"}";
                System.out.println("error :::" + e.getMessage());
        } finally {
                getComment.releaseConnection();
        }
    
   } catch (RuntimeException excp){
      System.out.println("Exception occured while processing job" + excp);
   }
    
   System.out.println("CustomJobProcessor End!");

 }// execute end

 /**
  * Sets the global properties.
  *
  * @param globalProperties the global properties
  */
 public void setGlobalProperties(final Properties globalProperties) {
  this.globalProperties = globalProperties;
 }
 
 /**
  * Sets the service registry.
  *
  * @param serviceRegistry the service registry
  */
 public void setServiceRegistry(final ServiceRegistry serviceRegistry) {
  this.serviceRegistry = serviceRegistry;
 }
}&lt;/PRE&gt;&lt;P&gt;By error as below&lt;/P&gt;&lt;P&gt;Method failed: HTTP/1.1 401 Unauthorized&lt;BR /&gt;==== resultString ====&lt;BR /&gt;{&lt;BR /&gt;"status" :&lt;BR /&gt;{&lt;BR /&gt;"code" : 401,&lt;BR /&gt;"name" : "Unauthorized",&lt;BR /&gt;"description" : "The request requires HTTP authentication."&lt;BR /&gt;},&lt;/P&gt;&lt;P&gt;"message" : "00270000 Authentication failed for Web Script org\/alfresco\/repository\/managePermission\/managepermissionby.get",&lt;BR /&gt;"exception" : "",&lt;/P&gt;&lt;P&gt;"callstack" :&lt;BR /&gt;[&lt;/P&gt;&lt;P&gt;],&lt;/P&gt;&lt;P&gt;"server" : "Enterprise v5.2.3 (r852994b1-b12) schema 10,065",&lt;BR /&gt;"time" : "Jan 27, 2022 11:22:05 AM"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;==== resultString ====&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 13:40:58 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/scheduled-job-call-web-script/m-p/126890#M34517</guid>
      <dc:creator>faispis</dc:creator>
      <dc:date>2022-01-26T13:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Scheduled job Call Web Script</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/scheduled-job-call-web-script/m-p/126891#M34518</link>
      <description>&lt;P&gt;Since you are in the Repository side, why to invoke a WebScript but to the code executed by that WebScript? Is there any other integration available by using Java API?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 09:27:36 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/scheduled-job-call-web-script/m-p/126891#M34518</guid>
      <dc:creator>angelborroy</dc:creator>
      <dc:date>2022-01-27T09:27:36Z</dc:date>
    </item>
  </channel>
</rss>

