cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

How to Delete ACL

adev
1-Newbie

How to Delete ACL

Hello,

Is there is any way from loadFromFile or customization where I can delete the ACL 

1 ACCEPTED SOLUTION

Accepted Solutions
BineshKumar1
12-Amethyst
(To:adev)

I don't think there is loadFromFile directive to delete ACL. When I had to cleanup, a lot of ACLS I used the below method. I am not sure whether this is a PTC supported method, but it did the job.

  public static void deleteACLRule(String type,String stateN,String groupName) {

  // String type = "wt.doc.WTDocument";

  WTGroup wtgroup = null;

  State state = null;

  try {

  @SuppressWarnings("deprecation")

  // String groupName ="teamMembers";

  String container_path = "/wt.inf.container.OrgContainer=Demo Organization/wt.pdmlink.PDMLinkProduct=Drive System";

  WTContainerRef containerRef = WTContainerHelper.service.getByPath(container_path);

  wt.query.QuerySpec qsGrp = new  wt.query.QuerySpec( wt.org.WTGroup.class);

  qsGrp.appendWhere(new SearchCondition(wt.org.WTGroup.class, wt.org.WTGroup.NAME , SearchCondition.EQUAL,groupName), null);

  QueryResult qGpResult = PersistenceHelper.manager.find((StatementSpec)qsGrp);

  System.out.println("Groups found : " + qGpResult.size());

  while (qGpResult.hasMoreElements()) {

  wtgroup = (WTGroup)qGpResult.nextElement();

  if (wtgroup.getContainerPath().toString().equals(container_path))

  {

  System.out.println(wtgroup.getName() + "    " +wtgroup.getContainerPath());

  System.out.println("Begin Delete");

  System.out.println(containerRef.getContainer().getDefaultDomainReference().getName() + "...." + type + " ..." + stateN + "..." + wt.org.WTPrincipalReference.newWTPrincipalReference(wtgroup).getDisplayName());

  if(!stateN.equals("ALL"))

  {

  state = State.toState(stateN);

  AccessControlHelper.manager.deleteAccessControlRule(containerRef.getContainer().getDefaultDomainReference(), type, state, wt.org.WTPrincipalReference.newWTPrincipalReference(wtgroup), false);

  }

  else

  {

  AccessControlHelper.manager.deleteAccessControlRule(containerRef.getContainer().getDefaultDomainReference(), type, null, wt.org.WTPrincipalReference.newWTPrincipalReference(wtgroup), false);

  }

  System.out.println("Delete Complete");

  }

  if(qGpResult.size() == 0) {

  System.out.println("No Group Found with Name  " + groupName);

  }

  }

  }

  catch (WTException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  }

  }

Regards

Binesh Kumar

View solution in original post

1 REPLY 1
BineshKumar1
12-Amethyst
(To:adev)

I don't think there is loadFromFile directive to delete ACL. When I had to cleanup, a lot of ACLS I used the below method. I am not sure whether this is a PTC supported method, but it did the job.

  public static void deleteACLRule(String type,String stateN,String groupName) {

  // String type = "wt.doc.WTDocument";

  WTGroup wtgroup = null;

  State state = null;

  try {

  @SuppressWarnings("deprecation")

  // String groupName ="teamMembers";

  String container_path = "/wt.inf.container.OrgContainer=Demo Organization/wt.pdmlink.PDMLinkProduct=Drive System";

  WTContainerRef containerRef = WTContainerHelper.service.getByPath(container_path);

  wt.query.QuerySpec qsGrp = new  wt.query.QuerySpec( wt.org.WTGroup.class);

  qsGrp.appendWhere(new SearchCondition(wt.org.WTGroup.class, wt.org.WTGroup.NAME , SearchCondition.EQUAL,groupName), null);

  QueryResult qGpResult = PersistenceHelper.manager.find((StatementSpec)qsGrp);

  System.out.println("Groups found : " + qGpResult.size());

  while (qGpResult.hasMoreElements()) {

  wtgroup = (WTGroup)qGpResult.nextElement();

  if (wtgroup.getContainerPath().toString().equals(container_path))

  {

  System.out.println(wtgroup.getName() + "    " +wtgroup.getContainerPath());

  System.out.println("Begin Delete");

  System.out.println(containerRef.getContainer().getDefaultDomainReference().getName() + "...." + type + " ..." + stateN + "..." + wt.org.WTPrincipalReference.newWTPrincipalReference(wtgroup).getDisplayName());

  if(!stateN.equals("ALL"))

  {

  state = State.toState(stateN);

  AccessControlHelper.manager.deleteAccessControlRule(containerRef.getContainer().getDefaultDomainReference(), type, state, wt.org.WTPrincipalReference.newWTPrincipalReference(wtgroup), false);

  }

  else

  {

  AccessControlHelper.manager.deleteAccessControlRule(containerRef.getContainer().getDefaultDomainReference(), type, null, wt.org.WTPrincipalReference.newWTPrincipalReference(wtgroup), false);

  }

  System.out.println("Delete Complete");

  }

  if(qGpResult.size() == 0) {

  System.out.println("No Group Found with Name  " + groupName);

  }

  }

  }

  catch (WTException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  }

  }

Regards

Binesh Kumar

Top Tags