com.pureinfo.ark.auth2.model.RightDef.java Source code

Java tutorial

Introduction

Here is the source code for com.pureinfo.ark.auth2.model.RightDef.java

Source

/**
 * PureInfo Ark
 * @(#)RightDef.java   1.0 2006-9-30
 * 
 * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. 
 * All rights reserved, see the license file.
 * 
 * www.pureinfo.com.cn
 */

package com.pureinfo.ark.auth2.model;

import org.dom4j.Element;

import com.pureinfo.dolphin.mapping.EntityMetadata;
import com.pureinfo.force.exception.PureException;
import com.pureinfo.force.xml.XMLUtil;

/**
 * <P>
 * Created on 2006-9-30 10:58:05 <BR>
 * Last modified on 2006-9-30
 * </P>
 * RightDef: definition for right. <br>
 * Format: <br>
 * &lt;right role="general-admin"&gt; <br>
 * &lt;allow action="view" /&gt; <br>
 * &lt;switch property="internalType"&gt; <br>
 * ... <br>
 * &lt;/switch&gt; <br>
 * &lt;/right&gt;
 * 
 * @author Why
 * @version 1.0, 2006-9-30
 * @since Ark 1.2
 */
public class RightDef extends RightDefBase {
    private String m_sRoles;

    /**
     * Constructor
     * 
     * @param _resourceMetadata
     *            the resource entity metadata.
     */
    public RightDef(EntityMetadata _resourceMetadata) {
        super(_resourceMetadata);
    }

    /**
     * Returns the roles, like 'admin1', 'admin1,admin2' etc.
     * 
     * @return the roles.
     */
    public String getRoles() {
        return m_sRoles;
    }

    /**
     * Sets the roles.
     * 
     * @param _sRoles
     *            the roles to set.
     */
    public void setRoles(String _sRoles) {
        m_sRoles = _sRoles;
    }

    //=========================================================================
    //logic interface for authorization

    //=========================================================================
    //implementation for IXMLSupporter

    /**
     * @see com.pureinfo.force.xml.IXMLSupporter#toXMLElement(org.dom4j.Element)
     */
    public void toXMLElement(Element _element) throws PureException {
        _element.addAttribute("role", m_sRoles);
        super.toXMLElement(_element);
    }

    /**
     * @see com.pureinfo.force.xml.IXMLSupporter#fromXML(org.dom4j.Element)
     */
    public void fromXML(Element _element) throws PureException {
        this.setRoles(XMLUtil.getAttributeValueTrim(_element, "role"));
        super.fromXML(_element);
    }

}