4 Replies Latest reply on Mar 27, 2019 7:44 AM by PraveenKM

    How to get embeddedLinks from an AssetReader inside a WCS Controller?

    PraveenKM

      Hi Team,

       

      I am trying to get the embedded links from an AssetReader instance inside a WCS Controller but getting the below error on OWCS 12c version.

       

      ***********OWCS Version Details:********

       

       

      *************** Code Used to get the embedded link: *************

       

      Map myAsset = newAssetReader()

      .forAsset(getAssetId())

      .select("ShortDescription")

      .evaluateEmbeddedLinks(true)

      .read();

       

      ********* Exception in sites.log *******************

       

      [2019-03-21T08:33:53.043-04:00] [wcsites_server1] [ERROR] [] [oracle.wcsites.request] [tid: 22] [userId: <anonymous>] [ecid: 005X9bnRGyZD4i0LvyCCyX0002c60002dO,0:1] [APP: sites] [partition-name: DOMAIN] [tenant-name: GLOBAL] COM.FutureTense.Common.ContentServerException: ContentServerException: (Exception processing controller MyController) Error code:GENERIC SERVER ERROR[[

      COM.FutureTense.Common.ContentServerException: ContentServerException: (Exception processing controller MyController) Error code:GENERIC SERVER ERROR

      at COM.FutureTense.Common.ContentServer.evalController(ContentServer.java:3910)

      at COM.FutureTense.Common.ContentServer.processController(ContentServer.java:1479)

      at COM.FutureTense.Common.ContentServer.evalPage(ContentServer.java:1310)

      at COM.FutureTense.Common.ContentServer.execute(ContentServer.java:483)

      at COM.FutureTense.Servlet.FTServlet.execute(FTServlet.java:120)

      at COM.FutureTense.Servlet.FTServlet.doGet(FTServlet.java:52)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286)

      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)

      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)

      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:350)

      at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)

      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)

      at com.lfg.sites.extend.webapp.filter.SitesLogFilter.doFilter(SitesLogFilter.java:45)

      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)

      at oracle.wcsites.eloquaintegration.EloquaAuthenticationFilter.doFilter(EloquaAuthenticationFilter.java:55)

      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)

      at COM.FutureTense.Servlet.URLRewriteFilter.doFilter(URLRewriteFilter.java:98)

      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)

      at com.fatwire.auth.RequestAuthenticationFilter.doFilter(RequestAuthenticationFilter.java:256)

      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)

      at com.fatwire.wem.sso.cas.filter.CASFilter.doFilter(CASFilter.java:626)

      at com.fatwire.wem.sso.SSOFilter.doFilter(SSOFilter.java:51)

      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)

      at com.fatwire.cs.ui.framework.UIFilter.doFilter(UIFilter.java:105)

      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)

      at COM.FutureTense.Security.Common.ContentSecurityFilter.doFilter(ContentSecurityFilter.java:112)

      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)

      at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:141)

      at java.security.AccessController.doPrivileged(Native Method)

      at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)

      at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:650)

      at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:124)

      at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:232)

      at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:94)

      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)

      at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:248)

      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)

      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3683)

      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3649)

      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)

      at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)

      at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)

      at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)

      at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2433)

      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2281)

      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2259)

      at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1692)

      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1652)

      at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:272)

      at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)

      at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)

      at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)

      at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)

      at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)

      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)

      at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)

      Caused by: javax.script.ScriptException: java.lang.Exception: Exception processing controller MyController

      at COM.FutureTense.Common.ControllerProcessorImpl.evaluate(ControllerProcessorImpl.java:185)

      at COM.FutureTense.Common.ContentServer.evalController(ContentServer.java:3908)

      ... 57 more

      Caused by: java.lang.Exception: Exception processing controller MyController

      ... 59 more

      Caused by: groovy.lang.MissingMethodException: No signature of method: com.fatwire.assetapi.data.AssetReaderImpl.evaluateEmbeddedLinks() is applicable for argument types: (java.lang.Boolean) values: [true]

      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)

      at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:49)

      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)

      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)

      at oracle.webcenter.sites.controller.MyController.buildQuestionnaireCompAssetDataJson(MyController:26)

      at oracle.webcenter.sites.controller.MyController.doWork(MyController:150)

      at com.fatwire.assetapi.data.BaseController.handleRequest(BaseController.java:400)

      at COM.FutureTense.Common.ControllerProcessorImpl._evaluate(ControllerProcessorImpl.java:342)

      at COM.FutureTense.Common.ControllerProcessorImpl.evaluate(ControllerProcessorImpl.java:152)

      ... 58 more

       

      **************************************************************************************************************************************************************

       

      Any help on the usage of getting the embedded links would be much appreciated. Thanks in Advance and Hoping for a solution.

       

      Regards,

      Praveen KM

        • 1. Re: How to get embeddedLinks from an AssetReader inside a WCS Controller?
          Joe_Scanlon

          That method is not available in the builder - your IDE should have complained about it

           

          Caused by: java.lang.Exception: Exception processing controller MyController

           

          ... 59 more

           

          Caused by: groovy.lang.MissingMethodException: No signature of method: com.fatwire.assetapi.data.AssetReaderImpl.evaluateEmbeddedLinks() is applicable for argument types: (java.lang.Boolean) values:

           

           

           

          But you could change to something like this in your controller:

           

           

          Map myAsset = newAssetReader()

          .forAsset(getAssetId())

          .select("ShortDescription")

          .read();   //fetch the asset

           

           

           

          EmbeddedLink link = new EmbeddedLink(ics,myAsset.get("ShortDescription"),false,false,true);  //grab field that has embedded link

          String str = link.evaluate();

          myAsset.put("ShortDescription",str); //add into your object to pass around

           

           

          Joe Scanlon

           

          M: 603.459.3242

          F: 1-941-296-7907

          E: joe.scanlon@allstar-it.com

           

           

          CONFIDENTIALITY NOTICE: This email message (including attachments) contains information which may be confidential and/or legally privileged.

          Unless you are the intended recipient, you may not use, copy or disclose to anyone the message or any information contained in the message or from any attachments that were sent with this email, and If you have received this email message in error, please advise the sender by email, and delete the message.

           

          Unauthorized disclosure and/or use of information contained in this email may result in civil and criminal liability

          • 2. Re: How to get embeddedLinks from an AssetReader inside a WCS Controller?
            PraveenKM

            Hi Joe,

             

            Thanks for the update.

             

            I did try the logic provided by you and it is throwing below error in the logs.

             

            Basically a page attribute holding ckeditor is embedded with a Link asset holding "Link" template. As soon as i refresh the page, the page breaks throwing below error in logs.

             

            ******** Error *****

             

            [2019-03-21T10:54:24.676-04:00] [wcsites_server1] [ERROR] [] [oracle.wcsites.request] [tid: 106] [userId: <anonymous>] [ecid: 005X9je13yrD4i0LvyCCyX0002c60002hd,0:1] [APP: sites] [partition-name: DOMAIN] [tenant-name: GLOBAL] COM.FutureTense.Common.ContentServerException: Unable to locate page MySite/LinkAsset/Link\ Error code:PAGE NOT FOUND

             

            Please let me know if you need any more details.

             

            Thanks,

            Praveen KM

            • 3. Re: How to get embeddedLinks from an AssetReader inside a WCS Controller?
              Graham L

              Looks like the evaluateEmbeddedLinks method is no longer in the interface (So much for backward compatibility)

               

              So you can use <render:stream /> or <insite:edit /> to render them in your template. You can also use the AssetFacade.processeEmbeddedLink(String) which under the hood basically does what Joe has written,

               

              public String processEmbeddedLink(String data)

                {

                  String ret = null;

                  if (null != data)

                  {

                    EmbeddedLink embeddedLink = new EmbeddedLink(this.ics, data);

                    ret = embeddedLink.evaluate();

                  }

                 

                  return ret;

                }

              • 4. Re: How to get embeddedLinks from an AssetReader inside a WCS Controller?
                PraveenKM

                Hi Graham,

                 

                Below is what i am trying to achieve, probably this will give more insight on the issue i am facing.

                 

                Template code of Page Asset - Page/TestProductPage

                 

                <%@ taglib prefix="cs" uri="futuretense_cs/ftcs1_0.tld"

                %><%@ taglib prefix="ics" uri="futuretense_cs/ics.tld"

                %><%@ taglib prefix="render" uri="futuretense_cs/render.tld"

                %><%@ taglib prefix="fragment" uri="futuretense_cs/fragment.tld"

                %><cs:ftcs><%-- Page/TestProductPage --%>

                <%-- Record dependencies for the Template --%>

                <ics:if condition='<%=ics.GetVar("tid")!=null%>'><ics:then><render:logdep cid='<%=ics.GetVar("tid")%>' c="Template"/></ics:then></ics:if>

                <html>

                <head>

                <script>

                var pageJsonData = ${pageJsonData};

                </script>

                </head>

                <body>

                     This is a test page

                </body>

                </cs:ftcs>

                 

                Page Asset contains an attribute “Copy1” of type text with ckeditor enabled to hold an embedded asset of type “LinkAsset”.

                LinkAsset is assigned a template called "Link"

                 

                 

                WCS_Controller Code associated to above Page template.

                 

                package oracle.webcenter.sites.controller

                 

                import com.fatwire.assetapi.data.*

                import com.openmarket.xcelerate.asset.*

                import com.fatwire.assetapi.fragment.*

                import javax.json.*

                 

                public class TestKMPController extends BaseController

                {

                @RequiredParams(query="c,cid")

                public void doWork(Map models)

                {

                              Map assetMap = newAssetReader()

                                      .forAsset(getAssetId())

                                           .select("Copy1")

                                      .includeLinks(true)

                                      .includeLinksForBlobs(true)

                                      .read();          

                             

                 

                              if(null != assetMap.get("Copy1")) {

                                     AssetFacade aFacade = new AssetFacadeImpl(ics)

                                     String evaluated = aFacade.processEmbeddedLink(assetMap.get("Copy1"))

                                     assetMap.put("Copy1", evaluated);

                              }

                             

                              //Object to hold page attributes

                              JsonArrayBuilder jsonArrayBuilderPage = Json.createArrayBuilder();

                              JsonObjectBuilder jsonObjBuilderPage = Json.createObjectBuilder();

                              jsonObjBuilderPage.add("Copy1", ((null != assetMap.Copy1) ? assetMap.Copy1: ""));

                              jsonArrayBuilderPage.add(jsonObjBuilderPage);

                             

                              JsonArray jsonArray = jsonArrayBuilderPage.build();

                              models.put("pageJsonData", jsonArray);       

                              models.put("pageAsset", assetMap);           

                }

                }

                 

                The “pageJsonData” containing the jsonArray is passed to a script variable for further processing.

                When I preview the page asset using the vanity URL, I get the below error in the logs.

                 

                [2019-03-21T10:54:24.676-04:00] [wcsites_server1] [ERROR] [] [oracle.wcsites.request] [tid: 106] [userId:<anonymous>] [ecid: 005X9je13yrD4i0LvyCCyX0002c60002hd,0:1] [APP: sites] [partition-name: DOMAIN] [tenant-name: GLOBAL] COM.FutureTense.Common.ContentServerException: Unable to locate page MySite/LinkAsset/Link\Error code:PAGE NOT FOUND

                 

                I believe WCS is unable to resolve the c and cid of the embedded asset due to which it is throwing an error "PAGE NOT FOUND"

                 

                I hope this helps to analyze and help me fix the issue.

                 

                Thanks,

                Praveen