FileNet设定文档权限

 权限管理对于文档来说非常,文档的权限就是一个安全锁,没有权限的人是无法获取该文件的。同样也会因为一些用户没有权限而造成读取文档的失败,这在项目中是会经常遇到的,不过这里不涉及用户因权限不够造成的问题。

import java.util.Iterator;
import com.filenet.api.engine.EventActionHandler;
import com.filenet.api.events.*;
import com.filenet.api.util.Id;
import com.filenet.api.core.*;
import com.filenet.api.collection.FolderSet;
import com.filenet.api.constants.*;
import com.filenet.apiimpl.util.Base64;

import org.apache.commons.logging.*;

public class ParentageSecurityEvent implements EventActionHandler{
    private static Log log = LogFactory.getLog(ParentageSecurityEvent.class);
    @SuppressWarnings("unused")
    public void onEvent(ObjectChangeEvent event, Id subId) {
    	try{
    	 ObjectStore os = event.getObjectStore();
    	 
         Document document = (Document) event.get_SourceObject();
         log.info("Verifing document :"+document.get_Name()+"    ID: "+document.get_Id());
         
           Folder folder = document.get_SecurityFolder();
        	 if (folder.get_PathName().startsWith("/Documents")){
        		 log.info("Setting folder parentage on document :"+ document.get_Name()+"  "+document.get_Id() +"   to parent folder :"+folder.get_PathName());
        		 folder.set_InheritParentPermissions(true);
        		 folder.save(RefreshMode.NO_REFRESH);
        		 document.set_SecurityFolder(folder);
        	 }else
        		 log.debug("Not applying folder parentage security for folder :"+folder.get_PathName());
               }catch (Exception e){
    	 log.error("Security of document not changed, exception in event occurred :"+e,e);
      }
   }
}


当然这些代码比较简单,下面是上面代码中一些方法的说明

 

Folder get_SecurityFolder()
Returns the value of the SecurityFolder property.
void set_SecurityFolder(Folder value)
Sets the value of the SecurityFolder property.
void set_InheritParentPermissions(java.lang.Boolean value)
Sets the value of the InheritParentPermissions property
void save(RefreshMode refreshMode)
Saves changes made to this object. You can optionally refresh all of the object's properties.

 

更多的关于FileNet权限管理的介绍请参考http://www.ibm.com/developerworks/cn/data/library/techarticle/dm-1107wanghl/index.html

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值