Subversion Repositories general

Rev

Rev 925 | Rev 946 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package ak.hostadmiral.core.model;

import ak.hostadmiral.util.ModelException;
import ak.hostadmiral.util.ModelSecurityException;

/**
 *
 * @hibernate.class table="domains"
 */
public class InetDomain
        extends GeneralModelObject
{
        private String name;
        private User   owner;

        protected InetDomain()
        {
        }

        /**
         *
         * @hibernate.property
         */
        public String getName()
        {
                return name;
        }

        protected void setName(String name)
        {
                this.name = name;
        }

        public void setName(User editor, String name)
                throws ModelException
        {
                if(!editableBy(editor))
                        throw new ModelSecurityException();

                this.name = name;
        }

        /**
         *
         * @hibernate.many-to-one
         */
        public User getOwner()
        {
                return owner;
        }

        protected void setOwner(User owner)
        {
                this.owner = owner;
        }

        public void setOwner(User editor, User owner)
                throws ModelException
        {
                if(!editableBy(editor))
                        throw new ModelSecurityException();

                this.owner = owner;
        }

        public String getTypeKey()
        {
                return ak.hostadmiral.core.CoreResources.TYPE_DOMAIN;
        }

        public String getIdentKey()
        {
                return ak.hostadmiral.core.CoreResources.IDENT_DOMAIN;
        }

        public Object[] getIdentParams()
        {
                return new Object[] { getName() };
        }

        public boolean viewableBy(User user)
        {
                return user.isSuperuser() || user.equals(owner);
        }

        public boolean editableBy(User user)
        {
                return user.isSuperuser();
        }

        public boolean deleteableBy(User user)
        {
                return user.isSuperuser();
        }

        protected static boolean allowedToCreate(InetDomainManager manager, User editor)
                throws ModelException
        {
                return editor.isSuperuser();
        }
}