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.portlet.dynamicdatamapping;
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 RequiredStructureException extends PortalException {
024    
025            @Deprecated
026            public static final int REFERENCED_STRUCTURE = 1;
027    
028            @Deprecated
029            public static final int REFERENCED_STRUCTURE_LINK = 2;
030    
031            @Deprecated
032            public static final int REFERENCED_TEMPLATE = 3;
033    
034            @Deprecated
035            public RequiredStructureException(int type) {
036                    _type = type;
037            }
038    
039            @Deprecated
040            public int getType() {
041                    return _type;
042            }
043    
044            public static class MustNotDeleteStructureReferencedByStructureLinks
045                    extends RequiredStructureException {
046    
047                    public MustNotDeleteStructureReferencedByStructureLinks(
048                            long structureId) {
049    
050                            super(
051                                    String.format(
052                                            "Structure %s cannot be deleted because it is " +
053                                                    "referenced by one or more structure links",
054                                            structureId),
055                                    REFERENCED_STRUCTURE_LINK);
056    
057                            this.structureId = structureId;
058                    }
059    
060                    public long structureId;
061    
062            }
063    
064            public static class MustNotDeleteStructureReferencedByTemplates
065                    extends RequiredStructureException {
066    
067                    public MustNotDeleteStructureReferencedByTemplates(long structureId) {
068                            super(
069                                    String.format(
070                                            "Structure %s cannot be deleted because it is " +
071                                                    "referenced by one or more templates",
072                                            structureId),
073                                    REFERENCED_TEMPLATE);
074    
075                            this.structureId = structureId;
076                    }
077    
078                    public long structureId;
079    
080            }
081    
082            public static class MustNotDeleteStructureThatHasChild
083                    extends RequiredStructureException {
084    
085                    public MustNotDeleteStructureThatHasChild(long structureId) {
086                            super(
087                                    String.format(
088                                            "Structure %s cannot be deleted because it has child " +
089                                                    "structures",
090                                            structureId),
091                                    REFERENCED_STRUCTURE);
092    
093                            this.structureId = structureId;
094                    }
095    
096                    public long structureId;
097    
098            }
099    
100            private RequiredStructureException(String message, int type) {
101                    super(message);
102    
103                    _type = type;
104            }
105    
106            private final int _type;
107    
108    }