Monday, 17 February 2014

Oracle WebCenter Announcement service error (failure to authenticate the user)




The Oracle WebCenter  announcement service task flow provides ability to post announcement to all authenticated users.

We have used announcement service in our portal application and recently we hit with below error

"failure to authenticate the user testuser@abc.com, due to: Unexpected error occured,due to:
oracle.j2se.ws.client.jaxws.JSRSOAPFaultException:Client received SOAP Fault from server:SOAP must
understan error.Server could not understand one or more SOAP headers:{http://docs.oasis-open.org
/wss/2004/01/oasis-200401-wss-wsssecurity-1.0.xsd}security"


and here is the work around which we did to address the error.


From oracle document source i found that,this error may be caused due to various reasons. We need to Check the following 

•        Ensure that the OWSM SAML policy setting is appropriately defined between the discussions connection and the discussions server.

•        For the WebCenter Portal Discussions service, review WC_Spaces-diagnostic.log for errors and exceptions. If the log does not provide enough information to correct errors, then turn on debugging for the oracle.webcenter.collab.share and oracle.webcenter.collab.forum packages.

•        For the back-end discussions server, review WC_Collaboration-diagnostics.log and jive.error.log inside your domain's$DOMAIN_HOME/config/fmwconfig/servers/SERVER_NAME/owc_discussions/logs directory. If the logs do not provide enough information to correct errors, then turn on debugging for Oracle WebCenter Portal's Discussion Server. To turn on debug logs, log on to Oracle WebCenter Portal's Discussion Server admin console, go to page logs, the Debug tab, and enable. Restart the WC_Collaboration domain to change the logging setting.

•        Make sure that the WebCenter Portal application and the back-end discussions server are in time sync. This is important with OWSM WS-Security.

 In our case,  I faced this error due to the first reason (Service policy is not attached in the server) and below are the steps

We need to make sure that , client policy attached in JDeveloper discussion connection server should match to the service policy attached in the web logic server.

In the JDeveloper, the policy URI for authenticated access is set as marked below and we need to make sure the corresponding service policy is attached in the server. If there is no service policy attached then it will through the above mentioned error.




Step 1: Go to discussion server in your enterprise manager server, navigate to Application Deployment -> web service  as shown below



Step 2: Click on Authenticated Web service endpoints as shown below.






Step 3: Check whether corresponding service policy attached under OWSM policies as shown below.




Step 4: if there is no policy attached then you need to attach the policy, in this case i am attaching, the corresponding service policy as shown below.

i)             Click on Attach/Detach icon






ii)            Select the service policy and attach






  
iii)           Click on OK and It will ask for restarting of  the application .



Note: Once you restart the application please do check whether your service policy is attached or not. some times,  although service policy is attached and still it throws the same error, then try detaching the policy and attach once again.

Hope this helps !




Tuesday, 11 February 2014

Oracle WebCenter Polls Service Customization to keep poll result until next poll is published

As you all know,
The Polls service lets you create, edit, take, and analyze online polls.

The default behavior of Take Poll Service is,It displays the most recently-published available poll, unless it is set to display a specific poll with the Poll Id parameter. After a user submits a response for that poll, this task flow displays the next most recently-published poll. But what if , you have not published any new poll and user already taken the recently published poll. Then the Poll service show "No Polls Available" in your poll section.

Recently we got the requirement to keep and show the  recently published poll result to end user until the new poll published.



Among the Polls Service Tasks flows provide by framework, we can use two main tasks flow in order achieve our requirement.
1)Take Poll
2)View Poll Result

Both these task flows accept the Poll Id parameter

our goal here is to switch between these two tasks flows.
Because we need to show the published poll for the user who has not taken the Poll yet (by using Take Poll)
and recently published poll result for the user who has taken the poll(By using View Poll result)

In order to do lets quickly observe the Poll service schema which framework provides. In order to do this,

Try to enable the show library option in the "Navigator display options" in Jdeveloper as shown below and observe the schema related to Poll service.(You can able to see these only when you already added the service to your project included the libraries.)



 

By Observing the Poll schema we created one AM Method and one VO based on the below query


select survey_id,response_date,user_id
from wc_survey_response
where user_id = :bind_loginuserid
ORDER BY response_date desc

In VO create one bind variable - (Say for example 'bind_loginuserid' ) of type string and make it required.

In the AmImpl java create the below method to get recent poll responce id


    public String getLastRespondedSurveyId(String userid){
        ViewObjectImpl vo = this.getSurveyResponseVO();
        vo.setNamedWhereClauseParam("bind_loginuserid", userid);
        vo.executeQuery();
       
        if(vo.first() != null){
            return (String)vo.first().getAttribute("SurveyId");
        }
        else{
            return null;
        }
    }
         
          
Next Drag and drop the take poll webcenter service task flow on to the page and in the bindings, click on edit icon to set the task flow parameter as shown below


for the pollId parameter, we are calling bean method and inside bean method we are conditionally calling one of the two task flows .

here is the bean method for your reference
         
         
              public String getPollSurveyId(){
       SurveyBuilder surveyBuilder = SurveyBuilder.getCurrentInstance();
        int count = surveyBuilder.getTakeSurveyBean().getAvailableSurveyCount();
        if(count!=0){
           return "/oracle/webcenter/collab/survey/view/jsf/taskflows/take-polls-definition.xml#take-polls";
        }
        else {
            //String value ="ab3ffed8-5b73-4e97-ac33-7c320c839c02";
            //ADFUtil.setEL("#{pageFlowScope.setPollId}", value);
            return "/oracle/webcenter/collab/survey/view/jsf/taskflows/view-results-definition.xml#view-results";
        }
        //return null;
       
    }
   
    
    public String getLastRespondedPoll(){
        SurveyBuilder surveyBuilder = SurveyBuilder.getCurrentInstance();
         int count = surveyBuilder.getTakeSurveyBean().getAvailableSurveyCount();
         if(count!=0){
             return null;
         }
         else{
             return (String)ADFUtil.executeOperationBinding("getLastRespondedSurveyId", null);
         }
       
    }



the string which we returning is nothing but poll id of either the takepoll or poll result taskflows based on whether user already taken the poll or not. Note: if you want to know poll id of the task flow then just  drag drop the two task flow to find out their task flow id

thats it !!!... so when poll published by admin, it will show the poll as shown below



and when the end user takes the poll, the poll result will be displayed until the next poll is published as shown below
there by achieving the the requirement of keeping poll result until the next poll is published.