October 04, 2011, 10:04 PM
TomCConditional fex execution based on variable table
I'm a little unclear about how to control the flow of procedure execution and I would really appreciate some input.
I have a custom wfext plugin which is setting variables in (what I think is the) WebFOCUS variable table based on encrypted authentication parameters passed in the report request URL. When the Java plugin is called it is passed a String[] parameter called NewVars. I use
NewVars[0] = "ROLE=" + userRole
to set a variable showing the requestor's privileges. From what I understand this ROLE variable goes into the variable table. However, I'm not sure how to access this in my procedure. I want to kill / prevent execution of a procedure if ROLE is not a member of a short list.
I assumed I could use a DM IF statement and reference the ROLE variable, but it doesn't seem to have an effect. I created two DM Labels called 'AUTH_PASS' and 'AUTH_FAIL' and placed each of these in front of a different report within the procedure viewer, with the idea that only the relevant report would be generated, but the condition doesn't seem to be working. I always get the AUTH_FAIL report.
I have included the text of my procedure below (as you'll see this obviously isn't the final version, but rather for testing). Any help would be very much appreciated. I already tried 'IF ROLE==...' and 'IF &ROLE=...' but these either errored or made no difference.
-* File Role_Test.fex
SET EMPTYREPORT = ON
-IF ROLE='SysAdmin' THEN GOTO AUTH_PASS
- ELSE GOTO AUTH_FAIL;
-AUTH_FAIL
TABLE FILE RPT_ORG_ID_COMMON_NAME_VW
PRINT
RPT_ORG_ID_COMMON_NAME_VW.RPT_ORG_ID_COMMON_NAME_VW.COMMON_NAME
HEADING
"Auth: Failed"
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K FORMULA
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
TYPE=HEADING,
LINE=1,
JUSTIFY=LEFT,
$
TYPE=HEADING,
LINE=1,
OBJECT=TEXT,
ITEM=1,
STYLE=NORMAL,
$
TYPE=REPORT,
COLUMN=N1,
WRAP=6.000000,
$
ENDSTYLE
END
-AUTH_PASS
TABLE FILE RPT_ORG_ID_COMMON_NAME_VW
PRINT
RPT_ORG_ID_COMMON_NAME_VW.RPT_ORG_ID_COMMON_NAME_VW.COMMON_NAME
HEADING
"Auth: Passed"
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K FORMULA
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
TYPE=HEADING,
LINE=1,
JUSTIFY=LEFT,
$
TYPE=HEADING,
LINE=1,
OBJECT=TEXT,
ITEM=1,
STYLE=NORMAL,
$
TYPE=REPORT,
COLUMN=N1,
WRAP=6.000000,
$
ENDSTYLE
END
October 05, 2011, 10:50 AM
DavSmith&ROLE is proper but 2 other problems will cause this not to work.
1. The main problem is the use of "=" instead of the proper "EQ" on your branching line. This is a common error and I make it often enough.
2. You need to either add an "-EXIT" before the "-AUTH_PASS" or put in a "-GOTO
" and add the label to the end. I prefer using "-GOTO". This is needed so if "-AUTH_FAIL" runs, "-AUTH_PASS" doesn't run.
First, ensure each of the two TABLE request run fine separately.
Second, make sure your DM "&ROLE" variable is populated with the value you want.
If good, then here is my suggestion for your code [Changes colored in RED]:
[CODE]
-* File Role_Test.fex
SET EMPTYREPORT = ON
-IF &ROLE EQ 'SysAdmin' THEN GOTO AUTH_PASS
- ELSE GOTO AUTH_FAIL;
-AUTH_FAIL
TABLE FILE RPT_ORG_ID_COMMON_NAME_VW
PRINT
RPT_ORG_ID_COMMON_NAME_VW.RPT_ORG_ID_COMMON_NAME_VW.COMMON_NAME
HEADING
"Auth: Failed"
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K FORMULA
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
TYPE=HEADING,
LINE=1,
JUSTIFY=LEFT,
$
TYPE=HEADING,
LINE=1,
OBJECT=TEXT,
ITEM=1,
STYLE=NORMAL,
$
TYPE=REPORT,
COLUMN=N1,
WRAP=6.000000,
$
ENDSTYLE
END
-GOTO ENDTEST
-AUTH_PASS
TABLE FILE RPT_ORG_ID_COMMON_NAME_VW
PRINT
RPT_ORG_ID_COMMON_NAME_VW.RPT_ORG_ID_COMMON_NAME_VW.COMMON_NAME
HEADING
"Auth: Passed"
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K FORMULA
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
TYPE=HEADING,
LINE=1,
JUSTIFY=LEFT,
$
TYPE=HEADING,
LINE=1,
OBJECT=TEXT,
ITEM=1,
STYLE=NORMAL,
$
TYPE=REPORT,
COLUMN=N1,
WRAP=6.000000,
$
ENDSTYLE
END
-ENDTEST
October 05, 2011, 12:32 PM
TomCThanks very much for the info DavSmith
I have tried with your suggestions but I'm still having some issues - I currently have parameter prompting on (XMLPROMPT) and when I try to run my report I am prompted for the ROLE parameter. If I turn parameter prompting off I just get an error.
Do you know if I need to do anything else to transfer the ROLE parameter I set in my plug-in through
NewVars[0] = "ROLE=SysAdmin"
to be available to my report? I have seen the functions like CopyWFVarToSessionVar but I don't really understand the terminology enough to know if this is what I need
Any suggestions much appreciated!
October 05, 2011, 12:46 PM
DavSmithHi Tom, Glad it helped somewhat. Unfortunately, I'm not familiar with the IWAY environment or Java plugins so I can't answer you're question as to how to get your &ROLE variable populated so that the paramter prompting does not occur.
Any IWAY/Java experts out there willing to help Tom? If not, a call to the IBI Helpline is your best bet.
Good luck
David
October 07, 2011, 05:38 PM
njsdenTom, couldn't you just default &ROLE to "something" at the beginning of the procedure to avoid DM complaining about the non-existence of it?
-DEFAULTH &ROLE='NONE'
SET EMPTYREPORT = ON
-IF &ROLE EQ 'SysAdmin' THEN GOTO AUTH_PASS
- ELSE GOTO AUTH_FAIL;
...
If this procedured is EXEC'd later on and passed a value for &ROLE this new value will take precedence and will override 'NONE' anyway.
October 11, 2011, 02:58 PM
TomCThanks for your suggestion njsden but there was no change in my report. The syntax highlighting in Developer Studio did not recognise the default(h) statement or any of the variations I tried. Are you sure this syntax is valid for 7.7?
According to IBI support my problem is that I am creating an Application Server session variable in my plugin, which must then be copied to a WebFOCUS variable. They suggested I tried the CopySessionVarToWFVar method, but this is currently returning errors.
Here's hoping I get my problem solved before new year...
October 21, 2011, 01:12 PM
TomCThanks again for all the suggestions on this.
In the end a solution was found by the IBI support people.
The Java plugin is still setting the ROLE variable in the same way (NewVars[0] = "ROLE=SysAdmin") and the site.wfs needed to look like this:
<VER 1>
# $Revision: 1.5 $
# place any variables here from cgivars.wfs that you wish to override.
<call> checkAuth()
<SET>ROLE(PASS)