love fish大鹏一曰同风起,扶摇直上九万里

常用链接

统计

积分与排名

friends

link

最新评论

更新受控文件属性时报错Error: Controlled document has no specified document class

Error Executing Query
Controlled document has no specified document class.
受控信息丢失!

在DCM中点击“受控信息” 报错:class java.lang.NullPointerException


执行如下脚本
create object dcm_extended_sysobject set parent_id='0902055880155f4b',set document_class='ECR_PCN相关表单',set permanent_link=false,set child_id='37020558800178ad',set relation_name='dcm_extended_sysobject'

parent_id:受控文件ID
document_class:在表dcm_document_class中查找相应值
child_id:是执行脚本后生成对象的ID

import com.documentum.fc.client.DfClient;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfPersistentObject;
import com.documentum.fc.client.IDfRelation;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfSysObject;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.DfId;
import com.documentum.fc.common.DfList;
import com.documentum.fc.common.DfLoginInfo;
import com.documentum.fc.common.IDfList;
import com.documentum.fc.common.IDfLoginInfo;

/**
 *
 
*/


/**
 * 
@author liaojiyong
 * @date Aug 24, 2009
 * 
@version 1.0
 
*/

public class ControlledDocDeal {
    
public static void main(String[] args) {
        IDfSessionManager sessionManager 
= null;
        IDfSession session 
= null;
        IDfClient localClient;
        
try {
            localClient 
= DfClient.getLocalClient();
            sessionManager 
= localClient.newSessionManager();

            String docbase 
= "XXX";
            System.out.println(
"\n" + docbase);

            IDfLoginInfo loginInfo 
= new DfLoginInfo();
            loginInfo.setUser(
"dmadmin");
            loginInfo.setPassword(
"dmadmin");
            sessionManager.setIdentity(docbase, loginInfo);
            session 
= sessionManager.getSession(docbase);
            IDfList list 
= new DfList();

            
//输入objectid
            String objectId="0902055880156cee";
            IDfSysObject obj 
= (IDfSysObject) session.getObject(new DfId(objectId));
            list.append(obj);
            doBusiness(session,list);
        }
 catch (Exception e) {
            e.printStackTrace();
        }


    }


    
private static void doBusiness(IDfSession idfsession, IDfList list) throws DfException, Exception {
        
for (int i = 0; i < list.getCount(); i++{
            IDfSysObject obj 
= (IDfSysObject) list.get(i);
            String objectId 
= obj.getObjectId().toString();
            String type 
= obj.getString("r_object_type");
            String qualification 
= "dcm_extended_sysobject  where parent_id='" + objectId + "'";
            IDfPersistentObject sysObj 
= idfsession.getObjectByQualification(qualification);
            
if (sysObj != null{
            }
 else {
                String document_class 
= "其它";

                
// get Controlled document class
                qualification = "dcm_document_class where docbase_type='" + type + "'";
                sysObj 
= idfsession.getObjectByQualification(qualification);
                
if (sysObj != null{
                    document_class 
= sysObj.getString("object_name");
                }


                
// add a controlled relation
                IDfRelation relObj = (IDfRelation) idfsession.newObject("dcm_extended_sysobject");
                relObj.setString(
"parent_id", objectId);
                relObj.setString(
"document_class", document_class);
                relObj.setBoolean(
"permanent_link"false);
                relObj.setString(
"relation_name""dcm_extended_sysobject");
                relObj.save();
                relObj.setString(
"child_id", relObj.getObjectId().toString());
                relObj.save();

            }

        }

    }


}

posted on 2009-08-20 20:02 liaojiyong 阅读(312) 评论(0)  编辑  收藏 所属分类: Documentum


只有注册用户登录后才能发表评论。


网站导航: