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.kernel.exception;
016    
017    /**
018     * @author Brian Wing Shun Chan
019     * @author Isaac Obrist
020     */
021    public class GroupParentException extends PortalException {
022    
023            @Deprecated
024            public static final int CHILD_DESCENDANT = 3;
025    
026            @Deprecated
027            public static final int SELF_DESCENDANT = 1;
028    
029            @Deprecated
030            public static final int STAGING_DESCENDANT = 2;
031    
032            /**
033             * @deprecated As of 7.0.0, replaced by the inner classes
034             */
035            @Deprecated
036            public GroupParentException() {
037                    _type = 0;
038            }
039    
040            /**
041             * @deprecated As of 7.0.0, replaced by the inner classes
042             */
043            @Deprecated
044            public GroupParentException(int type) {
045                    _type = type;
046            }
047    
048            /**
049             * @deprecated As of 7.0.0, replaced by the inner classes
050             */
051            @Deprecated
052            public GroupParentException(String msg) {
053                    super(msg);
054    
055                    _type = 0;
056            }
057    
058            /**
059             * @deprecated As of 7.0.0, replaced by the inner classes
060             */
061            @Deprecated
062            public GroupParentException(String msg, Throwable cause) {
063                    super(msg, cause);
064    
065                    _type = 0;
066            }
067    
068            /**
069             * @deprecated As of 7.0.0, replaced by the inner classes
070             */
071            @Deprecated
072            public GroupParentException(Throwable cause) {
073                    super(cause);
074    
075                    _type = 0;
076            }
077    
078            /**
079             * @deprecated As of 7.0.0, replaced by the inner classes
080             */
081            @Deprecated
082            public int getType() {
083                    return _type;
084            }
085    
086            public static class MustNotBeOwnParent extends GroupParentException {
087    
088                    public MustNotBeOwnParent(long groupId) {
089                            super(
090                                    String.format(
091                                            "Site %s cannot be its own parent site",
092                                            groupId),
093                                    SELF_DESCENDANT);
094    
095                            this.groupId = groupId;
096                    }
097    
098                    public long groupId;
099    
100            }
101    
102            public static class MustNotHaveChildParent extends GroupParentException {
103    
104                    public MustNotHaveChildParent(long groupId, long parentGroupId) {
105                            super(
106                                    String.format(
107                                            "Site %s cannot have a child site %s as its parent site",
108                                            groupId, parentGroupId),
109                                    CHILD_DESCENDANT);
110    
111                            this.groupId = groupId;
112                            this.parentGroupId = parentGroupId;
113                    }
114    
115                    public long groupId;
116                    public long parentGroupId;
117    
118            }
119    
120            public static class MustNotHaveStagingParent extends GroupParentException {
121    
122                    public MustNotHaveStagingParent(long groupId, long parentGroupId) {
123                            super(
124                                    String.format(
125                                            "Site %s cannot have a staging site %s as its parent site",
126                                            groupId, parentGroupId),
127                                    STAGING_DESCENDANT);
128    
129                            this.groupId = groupId;
130                            this.parentGroupId = parentGroupId;
131                    }
132    
133                    public long groupId;
134                    public long parentGroupId;
135    
136            }
137    
138            private GroupParentException(String message, int type) {
139                    super(message);
140    
141                    _type = type;
142            }
143    
144            private final int _type;
145    
146    }