001
014
015 package com.liferay.portlet.documentlibrary;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.exception.PortalException;
020 import com.liferay.portal.kernel.exception.SystemException;
021 import com.liferay.portal.kernel.language.LanguageUtil;
022 import com.liferay.portal.kernel.repository.model.Folder;
023 import com.liferay.portal.kernel.util.StringPool;
024 import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
025 import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
026
027 import java.util.Locale;
028
029
033 @ProviderType
034 public class InvalidFolderException extends PortalException {
035
036 public static final int CANNOT_MOVE_INTO_CHILD_FOLDER = 1;
037
038 public static final int CANNOT_MOVE_INTO_ITSELF = 2;
039
040
044 @Deprecated
045 public InvalidFolderException() {
046 super();
047 }
048
049 public InvalidFolderException(int type, long folderId) {
050 _type = type;
051 _folderId = folderId;
052 }
053
054
058 @Deprecated
059 public InvalidFolderException(String msg) {
060 super(msg);
061 }
062
063
067 @Deprecated
068 public InvalidFolderException(String msg, Throwable cause) {
069 super(msg, cause);
070 }
071
072
076 @Deprecated
077 public InvalidFolderException(Throwable cause) {
078 super(cause);
079 }
080
081 public long getFolderId() {
082 return _folderId;
083 }
084
085 public String getMessageArgument(Locale locale) throws SystemException {
086 try {
087 if (_folderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
088 return LanguageUtil.get(locale, "home");
089 }
090
091 Folder folder = DLAppLocalServiceUtil.getFolder(_folderId);
092
093 return folder.getName();
094 }
095 catch (PortalException pe) {
096 return StringPool.BLANK;
097 }
098 }
099
100 public String getMessageKey() {
101 if (_type == CANNOT_MOVE_INTO_CHILD_FOLDER) {
102 return "unable-to-move-folder-x-into-one-of-its-children";
103 }
104 else if (_type == CANNOT_MOVE_INTO_ITSELF) {
105 return "unable-to-move-folder-x-into-itself";
106 }
107
108 return null;
109 }
110
111 private long _folderId;
112 private int _type;
113
114 }