4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
7 * Wooyoung Cho <wooyoung1.cho@samsung.com>
8 * Shihyun Kim <shihyun.kim@samsung.com>
9 * Taeyoung Son <taeyoung2.son@samsung.com>
10 * Yongsung kim <yongsung1.kim@samsung.com>
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
16 * http://www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
29 package org.tizen.installmanager.lib;
31 import org.tizen.installmanager.core.Config;
34 * This class manages error codes and states
36 * @author Shihyun Kim <shihyun.kim@samsung.com>
38 public class ErrorController {
40 * Define case of error
42 * @author Shihyun Kim <shihyun.kim@samsung.com>
45 public enum ErrorCode {
46 CANNOT_FIND_CONFIG_FILE("The installmanager.conf file not found."),
47 CANNOT_FIND_FILE_IN_REPOSITROY("Cannot connect to SDK package server."),
48 CANNOT_CREATE_DOWNLOAD_FILE("Download file cannot be created."),
49 CANNOT_CHECK_INSTLLED_FILE_LIST("Installed file list cannot be checked."),
50 CANNOT_MOVE_FILE_TO_TARGET_DIRECTORY("File cannot be moved to the target directory."),
51 CANNOT_CONNECT_TO_PROXY_SERVER("Proxy server connection fails."),
52 WRONG_PACKAGE_URL("Package URLs are invalid."),
53 CANCEL("Download canceled."),
54 ERROR("Unknown error."),
55 UNKNOWN_PACKAGE_EXTENSION("Package extension not supported."),
56 INVALID_PACKAGE_VERSION("Invalid package version."),
57 CANNOT_FIND_INSTALLABLE_OR_REMOVABLE_PACKAGES("Install or uninstall packages not found. Network connection may have failed."),
58 CANNOT_FIND_FILE_IN_LOCAL("Local file not found."),
59 CANNOT_SAVE_CONFIG("Configuration file cannot be saved."),
60 CANNOT_CREATE_SHORTCUT("Shortcut creation failed."),
61 CANNOT_CREATE_INSTALL_LIST("Install list creation failed."),
62 CANNOT_CREATE_CONFIG_FILE("Configuration directory or file creation failed."),
63 CANNOT_FIND_USER_CONFIG_FILE("User configuration file creation failed."),
64 CANNOT_REGISTER_TARGET_DIR("Target directory registration failed."),
65 CANNOT_PARSING_TEXT("Configuration file parsing failed."),
66 CANNOT_SAVE_PROPERTY_FILE("The installmanager.conf or Package file cannot be saved."),
67 CANNOT_UNPACK_PACKAGE("The package.zip file unpackaging failed."),
68 CANNOT_CREATE_RESOURCE("Resource file creation failed."),
69 CANNOT_FIND_PACKAGE("Required packages not found. The package server may be invalid."),
70 CANNOT_REMOVE_PACKAGE("Package removal failed."),
71 CANNOT_REMOVE_MISSING_PACKAGE("Missing package cannot be removed."),
72 CANNOT_ACCESS_FILE("File access failed."),
73 CANNOT_REMOVE_OLDSDK("Old SDK removal failed."),
74 COPY_FILE_IS_FAIL("Copying the file to the target directory failed."),
75 OLD_TIZEN_SDK_EXISTS("Old Tizen SDK is installed. Remove the old SDK and run the Tizen SDK Install Manager again."),
76 UNSUPPORTED_PLATFORM("Platform not supported."),
77 REMOVE_SCRIPT_NOT_EXISTS("Removal script not found."),
78 REMOVE_SCRIPT_FATAL_ERROR("Fatal error occurred while uninstalling the Tizen SDK."),
79 INSTALLATION_FAIL("Installation failed."),
80 INSTALL_CANCELED("Installation canceled."),
81 INSTALLED_VERSION_IS_HIGH("Installation progress failed due to high installed package version."),
82 CANNOT_CREATE_FILE("File creation failed."),
83 THREAD_INTERRUPTED("Thread execution interrupted."),
84 CIRCULAR_PACKAGE_DEPENDENCY("Circular package dependency detected."),
86 //Configuration file error
87 CONFIG_CANNOT_PARSING_PACKAGE_LIST("Package list cannot be read. Check the repository or proxy server."),
88 CONFIG_CANNOT_FIND_PACKAGE_LIST_FILE_IN_REPOSITORY("Package list file not found in the repository."),
89 CONFIG_CANNOT_REMOVE_CONFLICT_PACKAGES("Conflict package removal failed."),
90 CONFIG_CANNOT_REMOVE_UPDATABLE_PACKAGES("Updatable package removal failed."),
91 CONFIG_CANNOT_READ_SERVER_TYPE("Server type cannot be read. Check the server type in the installmanager.conf file."),
94 PACKAGE_WRONG_SIZE("Package size incorrect."),
95 PACKAGE_WRONG_CHECKSUM("Package file checksum error."),
96 PACKAGE_NOT_EXIST_TO_INSTALL_OR_UNINSTALL("Install or uninstall package not found."),
97 INSTALL_SCRIPT_NOT_EXISTS("Install script files not found."),
98 INSTALL_SCRIPT_FATAL_ERROR("Fatal error occurred while installing the Tizen SDK."),
101 INTERNET_CONNECTION_ERROR("Server connection failed. Check the network status or try again with the '-proxy <address>:<port>'."),
102 SERVER_CONNECTION_TIME_OUT("Server connection timed out."),
103 PROXY_NOT_PROVIDED("Proxy setting missing. Use the '-proxy <proxy-address>:<port>' option."),
104 PROXY_SERVER_IS_WRONG("Proxy server connection failed. Check the proxy server."),
105 PROXY_CONNECT_ERROR("Proxy server connection failed. Check the proxy server."),
106 URL_SECURITY_EXCEPTION("Proxy server URL security error."),
107 URL_ADDRESS_IS_WRONG("Incorrect URL."),
108 URL_PORT_IS_WRONG("Incorrect port number."),
109 NO_ROUTE_TO_HOST("Server not found. Check the URL."),
110 NOT_LOGGED_IN("Login failed."),
111 NOT_SUPPORT_HTTPS_PROTOCOL("HTTPS not supported."),
113 //Http Socket error message
114 HTTP_ERROR_MESSAGE_403("403 Forbidden is returned by http protocol. " +
115 "The server can be reached, but the server declined to allow access to the page."),
116 HTTP_ERROR_MESSAGE_401("Server requires authentication."),
119 WRONG_OPTION("Incorrect option. Check it."),
120 USESNAPSHOT_REPOSITORY_NOT_PROVIDED("Repository setting is missing. Use the '-snapShot <repository>' option."),
121 REPOSITORY_NOT_PROVIDED("Repository setting is missing. Use the '-repository <repository>' option."),
122 PACKAGES_NOT_PROVIDED("Repository setting is missing. Use the '-proxy <repository>' option."),
125 CANNOT_FIND_INSTALLED_FILE_LIST("Installation file list not found."),
126 CANNOT_REMOVE_TARGET_DIR("Target directory removal failed."),
127 INSTALLATION_STOP("Required packages for the META package not installed."),
128 UNINSTALLATION_FAIL("Uninstallation failed."),
129 FILE_NOT_FOUND("File not found."),
130 REMOVE_OLD_SDK_OK("Old SDK uninstallation completed. Restart Install Manager."),
131 INVALID_INSTALL_PATH("Invalid installation path."),
132 DOWNLOAD_AND_EXIT("Packages downloaded successfully. Exit Install Manager."),
133 CANNOT_DOWNLOAD_FILE("File download failed."),
134 CANNOT_FIND_JAVA("\'JAVA\' not found. Check the java installation."),
135 UNKOWN_ERROR("Unknown error."),
136 NO_ERROR("Install Manager error. Send the log file to the Tizen SDK team."),
137 ERROR_TEMP("Information retrieval from the default SDK package server failed.\n In Advanced Configuration, select the package server and distribution."),
139 SNAPSHOT_PATH_IS_NULL("Snapshot path missing."),
140 FAIL_TO_EXTRACT_SDK_IMAGE_FILE("SDK image file extraction failed."),
142 //Using add extra repository dialog
143 SPACE_IN_REPOSITORY_NAME("Name cannot contain spaces."),
144 NOTHING_TO_REPOSITORY_NAME("Name must be more than 1 character long."),
145 HANGUL_IN_REPOSITORY_NAME("Repository name must be in English."),
146 WRONG_PACKAGE_SERVER("Package list files not found. Check the package list files on the package server."),
147 WRONG_PACKAGE_LIST_FORMAT("Mandatory field missing in the package list file."),
148 WRONG_URL_FORMAT_HTTP("URL must begin with 'http://'."),
149 WRONG_URL_FORMAT("Incorrect URL format. Enter the URL in the correct format."),
150 CANNOT_CONNECT_URL_ADDRESS("Connection to the URL failed. Enter the correct URL."),
151 PACKAGE_NOT_IN_EXTENSION_SERVER("Package file not found on the package server."),
152 OVERLAP_EXTENSION_REPOSITORY("Extension repository URL already exists.\nEnter a different extension repository URL."),
153 OVERLAP_BUILT_IN_EXTENSION_REPOSITORY("Built-in extension repository URL already exists.\nEnter a different extension repository URL.");
155 private String errorMessage = "";
157 ErrorCode(String arg) {
161 public String getErrorMessage() {
165 public void setErrorMessage(String msg) {
170 static public boolean isInstallManagerUpdatable = false;
173 static private ErrorCode mErrorCode = ErrorCode.NO_ERROR;
174 static private boolean mInstallationStatus = true;
175 static private String errorMsg = "";
177 private static int exitCode = Config.EXITCODE_NORMAL;
183 static public void setError(ErrorCode errorCode) {
184 mErrorCode = errorCode;
189 * @return Latest error message.
191 static public String getErrorMessage() {
192 if (mErrorCode != null) {
193 return mErrorCode.getErrorMessage();
199 static public void setErrorMessage(String msg) {
205 * @return Latest error code.
207 static public ErrorCode getErrorCode() {
212 * Set status of installation.
215 static public void setInstallationSuccess(boolean status) {
216 Log.log("Set installation success: "+status);
217 if (status == true) {
220 mInstallationStatus = status;
224 * Get status of installation.
227 static public boolean checkInstallationSuccess() {
228 return mInstallationStatus;
232 * Get error message of e
236 public static String getMessage(ErrorCode e) {
237 return e.getErrorMessage();
241 * Sets exit code to be used on exit
244 public static void setExitCode(int exitCode) {
245 ErrorController.exitCode = exitCode;
249 * Gets exit code to be used on exit
251 public static int getExitCode() {
252 return ErrorController.exitCode;