File Source: WeblogPermission.java

         /* 
    P/P   *  Method: void pcSetDetachedState(Object)
          * 
          *  Postconditions:
          *    Param_0.pcDetachedState == Param_1
          *    init'ed(Param_0.pcDetachedState)
          */
     1  /*
     2   * Copyright 2005 Sun Microsystems, Inc.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package org.apache.roller.weblogger.pojos; 
    18  
    19  import org.apache.commons.lang.builder.EqualsBuilder;
    20  import org.apache.commons.lang.builder.HashCodeBuilder;
    21  import org.apache.roller.util.UUIDGenerator;
    22  
    23  /**
    24   * Represents a user's permissions within a website.
    25   *
    26   * @ejb:bean name="WeblogPermission"
    27   * @struts.form include-all="true"
    28   * @hibernate.class lazy="true" table="roller_user_permissions"
    29   * @hibernate.cache usage="read-write"
    30   *
    31   * @author Dave Johnson
    32   */
    33  public class WeblogPermission
    34  {
    35      private String      id = UUIDGenerator.generateUUID();
    36      private Weblog website = null;
    37      private User    user = null;
    38      private boolean     pending = true;
             /* 
    P/P       *  Method: org.apache.roller.weblogger.pojos.WeblogPermission__static_init
              * 
              *  Presumptions:
              *    init'ed(java.lang.Boolean.TYPE)
              *    init'ed(java.lang.Short.TYPE)
              * 
              *  Postconditions:
              *    ADMIN == 3
              *    AUTHOR == 1
              *    new Class[](WeblogPermission__static_init#2) num objects == 1
              *    new String[](WeblogPermission__static_init#1) num objects == 1
              *    new byte[](WeblogPermission__static_init#3) num objects == 1
              *    LIMITED == 0
              *    pcFieldFlags == &new byte[](WeblogPermission__static_init#3)
              *    pcFieldNames == &new String[](WeblogPermission__static_init#1)
              *    pcFieldTypes == &new Class[](WeblogPermission__static_init#2)
              *    pcFieldTypes.length == 5
              *    ...
              */
    39      public static short LIMITED = 0x00; // 0000 
    40      public static short AUTHOR  = 0x01; // 0001
    41      public static short ADMIN   = 0x03; // 0011 
    42      private short       permissionMask = LIMITED;
    43      
    44      /** Creates a new instance of PermissionsData */
    45      public WeblogPermission() 
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.pojos.WeblogPermission()
              * 
              *  Preconditions:
              *    init'ed(LIMITED)
              * 
              *  Postconditions:
              *    init'ed(this.id)
              *    this.pending == 1
              *    this.permissionMask == LIMITED
              *    init'ed(this.permissionMask)
              *    this.user == null
              *    this.website == null
              */
    46      {
    47      }
    48  
    49      /**
    50       * Check for specific permission.
    51       */
    52      public boolean has(short priv)
    53      {
                 /* 
    P/P           *  Method: bool has(short)
                  * 
                  *  Preconditions:
                  *    init'ed(this.pcStateManager)
                  *    init'ed(this.permissionMask)
                  *    (soft) pcInheritedFieldCount <= 232-3
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    54          return (getPermissionMask() & priv) == priv;
    55      }
    56      /**
    57       * @ejb:persistent-field
    58       * @hibernate.id column="id"
    59       *     generator-class="assigned"  
    60       */
    61      public String getId() 
    62      {
                 /* 
    P/P           *  Method: String pcgetId()
                  * 
                  *  Preconditions:
                  *    init'ed(this.id)
                  * 
                  *  Postconditions:
                  *    return_value == this.id
                  *    init'ed(return_value)
                  */
    63          return id;
    64      }
    65      /** @ejb:persistent-field */
    66      public void setId(String id) 
    67      {
    68          // Form bean workaround: empty string is never a valid id
                 /* 
    P/P           *  Method: void pcsetId(String)
                  * 
                  *  Postconditions:
                  *    this.id == One-of{old this.id, Param_1}
                  * 
                  *  Test Vectors:
                  *    Param_1: Addr_Set{null}, Inverse{null}
                  *    java.lang.String:length(...)@69: {1..232-1}, {0}
                  */
    69          if (id != null && id.trim().length() == 0) return; 
    70          this.id = id;
    71      }
    72      /** 
    73       * @hibernate.many-to-one column="website_id" cascade="none" not-null="false"
    74       */
    75      public Weblog getWebsite() 
    76      {
                 /* 
    P/P           *  Method: Weblog pcgetWebsite()
                  * 
                  *  Preconditions:
                  *    init'ed(this.website)
                  * 
                  *  Postconditions:
                  *    return_value == this.website
                  *    init'ed(return_value)
                  */
    77          return website;
    78      }
    79      public void setWebsite(Weblog website) 
    80      {
                 /* 
    P/P           *  Method: void pcsetWebsite(Weblog)
                  * 
                  *  Postconditions:
                  *    this.website == Param_1
                  *    init'ed(this.website)
                  */
    81          this.website = website;
    82      }
    83      /** 
    84       * @hibernate.many-to-one column="user_id" cascade="none" not-null="false"
    85       */
    86      public User getUser() 
    87      {
                 /* 
    P/P           *  Method: User pcgetUser()
                  * 
                  *  Preconditions:
                  *    init'ed(this.user)
                  * 
                  *  Postconditions:
                  *    return_value == this.user
                  *    init'ed(return_value)
                  */
    88          return user;
    89      }
    90      public void setUser(User user) 
    91      {
                 /* 
    P/P           *  Method: void pcsetUser(User)
                  * 
                  *  Postconditions:
                  *    this.user == Param_1
                  *    init'ed(this.user)
                  */
    92          this.user = user;
    93      }
    94      /**
    95       * Bit mask that encodes user's permissions in website.
    96       * @ejb:persistent-field
    97       * @hibernate.property column="permission_mask" non-null="true" unique="false"
    98       */
    99      public short getPermissionMask() 
   100      {
                 /* 
    P/P           *  Method: short pcgetPermissionMask()
                  * 
                  *  Preconditions:
                  *    init'ed(this.permissionMask)
                  * 
                  *  Postconditions:
                  *    return_value == this.permissionMask
                  *    init'ed(return_value)
                  */
   101          return permissionMask;
   102      }
   103      /** @ejb:persistent-field */
   104      public void setPermissionMask(short permissionMask) 
   105      {
                 /* 
    P/P           *  Method: void pcsetPermissionMask(short)
                  * 
                  *  Postconditions:
                  *    this.permissionMask == Param_1
                  *    init'ed(this.permissionMask)
                  */
   106          this.permissionMask = permissionMask;
   107      }
   108      /**
   109       * True if user has been invited to join site but has not yet accepted.
   110       * And false if user is member of website.
   111       * @ejb:persistent-field
   112       * @hibernate.property column="pending" non-null="true" unique="false"
   113       */
   114      public boolean isPending() 
   115      {
                 /* 
    P/P           *  Method: bool pcisPending()
                  * 
                  *  Preconditions:
                  *    init'ed(this.pending)
                  * 
                  *  Postconditions:
                  *    return_value == this.pending
                  *    init'ed(return_value)
                  */
   116          return pending;
   117      }
   118      /** @ejb:persistent-field */
   119      public void setPending(boolean pending) 
   120      {
                 /* 
    P/P           *  Method: void pcsetPending(bool)
                  * 
                  *  Postconditions:
                  *    this.pending == Param_1
                  *    init'ed(this.pending)
                  */
   121          this.pending = pending;
   122      }
   123      
   124      //------------------------------------------------------- Good citizenship
   125  
   126      public String toString() {
                 /* 
    P/P           *  Method: String toString()
                  * 
                  *  Preconditions:
                  *    init'ed(this.id)
                  *    init'ed(this.pending)
                  *    init'ed(this.permissionMask)
                  * 
                  *  Postconditions:
                  *    java.lang.StringBuffer:toString(...)._tainted == this.id._tainted
                  *    init'ed(java.lang.StringBuffer:toString(...)._tainted)
                  *    return_value == &java.lang.StringBuffer:toString(...)
                  */
   127          StringBuffer buf = new StringBuffer();
   128          buf.append("{");
   129          buf.append(this.id);
   130          buf.append(", ").append(this.permissionMask);
   131          buf.append(", ").append(this.pending);
   132          buf.append("}");
   133          return buf.toString();
   134      }
   135      
   136      public boolean equals(Object other) {
                 /* 
    P/P           *  Method: bool equals(Object)
                  * 
                  *  Preconditions:
                  *    (soft) init'ed(other.user)
                  *    (soft) init'ed(other.website)
                  *    (soft) init'ed(this.user)
                  *    (soft) init'ed(this.website)
                  * 
                  *  Presumptions:
                  *    org.apache.commons.lang.builder.EqualsBuilder:append(...)@140 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    other == this: {0}, {1}
                  */
   137          if (other == this) return true;
   138          if (other instanceof WeblogPermission != true) return false;
   139          WeblogPermission o = (WeblogPermission)other;
   140          return new EqualsBuilder()
   141              .append(user, o.user) 
   142              .append(website, o.website) 
   143              .isEquals();
   144      }
   145      
   146      public int hashCode() { 
                 /* 
    P/P           *  Method: int hashCode()
                  * 
                  *  Preconditions:
                  *    init'ed(this.user)
                  *    init'ed(this.website)
                  * 
                  *  Presumptions:
                  *    org.apache.commons.lang.builder.HashCodeBuilder:append(...)@147 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   147          return new HashCodeBuilder()
   148              .append(user)
   149              .append(website)
   150              .toHashCode();
   151      }
   152  
   153  }
+  154  Other Messages








SofCheck Inspector Build Version : 2.18479
WeblogPermission.java 2009-Jan-02 14:25:40
WeblogPermission.class 2009-Sep-04 03:12:38