Re: Turning RQL into a user-defined job (ASP)

143 views
Skip to first unread message
Message has been deleted

Jian Huang

unread,
Dec 17, 2012, 4:50:23 PM12/17/12
to reddot-c...@googlegroups.com
Hi Neil,

As a workflow reaction to call a user define job?  I don't think it is possible as there is no way to pass the page guid.

However, if in the workflow you have it create a workflow xml, then have something to monitor the folder for new xmls, read from xml for project guid and page guid, then have custom console app to execute the RQL, then it is possible.

-Jian

On Monday, December 17, 2012 10:56:11 AM UTC-5, Neil Fegen wrote:
Hi guys

I'd like to call a user-defined job to look for pages of template X and remove keyword Y if the page was created between certain dates.

I have the following RQL working in a SmartEdit page - what changes do I need to make to call it as a user-defined job .asp file? I presume changing the login guid/session key calls (to what?) but what else?

<% 
set objIO = Server.CreateObject("RDCMSAsp.RDPageData")
objIO.XmlServerClassName = "RDCMSServer.XmlServer"
set XMLDomPage = Server.CreateObject("Microsoft.XMLDOM")

xmlData = "<IODATA loginguid=""<%inf_loginGuid%>"" sessionkey=""<%inf_SessionKey%>"">" & _
"<PAGE action=""search"" templateguid=""30422810663E41BFB6CF5C03CBC8B6F4"" projectguid=""<%inf_projectGuid%>"" createdatefrom=""40544"" createdateto=""40908"" keyword=""2011"" flags=""1"" maxrecords=""200""/>" & _
"</IODATA>"
xmlData = objIO.ServerExecuteXml(xmlData,sError)
if sError>"" then Response.write "An error has occurred with listing the pages:<br />" & sError & "<br /><br />" End if
Call XMLDomPage.LoadXML(xmlData)
set pageData = XMLDomPage.getElementsByTagName("PAGE")

For n = 0 to (pageData.Length-1)
xmlData = "<IODATA loginguid=""<%inf_loginGuid%>"" sessionkey=""<%inf_SessionKey%>"">" & _
"<PROJECT>" & _
"<PAGE guid=""" & pGuid & """ action=""assign"">" & _
"<KEYWORDS>" & _
"<KEYWORD guid=""8F303AE60F0F41659F58DF56B8809117"" delete=""1"" changed=""1""/>" & _
"</KEYWORDS>" & _
"</PAGE>" & _
"</PROJECT>" & _
"</IODATA>"
xmlData = objIO.ServerExecuteXml(xmlData,sError)
if sError>"" then Response.write "An error has occurred with removing the keywords:<br />" & sError & "<br /><br />" End if
Call XMLDomPage.LoadXML(xmlData)
Next

set XMLDomPage = nothing
set objIO = nothing
set xmlData = nothing
%>

Many thanks

Neil

Jian Huang

unread,
Dec 17, 2012, 4:55:51 PM12/17/12
to reddot-c...@googlegroups.com
Ooops, just re-read the RQL.  You are using page search (though you should use xsearch RQL for performance reasons).  Besides login guid and session guid (you need to do login rql to get login guid, project switch rql to get session guid), you just need project guid.

Please search in the forum for the project switch rql needed in used defined job.

Best,

-Jian

Manuel Schnitger (OpenText)

unread,
Dec 18, 2012, 10:22:07 AM12/18/12
to reddot-c...@googlegroups.com
Hi Neil,

I think/hope, this might help. Just save the code as a file with the name "JobDeleteKeywords.asp" under \program files\reddot\cms\asp\plugins\DeleteKeywords\. Then create a user defined job and select that you wish to call a url. If you place the asp file under the mentioned path then you could enter "http://localhost/cms/plugins/DeleteKeywords/DeleteKeywords.asp" as the url of the job. After that you should modify the constants mentioned in the file. Whenever you need to perform something similar you could use the file. Just delete the page search part and the part where the keywords are deleted and put in other stuff that you'd like to execute.

If the script doesn't work then just drop me a line and I'll try to help.

Best regards,
Manuel

P.S.: I tested the script with WSM 10.1 and it worked. If you wish to use it with V11 then you will have to modify it slightly.


<%@ LANGUAGE="VBSCRIPT" %>
<% Option explicit %>
<%
Server.ScriptTimeout = 36000
response.buffer      = true
'******************************************************************
'** All rights reserved.                                         **
'** Developer: M.Schnitger (msch...@opentext.com)               **
'** Company: OpenText Software GmbH, Munich, Germany             **
'** Date: 12/2012                                                **
'** Project: "general"                                           **
'** Modulname: DeleteKeywords.asp                                **
'** WSM-Version: 10.x                                            **
'** Release: 1.0                                                 **
'** Copyright (c) OpenText Corporation 2012                      **
'** Don't try this at home ;-)                                   **
'******************************************************************
%>
<font face="courier" size="2">
<%

'***************************
'* declare constants
'***************************
const sName     = "admin2"
const sPassword = "admin2"
const sProjectGuid = "A02EA0F99D834FC9A481E625518C9AF3"
const sKeywordGuid = "B4580DCBBB9F4DA9BB485B33D67144D4"

    '**************************************
    '* log on
    '**************************************
    dim sLoginGuid
    sLoginGuid = Login(sName,sPassword)
    response.write "<br>LoginGuid:&nbsp;" & sLoginGuid  & "<br>"
    session("LoginGuid") = sLoginGuid

    '**************************************
    '* validate
    '**************************************
    dim sSessionKey
    sSessionKey = Validate(sLoginGuid,sProjectGuid)
    response.write "<br>Sessionkey:&nbsp;" & sSessionKey & "<br>"
    session("SessionKey") = sSessionKey
   
    '**************************************
    '* search pages based on a specific keyword
    '**************************************   
    dim aPageList, a
    aPagelist = PageSearch (sKeywordGuid)
    for a = 1 to ubound(aPageList)   
        response.write aPageList(a,2) & "<br>"
        '**************************************
        '* search pages based on a specific keyword
        '**************************************
        call DeleteKeywords(aPageList(a,0),sKeywordGuid)   
    next
   
    '**************************************
    '* log off
    '**************************************
    Logout sLoginGuid




'**********************************************************************************************************************************************************
'* RQL Functions ---RQL Functions ---RQL Functions ---RQL Functions ---RQL Functions ---RQL Functions ---RQL Functions ---RQL Functions ---RQL Functions ---RQL Functions ---
'**********************************************************************************************************************************************************


'*************************************************************************
'* search for all pages having a specific keyword
'*************************************************************************

function DeleteKeywords(sPageGuid,sKeywordGuid)

  dim      RQLObject,RQLStatement,RQLRequest,sError
  set RQLObject                            = Server.CreateObject("RDCMSAsp.RdPageData")            
  RQLObject.XmlServerClassName          = XmlServerClassName  
  const XmlServerClassName              = "RDCMSServer.XmlServer"
  const DhtmlClassName                  = "RDCMSAsp.RdPageData"
 
   RQLStatement = "<IODATA loginguid=""" & sLoginGuid & """ sessionkey=""" & sLoginGuid & """>" & _
                  "<PROJECT>" & _
                  "<PAGE guid=""" & sPageGuid & """ action=""assign"">" & _
                  "<KEYWORDS>" & _
                  "<KEYWORD guid=""" & sKeywordGuid & """ delete=""1"" changed=""1""/>" & _

                  "</KEYWORDS>" & _
                  "</PAGE>" & _
                  "</PROJECT>" & _
                  "</IODATA>"
                 
                  response.write server.htmlencode(RQLStatement)
  RQLRequest   = RQLObject.ServerExecuteXml(RQLStatement, sError)
                 if sError>"" then Response.write "Delete keyword. An error has occured:</BR></BR>"+sError

end function
'*******************************
'*******************************


'*************************************************************************
'* search for all pages having a specific keyword
'*************************************************************************
function PageSearch (sKeywordGuid)
   
  dim XMLDomSearchResult, RQLObject, RqlStatement,RQLRequest,sError,XMLDomSearchPages ,i   
 
  set XMLDomSearchResult                = Server.CreateObject("RDCMSAspObj.RdObject")
  set RQLObject                            = Server.CreateObject("RDCMSAsp.RdPageData")            
  RQLObject.XmlServerClassName          = XmlServerClassName  
  const XmlServerClassName              = "RDCMSServer.XmlServer"
  const DhtmlClassName                  = "RDCMSAsp.RdPageData"
 
 

  RqlStatement = "<IODATA sessionkey=""" & sSessionKey & """>"&_
                 "<PAGE action=""xsearch"">"&_
                 "<SEARCHITEMS>"&_
                 "<SEARCHITEM key=""keyword"" value=""" & sKeywordGuid & """ operator=""eq"" />"&_
                 "</SEARCHITEMS>"&_
                 "</PAGE>"&_
                 "</IODATA>"
  RQLRequest   = RQLObject.ServerExecuteXml(RQLStatement, sError)
                 if sError>"" then Response.write "List pages. An error has occured:</BR></BR>"+sError
       
                 Call XMLDomSearchResult.LoadXML (RQLRequest)

                                  Set XMLDomSearchPages   = XMLDomSearchResult.ObjectByQuery ("//PAGES")
                               
                                  redim aPages(XMLDomSearchPages.objects.count,2)
                                 
                    for i = 1 to XMLDomSearchPages.objects.count
                    aPages(i,0) = XMLDomSearchPages.objects(i)("guid")
                    aPages(i,1) = XMLDomSearchPages.objects(i)("id")
                    aPages(i,2) = XMLDomSearchPages.objects(i)("headline")
                  next

                                 PageSearch = aPages

end function
'*******************************
'*******************************


'*********************************************************************************
'* Login
'*********************************************************************************
function Login(sName,sPassword)

    '***************************
    '* declare variables
    '***************************
    dim XmlDom
    dim RQLObject
    dim RQLStatement
    dim RQLRequest
    dim sError
    dim sLoginGuid
   
   
    '***************************
    '* initialize objects
    '***************************
    set XmlDom                    = Server.CreateObject("RDCMSAspObj.RdObject")
    set RQLObject                 = Server.CreateObject("RDCMSAsp.RdPageData")
    RQLObject.XmlServerClassName  = XmlServerClassName
    const XmlServerClassName      = "RDCMSServer.XmlServer"
    const DhtmlClassName          = "RDCMSAsp.RdPageData"


    RQLStatement = "<IODATA>" & _
                   "<ADMINISTRATION action=""login"" name=""" & sName & """ password=""" & sPassword & """/>" & _
                   "</IODATA>"
    RQLRequest   = RQLObject.ServerExecuteXml(RQLStatement, sError)
                   if sError>"" then Response.write "Login Error:</BR></BR>"+sError

                   XMLDOM.LoadXml cstr(RQLRequest)

    sLoginGuid   = XMLDOM.objects("LOGIN")("guid")

    Login = sLoginGuid

end function
'**********
'**********

'*********************************************************************************
'* Validate
'*********************************************************************************
function Validate(sLoginGuid,sProjectGuid)

    '***************************
    '* declare variables
    '***************************
    dim XmlDom
    dim RQLObject
    dim RQLStatement
    dim RQLRequest
    dim sError
    dim sSessionKey

    '***************************
    '* initialize objects
    '***************************
    set XmlDom                    = Server.CreateObject("RDCMSAspObj.RdObject")
    set RQLObject                 = Server.CreateObject("RDCMSAsp.RdPageData")
    RQLObject.XmlServerClassName  = XmlServerClassName
    const XmlServerClassName      = "RDCMSServer.XmlServer"
    const DhtmlClassName          = "RDCMSAsp.RdPageData"

    RQLStatement = "<IODATA loginguid=""" & sLoginGuid & """>"&_
                          "<ADMINISTRATION action=""validate"" guid=""" & sLoginGuid & """ checkonly=""1"" useragent=""script"" >"&_
                         "<PROJECT guid=""" & sProjectGuid & """ />"&_
                         "</ADMINISTRATION>"&_
                         "</IODATA>"
    RQLRequest   = RQLObject.ServerExecuteXml(RQLStatement, sError)
                   if sError>"" then Response.write "An error has occured:</BR></BR>"+sError

    XMLDOM.LoadXml cstr(RQLRequest)

    sSessionKey=XMLDOM.objects("SERVER")("key")

    Validate = sSessionKey

end function
'**********
'**********

'*********************************************************************************
'* Logout
'*********************************************************************************
function Logout(sLoginGuid)

    '***************************
    '* declare variables
    '***************************
    dim XmlDom
    dim RQLObject
    dim RQLStatement
    dim RQLRequest
    dim sError

    '***************************
    '* initialize objects
    '***************************
    set XmlDom                    = Server.CreateObject("RDCMSAspObj.RdObject")
    set RQLObject                 = Server.CreateObject("RDCMSAsp.RdPageData")
    RQLObject.XmlServerClassName  = XmlServerClassName
    const XmlServerClassName      = "RDCMSServer.XmlServer"
    const DhtmlClassName          = "RDCMSAsp.RdPageData"

    RQLStatement = "<IODATA loginguid=""" & sLoginGuid & """>"&_
                   "<ADMINISTRATION>"&_
                   "<LOGOUT guid=""" & sLoginGUID & """ />"&_
                   "</ADMINISTRATION>"&_
                   "</IODATA>"
    RQLRequest   = RQLObject.ServerExecuteXml(RQLStatement, sError)

                   if sError>"" then Response.write "Logout Error"+sError

end function
'**********
'**********







%>
Reply all
Reply to author
Forward
0 new messages