Java tutorial
/** * 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> * <right role="general-admin"> <br> * <allow action="view" /> <br> * <switch property="internalType"> <br> * ... <br> * </switch> <br> * </right> * * @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); } }