Filenet Component 节点修改附件文档权限
By:Roy.LiuLast updated:2009-11-06
这个包(import com.filenet.wcm.toolkit.server.operations.util.opsUtil;)我好像没找到,在网上看到有人说 3.5 里面有,我现在用的 p8 4.5 里面没找到,但收藏下来,以备后用.
package com.filenet.operations;
import java.util.Iterator;
import com.filenet.wcm.api.Document;
import com.filenet.wcm.api.GettableObject;
import com.filenet.wcm.api.ObjectFactory;
import com.filenet.wcm.api.Permission;
import com.filenet.wcm.api.Permissions;
import com.filenet.wcm.api.Property;
import com.filenet.wcm.api.Session;
import com.filenet.wcm.toolkit.server.operations.util.opsUtil;
import com.filenet.wcm.toolkit.util.WcmException;
import filenet.vw.api.VWAttachment;
import filenet.vw.api.VWException;
public class ChangePermission {
public void setDocPermission(VWAttachment sourceDocument,String currentUserName) throws WcmException
{
boolean exist = false;
String userName = null;
int maskNumber = 131201;
opsUtil opsUtil=new opsUtil();
Session session = opsUtil.getSession();
GettableObject attachment = opsUtil.getAttachment(sourceDocument, session);
Document doc = (Document) attachment;
Permissions permissions = doc.getPermissions();
Iterator iterator = permissions.iterator();
try{
while (iterator.hasNext()) {
Permission permission = (Permission) iterator.next();
userName = permission.getGranteeName(); // #AUTHENTICATED-USERS,Administrator@fndemo.com,tester1@fndemo.com,tester2@fndemo.com,Administrator@fndemo.com,
if (userName.equalsIgnoreCase(currentUserName.trim())) {
permission.setAccess(maskNumber);
permissions.add(permission);
doc.setPermissions(permissions);
doc.refresh();
exist = true;
}
}
if(!exist){
Permission permission = ObjectFactory.getPermission(maskNumber,1,currentUserName,2000);
permission.setInheritableDepth(0);
permissions.add(permission);
doc.setPermissions(permissions, Property.PERMISSIONS);
doc.refresh();
}
}catch(Exception e)
{
e.printStackTrace();
}
}
public void removeDocPermission(VWAttachment sourceDocument,String currentUserName) throws WcmException {
opsUtil opsUtil=new opsUtil();
Session session = opsUtil.getSession();
String userName = null;
GettableObject go = opsUtil.getAttachment(sourceDocument, session);
Document doc = (Document) go;
Permissions permissions = doc.getPermissions();
Iterator iterator = permissions.iterator();
try{
while (iterator.hasNext()) {
Permission permission = (Permission) iterator.next();
userName = permission.getGranteeName(); // #AUTHENTICATED-USERS,Administrator@fndemo.com,tester1@fndemo.com,tester2@fndemo.com,Administrator@fndemo.com,
if (userName.equalsIgnoreCase(currentUserName.trim())) {
iterator.remove();
Permission p = ObjectFactory.getPermission(131073,1,currentUserName,2000);
p.setInheritableDepth(0);
permissions.add(p);
permissions.add(p);
doc.setPermissions(permissions,Property.PERMISSIONS);
doc.refresh();
}
}
}catch(Exception e)
{
e.printStackTrace();
}
}
}
package com.filenet.operations;
import java.util.Iterator;
import com.filenet.wcm.api.Document;
import com.filenet.wcm.api.GettableObject;
import com.filenet.wcm.api.ObjectFactory;
import com.filenet.wcm.api.Permission;
import com.filenet.wcm.api.Permissions;
import com.filenet.wcm.api.Property;
import com.filenet.wcm.api.Session;
import com.filenet.wcm.toolkit.server.operations.util.opsUtil;
import com.filenet.wcm.toolkit.util.WcmException;
import filenet.vw.api.VWAttachment;
import filenet.vw.api.VWException;
public class ChangePermission {
public void setDocPermission(VWAttachment sourceDocument,String currentUserName) throws WcmException
{
boolean exist = false;
String userName = null;
int maskNumber = 131201;
opsUtil opsUtil=new opsUtil();
Session session = opsUtil.getSession();
GettableObject attachment = opsUtil.getAttachment(sourceDocument, session);
Document doc = (Document) attachment;
Permissions permissions = doc.getPermissions();
Iterator iterator = permissions.iterator();
try{
while (iterator.hasNext()) {
Permission permission = (Permission) iterator.next();
userName = permission.getGranteeName(); // #AUTHENTICATED-USERS,Administrator@fndemo.com,tester1@fndemo.com,tester2@fndemo.com,Administrator@fndemo.com,
if (userName.equalsIgnoreCase(currentUserName.trim())) {
permission.setAccess(maskNumber);
permissions.add(permission);
doc.setPermissions(permissions);
doc.refresh();
exist = true;
}
}
if(!exist){
Permission permission = ObjectFactory.getPermission(maskNumber,1,currentUserName,2000);
permission.setInheritableDepth(0);
permissions.add(permission);
doc.setPermissions(permissions, Property.PERMISSIONS);
doc.refresh();
}
}catch(Exception e)
{
e.printStackTrace();
}
}
public void removeDocPermission(VWAttachment sourceDocument,String currentUserName) throws WcmException {
opsUtil opsUtil=new opsUtil();
Session session = opsUtil.getSession();
String userName = null;
GettableObject go = opsUtil.getAttachment(sourceDocument, session);
Document doc = (Document) go;
Permissions permissions = doc.getPermissions();
Iterator iterator = permissions.iterator();
try{
while (iterator.hasNext()) {
Permission permission = (Permission) iterator.next();
userName = permission.getGranteeName(); // #AUTHENTICATED-USERS,Administrator@fndemo.com,tester1@fndemo.com,tester2@fndemo.com,Administrator@fndemo.com,
if (userName.equalsIgnoreCase(currentUserName.trim())) {
iterator.remove();
Permission p = ObjectFactory.getPermission(131073,1,currentUserName,2000);
p.setInheritableDepth(0);
permissions.add(p);
permissions.add(p);
doc.setPermissions(permissions,Property.PERMISSIONS);
doc.refresh();
}
}
}catch(Exception e)
{
e.printStackTrace();
}
}
}
From:一号门
Previous:陈琳 居然自杀了,重庆的呀。
COMMENTS