Coverage Summary for Class: RecursiveGrantDomainCreatePermissionSysPersister (com.acciente.oacc.sql.internal.persister)

Class Class, % Method, % Line, %
RecursiveGrantDomainCreatePermissionSysPersister 100% (1/ 1) 100% (2/ 2) 85.7% (12/ 14)


1 /* 2  * Copyright 2009-2018, Acciente LLC 3  * 4  * Acciente LLC licenses this file to you under the 5  * Apache License, Version 2.0 (the "License"); you 6  * may not use this file except in compliance with the 7  * License. You may obtain a copy of the License at 8  * 9  * http://www.apache.org/licenses/LICENSE-2.0 10  * 11  * Unless required by applicable law or agreed to in 12  * writing, software distributed under the License is 13  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 14  * OR CONDITIONS OF ANY KIND, either express or implied. 15  * See the License for the specific language governing 16  * permissions and limitations under the License. 17  */ 18 package com.acciente.oacc.sql.internal.persister; 19  20 import com.acciente.oacc.DomainCreatePermission; 21 import com.acciente.oacc.Resource; 22 import com.acciente.oacc.sql.SQLProfile; 23  24 import java.io.Serializable; 25 import java.sql.SQLException; 26 import java.util.HashSet; 27 import java.util.Set; 28  29 public class RecursiveGrantDomainCreatePermissionSysPersister extends CommonGrantDomainCreatePermissionSysPersister implements Serializable { 30  private static final long serialVersionUID = 1L; 31  32  public RecursiveGrantDomainCreatePermissionSysPersister(SQLProfile sqlProfile, 33  SQLStrings sqlStrings) { 34  super(sqlProfile, sqlStrings); 35  } 36  37  @Override 38  public Set<DomainCreatePermission> getDomainCreateSysPermissionsIncludeInherited(SQLConnection connection, 39  Resource accessorResource) { 40  SQLStatement statement = null; 41  42  try { 43  statement = connection.prepareStatement(sqlStrings.SQL_findInGrantDomainCreatePermissionSys_SysPermissionID_IsWithGrant_BY_AccessorID); 44  statement.setResourceId(1, accessorResource); 45  SQLResult resultSet = statement.executeQuery(); 46  47  // collect the create permissions that this resource has to domains 48  Set<DomainCreatePermission> domainCreatePermissions = new HashSet<>(); 49  while (resultSet.next()) { 50  domainCreatePermissions.add(getDomainCreateSysPermission(resultSet)); 51  } 52  resultSet.close(); 53  54  return domainCreatePermissions; 55  } 56  catch (SQLException e) { 57  throw new RuntimeException(e); 58  } 59  finally { 60  closeStatement(statement); 61  } 62  } 63 }