Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Feb 8, 2021
1 parent badec4a commit 5da9108
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 132 deletions.
31 changes: 31 additions & 0 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
<?php
/**
* COmanage Registry Grouper Lite Widget Groups Controller
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link http://www.internet2.edu/comanage COmanage Project
* @package registry-plugin
* @since COmanage Registry v3.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

App::uses('Validator', 'Vendor/cakephp/Validation');
App::uses('CoGrouperLite', 'GrouperLite.Model/');
Expand All @@ -11,6 +36,12 @@ class GrouperGroupsController extends GrouperLiteAppController

public $name = 'GrouperGroups';

/**
* Overrides parent beforeFilter to verify that Session contains the correct API settings.
*
* @return CakeResponse|void|null
*
*/
public function beforeFilter() {
parent::beforeFilter();

Expand Down
32 changes: 11 additions & 21 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ public function getGrouperUser(array $queryData) {
}

} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getGrouperUser: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getGrouperUser: An error occurred');
throw $e;
}

Expand Down Expand Up @@ -139,8 +138,7 @@ public function getGrouperMemberOfGroups(array $queryData) {
return $results['WsGetGroupsLiteResult']['wsGroups'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getGrouperMemberOfGroups: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getGrouperMemberOfGroups: An error occurred');
throw $e;
}

Expand Down Expand Up @@ -200,8 +198,7 @@ public function grouperGroupLeaveOrJoin(array $queryData) {
}
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - grouperGroupLeaveOrJoin: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - grouperGroupLeaveOrJoin: An error occurred');
throw $e;
}

Expand All @@ -228,8 +225,7 @@ public function getOptinGroups(array $queryData) {
return $results['WsGetMembershipsResults']['wsGroups'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getOptinGroups: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getOptinGroups: An error occurred');
throw $e;
}
return array();
Expand All @@ -253,8 +249,7 @@ public function getOwnerGroups(array $queryData) {
return $results['WsGetMembershipsResults']['wsGroups'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getOwnerGroups: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getOwnerGroups: An error occurred');
throw $e;
}
return array();
Expand All @@ -277,8 +272,7 @@ public function getOwnerStems(array $queryData) {
return $results['WsGetMembershipsResults']['wsStems'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getOwnerStems: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getOwnerStems: An error occurred');
throw $e;
}
return array();
Expand Down Expand Up @@ -329,14 +323,13 @@ private function useMembershipUrl(array $queryData) {
try {
return $this->http->sendRequest('POST', $connectionUrl, json_encode($groupsToShow));
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - useMembershipUrl: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - useMembershipUrl: An error occurred');
throw $e;
}
}

/**
* Returns a Distinct Grouper Group with its associated attributes and values
* Returns a Distinct Grouper Group with its associated values
*
* @param array $queryData Array of conditions for querying
* @return array Array of attributes for a Group
Expand All @@ -356,8 +349,7 @@ public function getGrouperGroupDescription(array $queryData) {
return $results['WsGetMembershipsResults']['wsGroups'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getGrouperGroupDescription: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getGrouperGroupDescription: An error occurred');
throw $e;
}
return array();
Expand Down Expand Up @@ -414,8 +406,7 @@ public function createUpdateGroup(array $queryData) {
}
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - createUpdateGroup: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - createUpdateGroup: An error occurred');
throw $e;
}
return false;
Expand Down Expand Up @@ -454,8 +445,7 @@ public function getGroupAttributes(array $queryData) {
return $results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns'];
}
} catch (Exception $e) {
CakeLog::write('error',
'GrouperLite API - getGroupAttributes: An issue surfaced of ' . var_export($e->getMessage(), true));
CakeLog::write('error', 'GrouperLite API - getGroupAttributes: An error occurred');
throw $e;
}
return array();
Expand Down
12 changes: 9 additions & 3 deletions Model/GrouperAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ private function initApi() {
* @throws GrouperLiteException
*/
public function getGroupAttributes(string $groupName) {
$args = array();
$args['conditions']['groupName'] = $groupName;
try {
$args = array();
$args['conditions']['groupName'] = $groupName;

return $this->grouperAPI->getGroupAttributes($args);
return $this->grouperAPI->getGroupAttributes($args);

} catch (Exception $e) {
CakeLog::write('error', 'GrouperLite Attribute Model - getGroupAttributes: An error occurred');
throw $e;
}
}

}
Loading

0 comments on commit 5da9108

Please sign in to comment.