Sunday, 1 May 2016

ADF Interview Questions - Set 9

Question: What is user customization?
Answer: Term personalization means user can perform changes visible only to that user. Term customization means user with admin privileges can perform global changes, visible to all users. You can achieve personalization functionality within standard ADF framework enabled with MDS. For customization functionality need to use Oracle WebCenter component - Composer.
UserCC class retrieve current user name from security context:



As per documentation, I have created all required Java classes to support Edit and View layers:


User customization and personalization are enabled to be stored across sessions with MDS. This option is needed to store changes for ADF components; Oracle WebCenter Composer is working without this option as well:


I have change customization class from SiteCC to UserCC, this enables personalization:


Session options factory is class must be configured in adf-config.xml to enable customization:


As per documentation, additionally you need to declare Oracle WebCenter Composer servlet in web.xml.
ADF Security defines two application level roles - admin and customer. Admin role is granted with Customization permission:


Session options factory class as per documentation defines two layers - Edit and View. You can see that Edit layer is applied on global level (it’s when Oracle WebCenter Composer is invoked to perform customization). View layer is applied on global and user levels (this means each user will see global customizations and their own personalization):

If Oracle WebCenter Composer is On, Edit layer is enabled, otherwise - View layer:



ADF Interview Questions - Set 8

Question: What is Query Collection in VO?
Answer: Query Collection is mainly used for caching the result of the executed query VO. A VO can have multiple query collections depending on the rowsets.
Example: If we have 2 rowsets where DEPTID =10 and DEPTID=20. So the results of the executed VO with these bind variables are stored in Query Collection.
Now we understood what are the other layers that are to be used before hitting the data source? Now let us see how it will be executed with an example: 

Example:  Let’s consider a java code snippet where we execute a VO and retrieve the values 
          ViewObject vo = ApplicationModule.findViewObject(“EmployeesVO”);
           vo.executeQuery(); 
           Row row = vo.first();                                          // gets the first row
     Steps involved in executing this VO are as follows: 


1.     ADF client starts interaction with the Application Module. 
2.     ADF Client looks for the requested View Object (EmployeesVO) instance in AM.
3.     Now before executing the VO, it does as below: 
a.     Checks for relevant Query Collection for Search Parameters (Bind Variables), if available uses the existing query collection.
b.    If not present created a new Query Collection based on the Search Parameters.
4.     Once the QC is initialized, the new Rowset instance calls the prepareRowSetQuery() on VO. This is used for placing your customcode before Querycollection. (Eg: the Query for the rowset with the bind variable).
5.     This is followed by executeQueryForCollection(), which delegates the call for query collection instance and JDBC call for particular Database. 
6.     Now when a client tries to get the first row in result set by calling first() , as the result set retrieves the first row it displays the first row.

Question: How and When Groovy Expression is used?
Answer: Groovy is interpreted at runtime; it can be treated as metadata and customized. So, you could have an application that has customized business rules in Groovy and those customizations stored in Oracle ADF’s Metadata Services (MDS).
Oracle ADF provides a number of different declarative points into which you can drop Groovy code:
1.     Values for view and entity objects attributes
2.     Validation rules on entity object attributes
3.     Expressions for error messages
4.     Values for view object bind variables
5.     View object transient attribute validation.
Examples:
1: For the transient attribute AnnualSalary you could define a Groovy expression for the default to be: Sal * 12
2: On the Sal attribute you might want to define that a salesman must have a salary of less than 1000: if (Job == "SALESMAN") {return newValue < 1000} else return true.

ADF Business Components view objects also provide the ability to use Groovy expressions. As with entity objects, view objects can support:
1.     Referencing attributes in the same view object
2.     Referencing attributes in other view objects
3.     Transient attribute validation
4.     Referencing methods in the Java class that backs the view object
5.     Referencing built in calls such as sum and min.

Question: What are the steps to configure MDS? What are different kinds of MDS you configured? Which file hold details of configured MDS?
Answer: To apply MDS to your application follow this:
1. Pages should be (.jspx) not (.jsp).
2. In your project properties --> ADF View check on "Enable User Customizations" then select "Across Sessions Using MDS".
3.Create a new class as below. This class has two main functions:
- getName() which return the folder name that hold all users changes.
- getValue() which return the folder name for the login user. This folder should be unique for every login user and will saved inside the getName() folder.


4. In Application Resources --> Descriptors --> ADF META-INF open adf-config.xml.
5. In adf-config file go to MDS Configurations and add your class


6. In adf-config file go to View tab and add all Tags.

7. Now you apply MDS to your application.
8. If you run your application in Integrated Weblogic there will be no problem, you should only specify the path to store the user changes (changes will stored in file system). You will find this path in your Application properties --> Run --> MDS.

ADF Interview Questions - Set 7

Question: Explain briefly the life-cycle phases of JSF?
Answer: The six phases of the JSF application lifecycle are as follows:
1. Restore View: A request comes through the FacesServlet controller. The controller examines the request and extracts the view ID, which is determined by the name of the JSP page.
2. Apply request values - process events: The purpose of the apply request values phase is for each component to retrieve its current state. The components must first be retrieved or created from the FacesContext object, followed by their values.
3. Process validations - process events: In this phase, each component will have its values validated against the application’s validation rules.
4. Update model values - process events: In this phase JSF updates the actual values of the server-side model ,by updating the properties of your backing beans.
5. Invoke application - process events: In this phase the JSF controller invokes the application to handle Form submissions.
6. Render response: In this phase JSF displays the view with all of its components in their current state.

Question: Write code to access the current row and or the view object inside your bean?
Answer: Code to access the current row and or the view object inside your bean:
BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();
DCBindingContainer dcbc = (DCBindingContainer) bc;
DCIteratorBinding lBinding = dcbc.findIteratorBinding("EmployeesViewIterator");
EmployeesViewRow row = (EmployeesViewRow) lBinding.getCurrentRow();
EmployeesView view = (EmployeesView) lBinding.getViewObject();

Question: What is Action Listener?
Answer: An action listener is a class that wants to be notified when a command component fires an action event. An action listener contains an action listener method that processes the action event object passed to it by the command component.

Question: What are mutable and immutable objects?
Answer: An immutable class is immutable, as in, it is not mutable. You cannot change it. If you have x::String, you can be absolutely 100% certain that x will never ever change ever (or at least, if it does, people are abusing the flexibility of your language and you have every right to tell them where to go).
A mutable class is not immutable. You can change it, other people can change it, and you can't rely on it being the same. It could be changed in another thread; you can't even be sure of it being in the same state from line to line unless you have good locking.
Question: What is Application module pooling and how can we handle it?
Answer: An application module pool is a collection of application module instances of the same type, such as an Orders application module or a Human Resources application module. This pool of application module instances is shared by multiple browser clients. The amount of time between submitting Web pages enables a smaller number of application module components to serve a larger number of active users. This reduces memory usage and improves performance.
This facility manages a configurable set of application module instances that grows and shrinks as the end-user load on your application changes during the day.
At any one time, the pool may contain application module instances that are partitioned into
three groups, based on their state. When the processing of a current HTTP request completes, the application module instance is checked back into the pool. If the AM instance has managed state, the pool keeps track that the AM is referenced by that particular session.
For example – We have pool of 5 Application module instances. After having request from multiple browsers, request will go to instance, which is available for time being. We have 3 state defined for appModule instances –
1- Available
2- Partially available- but referenced for preferred reuses by another active session that would be more efficient due to the managed state of the application module.
3- Unavailable- because it is being used at that very moment by a Web container thread

Note: Pools are created only for root application modules, not for nested ones that users access indirectly through a root application module.
In short –
Application module pooling:
• Enables users to share application modules
• Manages application state
• Provides the same instance or one with an identical state
when requested by an application with managed state

Question: How can we prevent unauthorised access to the ADF DC Model?
Answer: By using Bounded Task Flow

Question: How can we share AM for using same transaction?
Answer: By using AM Module Pooling.

Question: What are the MDS (Metadata Services)?
Answer: Metadata Services (MDS) is a feature provided by oracle to store customization and personalization information in a repository. The repository can either be stored in a database or in a file system as we will see.

For example if a screen has a table, this table has 8 columns, and there are a user (User1) want to see only 4 columns and hide the others. When User1 login again he want to see last changes which he make (see only 4 columns), the user can see any changes he make in the screen only if you apply MDS to your application.

Monday, 21 March 2016

ADF Interview Questions - Set 6

Question: What are the types of Application Authentication available at Run Time in ADF?
Answer: Two types-
1. Implicit: Based on JAAS permissions for anonymous-role role
2. Explicit: Based on security constraint on authentication servlet that you can define by using the Configure ADF Security Wizard

Question: What is ADF BC Model Authorization?
Answer: It prevents unauthorized access to entity objects or its attributes. Enable developers to:
1. Secure access to an entire entity object or only certain attributes
2. Specify the which of the following actions the members of a role can perform on entity objects or attributes.
Entity object - Read, Delete, Update
Attribute of EO - Update

Question: How to grant permissions on resources to Roles? 
Answer: You can associate roles to grants on resources as below:
Groups of pages - Grant access on Bounded task flow in jazn-data.xml
Individual pages - Grant access on Page Definition in jazn-data.xml 
Rows - Grant access on entity objects or attributes in EO security and authorization.

Question: How to secure page with no data?
Answer: You can create an empty page definition file and grant access on Page Definition in jazn-data.xml 

Question: What are the different Identity Store options available in ADF Security Wizard?
Answer: Application XML: 
1. Used for small-scale applications or testing
2. Uses the Oracle Platform Security for Java's file-based repository
3. Configured in JDeveloper—user and role information stored in jazn-data.xml
LDAP:
1. Identity store configured outside of JDeveloper
2. Scalable and secure
3. Integrates with Oracle Single Sign On

Question: What are the different Authentication Type options available in ADF Security Wizard?
Answer: 1. HTTP Basic Authentication: Browser authentication is used; the user name and password are not encrypted. This is useful for testing authentication without the need for a custom login page.
2. HTTP Digest Authentication: Browser authentication is used; the user name and password are encrypted, so it is more secure than basic authentication.
3. HTTPS Client Authentication (Public Key Certificate): This strong authentication mechanism uses a certificate and transmits over SSL.
4. Form-Based Authentication: The developer can specify a login page and a page to display when login fails.

Question: What is the difference between Authentication and Authorization in ADF?
Answer: Authentication determines which users can access the application where as Authorization determines what functions users are allowed to perform after they enter the application.

Question: How can we handle response to the Browser Back Button?
Answer: The task-flow-reentry property can used to determines if user can return to an exited task flow by clicking the
browser’s Back button:
1. reentry-allowed: Reentry is allowed 
2. reentry-not-allowed: User will return to a page within the bounded task flow but an exception will be thrown on performing any action like button click.
3. reentry-outcome-dependent: Depends on outcome when same ADF bounded task flow was previously exited.

Question: How can we handle exception in ADF?
Answer: By designating an Exception Handler Activity. The exception handler activity can be any supported activity type like a view or router.
Steps - Right-click the activity in the task flow diagram, then choose Mark Activity > Exception Handler.
When you designate that an activity is the exception handling activity for a task flow, the task flow metadata updates with an <exception-handler> element that specifies the ID of the activity

Question: What are the different data control scopes available in ADF Taskflow?
Answer: Shared and Isolated

Question: What are the different Transaction Start Options available in ADF Taskflow?
Answer: Transaction start options on the called task flow definition specify whether a called ADF bounded task flow should -
1. new-transaction - Create a new transaction
2. requires-existing-transaction - Join an existing transaction
3. requires-transaction - Create a new one only if there is no existing transaction


Project Accounting - Check funds queries at Task, Top Task and Project Level

FOR TASK

  SELECT project_id,
    (SUM(budget) - SUM(actuals)) "funds"
  FROM PA_TASK_FC_RESULTS_V
  WHERE project_id     =<p_project_id>
  AND start_date       > '31-MAR-15'
  AND end_date         < '1-APR-16'
  AND budget_version_id=
    (SELECT MAX(budget_version_id)
    FROM PA_TASK_FC_RESULTS_V
    WHERE project_id=<p_project_id>
    )
  and TASK_ID=<P_TASK_ID>
  GROUP BY project_id;
  
FOR TOP TASK 

  SELECT project_id,
    (SUM(budget) - SUM(actuals)) "funds"
  FROM PA_TOP_TASK_FC_RESULTS_V
  WHERE project_id     =<p_project_id>
  AND start_date       > '31-MAR-15'
  AND end_date         < '1-APR-16'
  AND budget_version_id=
    (SELECT MAX(budget_version_id)
    FROM PA_TOP_TASK_FC_RESULTS_V
    WHERE project_id=<p_project_id>
    )
  and TOP_TASK_ID=<P_TOP_TASK_ID>
  GROUP BY project_id;
  
FOR PROJECT 

  SELECT project_id,
    (SUM(budget) - SUM(actuals)) "funds"
  FROM PA_PRJ_FC_RESULTS_V
  WHERE project_id     =<p_project_id>
  AND start_date       > '31-MAR-15'
  AND end_date         < '1-APR-16'
  AND budget_version_id=
    (SELECT MAX(budget_version_id)
    FROM PA_PRJ_FC_RESULTS_V
    WHERE project_id=<p_project_id>
    )
  GROUP BY PROJECT_ID;

Blocking Outlook Calendar through PLSQL Code

-- Following code can be used for blocking the calendar of the recipients through email 
-- sent using PLSQL Code.
-- Create the following function

CREATE OR REPLACE FUNCTION ical_event (
   p_summary         IN VARCHAR2
 , p_organizer_name  IN VARCHAR2
 , p_organizer_email IN VARCHAR2
 , p_start_date      IN DATE
 , p_end_date        IN DATE
 , p_version         IN VARCHAR2 := NULL
 , p_prodid          IN VARCHAR2 := NULL
 , p_calscale        IN VARCHAR2 := NULL
 , p_method          IN VARCHAR2 := NULL
)
   RETURN VARCHAR2 

AS  

   l_retval VARCHAR2(32767);
   l_lf     CHAR(1) := CHR(10);

BEGIN

   l_retval := ''
      || 'BEGIN:VCALENDAR' || l_lf
      || 'VERSION:' || NVL(p_version,'2.0') || l_lf
      || 'PRODID:' || NVL(p_prodid,'-//Your company name//NONSGML ICAL_EVENT//EN') || l_lf
      || 'CALSCALE:' || NVL(p_calscale,'GREGORIAN') || l_lf
      || 'METHOD:' || NVL(p_method,'REQUEST') || l_lf
      || 'BEGIN:VEVENT' || l_lf
      || 'SUMMARY:' || p_summary || l_lf
      || 'ORGANIZER;CN="' || p_organizer_name || '":MAILTO:' || p_organizer_email || l_lf
      || 'DTSTART:' || TO_CHAR(p_start_date,'YYYYMMDD') || 'T' || TO_CHAR(p_start_date,'HH24MISS') || l_lf
      || 'DTEND:' || TO_CHAR(p_end_date,'YYYYMMDD') || 'T' || TO_CHAR(p_end_date,'HH24MISS') || l_lf
      || 'DTSTAMP:' || TO_CHAR(SYSDATE,'YYYYMMDD') || 'T' || TO_CHAR(SYSDATE,'HH24MISS') || l_lf
      || 'UID:' || RAWTOHEX(SYS_GUID()) || '@yoururl.com' || l_lf
      || 'STATUS:NEEDS-ACTION' ||  l_lf
      || 'END:VEVENT' || l_lf
      || 'END:VCALENDAR';
   
   RETURN l_retval;
      
END ical_event;


--Create the following procedure (replace "yoururl" as needed): 

CREATE OR REPLACE PROCEDURE send_ical_email (
   p_from      IN VARCHAR2
 , p_to        IN VARCHAR2
 , p_subj      IN VARCHAR2
 , p_body_html IN VARCHAR2
 , p_body_ical IN VARCHAR2
)

AS

   l_connection UTL_SMTP.CONNECTION;
   l_mail_serv  VARCHAR2(50) := 'mail.yoururl.com';
   l_mail_port  PLS_INTEGER := '25';
   l_lf         CHAR(1) := CHR(10);
   l_msg_body   VARCHAR2(32767);

BEGIN
   
   l_msg_body :=
         'Content-class: urn:content-classes:calendarmessage' || l_lf
      || 'MIME-Version: 1.0' || l_lf
      || 'Content-Type: multipart/alternative;' || l_lf
      || ' boundary="----_=_NextPart"' || l_lf
      || 'Subject: ' || p_subj || l_lf 
      || 'Date: ' || TO_CHAR(SYSDATE,'DAY, DD-MON-RR HH24:MI') || l_lf
      || 'From: <' || p_from || '> ' || l_lf 
      || 'To: ' || p_to || l_lf 
      || '------_=_NextPart' || l_lf
      || 'Content-Type: text/plain;' || l_lf
      || ' charset="iso-8859-1"' || l_lf
      || 'Content-Transfer-Encoding: quoted-printable' || l_lf
      || l_lf
      || 'You must have an HTML enabled client to view this message.' || l_lf
      || l_lf
      || '------_=_NextPart' || l_lf
      || 'Content-Type: text/html;' || l_lf
      || ' charset="iso-8859-1"' || l_lf
      || 'Content-Transfer-Encoding: quoted-printable' || l_lf
      || l_lf
      || p_body_html || l_lf
      || l_lf
      || '------_=_NextPart' || l_lf
      || 'Content-class: urn:content-classes:calendarmessage' || l_lf
      || 'Content-Type: text/calendar;' || l_lf
      || '  method=REQUEST;' || l_lf
      || '  name="meeting.ics"' || l_lf
      || 'Content-Transfer-Encoding: 8bit' || l_lf
      || l_lf
      || p_body_ical || l_lf
      || l_lf
      || '------_=_NextPart--';
            
   l_connection := utl_smtp.open_connection(l_mail_serv, l_mail_port);
   utl_smtp.helo(l_connection, l_mail_serv);
   utl_smtp.mail(l_connection, p_from);
   utl_smtp.rcpt(l_connection, p_to);
   utl_smtp.data(l_connection, l_msg_body);
   utl_smtp.quit(l_connection);
   
END send_ical_email;

-- Create a page process similar to the following that fires 
-- when the submit button is pressed (this will vary depending on step 3): 

DECLARE

   l_ical_event VARCHAR2(32767);

BEGIN

   l_ical_event := ical_event(
      p_start_date      => TO_DATE(:PXX_START_DATE || :PXX_START_TIME,'DD-MON-YYYYHH:MIPM')
    , p_end_date        => TO_DATE(:PXX_END_DATE || :PXX_END_TIME,'DD-MON-YYYYHH:MIPM')
    , p_summary         => :PXX_SUBJ
    , p_organizer_name  => :PXX_USER_NAME
    , p_organizer_email => :PXX_USER_EMAIL
   );

   send_ical_email( 
      p_to        => :PXX_TO_ADDRESS
    , p_from      => :PXX_USER_EMAIL
    , p_subj      => :PXX_SUBJ
    , p_body_html => :PXX_BODY_HTML 
    , p_body_ical => l_ical_event
   );
   
END;

That should do it. Submit the page to send the request.