You are here

JSP can't find PortalSecurityException

Submitted by LeakyBucket on Mon, 09/24/2012 - 16:42

Forums:

I'm trying to determine the users roles in a JSP that is being rendered by a JSR-168 Portlet.

The following code is throwing errors I can't explain:



private String getRoles(HttpServletRequest hsr) throws PortalSecurityException {
StringBuffer sb = new StringBuffer();
SimplePersonManager spm = new SimplePersonManager();
IPerson i = spm.getPerson(hsr);
Object [] roles = i.getAttributeValues("urn:sungardhe:dir:role");
String rolesStr = "";
for (int n=0; n rolesStr = roles[n].toString() + "," + rolesStr;
}
sb.append(rolesStr);
return sb.toString();
}
%>

I get the following in catalina.out:

An error occurred at line: 18 in the jsp file: /WEB-INF/view/jsp/inbox_preview.jsp
PortalSecurityException cannot be resolved to a type
15:
16:
17: 18: private String getRoles(HttpServletRequest hsr) throws PortalSecurityException {
19: StringBuffer sb = new StringBuffer();
20: SimplePersonManager spm = new SimplePersonManager();
21: IPerson i = spm.getPerson(hsr);

It also complains about SimplePersonManager and IPerson.

When I try to specify PortalSecurityException explicitly (import="org.jasig.portal.security.PortalSecurityException") it tells me that target is a package not a class.

I'm not a java developer so any insight would be helpful. Ellucian has been silent on my ticket.

CodeStorm:

Luminis Version:

Here's some working code we use to determine if someone has a particular role. 'arrayString' will contain a list of roles. In this case, we use the java function 'indexOf' to search for a particular role. This code is executed under the $CP_ROOT/webapps/luminis/jsp directory. If you want to run jsp code in other directories, there are other steps involved.

note: not sure if all the import statements are necessary. I copy/pasted this from a larger jsp. But I did take the time to make sure it ran without error:)

Also, in our personDirectory.xml file, I set things like: (removed all "set>value>pdsRole/value>value>urn:sungardhe:dir:role/value>/set>/entry>

So that I could refer to pdsRole rather than the long urn:sungardhe...blah blah. You probably haven't done that, so you'll need to change pdsRole in the below code to whatever is in your personDirectory.xml.







public String isFinaid(HttpServletRequest hsr)
throws PortalSecurityException
{
StringBuffer sb = new StringBuffer();
SimplePersonManager spm = new SimplePersonManager();
IPerson i = spm.getPerson(hsr);
Object [] idAllArray = i.getAttributeValues("pdsRole") ;
String arrayString = Arrays.toString(idAllArray);

String isFinaid = "no";

if (arrayString.indexOf("pcc_student_active_credit") > 0)
{
if (arrayString.indexOf("finaid") > 0 )
{
isFinaid = "yes";
}
}

return isFinaid;

}
%>

Thanks Jason,

That definitely points me in the right direction. I always forget that in Java context/location is the end all and be all. I had the jsp code packaged with the portlet but didn't have the uportal.jar with it.

I'm no longer getting compile errors. I'm getting a stack overflow now but new errors = progress.

Again thank you.