Archive for July, 2008

Jul 21 2008

Trials for LiveCycle ES Update 1 available

Published by Waldo Smeets under LiveCycle ES

LiveCycle ES Update 1 was announced on june 16th 2008 and a good tradition at Adobe is to make the software available to end users one month later.  So from today (or was it even earlier?) you can try the software – including all the new integration features with Alfresco – by selecting one of the options listed at www.adobe.com/devnet/livecycle/trial.  You can basically choose to download the multi-gigabyte installers from the website or get a DVD shipped to you for just a few euros.

Together with this release there is also separate trial downloads available for updated releases of LiveCycle Designer ES and LiveCycle Data Services ES 2.6 (for those Flex developers that don’t dare to get their hands dirty on the rest of LiveCycle yet, hehe).

If you are new to LiveCycle I highly recommend the turn key option with the JBoss download, which is ideal for evaluation purposes. This will install the application server, database, and samples with just a few mouse clicks.

For an overview of new features in LiveCycle ES Update 1:

Installing the software is pretty straightforward, especially when you follow the steps listed in How to Get Started and choose the turn key installation. However, if you are having issues or need help evaluating specific parts of the LiveCycle Enterprise Suite, feel free to contact us for questions or even better… make an appointment for a free consult with DrLiveCycle.

One response so far

Jul 08 2008

LiveCycle Data Services and Java EE container managed security

Disease

You want to authenticate via a Flex application and still leverage Java EE container managed security.

Prescription

With LiveCycle ES Data Services you can authenticate users using the Flex application and you can pass these credentials on to the back-end where they will be verified by the container. The server-side Flex Session give you access to the Principal object. Through the use of roles you can authorize users to invoke LiveCycle ES Data Services endpoints or avoid users invoking specific LiveCycle ES Data Services assembler methods.

Following steps explain how to set this up on Tomcat 5.5.

  • Download the source of this sample from Adobe share and import the Flex project
  • Configure container managed security in Tomcat.
  • Follow the steps in $LCDSHOME/resources/security/tomcat/readme.txt (download LiveCycle ES Data Services)
  • Create a LiveCycle ES Data Services project in Eclipse (Dr. FLex & Dr. LiveCycle)
  • In your project, create a context.xml under META-INF/
 

<Context>
      <Realm className="org.apache.catalina.realm.MemoryRealm" />
      <Valve className="flex.messaging.security.TomcatValve"/>
</Context>

 
  • In your project, edit services-config.xml in WEB-INF/flex, the <security> tag should point to the following login command:
 

<security>
    <login-command class="flex.messaging.security.TomcatLoginCommand"
                               server="Tomcat">
      <per-client-authentication>false</per-client-authentication>
    </login-command>

</security>

 
  • To pass on the credentials captured in your Flex application to your back-end you can use (see main.mxml in the code sample):
 

personDS.setCredentials(username.text, password.text);

 

      personDS is a LiveCycle ES Data Services Data Management endpoint

  • The container will only allow you to access the LiveCycle ES Data Services endpoint when these credentials are valid.
  • To obtain the Principal in the LiveCycle ES Data Services assembler you execute (see PersonAssember in the code sample). For more info on assemblers, go to Dr Flex & Dr. LiveCycle or consult the LiveCycle Data Services Developer Guide.
  Principal principal = FlexContext.getUserPrincipal();  

 

Tips to stay healthy :

You can extend this further by leveraging the integration between LiveCycle ES Data Services and Java EE security by protecting resources via roles to allow only specific users to invoke Data Services endpoints.

Embedding the following in your LiveCycle ES Data Services data-management-config.xml file, you can avoid users not having the correct role to invoke this endpoint (see sample code):

 

<destination id="persons">

    <adapter ref="java-dao" />
    <security>
        <security-constraint>
            <auth-method>Custom</auth-method>
            <roles>
                <role>help</role>
            </roles>
        </security-constraint>
    </security>

    ….

One response so far

Jul 08 2008

LiveCycle ES Data Services [Data Management] and Java Enums

Disease :

You want to use LiveCycle ES Data Services on top of a Java back-end that is using Java enums.

Prescription :

LiveCycle ES Data Services 2.6 supports Java enums. When serializing from Java to ActionScript, Data Services will transform the Java enum value into an ActionScript String. When serializing from ActionScript to Java, Data Services will assign the correct enum value to the corresponding Java attribute.

Let’s see how it looks like. To get started we create a LiveCycle ES Data Services project (What is the preferred LiveCycle Data Services development environment). In the next part we will run through all the steps needed to develop a LiveCycle ES Data Services Data Manangement application.

The Java side

The Java enum looks like this

 

package myenum.test;

public enum MyEnum {
    VOLVO,
    PORSCHE,
    AUDI,
    BMW;
}

 

 

The DTO looks like this:

 

package myenum.test;

public class MyDTO {

    public int id;
    public MyEnum car;
    public String name;
}

 

 

 

LiveCycle ES Data Services Data Management automatically takes care of all DTO’s that are modified and retrieved by the Flex application (created, deleted and updated objects). When a client side "commit" operation is invoked the modifications are sent to the server. Those changes are mapped to your back-end via an assembler class. Typically this class implements four methods (fill, createItem, updateItem and deleteItem). In this example the assembler class looks like this:

 

 

package myenum.test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import flex.data.assemblers.AbstractAssembler;

public class MyAssembler extends AbstractAssembler {

    @Override
    public Collection fill(List fillParameters) {
        ArrayList<MyDTO> list = new ArrayList<MyDTO>();
        MyDTO myDTO = new MyDTO();
        myDTO.id = 1;
        myDTO.name = "Marc";
        myDTO.car = MyEnum.AUDI;
        list.add(myDTO);
        // TODO Auto-generated method stub
        return list;
    }

    @Override
    public void createItem(Object item) {
        MyDTO myDTO = (MyDTO) item;
        System.out.format("Name : %s\nCar : %s", myDTO.name, myDTO.car);
    }

    @Override
    public void deleteItem(Object previousVersion) {

        MyDTO myDTO = (MyDTO) previousVersion;
        System.out.format("Name : %s\nCar : %s", myDTO.name, myDTO.car);
    }

    @Override
    public void updateItem(Object newVersion, Object previousVersion,
            List changes) {

        MyDTO myDTO = (MyDTO) newVersion;
        System.out.format("Name : %s\nCar : %s", myDTO.name, myDTO.car);
    }
}

 

In the real world these methods will be calling your specific services to retrieve and process the information.

Before we go to the Flex client we need to configure a Data Management endpoint by configuring the data-management-config.xml file in your LiveCycle ES Data Services project (located in WEB-INF/flex)

 

 

<destination id="myds">

    <adapter ref="java-dao" />
    <channels>
       <channel ref="my-rtmp"/>
    </channels>

    <properties>

        <auto-sync-enabled>true</auto-sync-enabled>

        <use-transactions>false</use-transactions>

        <source>myenum.test.MyAssembler</source>
        <scope>application</scope>

        <metadata>
            <identity property="id" />
        </metadata>

        <network>
            <session-timeout>20</session-timeout>
            <paging enabled="false" pageSize="10" />
            <throttle-inbound policy="ERROR" max-frequency="500" />
            <throttle-outbound policy="REPLACE" max-frequency="500" />
        </network>

        <server/>

    </properties>

</destination>

 

 

The Flex side

The ActionScript DTO (it maps directly to the Java class):

 

package vo
{
    [Managed]
    [RemoteClass(alias="myenum.test.MyDTO")]   
    public class MyDTO
    {
        public function MyDTO()
        {
        }
        public var id:int;
        public var name:String;
        public var car:String;

    }
}

 

The Flex application:

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

    <mx:Script>
        <![CDATA[
            import vo.MyDTO;

            private function createMyDTO():void {
                var myDTO:MyDTO = new MyDTO();
                myDTO.id = 0;
                myDTO.name = "Marc";
                myDTO.car = "BMW";
                myCol.addItem(myDTO);
            }

          ]]>
    </mx:Script>

 

    <mx:DataService id="myDS" destination="myds" autoCommit="false"/>
    <mx:ArrayCollection id="myCol"/>

    <mx:Panel x="116" y="49" width="488" height="204" layout="absolute">
        <mx:DataGrid id="myDG" x="0" y="0" width="100%" height="100%"
                     dataProvider="{myCol}" editable="true">
        </mx:DataGrid>
        <mx:ControlBar>
            <mx:Button label="Query" click="myDS.fill(myCol)"/>
            <mx:Button label="Create" click="createMyDTO()"/>
            <mx:Button label="Save"
                  enabled="{myDS.commitRequired}" click="myDS.commit()"/>
            <mx:Button label="Undo"
                  enabled="{myDS.commitRequired}" click="myDS.revertChanges()"/>
        </mx:ControlBar>
    </mx:Panel>
</mx:Application>

 

 

On the Java side "car" is a enum while in ActionScript it is a String. Assigning "BMW" to a newly created myVO results serverside in a new myVO with the car enum equal to BMW.

Notice that there are no explicit calls made to the server for creating, deleting or updating the DTO’s. The only interaction with the server happens through the fill and the save operation. LiveCycle ES Data Services Data Management takes care of the hard work.

image

You can download the sources for this sample as a LiveCycle ES Data Services project archive from Adobe Share, next import this into your Eclipse + Flex plugin environment.

Tip to stay healthy:

Check out Christophe Coenraets‘ website to find more examples about LiveCycle ES Data Services. You can download LiveCycle ES Data Services 2.6 (beta) from Adobe Labs.

2 responses so far