On Thu, Jun 23, 2011 at 7:52 AM, Jeff Pierce <[email protected]> wrote:
> We are trying to create a service that does some simple migration for
> our users and ideally this service runs when Jetspeed is started.  The
> service will require the use of the PageManager and it's APIs to look
> into the folders and pages for each user. We have injected the PM
> reference into our service. We are storing our pages in folders.  We
> have an init-method on our singleton Spring bean that gets called in
> our service.  When getFolder() is called an exception is thrown
> (Missing JSSubject).  I understand why the exception is happening.
>
> 1. Is there a supported way to get such a service to run as a
> privileged user when Jetspeed is starting up?

Yes, we wrapper standard Java subjects with the JSSubject.java class.
General pattern is to execute a privileged action on the JSSubject
class:

Exception executeException =
(Exception)JSSubject.doAsPrivileged(userSubject, new
PrivilegedAction()
 ...


> 2. Is there an example of Jetspeed doing something similar in the
> source some place?

Lots of places. see DatabasePageManagerServer.java, or the PageManager
tests TestCastorXmlPageManager.java, TestDatabasePageManager.java ....

There are also examples of constructing a Subject ...

  private Subject constructUserSubject()
    {
        // setup test subject
        Set principals = new PrincipalsSet();
        principals.add(new TestUser("user"));
        principals.add(new TestGroup("group"));
        principals.add(new TestRole("role"));
        return new Subject(true, principals, new HashSet(), new HashSet());
    }

> 3. Is there a supported way to get our service called after Jetspeed
> is fully up and running instead of relying on Spring's init-method?

All integration tests and standalone apps use Spring to bootstrap
Jetspeed. See the initialize method in JetspeedPageManagerServer.java.
It sets up the JNDI data source, and then points the
SpringComponentManager at the Spring configs necessary to run a page
manager.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to