Hi all
We have an application where we want to use the Aspects.The idea is to apply the aspect on dm_document.
The aspect in our application will require to add /override the behavior only. We are not using any specific attributes.
We are trying to override the behavior of doCheckout , doSave and doDelete depending upon the status of a registered table(ABC_STATUS).
The registered table has a field named as "flag". If the "flag" field is true, doCheckout/doSave or doDelete will throw an exception.
This is how we want the aspects to behave. But the behavior of aspect is not reflecting like if the "flag" field in my registered table is true then
an exception must be thrown and no checkouts should be allowed.
Iam attaching the aspect code [both implementation class as well as Interface class].Iam also attaching the screen shot where I have created
an Aspect on dm_document in Composer.
Please correct me if I am missing something..
package com.xyz.aspect;
import com.documentum.fc.client.DfDocument;
import com.documentum.fc.common.DfException;
import com.documentum.com.DfClientX;
import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.DfDocument;
import com.documentum.fc.client.IDfCollection;
import com.documentum.fc.client.IDfQuery;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSysObject; //adg add
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.IDfId;
import java.net.InetAddress;
import java.rmi.server.UID;
import com.xyz.aspect.IAspectDocument;
import com.documentum.fc.client.IDfModule;
public class AspectDocument extends DfDocument implements IAspectDocument,IDfModule{
public AspectDocument()
{
}
protected void doSave(boolean saveLock, String versionLabel, Object extendedArgs[])
throws DfException
{
String objID = getObjectId().toString();
System.out.println("The object id is Aspect called:"+objID);
System.out.println("doSave called !!!!! Aspect called in save -");
if(flag(objID))
{
throw new DfException ("SAVE operation failed. Cannot since flag is true");
}
else
super.doSave(saveLock, versionLabel, extendedArgs);
}
protected IDfId doCheckin(boolean fRetainLock, String versionLabels, String oldCompoundArchValue, String oldSpecialAppValue, String newCompoundArchValue, String newSpecialAppValue, Object extendedArgs[])
throws DfException
{
System.out.println("doCheckin() entered! (Aspect)!!!!!!");
String objIDChk = getObjectId().toString();
if(flag(objIDChk))
{
throw new DfException ("Save operation failed. Cannot checkin since flag is true");
}
else
return super.doCheckin(fRetainLock, versionLabels, oldCompoundArchValue, oldSpecialAppValue, newCompoundArchValue, newSpecialAppValue, extendedArgs);
}
protected IDfId doCheckout(String versionLabel, String compoundArchValue, String specialAppValue,
Object[] extendedArgs) throws DfException {
String objIDChk = getObjectId().toString();
System.out.println("doCheckout entered!!!!! Aspect called -objectID is "+objIDChk);
System.out.println("doCheckout entered!!!!! Aspect called -");
if(flag(objIDChk)){
throw new DfException("Checkout operation failed. Since flag is true");
}
else
return super.doCheckout(versionLabel, compoundArchValue, specialAppValue, extendedArgs);
}
public void doDestroy(boolean force, Object extendedArgs[]) throws DfException
{
String objID = getObjectId().toString();
if(flag(objID))
{
throw new DfException ("Delete operation failed. since flag is true");
}
else
super.doDestroy(force, extendedArgs);
}
public boolean flag(String objectID)
{
boolean status = false;
IDfSession qrySession = null;
//Collection for the result
IDfCollection recordCol = null;
try{
String queryRecord = "select flag from dm_dbo.ABC_STATUS where r_object_id ='" + objectID +"'" ;
qrySession = getSession();
IDfClientX clientx = new DfClientX();
IDfQuery recordQry = clientx.getQuery();
recordQry.setDQL(queryRecord);
recordCol = recordQry.execute(qrySession, IDfQuery.DF_READ_QUERY);
while(recordCol.next())
{
String checkFlag = recordCol.getValueAt(0).asString();
if(checkFlag.equalsIgnoreCase("T")){
status=true;
}else{
status=false;
}
}
if(recordCol != null)
recordCol.close();
return status;
}catch(DfException qryExpection)
{
System.out.println("Exception in handling IDfCollection " +qryExpection.getMessage());
recordCol = null;
qrySession = null;
return false;
}
}
///Code for Interface Class
package com.xyz.aspect;
import com.documentum.fc.common.DfException ;
public interface IAspectDocument {
}

Thanks in advance.