2 * Copyright (c) 2001-2002 International Business Machines Corp.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
9 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
10 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
12 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
13 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
14 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
16 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
17 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
18 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 #include "org_openafs_jafs_Group.h"
25 #include <afs_vosAdmin.h>
28 #include <afs_ptsAdmin.h>
29 #include <afs_AdminPtsErrors.h>
30 #include <afs_AdminClientErrors.h>
31 #include <afs_AdminCommonErrors.h>
34 ///// definitions in Internal.c ///////////////
36 extern jclass userCls
;
37 //extern jfieldID user_cellHandleField;
38 extern jfieldID user_nameField
;
39 extern jfieldID user_cachedInfoField
;
41 extern jclass groupCls
;
42 extern jfieldID group_nameField
;
43 extern jfieldID group_nameUidField
;
44 extern jfieldID group_ownerUidField
;
45 extern jfieldID group_creatorUidField
;
46 extern jfieldID group_listStatusField
;
47 extern jfieldID group_listGroupsOwnedField
;
48 extern jfieldID group_listMembershipField
;
49 extern jfieldID group_listAddField
;
50 extern jfieldID group_listDeleteField
;
51 extern jfieldID group_membershipCountField
;
52 extern jfieldID group_ownerField
;
53 extern jfieldID group_creatorField
;
55 //////////////////////////////////////////////////////
59 * Creates the PTS entry for a new group. Pass in 0 for the uid if PTS is to
60 * automatically assign the group id.
62 * env the Java environment
63 * cls the current Java class
64 * cellHandle the handle of the cell to which the group belongs
65 * jgroupName the name of the group to create
66 * jownerName the owner of this group
67 * gid the group id to assign to the group (0 to have one
68 * automatically assigned)
70 JNIEXPORT
void JNICALL
71 Java_org_openafs_jafs_Group_create
72 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jstring jgroupName
,
73 jstring jownerName
, jint gid
)
76 // convert java strings
77 const char *groupName
;
78 const char *ownerName
;
80 if( jgroupName
!= NULL
) {
81 groupName
= (*env
)->GetStringUTFChars(env
, jgroupName
, 0);
83 throwAFSException( env
, JAFSADMNOMEM
);
90 if( jownerName
!= NULL
) {
91 ownerName
= (*env
)->GetStringUTFChars(env
, jownerName
, 0);
93 throwAFSException( env
, JAFSADMNOMEM
);
100 // make sure the name is within the allowed bounds
101 if( groupName
!= NULL
&& strlen( groupName
) > PTS_MAX_NAME_LEN
) {
102 // release converted java strings
103 if( groupName
!= NULL
) {
104 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
106 if( ownerName
!= NULL
) {
107 (*env
)->ReleaseStringUTFChars(env
, jownerName
, ownerName
);
109 throwAFSException( env
, ADMPTSGROUPNAMETOOLONG
);
113 if( !pts_GroupCreate( (void *) cellHandle
, groupName
, ownerName
,
114 (int *) &gid
, &ast
) ) {
115 // release converted java strings
116 if( groupName
!= NULL
) {
117 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
119 if( ownerName
!= NULL
) {
120 (*env
)->ReleaseStringUTFChars(env
, jownerName
, ownerName
);
122 throwAFSException( env
, ast
);
126 // release converted java strings
127 if( groupName
!= NULL
) {
128 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
130 if( ownerName
!= NULL
) {
131 (*env
)->ReleaseStringUTFChars(env
, jownerName
, ownerName
);
137 * Deletes the PTS entry for a group. Deletes this group from the
138 * membership list of the users that belonged to it, but does not delete
139 * the groups owned by this group.
141 * env the Java environment
142 * cls the current Java class
143 * cellHandle the handle of the cell to which the group belongs
144 * jgroupName the name of the group to delete
146 JNIEXPORT
void JNICALL
147 Java_org_openafs_jafs_Group_delete
148 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jstring jgroupName
)
151 // convert java strings
152 const char *groupName
;
154 if( jgroupName
!= NULL
) {
155 groupName
= (*env
)->GetStringUTFChars(env
, jgroupName
, 0);
157 throwAFSException( env
, JAFSADMNOMEM
);
164 if( !pts_GroupDelete( (void *) cellHandle
, groupName
, &ast
) ) {
165 if( groupName
!= NULL
) {
166 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
168 throwAFSException( env
, ast
);
172 // release converted java strings
173 if( groupName
!= NULL
) {
174 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
180 * Retrieve the information for the specified group and populate the
183 * env the Java environment
184 * cellHandle the handle of the cell to which the user belongs
185 * name the name of the group for which to get the info
186 * group the Group object to populate with the info
188 void getGroupInfoChar
189 ( JNIEnv
*env
, void *cellHandle
, const char *name
, jobject group
)
194 pts_GroupEntry_t entry
;
197 // get the field ids if you haven't already
198 if( groupCls
== 0 ) {
199 internal_getGroupClass( env
, group
);
201 if ( !pts_GroupGet( cellHandle
, name
, &entry
, &ast
) ) {
202 throwAFSException( env
, ast
);
207 (*env
)->SetIntField(env
, group
, group_nameUidField
, entry
.nameUid
);
208 (*env
)->SetIntField(env
, group
, group_ownerUidField
, entry
.ownerUid
);
209 (*env
)->SetIntField(env
, group
, group_creatorUidField
, entry
.creatorUid
);
210 (*env
)->SetIntField(env
, group
, group_membershipCountField
,
211 entry
.membershipCount
);
213 if( entry
.listStatus
== PTS_GROUP_OWNER_ACCESS
) {
214 (*env
)->SetIntField(env
, group
, group_listStatusField
,
215 org_openafs_jafs_Group_GROUP_OWNER_ACCESS
);
216 } else if( entry
.listStatus
== PTS_GROUP_ACCESS
) {
217 (*env
)->SetIntField(env
, group
, group_listStatusField
,
218 org_openafs_jafs_Group_GROUP_GROUP_ACCESS
);
220 (*env
)->SetIntField(env
, group
, group_listStatusField
,
221 org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS
);
224 if( entry
.listGroupsOwned
== PTS_GROUP_OWNER_ACCESS
) {
225 (*env
)->SetIntField(env
, group
, group_listGroupsOwnedField
,
226 org_openafs_jafs_Group_GROUP_OWNER_ACCESS
);
227 } else if( entry
.listGroupsOwned
== PTS_GROUP_ACCESS
) {
228 (*env
)->SetIntField(env
, group
, group_listGroupsOwnedField
,
229 org_openafs_jafs_Group_GROUP_GROUP_ACCESS
);
231 (*env
)->SetIntField(env
, group
, group_listGroupsOwnedField
,
232 org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS
);
235 if( entry
.listMembership
== PTS_GROUP_OWNER_ACCESS
) {
236 (*env
)->SetIntField(env
, group
, group_listMembershipField
,
237 org_openafs_jafs_Group_GROUP_OWNER_ACCESS
);
238 } else if( entry
.listMembership
== PTS_GROUP_ACCESS
) {
239 (*env
)->SetIntField(env
, group
, group_listMembershipField
,
240 org_openafs_jafs_Group_GROUP_GROUP_ACCESS
);
242 (*env
)->SetIntField(env
, group
, group_listMembershipField
,
243 org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS
);
246 if( entry
.listAdd
== PTS_GROUP_OWNER_ACCESS
) {
247 (*env
)->SetIntField(env
, group
, group_listAddField
,
248 org_openafs_jafs_Group_GROUP_OWNER_ACCESS
);
249 } else if( entry
.listAdd
== PTS_GROUP_ACCESS
) {
250 (*env
)->SetIntField(env
, group
, group_listAddField
,
251 org_openafs_jafs_Group_GROUP_GROUP_ACCESS
);
253 (*env
)->SetIntField(env
, group
, group_listAddField
,
254 org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS
);
257 if( entry
.listDelete
== PTS_GROUP_OWNER_ACCESS
) {
258 (*env
)->SetIntField(env
, group
, group_listDeleteField
,
259 org_openafs_jafs_Group_GROUP_OWNER_ACCESS
);
260 } else if( entry
.listDelete
== PTS_GROUP_ACCESS
) {
261 (*env
)->SetIntField(env
, group
, group_listDeleteField
,
262 org_openafs_jafs_Group_GROUP_GROUP_ACCESS
);
264 (*env
)->SetIntField(env
, group
, group_listDeleteField
,
265 org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS
);
268 jowner
= (*env
)->NewStringUTF(env
, entry
.owner
);
269 jcreator
= (*env
)->NewStringUTF(env
, entry
.creator
);
271 (*env
)->SetObjectField(env
, group
, group_ownerField
, jowner
);
272 (*env
)->SetObjectField(env
, group
, group_creatorField
, jcreator
);
277 * Fills in the information fields of the provided Group.
278 * Fills in values based on the current PTS information of the group.
280 * env the Java environment
281 * cls the current Java class
282 * cellHandle the handle of the cell to which the group belongs
283 * name the name of the group for which to get the information
284 * group the Group object in which to fill in the
287 JNIEXPORT
void JNICALL
288 Java_org_openafs_jafs_Group_getGroupInfo
289 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jstring jname
, jobject group
)
294 if( jname
!= NULL
) {
295 name
= (*env
)->GetStringUTFChars(env
, jname
, 0);
297 throwAFSException( env
, JAFSADMNOMEM
);
303 getGroupInfoChar( env
, (void *)cellHandle
, name
, group
);
305 // get class fields if need be
306 if( groupCls
== 0 ) {
307 internal_getGroupClass( env
, group
);
310 // set name in case blank object
311 (*env
)->SetObjectField(env
, group
, group_nameField
, jname
);
314 (*env
)->ReleaseStringUTFChars(env
, jname
, name
);
320 * Sets the information values of this AFS group to be the parameter values.
322 * env the Java environment
323 * cls the current Java class
324 * cellHandle the handle of the cell to which the user belongs
325 * name the name of the user for which to set the information
326 * theGroup the group object containing the desired information
328 JNIEXPORT
void JNICALL
329 Java_org_openafs_jafs_Group_setGroupInfo
330 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jstring jname
, jobject group
)
333 pts_GroupUpdateEntry_t ptsEntry
;
337 jint jlistGroupsOwned
;
338 jint jlistMembership
;
342 // get the field ids if you haven't already
343 if( groupCls
== 0 ) {
344 internal_getGroupClass( env
, group
);
347 jlistStatus
= (*env
)->GetIntField(env
, group
, group_listStatusField
);
348 jlistGroupsOwned
= (*env
)->GetIntField(env
, group
,
349 group_listGroupsOwnedField
);
350 jlistMembership
= (*env
)->GetIntField(env
, group
, group_listMembershipField
);
351 jlistAdd
= (*env
)->GetIntField(env
, group
, group_listAddField
);
352 jlistDelete
= (*env
)->GetIntField(env
, group
, group_listDeleteField
);
354 if( jname
!= NULL
) {
355 name
= (*env
)->GetStringUTFChars(env
, jname
, 0);
357 throwAFSException( env
, JAFSADMNOMEM
);
364 if( jlistStatus
== org_openafs_jafs_Group_GROUP_OWNER_ACCESS
) {
365 ptsEntry
.listStatus
= PTS_GROUP_OWNER_ACCESS
;
366 } else if( jlistStatus
== org_openafs_jafs_Group_GROUP_GROUP_ACCESS
) {
367 ptsEntry
.listStatus
= PTS_GROUP_ACCESS
;
369 ptsEntry
.listStatus
= PTS_GROUP_ANYUSER_ACCESS
;
371 if( jlistGroupsOwned
== org_openafs_jafs_Group_GROUP_OWNER_ACCESS
) {
372 ptsEntry
.listGroupsOwned
= PTS_GROUP_OWNER_ACCESS
;
373 } else if( jlistGroupsOwned
==
374 org_openafs_jafs_Group_GROUP_GROUP_ACCESS
) {
375 ptsEntry
.listGroupsOwned
= PTS_GROUP_ACCESS
;
377 ptsEntry
.listGroupsOwned
= PTS_GROUP_ANYUSER_ACCESS
;
379 if( jlistMembership
== org_openafs_jafs_Group_GROUP_OWNER_ACCESS
) {
380 ptsEntry
.listMembership
= PTS_GROUP_OWNER_ACCESS
;
381 } else if( jlistMembership
==
382 org_openafs_jafs_Group_GROUP_GROUP_ACCESS
) {
383 ptsEntry
.listMembership
= PTS_GROUP_ACCESS
;
385 ptsEntry
.listMembership
= PTS_GROUP_ANYUSER_ACCESS
;
387 if( jlistAdd
== org_openafs_jafs_Group_GROUP_OWNER_ACCESS
) {
388 ptsEntry
.listAdd
= PTS_GROUP_OWNER_ACCESS
;
389 } else if( jlistAdd
== org_openafs_jafs_Group_GROUP_GROUP_ACCESS
) {
390 ptsEntry
.listAdd
= PTS_GROUP_ACCESS
;
392 ptsEntry
.listAdd
= PTS_GROUP_ANYUSER_ACCESS
;
394 if( jlistDelete
== org_openafs_jafs_Group_GROUP_OWNER_ACCESS
) {
395 ptsEntry
.listDelete
= PTS_GROUP_OWNER_ACCESS
;
396 } else if( jlistDelete
== org_openafs_jafs_Group_GROUP_GROUP_ACCESS
) {
397 ptsEntry
.listDelete
= PTS_GROUP_ACCESS
;
399 ptsEntry
.listDelete
= PTS_GROUP_ANYUSER_ACCESS
;
401 if( !pts_GroupModify( (void *) cellHandle
, name
, &ptsEntry
, &ast
) ) {
403 (*env
)->ReleaseStringUTFChars(env
, jname
, name
);
405 throwAFSException( env
, ast
);
410 (*env
)->ReleaseStringUTFChars(env
, jname
, name
);
416 * Begin the process of getting the users that belong to the group. Returns
417 * an iteration ID to be used by subsequent calls to
418 * getGroupMembersNext and getGroupMembersDone.
420 * env the Java environment
421 * cls the current Java class
422 * cellHandle the handle of the cell to which the group belongs
423 * jname the name of the group for which to get the members
424 * returns an iteration ID
426 JNIEXPORT jlong JNICALL
427 Java_org_openafs_jafs_Group_getGroupMembersBegin
428 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jstring jname
)
434 if( jname
!= NULL
) {
435 name
= (*env
)->GetStringUTFChars(env
, jname
, 0);
437 throwAFSException( env
, JAFSADMNOMEM
);
444 if( !pts_GroupMemberListBegin( (void *) cellHandle
, name
, &iterationId
,
447 (*env
)->ReleaseStringUTFChars(env
, jname
, name
);
449 throwAFSException( env
, ast
);
454 (*env
)->ReleaseStringUTFChars(env
, jname
, name
);
457 return (jlong
) iterationId
;
462 * Returns the next members that belongs to the group. Returns
463 * null if there are no more members.
465 * env the Java environment
466 * cls the current Java class
467 * iterationId the iteration ID of this iteration
468 * returns the name of the next member
470 JNIEXPORT jstring JNICALL
471 Java_org_openafs_jafs_Group_getGroupMembersNextString
472 (JNIEnv
*env
, jclass cls
, jlong iterationId
)
475 char *userName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
479 throwAFSException( env
, JAFSADMNOMEM
);
483 if( !pts_GroupMemberListNext( (void *) iterationId
, userName
, &ast
) ) {
485 if( ast
== ADMITERATORDONE
) {
488 throwAFSException( env
, ast
);
493 juser
= (*env
)->NewStringUTF(env
, userName
);
499 * Fills the next user object belonging to that group. Returns 0 if there
500 * are no more users, != 0 otherwise.
502 * env the Java environment
503 * cls the current Java class
504 * cellHandle the handle of the cell to which the users belong
505 * iterationId the iteration ID of this iteration
506 * juserObject a User object to be populated with the values of the
508 * returns 0 if there are no more users, != 0 otherwise
510 JNIEXPORT jint JNICALL
511 Java_org_openafs_jafs_Group_getGroupMembersNext
512 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jlong iterationId
,
519 userName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
522 throwAFSException( env
, JAFSADMNOMEM
);
526 if( !pts_GroupMemberListNext( (void *) iterationId
, userName
, &ast
) ) {
528 if( ast
== ADMITERATORDONE
) {
531 throwAFSException( env
, ast
);
536 juser
= (*env
)->NewStringUTF(env
, userName
);
539 internal_getUserClass( env
, juserObject
);
542 (*env
)->SetObjectField(env
, juserObject
, user_nameField
, juser
);
544 getUserInfoChar( env
, (void *) cellHandle
, userName
, juserObject
);
545 (*env
)->SetBooleanField( env
, juserObject
, user_cachedInfoField
, TRUE
);
553 * Signals that the iteration is complete and will not be accessed anymore.
555 * env the Java environment
556 * cls the current Java class
557 * iterationId the iteration ID of this iteration
559 JNIEXPORT
void JNICALL
560 Java_org_openafs_jafs_Group_getGroupMembersDone
561 (JNIEnv
*env
, jclass cls
, jlong iterationId
)
565 if( !pts_GroupMemberListDone( (void *) iterationId
, &ast
) ) {
566 throwAFSException( env
, ast
);
573 * Adds a user to the specified group.
575 * env the Java environment
576 * cls the current Java class
577 * cellHandle the handle of the cell to which the group belongs
578 * jgroupName the name of the group to which to add a member
579 * juserName the name of the user to add
581 JNIEXPORT
void JNICALL
582 Java_org_openafs_jafs_Group_addMember
583 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jstring jgroupName
,
587 const char *groupName
;
588 const char *userName
;
590 if( jgroupName
!= NULL
) {
591 groupName
= (*env
)->GetStringUTFChars(env
, jgroupName
, 0);
593 throwAFSException( env
, JAFSADMNOMEM
);
600 if( juserName
!= NULL
) {
601 userName
= (*env
)->GetStringUTFChars(env
, juserName
, 0);
603 if( groupName
!= NULL
) {
604 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
606 throwAFSException( env
, JAFSADMNOMEM
);
613 if( !pts_GroupMemberAdd( (void *) cellHandle
, userName
, groupName
, &ast
) ) {
614 if( groupName
!= NULL
) {
615 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
617 if( userName
!= NULL
) {
618 (*env
)->ReleaseStringUTFChars(env
, juserName
, userName
);
620 throwAFSException( env
, ast
);
624 if( groupName
!= NULL
) {
625 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
627 if( userName
!= NULL
) {
628 (*env
)->ReleaseStringUTFChars(env
, juserName
, userName
);
633 * Removes a user from the specified group.
635 * env the Java environment
636 * cls the current Java class
637 * cellHandle the handle of the cell to which the group belongs
638 * jgroupName the name of the group from which to remove a
640 * juserName the name of the user to remove
642 JNIEXPORT
void JNICALL
643 Java_org_openafs_jafs_Group_removeMember
644 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jstring jgroupName
,
648 const char *groupName
;
649 const char *userName
;
651 if( jgroupName
!= NULL
) {
652 groupName
= (*env
)->GetStringUTFChars(env
, jgroupName
, 0);
654 throwAFSException( env
, JAFSADMNOMEM
);
661 if( juserName
!= NULL
) {
662 userName
= (*env
)->GetStringUTFChars(env
, juserName
, 0);
664 if( groupName
!= NULL
) {
665 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
667 throwAFSException( env
, JAFSADMNOMEM
);
674 if( !pts_GroupMemberRemove( (void *)cellHandle
, userName
,
675 groupName
, &ast
) ) {
676 if( groupName
!= NULL
) {
677 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
679 if( userName
!= NULL
) {
680 (*env
)->ReleaseStringUTFChars(env
, juserName
, userName
);
682 throwAFSException( env
, ast
);
686 if( groupName
!= NULL
) {
687 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
689 if( userName
!= NULL
) {
690 (*env
)->ReleaseStringUTFChars(env
, juserName
, userName
);
695 * Change the owner of the specified group.
697 * env the Java environment
698 * cls the current Java class
699 * cellHandle the handle of the cell to which the group belongs
700 * jgroupName the name of the group of which to change the
702 * jownerName the name of the new owner
704 JNIEXPORT
void JNICALL
705 Java_org_openafs_jafs_Group_changeOwner
706 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jstring jgroupName
,
710 const char *groupName
;
711 const char *ownerName
;
713 if( jgroupName
!= NULL
) {
714 groupName
= (*env
)->GetStringUTFChars(env
, jgroupName
, 0);
716 throwAFSException( env
, JAFSADMNOMEM
);
723 if( jownerName
!= NULL
) {
724 ownerName
= (*env
)->GetStringUTFChars(env
, jownerName
, 0);
726 if( groupName
!= NULL
) {
727 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
729 throwAFSException( env
, JAFSADMNOMEM
);
736 if( !pts_GroupOwnerChange( (void *)cellHandle
, groupName
,
737 ownerName
, &ast
) ) {
738 if( groupName
!= NULL
) {
739 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
741 if( ownerName
!= NULL
) {
742 (*env
)->ReleaseStringUTFChars(env
, jownerName
, ownerName
);
744 throwAFSException( env
, ast
);
748 if( groupName
!= NULL
) {
749 (*env
)->ReleaseStringUTFChars(env
, jgroupName
, groupName
);
751 if( ownerName
!= NULL
) {
752 (*env
)->ReleaseStringUTFChars(env
, jownerName
, ownerName
);
758 * Change the name of the specified group.
760 * env the Java environment
761 * cls the current Java class
762 * cellHandle the handle of the cell to which the group belongs
763 * joldGroupName the old name of the group
764 * jnewGroupName the new name for the group
766 JNIEXPORT
void JNICALL
767 Java_org_openafs_jafs_Group_rename
768 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jstring jgroupOldName
,
769 jstring jgroupNewName
)
772 const char *groupOldName
;
773 const char *groupNewName
;
775 if( jgroupOldName
!= NULL
) {
776 groupOldName
= (*env
)->GetStringUTFChars(env
, jgroupOldName
, 0);
777 if( !groupOldName
) {
778 throwAFSException( env
, JAFSADMNOMEM
);
785 if( jgroupNewName
!= NULL
) {
786 groupNewName
= (*env
)->GetStringUTFChars(env
, jgroupNewName
, 0);
787 if( !groupNewName
) {
788 if( groupOldName
!= NULL
) {
789 (*env
)->ReleaseStringUTFChars(env
, jgroupOldName
, groupOldName
);
791 throwAFSException( env
, JAFSADMNOMEM
);
798 if( !pts_GroupRename( (void *)cellHandle
, groupOldName
,
799 groupNewName
, &ast
) ) {
800 if( groupOldName
!= NULL
) {
801 (*env
)->ReleaseStringUTFChars(env
, jgroupOldName
, groupOldName
);
803 if( groupNewName
!= NULL
) {
804 (*env
)->ReleaseStringUTFChars(env
, jgroupNewName
, groupNewName
);
806 throwAFSException( env
, ast
);
810 if( groupOldName
!= NULL
) {
811 (*env
)->ReleaseStringUTFChars(env
, jgroupOldName
, groupOldName
);
813 if( groupNewName
!= NULL
) {
814 (*env
)->ReleaseStringUTFChars(env
, jgroupNewName
, groupNewName
);
818 // reclaim global memory used by this portion
819 JNIEXPORT
void JNICALL
820 Java_org_openafs_jafs_Group_reclaimGroupMemory (JNIEnv
*env
, jclass cls
)
823 (*env
)->DeleteGlobalRef(env
, groupCls
);