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