⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iofficepermissions.java

📁 一套完整的工商12315的源程序jsp部分在12315里,后台JAVA部分在gs12315src里,没有打包数据库.
💻 JAVA
字号:
package com.gs.db;

import com.gs.util.*;

/**
 * Defines a set of permissions for objects in the forum system that
 * users can be granted. IofficePermissions are used by the diprotection
 * proxy objects defined for each major component of the system.
 */


public class IofficePermissions implements Cacheable {

    /**
     * Total number of permission types
     */
    public static int MAX_PREV_NUM = 30;

    /**
     * Permission to administrate the system
     */
    public static final int SYSTEM_ADMIN=0;

    /**
     * Permission to modify group's information
     */
    public static final int GROUP_ADMIN = 1;
    /**
     * Permission to modify user's information
     */
    public static final int USER_ADMIN = 2;

    /**
     * Permission to post news
     */
    public static final int NEWS_POST	=4;
    /**
     * Permission to administrate news
     */
    public static final int NEWS_ADMIN	=5;

    /**
     * Permission to view conference report
     */
    public static final int CONREP_BROWSE=6;

    /**
     * Permission to post conference report
     */
    public static final int CONREP_POST	=7;

    /**
     * Permission to administrate all conference reports
     */
    public static final int CONREP_ADMIN=8;

    /**
     * Permission to modify user's information
     */
    public static final int ADDRESS_BOOK_ADMIN=9;

    /**
     * Permission to browse archive documents
     */
    public static final int ARCHIVE_BROWSE=3;
    /**
     * Permission to upload documents to the system archive DB
     */
    public static final int ARCHIVE_UPLOAD=10;
    /**
     * Permission to administrate all the archives
     */
    public static final int ARCHIVE_ADMIN=11;

    public static final int SUBSCRIBE_BROWSE=12;
    /**
     * Permission to subscribe/revoke information
     */
    public static final int SUBSCRIBE_REQUEST_REVOKE=13;
    /**
     * Permission to administrate subscribing affairs
     */
    public static final int SUBSCRIBE_ADMIN=14;

    /**
     * Permission to view the result of polls(not used currently)
     */
    public static final int POLL_BROWSERESULT=15;
    /**
     * Permission administrate polling(not used currently)
     */
    public static final int POLL_ADMIN	=16;
    /**
     * Permission to vote for a poll(not used currently)
     */
    public static final int POLL_VOTE	=17;

    /**
     * Permission to administrate NET-STATUS affairs, such as to add/remove
     * NET-STATUS parameters (used in CHINA TELECOM case)
     */
    public static final int NET_ADMIN	=18;
    /**
     * Permission to view NET-STATUS (used in CHINA TELECOM case)
     */
    public static final int NET_BROWSE = 20;

    /**
     * Permission to administrate evaluation process
     */
    public static final int CHECK_ADMIN	=19;

    /**
     * Permission to browse project information(used in CHINA TELECOM case)
     */
    public static final int PROJECT_BROWSE= 21;
    /**
     * Permission to input/modify  project information(used in CHINA TELECOM case)
     */
    public static final int PROJECT_UPLOAD=22;
    /**
     * Permission to administrate project information(used in CHINA TELECOM case)
     */
    public static final int PROJECT_ADMIN=23;

    public static final int MISSION_SEND= 24 ;


    public static final int CHECK_USER = 25;
    public static final int MANUFACTURER_MANAGER = 26;
    public static final int PROJECT_MANAGER = 27;
    public static final int DOCTYPE_MANAGER=28;

    public static final int CADRE_ADMIN = 29;

    //行政级别
    public static final int LEVEL_0 = 0;//局长
    public static final int LEVEL_1 = 1;//处长
    public static final int LEVEL_2 = 2;//科长
    public static final int LEVEL_3 = 3;//普通员工
    public static final int LEVEL_4 = 4;//监督员




    private boolean [] values = new boolean[IofficePermissions.MAX_PREV_NUM];

    /**
     * Factory method to create full permissions.
     */
    public static IofficePermissions full() {
    	int i;
	boolean[] prevs=new boolean[IofficePermissions.MAX_PREV_NUM];
    	for ( i=0; i<IofficePermissions.MAX_PREV_NUM; i++) prevs[i]=true;

        return new IofficePermissions(prevs);
    }

    /**
     * Factory method to create an object with no permissions.
     */
    public static IofficePermissions none() {
    	int i;
		boolean[] prevs=new boolean[IofficePermissions.MAX_PREV_NUM];
    	for ( i=0; i<IofficePermissions.MAX_PREV_NUM; i++) prevs[i]=false;

        return new IofficePermissions(prevs);
    }



    // by default, every user object is assigned the permission to modify
    // the information of himself, so does every group object
    /**
     * Factory method to create an object with  permissions for anonymous users
     */
    public static IofficePermissions anonymous() {
		return IofficePermissions.none();
    }

    /**
     * Factory method to create an object with  default permissions for a user.
     * By default, every user object is assigned the permission to modify  the
     * information of himself, so does every group object
     */
    public static IofficePermissions userDefault() {
      boolean[] prevs = new boolean[IofficePermissions.MAX_PREV_NUM];
      for (int i = 0; i < IofficePermissions.MAX_PREV_NUM; i++) prevs[i] = false;
      prevs[USER_ADMIN] = true;
      return new IofficePermissions(prevs);
    }

    public static IofficePermissions groupAdminDefault() {
      boolean[] prevs = new boolean[IofficePermissions.MAX_PREV_NUM];
      for (int i = 0; i < IofficePermissions.MAX_PREV_NUM; i++) prevs[i] = false;
      prevs[GROUP_ADMIN] = true;
      return new IofficePermissions(prevs);
    }

    /**
     * Create an object with the specified permission types
     */
    public IofficePermissions(int[] types) {
      values = new boolean[types.length];
      int i;
      for (i = 0; i < types.length; i++) {
        values[i] = false;
      }
      for (i = 0; i < types.length; i++) {
        if (types[i] >= 0 && types[i] < IofficePermissions.MAX_PREV_NUM)
          values[types[i]] = true;
      }
    }

    /**
     * Create an object with merged permissions of the two given IofficePermissions object
     */
    public IofficePermissions(IofficePermissions perm1,
            IofficePermissions perm2)
    {
       values = new boolean[IofficePermissions.MAX_PREV_NUM];
    	for ( int i=0; i<IofficePermissions.MAX_PREV_NUM; i++ )
    	{
        	values[i] = perm1.get(i) || perm2.get(i);
        }
    }

    /**
     * Create an object with the specified permission types
     * @param permissions - array index denotes premission type, element value
     * is true if has permission, false not.
     */
    public IofficePermissions(boolean [] permissions) {
        this.values = permissions;
    }

    public String toString() {
    	int i;
    	boolean hasPre = false;
        StringBuffer buf = new StringBuffer();
        for (i=0; i<values.length-1; i++) {
            if ( values[i] )
            {
          	if ( hasPre ) buf.append(",");
            	buf.append(i);
            	hasPre = true;
            }
        }
        if ( values[ i ] ) {
          	if ( hasPre ) buf.append(",");
        	buf.append(i);
        }
        return buf.toString();
    }

    /**
     * Returns true if the permission of a particular type is allowed.
     */
    public boolean get(int type) {
        if (type < 0 || type >= IofficePermissions.MAX_PREV_NUM||type >=values.length) {
            return false;
        }
     //   System.err.println(type);
     //   System.err.println(values[type]);
        return values[type];
    }

    /**
     * Returns true if the permissions include system or forum admin
     * permissions.
     */
    public boolean isSystemAdmin() {
        return (values[SYSTEM_ADMIN] );
    }

    /**
     * Implemention of Cacheable interface
     * @see Cacheable
     */
    public int getSize() {
        //Approximate the size of the object in bytes by calculating the size
        //of each field.
        int size = 0;
        size += CacheSizes.sizeOfObject();              //overhead of object
        size += CacheSizes.sizeOfObject();              //ref to array
        size += CacheSizes.sizeOfBoolean() * values.length;         //boolean array vals
        return size;

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -