url-rewritingwebcenterwebcenter-sites

Url rewriting session issue with oracle webcenter sites 11gR1


I'm trying to do url rewriting from "beautiful" human-readable urls to webcenter internal representation and vice versa. I'm using AssetDataManager to map asset id to asset description, which I use in the URL, and the other way around. This is what I have with url assembly:

Session ses = SessionFactory.getSession();
AssetDataManager mgr = (AssetDataManager) ses
   .getManager(AssetDataManager.class.getName());
List<AssetId> assets = new ArrayList<AssetId>();
assets.add(new AssetId()
{
    private long   id   = assetId;
    private String type = "Page";

    @Override
    public String getType()
    {
        return type;
    }

    @Override
    public long getId()
    {
        return id;
    }
});
Iterable<AssetData> assetDataItems = mgr.read(assets);

And this is for url disassembly:

Session ses = SessionFactory.getSession();
AssetDataManager mgr = (AssetDataManager) ses
  .getManager(AssetDataManager.class.getName());
final String assetType = "Page";

final String subType = null; 
final Condition condition = ConditionFactory.createCondition(
        "description", OpTypeEnum.EQUALS, pageName);
final List<String> desiredAttributes = Arrays.asList("id");
Query query = new SimpleQuery(assetType, subType, condition,
        desiredAttributes);
query.getProperties().setIsBasicSearch(true);

Iterable<AssetData> assetDataItems = mgr.read(query);

Both are used in the context of my custom assembler, which extends QueryAssembler. Assembly works fine, reusing existing session, but disassembly fails with:

COM.FutureTense.Common.ContentServerException: ContentServerException: (Unexpected runtime exception) Error code:GENERIC SERVER ERROR
    at com.openmarket.Satellite.servlet.BaseServlet.doGet(BaseServlet.java:126)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.fatwire.wem.sso.cas.filter.CASFilter.doFilter(CASFilter.java:554)
    at com.fatwire.wem.sso.SSOFilter.doFilter(SSOFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)
Caused by: com.openmarket.Satellite.RequestContext$RequestContextInitializationException: Co-resident Satellite Server failed to capture ICS
    at com.openmarket.Satellite.RequestContext.getICS(RequestContext.java:1030)
    at com.openmarket.Satellite.RequestContext.captureInputCoResident(RequestContext.java:518)
    at com.openmarket.Satellite.RequestContext.<init>(RequestContext.java:428)
    at com.openmarket.Satellite.servlet.BaseServlet.doGet(BaseServlet.java:112)
    ... 18 more
Caused by: java.lang.NullPointerException
    at COM.FutureTense.Common.CS.PushVars(CS.java:217)
    at com.openmarket.framework.objects.ContentCatalog.Lookup(ContentCatalog.java:305)
    at com.openmarket.framework.objects.AbstractContent.Read(AbstractContent.java:510)
    at com.openmarket.framework.objects.AbstractObject.Read(AbstractObject.java:460)
    at com.openmarket.framework.objects.AbstractObject.Read(AbstractObject.java:446)
    at com.openmarket.xcelerate.asset.AssetType.Load(AssetType.java:499)
    at com.fatwire.assetapi.util.AssetUtil.isComplexAsset(AssetUtil.java:125)
    at com.fatwire.assetapi.util.AssetUtil.isFlexAsset(AssetUtil.java:274)
    at com.fatwire.assetapi.data.AssetDataManagerImpl.read(AssetDataManagerImpl.java:79)
    at mypackage.urlassembler.ComplexDisassemblyData.getAssetIdFromPageName(ComplexDisassemblyData.java:189)
    at mypackage.urlassembler.ComplexDisassemblyData.valueOf(ComplexDisassemblyData.java:145)
    at mypackage.urlassembler.MyCustomURLAssembler.getDisassemblyContext(MyCustomURLAssembler.java:79)
    at com.fatwire.cs.core.uri.AbstractAssembler.disassemble(AbstractAssembler.java:418)
    at com.fatwire.cs.core.uri.AssemblerEngine.disassemble(AssemblerEngine.java:242)
    at COM.FutureTense.Servlet.ServletRequest.disassembleURI(ServletRequest.java:852)
    at COM.FutureTense.Servlet.ServletRequest.initializeParameters(ServletRequest.java:1023)
    at COM.FutureTense.Servlet.ServletRequest.getParameters(ServletRequest.java:786)
    at COM.FutureTense.Servlet.FRequestObj.prepInput(FRequestObj.java:1090)
    at COM.FutureTense.Servlet.FRequestObj.init(FRequestObj.java:973)
    at COM.FutureTense.Servlet.FRequestObj.<init>(FRequestObj.java:271)
    at COM.FutureTense.Servlet.FRequestObj.newInstance(FRequestObj.java:231)
    at COM.FutureTense.Servlet.FRequestObj.newInstance(FRequestObj.java:218)
    at COM.FutureTense.CS.Factory.newCS(Factory.java:66)
    at com.openmarket.Satellite.RequestContext.getICS(RequestContext.java:1026)
    ... 21 more

Which seems very strange. For some reason it is unable to use the existing session. If I change disassembly session retrieval to this, it works fine:

Session ses = SessionFactory.newSession(userName, pass);

However, I certainly would not want to create another session every time I want to resolve an url. Why do I get the exception? What would be a good way to handle this?


Solution

  • Ok, so apparently URL disassembly can't do anything related to DB content, as it is meant to be executed on a satellite server where it doesn't have the connectivity. For URL assembly using the DB is fine though...

    So based on this, I figured out that I need to move my Asset API code to a helper class that is called from an uncached wrapper. From there it works fine.