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 RequiredGroupException extends PortalException {
024    
025            @Deprecated
026            public static final int CURRENT_GROUP = 3;
027    
028            @Deprecated
029            public static final int PARENT_GROUP = 2;
030    
031            @Deprecated
032            public static final int SYSTEM_GROUP = 1;
033    
034            /**
035             * @deprecated As of 7.0.0, replaced by the inner classes
036             */
037            @Deprecated
038            public int getType() {
039                    return _type;
040            }
041    
042            public static class MustNotDeleteCurrentGroup
043                    extends RequiredGroupException {
044    
045                    public MustNotDeleteCurrentGroup(long groupId) {
046                            super(
047                                    String.format(
048                                            "Site %s cannot be deleted because it is currently being " +
049                                                    "accessed",
050                                            groupId),
051                                    CURRENT_GROUP);
052    
053                            this.groupId = groupId;
054                    }
055    
056                    public long groupId;
057    
058            }
059    
060            public static class MustNotDeleteGroupThatHasChild
061                    extends RequiredGroupException {
062    
063                    public MustNotDeleteGroupThatHasChild(long groupId) {
064                            super(
065                                    String.format(
066                                            "Site %s cannot be deleted because it has child sites",
067                                            groupId),
068                                    PARENT_GROUP);
069    
070                            this.groupId = groupId;
071                    }
072    
073                    public long groupId;
074    
075            }
076    
077            public static class MustNotDeleteSystemGroup
078                    extends RequiredGroupException {
079    
080                    public MustNotDeleteSystemGroup(long groupId) {
081                            super(
082                                    String.format(
083                                            "Site %s cannot be deleted because it is a system " +
084                                                    "required site",
085                                            groupId),
086                                    SYSTEM_GROUP);
087    
088                            this.groupId = groupId;
089                    }
090    
091                    public long groupId;
092    
093            }
094    
095            private RequiredGroupException(String message, int type) {
096                    super(message);
097    
098                    _type = type;
099            }
100    
101            private final int _type;
102    
103    }