Thursday, December 6, 2012

Oracle ADF Ready To Use Sample Codes

*********Add Faces Message*********
FacesContext facesContext = FacesContext.getCurrentInstance();

facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, rb.getString("reqEmail"),null));

*********To Show Rich Popup*********
private RichPopup richPopup;
UIComponent source = (UIComponent)actionEvent.getSource();
String alignId = source.getClientId(facesContext);
RichPopup.PopupHints hints = new RichPopup.PopupHints();
hints.add(RichPopup.PopupHints.HintTypes.HINT_ALIGN_ID, source).add(RichPopup.PopupHints.HintTypes.HINT_LAUNCH_ID,
source).add(RichPopup.PopupHints.HintTypes.HINT_ALIGN,RichPopup.PopupHints.AlignTypes.
ALIGN_START_AFTER);
richPopup.show(hints);

*********To get Application Module Connection Object*********
ELContext elContext = null;
ValueExpression valueExp = null;
try {
            FacesContext fc = FacesContext.getCurrentInstance();
            Application app = fc.getApplication();
            ExpressionFactory elFactory = app.getExpressionFactory();
            elContext = fc.getELContext();
            valueExp = elFactory.createValueExpression(elContext, "#{data.idWorkshopAppModuleDataControl.dataProvider}",Object.class);
} catch (Exception e) {
            logger.error("getAm():" + e);
}
 return (idWorkshopAppModuleImpl)valueExp.getValue(elContext);

*********To access attribute using Key value*******
//Inside any method in App module
Key key= new Key( new Object[]{empID});
Row row=this.getEmployeeView1().getRow(key);
Row.setAttribute(“AttribName”, AttribValue);
try{
            this.getDBTransaction().commit();
}catch(Exception e) {}

*********Setting the Value of Named Bind Variables Programmatically*********
// changed lines in TestClient class
ViewObject vo = am.findViewObject("UserList");
vo.setNamedWhereClauseParam("TheName","alex%");
vo.setNamedWhereClauseParam("HighUserId", new Number(315));
vo.executeQuery();

*********Defining new Bind variable at Runtime:*********
vo.setWhereClause("user_role = :TheUserRole");
vo.defineNamedWhereClauseParam("TheUserRole", null, null);
vo.setNamedWhereClauseParam("TheUserRole","technician");
// execute the query and process the results, and then later...
vo.setNamedWhereClauseParam("TheUserRole","user");


*********Creating and Setting View Criteria attributes:**********
ApplicationModule am =
Configuration.createRootApplicationModule(amDef, config);
ViewObject vo = am.findViewObject("UserList");
// 1. Create a view criteria rowset for this view object
ViewCriteria vc = vo.createViewCriteria();
// 2. Use the view criteria to create one or more view criteria rows
ViewCriteriaRow vcr1 = vc.createViewCriteriaRow();
ViewCriteriaRow vcr2 = vc.createViewCriteriaRow();
// 3. Set attribute values to filter on in appropriate view criteria rows
vcr1.setAttribute("UserId","> 304");
vcr1.setAttribute("Email","d%");
vcr1.setAttribute("UserRole","technician");
vcr2.setAttribute("UserId","IN (324,326)");
vcr2.setAttribute("LastName","Baer");
// 4. Add the view criteria rows to the view critera rowset
vc.add(vcr1);
vc.add(vcr2);
// 5. Apply the view criteria to the view object
vo.applyViewCriteria(vc);
// 6. Execute the query
vo.executeQuery();

setWhereClause() : uses the column name while the createViewCriteriaRow's setAttribute uses attribute name.
We can also use the setConjuction(ViewCriteria.VIEW_CNJ_AND ) method on VC to set the AND or OR operation that will be used between View Criterias.


**********Using Entity object to get attribute value**********
private EntityImpl retrieveServiceRequestById(long requestId) {
String entityName = "devguide.model.entities.ServiceRequest";
EntityDefImpl svcReqDef = EntityDefImpl.findDefObject(entityName);
Key svcReqKey = new Key(new Object[]{requestId});
return svcReqDef.findByPrimaryKey(getDBTransaction(),svcReqKey);
}


*********Using association to get the attribute value for the related Entity object*********
public String findServiceRequestTechnician(long requestId) {
// 1. Find the service request entity
EntityImpl svcReq = retrieveServiceRequestById(requestId);
if (svcReq != null) {
// 2. Access the User entity object using the association accessor attribute
EntityImpl tech = (EntityImpl)svcReq.getAttribute("TechnicianAssigned");
if (tech != null) {
// 3. Return some of the User entity object's attributes to the caller
return tech.getAttribute("FirstName")+" "+tech.getAttribute("LastName");
}
else {
return "Unassigned";
}
}
else {
return null;
}
}


*********Updating Attribute using EO*********
public void updateRequestStatus(long requestId, String newStatus) {
// 1. Find the service request entity
EntityImpl svcReq = retrieveServiceRequestById(requestId);
if (svcReq != null) {
// 2. Set its Status attribute to a new value
svcReq.setAttribute("Status",newStatus);
try {
// 3. Commit the transaction
getDBTransaction().commit();
}
catch (JboException ex) {
getDBTransaction().rollback();
throw ex;
}
}
}


*********Creating new Row in EO*********
public long createProduct(String name, String description) {
String entityName = "devguide.model.entities.Product";
// 1. Find the entity definition for the Product entity
EntityDefImpl productDef = EntityDefImpl.findDefObject(entityName);
// 2. Create a new instance of a Product entity
EntityImpl newProduct = productDef.createInstance2(getDBTransaction(),null);
// 3. Set attribute values
newProduct.setAttribute("Name",name);
newProduct.setAttribute("Description",description);
try {
// 4. Commit the transaction
getDBTransaction().commit();
}
catch (JboException ex) {
getDBTransaction().rollback();
throw ex;
}
// 5. Access the database trigger assigned ProdId value and return it
DBSequence newIdAssigned = (DBSequence)newProduct.getAttribute("ProdId");
return newIdAssigned.getSequenceNumber().longValue();
}


*********Creating new Row using VO*********
import java.sql.Timestamp;
import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
import oracle.jbo.domain.DBSequence;
import oracle.jbo.domain.Date;
public class TestCreatingServiceRequest {
public static void main(String[] args) throws Throwable {
String amDef = "devguide.model.SRService";
String config = "SRServiceLocal";
ApplicationModule am =
Configuration.createRootApplicationModule(amDef, config);
// 1. Find the ServiceRequests view object instance.
ViewObject svcReqs = am.findViewObject("ServiceRequests");
// 2. Create a new row and insert it into the row set
Row newSvcReq = svcReqs.createRow();
svcReqs.insertRow(newSvcReq);
// 3. Show effect of entity object defaulting for Status attribute
System.out.println("Status defaults to: "+newSvcReq.getAttribute("Status"));
// 4. Set values for some of the required attributes
newSvcReq.setAttribute("CreatedBy",308); // Nancy Greenberg (user)
Date now = new Date(new Timestamp(System.currentTimeMillis()));
newSvcReq.setAttribute("RequestDate",now);
newSvcReq.setAttribute("ProdId",119); // Ice Maker
newSvcReq.setAttribute("ProblemDescription","Cubes melt immediately");
// 5. Commit the transaction
am.getTransaction().commit();
// 6. Retrieve and display the trigger-assigned service request id
DBSequence id = (DBSequence)newSvcReq.getAttribute("SvrId");
System.out.println("Thanks, reference number is "+id.getSequenceNumber());
Configuration.releaseRootApplicationModule(am, true);
}
}


**********Gettning Records from Master and Details table**********
import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.RowSet;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
public class TestClient {
public static void main(String[] args) {
String amDef = "devguide.model.SRService";
String config = "SRServiceLocal";
ApplicationModule am =
Configuration.createRootApplicationModule(amDef,config);
// 1. Find the StaffList view object instance.
ViewObject staffList = am.findViewObject("StaffList");
// 2. Execute the query
staffList.executeQuery();
// 3. Iterate over the resulting rows
while (staffList.hasNext()) {
Row staffMember = staffList.next();
// 4. Print the staff member's full name
System.out.println("Staff Member: "+staffMember.getAttribute("FullName"));
// 5. Get related rowset of ServiceRequests using view link accessor
RowSet reqs = (RowSet)staffMember.getAttribute("ServiceRequests");
// 6. Iterate over the ServiceRequests rows
while (reqs.hasNext()) {
Row svcreq = reqs.next();
// 7. Print out some service request attribute values
System.out.println(" ["+svcreq.getAttribute("Status")+"] "+
svcreq.getAttribute("SvrId")+": "+
svcreq.getAttribute("ProblemDescription"));
if(!svcreq.getAttribute("Status").equals("Closed")) {
// 8. Get related rowset of ServiceHistories
RowSet hists = (RowSet)svcreq.getAttribute("ServiceHistories");
// 9. Iterate over the ServiceHistories rows
while (hists.hasNext()) {
Row hist = hists.next();
// 10. Print out some service request history attributes
System.out.println(" "+hist.getAttribute("LineNo")+": "+
hist.getAttribute("Notes"));
}
}
}
}


*********Finding and Updating a foreign key value**********
import oracle.jbo.ApplicationModule;
import oracle.jbo.JboException;
import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
public class TestFindAndUpdate {
public static void main(String[] args) {
String amDef = "devguide.model.SRService";
String config = "SRServiceLocal";
ApplicationModule am =
Configuration.createRootApplicationModule(amDef,config);
// 1. Find the ServiceRequests view object instance
ViewObject vo = am.findViewObject("ServiceRequests");
// 2. Construct a new Key to find ServiceRequest# 101
Key svcReqKey = new Key(new Object[]{101});
// 3. Find the row matching this key
Row[] reqsFound = vo.findByKey(svcReqKey,1); //An entity-based view object delegates the task of finding rows by key to its underlying
if (reqsFound != null && reqsFound.length > 0) { //entity row parts. When you use the findByKey() method to find a view row by key,
Row svcReq = reqsFound[0]; //the view row turns around and uses the entity definition's findByPrimaryKey() to
// 4. Print some service request information //find each entity row contributing attributes to the view row key.
String curStatus = (String)svcReq.getAttribute("Status");
System.out.println("Current status is: "+curStatus);
try {
// 5. Try setting the status to an illegal value
svcReq.setAttribute("Status","Reopened");
}
catch (JboException ex) {
System.out.println("ERROR: "+ex.getMessage());
}
// 6. Set the status to a legal value
svcReq.setAttribute("Status","Open");
// 7. Show the value of the status was updated successfully
System.out.println("Current status is: "+svcReq.getAttribute("Status"));
// 8. Show the current value of the assigned technician
System.out.println("Assigned: "+svcReq.getAttribute("TechnicianEmail"));
// 9. Reassign the service request to technician # 303
svcReq.setAttribute("AssignedTo",303); // Alexander Hunold (technician)
// 10. Show the value of the reference info reflects new technician
System.out.println("Assigned: "+svcReq.getAttribute("TechnicianEmail"));
// 11. Rollback the transaction
am.getTransaction().rollback();
System.out.println("Transaction cancelled");
}
Configuration.releaseRootApplicationModule(am,true);
}
}

Thursday, October 18, 2012

WebCenter Portal Deployment Error


Error::

[October 18, 2012 12:31:34 PM MVT] java.lang.InstantiationError: ServiceContext resource configuration file "META-INF/context.provider" found, but the class defined "class oracle.webcenter.framework.internal.service.DefaultServiceContext" is not an instance of oracle.webcenter.framework.service.ServiceContext.
[October 18, 2012 12:31:34 PM MVT] ServiceContext resource configuration file "META-INF/context.provider" found, but the class defined "class oracle.webcenter.framework.internal.service.DefaultServiceContext" is not an instance of oracle.webcenter.framework.service.ServiceContext.
[October 18, 2012 12:31:34 PM MVT] Deploy operation failed.

Solution::

1) Ensure that there is no space in the domain path or working directory (if deploying through JDev itself).

2) If there is no space and still getting the issue, then clear the tmp folder for the manged server where application is being deployed. Stop the managed server and  delete content of following folder

MIDDLEWARE_HOME/user_projects/domains/DOMAIN_NAME/servers/WC_Spaces1/tmp

Now deploy the application again. This time it should work.

Thursday, September 27, 2012

Call Managed bean method without using DC

To call a managed bean method without exposing the managed bean as data control, we can do following;

For a method like this:

public class MyBean {
    public MyBean() {
        super();
    }
  public void myMethod(String arg1) {
    System.out.println(arg1);
  }
}


Add following method invocation code in page definition file:


<methodAction  id="CallMyMethodOnMyBean"              
                InstanceName="${MyBean}"
                MethodName="myMethod" DataControl="AppModuleDataControl">
       <NamedData NDName="arg1" NDType="java.lang.String" NDValue="Foo"/>
</methodAction>

Sample:: http://java.net/projects/smuenchadf/sources/samples/content/MethodActionThatCallsManagedBeanWithoutDataControlInvolved.zip

Wednesday, September 26, 2012

Combine Security Providers in Weblogic

By default, WebCenter services only use first security provider configured in the list. In order to fetch the user details from second or any further provider, we just need to add "virtualize = true" under the domain -> Security Provider Configuration -> Configure -> add new property

For details, please check:

http://andrejusb.blogspot.in/2011/06/webcenter-11g-ps3ps4-aggregating.html



Tuesday, August 21, 2012

A day on Python - Basics

Why Python: Provide better inegration with other language.

How to start Python: login to command promp and type python

Basic Syntax: Require tabs or equal number of spaces to make block.
No Declaration required.

a=10
a =>10
print a => 10

a="Hello\n how are u"
a => "Hello\n how are u"
print a => Hello
                how r u
print type(a) => 'str'

a=2+3j
print a.real and print a.imag
operators: ==,!=,<>, bitwise operators, += ,...

a=10
a is 10 => true
a is not 10 => false

a='hello'
'h' in a => true
'H' in a => false

which python => path and name of interpreter.

Create Script:
vi Script.py
#! /user/bin/

import Script.py => This will execute all the command defined outsids the functions
To import function use: from script import function/variable/*

Using modules::
help()
modules =>List of all modules

To write command in multiple lines:
a='''line1
line2
line3'''
print a => line1
                line2
                line3

Type Casting:
a='458'
b = int(a)

a="Part1"
b="and Part2"
a+' '+b => Part1 and Part2
s= a*2
print s => Part1Part1

If Statement
if a>10:
(tab) print "true"
(tab) print "If done"
else:
(tab) print "Else Part"
(press ctrl+D) to terminate the command if using on prompt

a=[1,2,3]
for var in a
(tab/space) print var
for i in range(1,10)
(tab/space) print var


Using else with while
i=2
a=10
while i<a:
  if  a%i ==0
    print "Not Prime"
    break
 i+=1
else:
   print "Prime" => This else will only be executed when the condition of while is false, not when break is called.

Taking inputs:
1) Integer inputs:
a = input("Enter Value")
Enter Value 10
a => 10
2) String/Char input:
a=raw_input("Enter")
Enter 10
a => '10'

List of Char/String to String
a=['a','b']
s= ''.join(a)
print s =>'ab'
Split again to list
list(s) => ['a','b']
a="hello"
list(a) => ['h','e','l','l','o']
a="Hello how r u"
a.split(' ') => ['Hello', 'how', 'r', 'u']

Concatinate:
a=[1,2,3,4]
a+[10,20] => [1,2,3,4,10,20]

Sorting
a=[1,2,5,4,3]
a.sotr() => [1,2,3,4,5]
a.reverse()
a.pop() => Delete last element and return that element
a.pop(index) => Delete element at index
a.remove(3) => Will remove elemement 3 itself (not at index 3)
a.append([1,2,3]) =>will append [1,2,3] as list at last position
a.insert(0,10) => insert at 0th index

Call be Value and Reference
a=[1,2,3]
b=a => by reference
c=a[:] => by value

Dictionary::
dict={key1:'Value', key2:Value}
dict.has_key(key1) => True
dick.get(key1) => Value
del dick[Key1] => Will delete Key1
d.keys() => Return all Keys
d.values()
d.items()
d.iterkeys() => To iterate over keys

Tuple: Unmodifiable list
a= 1,2,3 or a=(1,2,3)

Using Functions
def functionName(n):
(tab/space) function body

Exception Handling
try:
     body
except ExceptionType,msg
     print msg

Using Modules:
Math: This module provides map, reduce and filter

Saturday, August 18, 2012

Create Row as last row in table


Source: https://blogs.oracle.com/jdevotnharvest/entry/how_to_add_new_adf

public String onRowCreate() {
 BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
 //access the name of the iterator the table is bound to. Its "allDepartmentsIterator"
 //in this sample
 DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("allDepartmentsIterator");
 //access the underlying RowSetIterator
 RowSetIterator rsi = dciter.getRowSetIterator();
 //get handle to the last row
 Row lastRow = rsi.last();
 //obtain the index of the last row
 int lastRowIndex = rsi.getRangeIndexOf(lastRow);
 //create a new row
 Row newRow = rsi.createRow();
 //initialize the row
 newRow.setNewRowState(Row.STATUS_INITIALIZED);
 //add row to last index + 1 so it becomes last in the range set
 rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow); 
 //make row the current row so it is displayed correctly
 rsi.setCurrentRow(newRow);                          
 return null;
}  
For the table to show the newly created row after this ensure:

1. The table is configured to always show the current selected row by setting 
 its displayRow property to selected
2. The table is PPR'ed after the row is created, which can be done declarative 
using the PartialTriggers property of the table pointing to the ID of the command creating the new row

Friday, August 10, 2012

Oracle ADF Global Resource Bundle

Keeping resource bundle inside ViewController project will not allow the bundle to be updated at runtime. In order to update the resource bundle at runtime without redeploying the application or without restarting the server there are few options, some of them are listed below:

1) Keep the resource bundle string in database: This is already discussed in following post.

2) Keep resource bundle in custom location on weblogic server: This method requires the path of property file to be set in setDomainEnv.cmd file as follows

set JAVA_OPTIONS=%JAVA_OPTIONS% -DpropFileLoc=C:\bundleDir\MyBundle.properties

This property can be read in bean file using

       String propFilePath = System.getProperty("propFileLoc");

Now the bundle string can be read using either of following:

       InputStream iStream = this.getClass().getResourceAsStream(propFilePath );
OR
       InputStream iStream = new FileInputStream(propFilePath);

       prop.load(iStream );
       bundleText=prop.getProperty("bundleText");

The advantage of above way of accessing the bundle is that we can keep the bundle file at any custom location on the server.

3) Keep resource bundle file in Domain directory: This method does not require the setDomainEnv.cmd file to be changed. The file can directly be accessed using following code:

        InputStream is=new FileInputStream("./MyBundle.properties");
        Properties prop=new Properties();
        prop.load(is);
        prop.getProperty("bundleText");

Instead of writing bean for loading the resource bundle, we can write a servlet to read the property file and return the key value. On jspx page, the servlet can then be access from the component attributes like value or image as follow:

         <af:image id="i1" source="/myServlet?propName=bundleText"/>

Wednesday, August 8, 2012

Exception while creating Content repository connection

Upgraded to JDeveloper 11.1.1.6 and got below exception while creating content repository connection

Performing action Content Repository...[ from oracle.jdeveloper.appresources.ApplicationResourcesWindow ]
Exception while performing action Content Repository...
java.lang.NoClassDefFoundError: javax/jcr/Credentials
j.lang.Class.getDeclaredMethods0(Native Method)
j.lang.Class.privateGetDeclaredMethods(Class.java:2427)
j.lang.Class.getDeclaredMethod(Class.java:1935)
j.a.Component.isCoalesceEventsOverriden(Component.java:5974)
j.a.Component.access$500(Component.java:170)
j.a.Component$3.run(Component.java:5928)
j.a.Component$3.run(Component.java:5926)
j.security.AccessController.doPrivileged(Native Method)
j.a.Component.checkCoalescing(Component.java:5925)
j.a.Component.<init>(Component.java:5894)
j.a.Container.<init>(Container.java:251)
jx.s.JComponent.<init>(JComponent.java:570)
jx.s.JPanel.<init>(JPanel.java:65)
jx.s.JPanel.<init>(JPanel.java:92)
jx.s.JPanel.<init>(JPanel.java:100)
o.webcenter.content.internal.dt.connection.wizard.Adapter
.......
Caused by:
oracle.classloader.util.AnnotatedClassNotFoundException:

Missing class: javax.jcr.Credentials

Solution: Copy the JCR1.0 jar file in Middleware_Home/Jdeveloper/lib/java/api folder.

Monday, June 18, 2012

Webcenter Portal Cluster


pack.sh -domain=$MW_HOME/user_projects/domains/vfm2m_wc -template=/tmp/m2m_domain.jar -template_name=”M2M Domain” -managed=true

unpack.sh -domain=/home/oracle/Oracle/Middleware/user_projects/domains/vfm2m_wc -template=/tmp/m2m_domain.jar

Wednesday, June 13, 2012

Password Policy in OID


In general, establishing a password policy requires the following steps:

1) Create a password policy entry in the appropriate container and associate it with the pwdpolicy object. (Default entries exists when you first install Oracle Internet Directory.)
2) Create the desired policy by setting values for attributes defined under the pwdpolicy object class for the entry created in step 1.
3) Enable the policy by setting the orclepwdpolicynable attribute to 1. If this is not set to 1, Oracle Internet Directory ignores the policy.
4) Determine the subtree to be governed by the policy. Add and populate a pwdpolicysubentry attribute with the policy's DN, at the root of that subtree.

http://docs.oracle.com/cd/E25178_01/oid.1111/e10029/pwdpolicies.htm

Configuring redirection in OHS from http to https

In order to redirect the http requests coming to OHS to https , we can make following changes in httpd.conf file::

NameVirtualHost *:80
<VirtualHost *:80>
 ServerName "host name of the server sending the request"
 SeverAdmin your@Address
 RewriteEngine on
 RewriteOptions inherit
 Redirect permanent / https://"host name of the server":443
</VirtualHost>


Wednesday, June 6, 2012

A failure occurred attempting to load LDIF for provider


Issue ::

<The realm "myrealm" failed to be loaded: weblogic.security.service.SecurityServiceException: com.bea.common.engine.ServiceInitializationException: weblogic.security.spi.ProviderInitializationException: A failure occurred attempting to load LDIF for provider Authorizer from file /home/oracle/Oracle/Middleware/wlserver_10.3/server/lib/XACMLAuthorizerInit.ldift..
weblogic.security.service.SecurityServiceException: com.bea.common.engine.ServiceInitializationException: weblogic.security.spi.ProviderInitializationException: A failure occurred attempting to load LDIF for provider Authorizer from file /home/oracle/Oracle/Middleware/wlserver_10.3/server/lib/XACMLAuthorizerInit.ldift.

Caused By: com.bea.common.engine.ServiceInitializationException: weblogic.security.spi.ProviderInitializationException: A failure occurred attempting to load LDIF for provider Authorizer from file /home/oracle/Oracle/Middleware/wlserver_10.3/server/lib/XACMLAuthorizerInit.ldift.
        at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:365)
        at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:315)
        at com.bea.common.engine.internal.ServiceEngineImpl.lookupService(ServiceEngineImpl.java:257)
        at com.bea.common.engine.internal.ServicesImpl.getService(ServicesImpl.java:72)
        at weblogic.security.service.CSSWLSDelegateImpl.getService(CSSWLSDelegateImpl.java:155)
        Truncated. see log file for complete stacktrace
Caused By: weblogic.security.spi.ProviderInitializationException: A failure occurred attempting to load LDIF for provider Authorizer from file /home/oracle/Oracle/Middleware/wlserver_10.3/server/lib/XACMLAuthorizerInit.ldift.

Solution::


connect to DB and run rdbms_security_store_oracle.sql

Tuesday, June 5, 2012

Populating OID Schema Attributes and Object Classes

Following are sample LDIFs that can be used to populate the schema attributes and the object classes::

1) To define custom attributes ::


dn: cn=subSchemaSubentry
changetype: modify
add:  attributetypes
attributetypes: ( 1.1.1.1.1.1.1000.0.0.1 NAME 'Attribute1' DESC 'This is Attrib1' EQUALITY 'caseIgnoreMatch' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15'  X-ORIGIN 'user defined' )
attributetypes: ( 1.1.1.1.1.1.1000.0.0.2 NAME 'Attribute2' DESC 'This is Attrib2' EQUALITY 'caseIgnoreMatch' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15'  X-ORIGIN 'user defined' )

2) Add the defined attributes to the catalog to make them searchable if required::


dn: cn=catalogs
changetype: modify
add: orclindexedattribute
orclindexedattribute: Attribute1

dn: cn=catalogs
changetype: modify
add: orclindexedattribute
orclindexedattribute: Attribute2

3) Adding Object Classes ::


dn: cn=subschemasubentry
changetype: modify
add: objectclasses
objectclasses: ( 1.1.1.1.1.1.1001.0.0.1 NAME 'class1' DESC 'This is Object class' SUP top  AUXILIARY MAY ( Attribute1 $ Attribute2 ) )
objectclasses: ( 1.1.1.1.1.1.1001.0.0.1 NAME 'class2' DESC 'This is another Object class' SUP top  AUXILIARY MAY ( Attribute1 $ Attribute2 ) )

4) Once all the ldif files are created, use the Ldapmodify command to execute the ldifs

ldapmodify -h OIDHostname -p 3060 -D cn=orcladmin -w passwod -f LdifFile.ldif




Configuring Logout URL for WebCenter Portal application

If the application is authenticates using OAM, then the logout for the application can be configured as follows::

1) Configure the destination for the logout link as follows

<af:goLink text="Log out" destination="adfAuthentication?logout=true&amp;end_url=/index.html"/>

2) Now goto MW_HOME/Oracle_WC1/common/bin and execute wlst.sh
3) Connect to admin server using connect('weblogic','password', 't3://host:adiminport')
4) Now run addOAMSSOProvider(loginuri="/${app.context}/adfAuthentication", logouturi="/oamsso/logout.html")
5) After successful run, restart the servers.

Thursday, May 31, 2012

ORA-12899: value too large for column "TEST1_OIM"."PCQ"."PCQ_QUESTION"

The above error is coming while setting the challenge question for the user. The reason for the error is the number of characters in the question after encryption by OIM that are getting inserted into the PCQ table. Default is 100. The message that comes on the UI is "Password reset successful but challenge question registration failed".

The resolution is yet to come. Either change the question or increase the column size. 

Getting connection to WS in connections.xml

To get connection object for the WS specified in the connections.xml, use::

WebServiceConnection wsc = (WebServiceConnection)ADFContext.getCurrent().getConnectionsContext().lookup("Name");

where Name is the reference name generated in connections.xml.

wsc.getJaxWSPort(Service.class);

where Service is the service name pointed by the connection.

Tuesday, May 29, 2012

Invalid/unknown SSL header was received from peer during SSL handshake.>

This is the exception that we got, when we were trying to start one of our server in cluster. The managed server to be started is on machine1 and cluster is on different machine2. We changed the communication type to plain in the console under nodemager settings for the machine2. But still the issue was same.The server was still using SSL for communication, since the last line of the log after nodemanager start/restart, was still "secure socket listener started on port 5556".

It got resolved by changing the SecureListener to false in the nodemanager.properties file, which made the nodemanager to use Plain communication. This changed the last line in nodemanager log after restating to
Plain socket listener started on port 5556.

Saturday, May 26, 2012

InvalidAttributeValueException: Malformed 'objectClass' attribute value

The above error comes when the method used to insert/set the value of the attribute mentioned in the error, is not as per the schema/ its type. In case of objectClass its supposed to be a multivalued attribute and this error will come if we by mistake we used the setAttributeValue() method instead of setAttributeValues()....

Friday, May 25, 2012

Startup Classes not found while starting Managed Server

After configuring new servers and while starting them from em, we were getting startup classed not found exception. The issue was resolved by changing startScriptEnable=true in the nodemanager.properties file.

Tuesday, May 8, 2012

Call Render Response phase from MBean or BBean



FacesContext.getCurrentInstance().renderResponse();

When this is required to be used?
When we have set immediate as true on a command component and want to skip the validation phase for a component.
http://docs.oracle.com/cd/E23943_01/web.1111/b31973/af_lifecycle.htm#CIAHCFJF
Above link also explains the use of autosubmit and immediate in few scenarios.

Partial Submit Vs Auto submit
https://blogs.oracle.com/jdevotnharvest/entry/partial_submit_vs_auto_submit

Sunday, May 6, 2012

Login issue after configuring LoadBalancing using Webcache

We configured loadbalancing between our two portal servers. After doing the configuration when we opened the URL for ohs server with url string attached for our application, we were successfully redirected to the login page of our application but we were not able to login into our application. However login was working when hitting direct application URL. The issue was with the session binding configuration. It requires the configuration to have JSESSIONID based login. So just set the JSESSIONID to be used for login.

Not able to login on portal and using any admin account

We faced an issue where we were stuck on the login page of our portal and also the for the oam, oim console as well. None of the username passwords were working. Looking at the logs gave an statement like "Invalid life cycle state.".... "Unable to connect to connection pool".... . The issue was the password for ODS user for oiddb schema was expired. The issue got resolved by changing the password for ods user. 

OAM Error page customization

We got a requirement to customize the error page of OAM thats comes when any unexpected error occurs or user reaches max session after login. The page that need to be customized is servererror.jsp page that can be find inside oam-server.ear file or we can find it in tmp folder of oam server under x-d-- (some name like this) folder. Provided that we got the license to customize the page, the changes can be done in the page under tmp folder or oam-server.ear file. The changes of the page inside tmp folder will be reflected without any restart, just by refreshing the page. We also need to delete the .class file ie the complied jsp file for servererror-jsp.class file.

However it may not be possible to customize the error messages that comes but still if u got the license to do that :) then you can find these messages inside serverMsg.class folder. Exact path can be found inside the jsp file itself.

On the similar path the other pages like Authorization error page (AuthZError), policy manager page can be customized that can be found inside oam-admin.ear file.

Tuesday, April 10, 2012

Common web.xml usages in Webcenter Portal Application

1) For Error codes like 404,401,400,500 or any other, we can redirect over application to an custom error page. The settings can be done in web.xml file as follows::

  <error-page>
    <error-code>404</error-code>
    <location>/error.html</location>
  </error-page>
  <error-page>
    <error-code>401</error-code>
    <location>/error.html</location>
  </error-page>

2) Session Timeout setting::


  <session-config>
    <session-timeout>15</session-timeout>
  </session-config>

3) Custom DataSource references::


   <resource-ref>
    <res-ref-name>jdbc/CustomDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
 

Tuesday, February 14, 2012

How to fetch operational attributes from LDAP

There are some attributes that are used by LDAP to populate the data by it self. These are not fetched by default using context adapter. We need to explicitly mention the attributes that we want to fetch. For this we can simply use the ldapTemplate search method or look up method. It may be better to go with search

ldapTemplate.search(Base,search Criteria, scope, operationalAttrbs[], contextMapper);

Friday, February 10, 2012

OIM Client: Some important methods

Today we had some requirements on creating password policies like for password expire, change password. After going through SPML web services, OIM client proved to e a useful api. It provided all the method for changing password, create user and many more. After creating password policy using OIM design console and applying those policies using usage object tab, it was quite handful to use oim clinet jar to call password reset and many other operations.