我正在尝试向 Perforce 中的文件夹上的组授予权限。但是,在 Perforce 中从 Java 创建/更新的权限表是空的。
以下是我做的步骤 -
//Get the server object.
IOptionsServer server = ServerFactory.getOptionsServer("p4java://<ip>:1666", null);
server.connect();
server.setUserName("<username>"); // this is a super user
server.login("<password>");
//Create a user group and add users.
IUserGroup ug = new UserGroup();
String groupName = "<usergroup_somename>;
ug.setName(groupName);
List<String> userList = new ArrayList<>();
userList.add("<username1>");
userList.add("<username2>");
userList.add("<username3>");
ug.setUsers(userList);
server.createUserGroup(ug);
//Get the permission table.
GetProtectionEntriesOptions gpo = new GetProtectionEntriesOptions();
gpo.setAllUsers(true);
List<IProtectionEntry> peList = server.getProtectionEntries(null, gpo);
//Create a new Protection entry
IProtectionEntry pe = new ProtectionEntry();
pe.setGroup(true);
pe.setName(groupName);
depotFilePath = "//depottest/Level1/Level2/..."; // the folders exist in Perforce
pe.setPath(depotFilePath);
pe.setMode("write");
pe.setHost("*");
pe.setPathExcluded(false);
pe.setOrder(peList.size());
pe.setType(EntryType.INCLUDE);
//Add the new created permission into the fetched Permission table list.
peList.add(pe);
//Create/Update the Permission table using either of the following methods separately or in combination creates a blank permission table.
server.createProtectionEntries(peList);
server.updateProtectionEntries(peList);
根据文档,最终的方法应该创建/替换/更新权限表,但是,这不会发生,而是 Perforce 服务器中的权限表被删除/空白。
我可能会遗漏一些东西。有人可以就如何解决这个问题提出一些建议吗?
PS我试过只使用updateProtectionEntries(peList)
方法或server.createProtectionEntries(peList)
方法,两者一起使用,但Perforce服务器中的权限表仍然是空白的。