on 05-03-2006 8:35 AM
Dear All,
I refered the weblog called "<b>Restricting the usage of iviews and pages"</b> using the following link, https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3365. [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken]
I followed the same procedure which is specified in the weblog but when i add the particular iview to the Desktop innerpage and i tried to refresh the corresponding desktop, it is giving an error called page could not create an iview.
If anybody of u done it already please help me.
Thanks in advance,
Regards,
sireesha.
Hi sireesha,
I tried adding the iView to the desktop innerpage and it works fine. Refreshing doesn't give any error. What exactly did u do? Did u run the application and checked if there is no error in that? If it works fine, then u can create iView from the par. Then Open Defaultframeworkpage and open the desktop innerpage. Make sure u have closed the iView u created and then try adding the iView to the page.
Regards,
Harini S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Harini,
When i try to run the application it is giving the following error.
<b>Portal Runtime Error
An exception occurred while processing a request for :
iView : N/A
Component Name : N/A
com/sapportals/portal/htmlb/page/PageProcessorComponent.
Exception id: 09:32_05/05/06_0006_94105150
See the details for the exception ID in the log file</b>
Here i am putting my source code, please go through it and let me know any changes are required in the source file.
public class RoleRestriciton extends PageProcessorComponent {
public DynPage getPage() {
return new RoleRestricitonDynPage();
}
public static class RoleRestricitonDynPage extends DynPage {
/**
Initialization code executed once per user.
*/
public void addRole() {
IRole irole;
IUser user;
IRoleFactory irolefactory = UMFactory.getRoleFactory();
IUserFactory userfactory = UMFactory.getUserFactory();
IPortalComponentResponse response =(IPortalComponentResponse) this.getResponse();
Iterator roleiterator;
try {
user = userfactory.getUserByLogonID("bsireesha");
irole = irolefactory.getRoleByUniqueName("MyTestRole");
irolefactory.addUserToRole(user.getUniqueID(), irole.getUniqueID());
} catch (UMException e) {
e.printStackTrace();
}
}
public void removeRole() {
IRole irole;
IUser user;
IRoleFactory irolefactory = UMFactory.getRoleFactory();
IUserFactory userfactory = UMFactory.getUserFactory();
IPortalComponentResponse response =(IPortalComponentResponse) this.getResponse();
Iterator roleiterator;
try {
user = userfactory.getUserByLogonID("bsireesha");
irole = irolefactory.getRoleByUniqueName("MyTestRole");
irolefactory.removeUserFromRole(user.getUniqueID(), irole.getUniqueID());
} catch (UMException e) {
e.printStackTrace();
}
}
public boolean checkMyTime() {
Date sysDate= new Date();
if(sysDate.getHours() >= 13 && sysDate.getHours() <= 15){
return true;
}
else{
return false;
}
}
public void doInitialization() {
}
public void doProcessAfterInput() throws PageException {
}
public void doProcessBeforeOutput() throws PageException {
//Form myForm = this.getForm(); // get the form from DynPage
boolean inTime;
int FlagLock=1;
inTime = checkMyTime();
if(inTime && FlagLock == 1)
{
removeRole();
FlagLock = 0;
}
else{
addRole();
FlagLock = 1;
}
// create your GUI here....
}
}
}
Regards,
Sireesha.
Hi sireesha,
I have an userid called testuser in my server havin content admin role. I tried removing the role between 12 to 1pm and it works. If the code is run between this time, the role is removed. U can check this by loggin in between this time with that userid.
For getting some response output, I have added 2 lines in the code. If u run the code from ur portalapp.xml, then the output is
Time valid for removing the role
and the role is removed. Check this code.
import java.util.Iterator;
import java.util.Date;
import com.sap.security.api.IRole;
import com.sap.security.api.IRoleFactory;
import com.sap.security.api.IUser;
import com.sap.security.api.IUserFactory;
import com.sap.security.api.UMException;
import com.sap.security.api.UMFactory;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
import com.sapportals.htmlb.*;
import com.sapportals.htmlb.enum.*;
public class RoleRestriciton extends PageProcessorComponent {
public DynPage getPage() {
return new RoleRestricitonDynPage();
}
public static class RoleRestricitonDynPage extends DynPage {
/**
Initialization code executed once per user.
*/
public void addRole() {
IRole irole;
IUser user;
IRoleFactory irolefactory = UMFactory.getRoleFactory();
IUserFactory userfactory = UMFactory.getUserFactory();
IPortalComponentResponse response =(IPortalComponentResponse) this.getResponse();
Iterator roleiterator;
try {
user = userfactory.getUserByLogonID("testuser");
irole = irolefactory.getRoleByUniqueName("content_admin_role");
irolefactory.addUserToRole(user.getUniqueID(), irole.getUniqueID());
} catch (UMException e) {
e.printStackTrace();
}
}
public void removeRole() {
IRole irole;
IUser user;
IRoleFactory irolefactory = UMFactory.getRoleFactory();
IUserFactory userfactory = UMFactory.getUserFactory();
IPortalComponentResponse response =(IPortalComponentResponse) this.getResponse();
Iterator roleiterator;
try {
user = userfactory.getUserByLogonID("testuser");
irole = irolefactory.getRoleByUniqueName("content_admin_role");
irolefactory.removeUserFromRole(user.getUniqueID(), irole.getUniqueID());
} catch (UMException e) {
e.printStackTrace();
}
}
public boolean checkMyTime() {
Date sysDate= new Date();
IPortalComponentResponse response = (IPortalComponentResponse)this.getResponse();
if(sysDate.getHours() >= 12 && sysDate.getHours() <= 13){
response.write("Time valid for removing the role");
return true;
}
else{
response.write("Time invalid now for removing the role");
return false;
}
}
public void doInitialization() {
}
public void doProcessAfterInput() throws PageException {
}
public void doProcessBeforeOutput() throws PageException {
//Form myForm = this.getForm(); // get the form from DynPage
boolean inTime;
int FlagLock=1;
inTime = checkMyTime();
if(inTime && FlagLock == 1)
{
removeRole();
FlagLock = 0;
}
else{
addRole();
FlagLock = 1;
}
// create your GUI here....
}
}
}
Hope this helps.
Regards,
Harini S
Hi Harini,
I tried with your code, again i am getting the same error, which have given u previously,
could u please tell me how to get the logfile for this.so that i can post you the log file.
and one more thing is, in your code u didnot declare the variable called, inTime and FlagLock so i added the following lines in the PBO part. Please go through it once.
boolean inTime;
int FlagLock=1;
Thanks & Regards,
Sireesha.
Hi sireesha,
I have declared those two lines. See clearly.
Don't keep changing the old code itself. U can create a new project and paste the code there and check.
For the log file, goto
System Admin -> Support -> Portal runtime -> Log viewer
Put the exception id in the search box and click search. It will give u the file in which exception has been logged. Check the last part of the file.
Regards,
Harini S
Hi Harini,
Here i am putting the log file, please go through it.
ID:01:06_05/05/06_0013_94105150
[EXCEPTION]
#1#com.sapportals.portal.prt.component.PortalComponentException: Error in init method
Component : RoleRestriction.RoleRestriciton
at com.sapportals.portal.prt.component.PortalComponentContext.init(PortalComponentContext.java:251)
at com.sapportals.portal.prt.core.broker.PortalComponentContextItem.refresh(PortalComponentContextItem.java:267)
at com.sapportals.portal.prt.core.broker.PortalComponentContextItem.getContext(PortalComponentContextItem.java:312)
at com.sapportals.portal.prt.component.PortalComponentRequest.getComponentContext(PortalComponentRequest.java:385)
at com.sapportals.portal.prt.connection.PortalRequest.getRootContext(PortalRequest.java:435)
at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:607)
at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:232)
at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:522)
at java.security.AccessController.doPrivileged(Native Method)
at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:405)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:153)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
Caused by: com.sapportals.portal.prt.core.broker.PortalComponentInstantiationException: Could not instantiate implementation class com.obt.practice.RoleRestriciton of Portal Component RoleRestriction.RoleRestriciton because: Linkage error while loading implementation class
at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.getInstanceInternal(PortalComponentItemFacade.java:234)
at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.getComponentInstance(PortalComponentItemFacade.java:160)
at com.sapportals.portal.prt.core.broker.PortalComponentItem.getComponentInstance(PortalComponentItem.java:732)
at com.sapportals.portal.prt.component.PortalComponentContext.getComponent(PortalComponentContext.java:103)
at com.sapportals.portal.prt.component.PortalComponentContext.init(PortalComponentContext.java:242)
... 26 more
Caused by: java.lang.NoClassDefFoundError: com/sapportals/portal/htmlb/page/PageProcessorComponent
-
Loader Info -
ClassLoader name: [com.sapportals.portal.prt.util.ApplicationClassLoader@60feb4]
Parent loader name: [com.sapportals.portal.prt.util.ApplicationClassLoader@1adb94f]
No references !
No resources !
-
The error occurred while trying to load "com.obt.practice.RoleRestriciton".
at com.sap.engine.frame.core.load.ReferencedLoader.loadClass(ReferencedLoader.java:328)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.getInstanceInternal(PortalComponentItemFacade.java:228)
... 30 more
Thanks.
Sireesha.
Hi Harini,
I tried all the ways but it is not working, and one more thing what i found is, i tried by removing all the code and just added a single control to the form, even for that also it is giving the error. i couldn't execute the even a single line of code in a Dynpage. The Exception is common to all the same error it is showing in the trace file.
Do u have any idea abt this type of error?
Regards,
Sireesha.
Hi Harini,
i've added the iview to the desktop innerpage and if i run my portal applicaiton the corresponding roles is removing/adding based on the time. but automatically it is not removing/adding the role to the user.if i run my application independently only the changes are reflecting in the user.
Thanks & Regards,
sireesha.
Hi sireesha,
U need not run the application independently. When u add that iView to the desktop innerpage itself, it will run automatically (whenever the defaultframeworkpage is getting loaded). Have u added the iView properly? If so, it should work. I have tried. Otherwise, try adding that iView in the defaultframework page itself(at the first level)without going inside desktop innnerpage and adding it. Hope that helps.
Regards,
Harini S
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.