1 16 package org.outerj.daisy.books.store; 17 18 import org.outerx.daisy.x10Bookstoremeta.BookAclDocument; 19 import org.outerx.daisy.x10Bookstoremeta.BookAclSubject; 20 import org.outerx.daisy.x10Bookstoremeta.BookAclAction; 21 22 26 public final class BookAclEntry { 27 private final BookAclSubjectType subjectType; 28 private final long subjectValue; 29 private final BookAclActionType readPermission; 30 private final BookAclActionType managePermission; 31 32 public BookAclEntry(BookAclSubjectType subjectType, long subjectValue, 33 BookAclActionType readPermission, BookAclActionType managePermission) { 34 if (subjectType == null) 35 throw new IllegalArgumentException ("subjectType cannot be null"); 36 if (readPermission == null) 37 throw new IllegalArgumentException ("readPermission cannot be null"); 38 if (managePermission == null) 39 throw new IllegalArgumentException ("managePermission cannot be null"); 40 if (subjectType == BookAclSubjectType.EVERYONE && subjectValue != -1) 41 throw new IllegalArgumentException ("subjectValue must be -1 if subjectType is 'everyone'"); 42 43 this.subjectType = subjectType; 44 this.subjectValue = subjectValue; 45 this.readPermission = readPermission; 46 this.managePermission = managePermission; 47 } 48 49 public BookAclSubjectType getSubjectType() { 50 return subjectType; 51 } 52 53 public long getSubjectValue() { 54 return subjectValue; 55 } 56 57 public BookAclActionType getReadPermission() { 58 return readPermission; 59 } 60 61 public BookAclActionType getManagePermission() { 62 return managePermission; 63 } 64 65 public BookAclDocument.BookAcl.BookAclEntry getXml() { 66 BookAclDocument.BookAcl.BookAclEntry entryXml = BookAclDocument.BookAcl.BookAclEntry.Factory.newInstance(); 67 entryXml.setSubjectType(BookAclSubject.Enum.forString(subjectType.toString())); 68 entryXml.setSubjectValue(subjectValue); 69 entryXml.setPermRead(BookAclAction.Enum.forString(readPermission.toString())); 70 entryXml.setPermManage(BookAclAction.Enum.forString(managePermission.toString())); 71 return entryXml; 72 } 73 } 74 | Popular Tags |