我正在做一个连接到Documentum数据存储的项目。我正在尝试使用以下函数更新分配给文件夹子文件夹的所有acl名称:
try {
StringBuilder str = new StringBuilder();
str.append(dirDestination);
str.append("/");
str.append(companyName);
String query = "update dm_folder object set acl_name = '@acl_name' , set acl_domain ='@acl_domain' where folder ('@acl_dirPath',descend)";
query = query.replace("@acl_name",newAclName);
query = query.replace("@acl_domain",inheritedAclDomain );
query = query.replace("@acl_dirPath",str.toString() );
IDfQuery ACLQuery = new DfQuery();
ACLQuery.setDQL(query);
ACLQuery.execute(_session, IDfQuery.DF_EXEC_QUERY);
log.info("All the sub folders have received the new ACL.");
}catch(Exception E){
System.out.println(E.getLocalizedMessage());
}
该功能完美正常,但我想知道由于使用这些代码行而更新了多少个文件夹。
一种方法是使用IDfCollections
似乎不适用于这个DQL,因为我写了以下内容并且我一直得到1:
try{
StringBuilder path = new StringBuilder();
path.append(dirDestination);
path.append("/" + companyName);
String query = "update dm_folder object set acl_name = '@newAclName' , set acl_domain ='@newAclDomain' where folder ('@aclPath',descend)";
query = query.replace("@newAclName" , newAclName );
query = query.replace("@newAclDomain" , inheritedAclDomain );
query = query.replace("@aclPath" , path );
IDfQuery ACLQuery = new DfQuery();
ACLQuery.setDQL(query);
IDfCollection count = ACLQuery.execute(_session, IDfQuery.DF_EXEC_QUERY);
int counter = 0 ;
while (count.next()){
counter++ ;
}
System.out.println("counter for sub folders ==> " + counter);
log.info("The ACl name for all the sub folders are updated .");
}catch(Exception E ){
System.out.println(E.getLocalizedMessage());
}
所以问题是我怎样才能知道有多少对象被更新的元数据?另一种方法是根据对象的修改日期进行检查。但还有其他更简单(更直接)的方式吗?
答案 0 :(得分:1)
你只需要在while循环中获取objects_updated而不是increment变量:
IDfCollection count = ACLQuery.execute(_session, IDfQuery.DF_EXEC_QUERY);
int counter = 0 ;
if (count.next()) {
counter = count.getInt("objects_updated");
}
System.out.println("count of updated sub folders ==> " + counter );