001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.exception;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    
019    /**
020     * @author Brian Wing Shun Chan
021     * @author Isaac Obrist
022     */
023    public class GroupParentException extends PortalException {
024    
025            @Deprecated
026            public static final int CHILD_DESCENDANT = 3;
027    
028            @Deprecated
029            public static final int SELF_DESCENDANT = 1;
030    
031            @Deprecated
032            public static final int STAGING_DESCENDANT = 2;
033    
034            /**
035             * @deprecated As of 7.0.0, replaced by the inner classes
036             */
037            @Deprecated
038            public GroupParentException() {
039                    _type = 0;
040            }
041    
042            /**
043             * @deprecated As of 7.0.0, replaced by the inner classes
044             */
045            @Deprecated
046            public GroupParentException(int type) {
047                    _type = type;
048            }
049    
050            /**
051             * @deprecated As of 7.0.0, replaced by the inner classes
052             */
053            @Deprecated
054            public GroupParentException(String msg) {
055                    super(msg);
056    
057                    _type = 0;
058            }
059    
060            /**
061             * @deprecated As of 7.0.0, replaced by the inner classes
062             */
063            @Deprecated
064            public GroupParentException(String msg, Throwable cause) {
065                    super(msg, cause);
066    
067                    _type = 0;
068            }
069    
070            /**
071             * @deprecated As of 7.0.0, replaced by the inner classes
072             */
073            @Deprecated
074            public GroupParentException(Throwable cause) {
075                    super(cause);
076    
077                    _type = 0;
078            }
079    
080            /**
081             * @deprecated As of 7.0.0, replaced by the inner classes
082             */
083            @Deprecated
084            public int getType() {
085                    return _type;
086            }
087    
088            public static class MustNotBeOwnParent extends GroupParentException {
089    
090                    public MustNotBeOwnParent(long groupId) {
091                            super(
092                                    String.format(
093                                            "Site %s cannot be its own parent site",
094                                            groupId),
095                                    SELF_DESCENDANT);
096    
097                            this.groupId = groupId;
098                    }
099    
100                    public long groupId;
101    
102            }
103    
104            public static class MustNotHaveChildParent extends GroupParentException {
105    
106                    public MustNotHaveChildParent(long groupId, long parentGroupId) {
107                            super(
108                                    String.format(
109                                            "Site %s cannot have a child site %s as its parent site",
110                                            groupId, parentGroupId),
111                                    CHILD_DESCENDANT);
112    
113                            this.groupId = groupId;
114                            this.parentGroupId = parentGroupId;
115                    }
116    
117                    public long groupId;
118                    public long parentGroupId;
119    
120            }
121    
122            public static class MustNotHaveStagingParent extends GroupParentException {
123    
124                    public MustNotHaveStagingParent(long groupId, long parentGroupId) {
125                            super(
126                                    String.format(
127                                            "Site %s cannot have a staging site %s as its parent site",
128                                            groupId, parentGroupId),
129                                    STAGING_DESCENDANT);
130    
131                            this.groupId = groupId;
132                            this.parentGroupId = parentGroupId;
133                    }
134    
135                    public long groupId;
136                    public long parentGroupId;
137    
138            }
139    
140            private GroupParentException(String message, int type) {
141                    super(message);
142    
143                    _type = type;
144            }
145    
146            private final int _type;
147    
148    }