Revision 32467

View differences:

branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.api/src/main/java/org/gvsig/installer/lib/api/InstallerInfo.java
31 31

  
32 32

  
33 33
/**
34
 * Information of a plugin that is used on the installation process. 
35
 * This information is composed by next fields:
36
 * </br>
37
 * <li>
38
 * <lu><b>Code</b>: unique identifier for the plugin.</lu>
39
 * <lu><b>Name</b>: name of the plugin.</lu>
40
 * <lu><b>Decription</b>: brief description of the plugin functionality</lu> * 
41
 * <lu><b>Version</b>: number of version.</lu>
42
 * <lu><b>Build</b>: build number.</lu>
43
 * <lu><b>State</b>: the state of the plugin (testing, RC1...).</lu>
44
 * <lu><b>Is Official</b>: if the plugin is official or if is a not official plugin.</lu>
45
 * <lu><b>Type</b>: plugin type (plugin, theme, translation...). Depending of this value a
46
 * different installation provider is selected to control the installation process.</lu>
47
 * <li>
48
 *
34 49
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
35 50
 */
36 51
public interface InstallerInfo {
37 52
	
53
	/**
54
	 * @return
55
	 * Gets the code of the plugin.
56
	 */
38 57
	public String getCode();
39 58
		
40 59
	public void setCode(String code);
41 60
	
61
	/**
62
	 * @return
63
	 * Gets the name of the plugin.
64
	 */
42 65
	public String getName();
43 66
	
44 67
	public void setName(String name);
45 68
	
69
	/**
70
	 * @return
71
	 * Gets the description of the plugin.
72
	 */
46 73
	public String getDescription();
47 74
	
48 75
	public void setDescription(String description);
49 76
	
77
	/**
78
	 * @return
79
	 * Gets the version of the plugin.
80
	 */
50 81
	public String getVersion();
51 82
		
52 83
	public void setVersion(String version);
53 84
	
85
	/**
86
	 * @return
87
	 * Gets the build number of the plugin.
88
	 */
54 89
	public int getBuild();	
55 90
		
56 91
	public void setBuild(int build);
57 92
	
93
	/**
94
	 * @return
95
	 * Gets the state of the plugin.
96
	 */
58 97
	public String getState();
59 98
	
60 99
	public void setState(String state);
61 100
	
101
	/**
102
	 * @return
103
	 * Gets if the plugin is official.
104
	 */
62 105
	public boolean isOfficial();
63 106
	
64 107
	public void setOfficial(boolean official);
65
		
108
	
109
	/**
110
	 * @return
111
	 * Gets the type of the plugin.
112
	 */
113
	public String getType();
114
	
115
	public void setType(String type);
116
	
117
	/**
118
	 * Add an external file that have to be copied in the
119
	 * installation process.
120
	 * @param file
121
	 * The file to copy.
122
	 * @deprecated
123
	 * This method will be deleted on next releases because 
124
	 * all the files that a plugin needs to work should be
125
	 * contained in its directory.
126
	 */
66 127
	public void addFileToCopy(File file);
67 128
	
129
	/**
130
	 * Gets one external file that is copied on
131
	 * the installation process.
132
	 * @param index
133
	 * The position of the external file.
134
	 * @return
135
	 * The file that have to be copied.
136
	 * @deprecated
137
	 * This method will be deleted on next releases because 
138
	 * all the files that a plugin needs to work should be
139
	 * contained in its directory.
140
	 */
68 141
	public File getFileToCopyAt(int index);
69 142
	
143
	/**
144
	 * Gest the number of external files that have to be
145
	 * copied in the installation process.
146
	 * @return
147
	 * The number of files.
148
	 * @deprecated
149
	 * This method will be deleted on next releases because 
150
	 * all the files that a plugin needs to work should be
151
	 * contained in its directory.
152
	 */
70 153
	public int getFileToCopySize();
71 154
	
155
	/**
156
	 * Removes one of the files that have to be copied in the
157
	 * installation process.
158
	 * @param index
159
	 * the position of the file.
160
	 * @deprecated
161
	 * This method will be deleted on next releases because 
162
	 * all the files that a plugin needs to work should be
163
	 * contained in its directory.
164
	 */
72 165
	public void removeFileToCopy(int index);
73 166
	
167
	/**
168
	 * Sets the ant script that can be executed in the
169
	 * installation process.
170
	 * @param antScript
171
	 * The ant script to copy.
172
	 * @deprecated
173
	 * This method will be deleted on next releases because 
174
	 * all the files that a plugin needs to work should be
175
	 * contained in its directory.
176
	 */
74 177
	public void setAnScript(String antScript);
75 178
	
179
	/**
180
	 * Gets the ant script that has to be executed in the
181
	 * installation process.
182
	 * @return
183
	 * the script.
184
	 * @deprecated
185
	 * This method will be deleted on next releases because 
186
	 * all the files that a plugin needs to work should be
187
	 * contained in its directory.
188
	 */
76 189
	public String getAntScript();
77
	
78
	public String getType();
79
	
80
	public void setType(String type);
81 190

  
82 191
}
83 192

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.api/src/main/java/org/gvsig/installer/lib/api/InstallerLocator.java
51 51
	 */
52 52
	private static final InstallerLocator instance = new InstallerLocator();
53 53
	
54
	/* (non-Javadoc)
55
	 * @see org.gvsig.tools.locator.Locator#getLocatorName()
54
	/**
55
	 * @see Locator#getLocatorName()
56 56
	 */
57 57
	public String getLocatorName() {
58 58
		return LOCATOR_NAME;
......
84 84
	 * Registers the Class implementing the {@link InstallerManager} interface.
85 85
	 *
86 86
	 * @param clazz
87
	 *            implementing the InstallerManager interface
87
	 * implementing the InstallerManager interface
88 88
	 */
89 89
	@SuppressWarnings("unchecked")
90 90
	public static void registerInstallerManager(Class clazz) {
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.api/src/main/java/org/gvsig/installer/lib/api/InstallerLibrary.java
31 31
import org.gvsig.tools.library.LibraryException;
32 32

  
33 33
/**
34
 * Library for the installer.
34 35
 * 
35 36
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
36 37
 */
......
38 39

  
39 40
	@Override
40 41
	protected void doInitialize() throws LibraryException {
41
		// TODO Auto-generated method stub
42
		
42
				
43 43
	}
44 44

  
45 45
	@Override
46 46
	protected void doPostInitialize() throws LibraryException {
47
		// TODO Auto-generated method stub
48
		
47
				
49 48
	}
50 49

  
51 50
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.api/src/main/java/org/gvsig/installer/lib/api/execution/InstallerExecutionServiceException.java
30 30
import org.gvsig.tools.exception.BaseException;
31 31

  
32 32
/**
33
 * Base exception for all the exceptions that are thrown by the process
34
 * of execution of an installer. The {@link InstallerExecutionService} throws
35
 * this exception on its methods.
36
 *  
33 37
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
34 38
 */
35 39
public class InstallerExecutionServiceException extends BaseException{
......
45 49
	}
46 50

  
47 51
	/**
48
	 * @see BaseException#BaseException(String, Throwable)
52
	 * @see BaseException#BaseException(String, Throwable, String, long)
49 53
	 */
50 54
	public InstallerExecutionServiceException(String message, Throwable cause) {
51 55
		super(message, cause,  KEY, serialVersionUID);
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.api/src/main/java/org/gvsig/installer/lib/api/execution/InstallerExecutionService.java
32 32

  
33 33
import org.gvsig.installer.lib.api.InstallerInfo;
34 34
import org.gvsig.installer.lib.api.creation.InstallerCreationService;
35
import org.gvsig.installer.lib.api.creation.InstallerCreationServiceException;
35 36
import org.gvsig.tools.service.Service;
36 37

  
37 38
/**
38 39
 * <p>
39
 * This service is used to execute an installer file and install the
40
 * plugins contained in it. It has methods to set the installer file,
40
 * This service is used to read an installer file and install the
41
 * plugins contained in it. It has methods to add installers,
41 42
 * to read the plugins that can be installed, to select the plugins
42 43
 * to install and to install them.  
43 44
 * </p>
......
55 56
	 * Sets the stream that contains the installer that contains the 
56 57
	 * information to install some plugins. This stream is a zip file
57 58
	 * that has to have the structure defined in the {@link InstallerCreationService}
58
	 * documentation.	 * 
59
	 * documentation.	 
59 60
	 * @param inputStream
60 61
	 * The stream that contains the installer information.
61 62
	 * @throws InstallerExecutionServiceException
......
63 64
	 */
64 65
	public void addInstaller(InputStream inputStream) throws InstallerExecutionServiceException;
65 66
	
67
	/**
68
	 * It sets the directory where the application is located, that it has to
69
	 * be a valid gvSIG root directory. This directory is used to install the plugins.
70
	 * @param applicationDirectory
71
	 * The directory where the gvSIG is located.
72
	 * @throws InstallerExecutionServiceException
73
	 * This exception is thrown when the directory doesn't exist or the directory is
74
	 * not a valid gvSIG root directory.
75
	 */
76
	public void setApplicationDirectory(File applicationDirectory) throws InstallerExecutionServiceException;
77
	
78
	/**
79
	 * In the main gvSIG directory there is a directory named <b>install</b> that could
80
	 * have some installers that can be used to install new plugins. This method retrieve
81
	 * all the information of the installers located in this directory and allows to the 
82
	 * user to show this information.
83
	 * @throws InstallerExecutionServiceException
84
	 * If there is any problem reading the directory or the installers.
85
	 */
66 86
	public void addInstallersFromInstallDirectory() throws InstallerExecutionServiceException;
67 87
	
88
	/**
89
	 * Deletes all the information of the previous loaded installers.
90
	 */
68 91
	public void deleteInstallers();	
92
		
93
	/**
94
	 * Sets the plugin to install.
95
	 * @param index
96
	 * Position of the plugin to install.
97
	 * @throws InstallerExecutionServiceException
98
	 * If the plugin doesn't exist. 
99
	 */
100
	public void setPluginToInstall(int index) throws InstallerExecutionServiceException;
69 101
	
70
	public void setApplicationDirectory(File applicationDirectory) throws InstallerExecutionServiceException;
102
	/**
103
	 * Sets the plugin to install.
104
	 * @param code
105
	 * Code of the plugin to install.
106
	 * @throws InstallerExecutionServiceException
107
	 * If the plugin doesn't exist. 
108
	 */
109
	public void setPluginToInstall(String code) throws InstallerCreationServiceException;
71 110
	
72 111
	/**
73
	 * It 
74
	 * @param outputDirectory
112
	 * Install the selected plugin. This method only can be executed if the 
113
	 * selected plugin is located on the <b>install</b> directory of gvSIG.
114
	 * Otherwise the method to use is {{@link #executeInstaller(InputStream)} that
115
	 * provides the strem used to install the plugin.
75 116
	 * @throws InstallerExecutionServiceException
117
	 * If there is an error installing the plugin.
76 118
	 */
77 119
	public void executeInstaller() throws InstallerExecutionServiceException;
78 120
	
121
	/**
122
	 * Install the selected plugin. This method provides of a stream that has been
123
	 * added before using the {{@link #addInstaller(InputStream)}} method. This stream
124
	 * is needed other time because there are some {@link InputStream}'s that don't
125
	 * support the {@link InputStream#reset()} method.	 * 
126
	 * @throws InstallerExecutionServiceException
127
	 * If there is an error installing the plugin.	 * 
128
	 */
79 129
	public void executeInstaller(InputStream is) throws InstallerExecutionServiceException;
80 130
		
81
	public void setPluginToInstall(int index);
82
	
83
	public void setPluginToInstall(String code);
84
	
131
	/**
132
	 * @return
133
	 * The number of plugins that can be selected to install.
134
	 */
85 135
	public int getPluginsSize();
86 136
	
137
	/**
138
	 * Return the information of a plugin from a concrete position. 
139
	 * @param index
140
	 * The position of the plugin.
141
	 * @return
142
	 * The information of a plugin.
143
	 */
87 144
	public InstallerInfo getPluginInfoAt(int index);
88 145
}
89 146

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.api/src/main/java/org/gvsig/installer/lib/api/creation/InstallerCreationServiceException.java
30 30
import org.gvsig.tools.exception.BaseException;
31 31

  
32 32
/**
33
 * Base exception for all the exceptions that are thrown by the process
34
 * of creation of an installer. The {@link InstallerCreationService} throws
35
 * this exception on its methods.
36
 *  
33 37
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
34 38
 */
35 39
public class InstallerCreationServiceException extends BaseException{
......
45 49
	}
46 50

  
47 51
	/**
48
	 * @see BaseException#BaseException(String, Throwable)
52
	 * @see BaseException#BaseException(String, Throwable, String, long)
49 53
	 */
50 54
	public InstallerCreationServiceException(String message, Throwable cause) {
51 55
		super(message, cause,  KEY, serialVersionUID);
52 56
	}
53 57

  
54
	
58
	/**
59
	 * @see BaseException#BaseException(String, String, long)
60
	 */
55 61
	public InstallerCreationServiceException(String message, String key,
56 62
			long serialVersion) {
57 63
		super(message, key, serialVersion);
58 64
	}
59

  
65
	
66
	/**
67
	 * @see BaseException#BaseException(String, Throwable, String, long)
68
	 */
60 69
	public InstallerCreationServiceException(String message, Throwable cause,
61 70
			String key, long serialVersion) {
62 71
		super(message, cause, key, serialVersion);
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/execution/DefaultInstallerExecutionService.java
37 37
import java.util.Map;
38 38

  
39 39
import org.gvsig.installer.lib.api.InstallerInfo;
40
import org.gvsig.installer.lib.api.creation.InstallerCreationServiceException;
40 41
import org.gvsig.installer.lib.api.execution.InstallerExecutionService;
41 42
import org.gvsig.installer.lib.api.execution.InstallerExecutionServiceException;
42 43
import org.gvsig.installer.lib.impl.DefaultInstallerManager;
......
175 176
		return installerInfos.get(pluginToInstallIndex);
176 177
	}
177 178

  
178
	public void setPluginToInstall(int index) {
179
	public void setPluginToInstall(int index) throws InstallerExecutionServiceException{
180
		if (index > installerInfos.size()){
181
			throw new InstallerExecutionServiceException("The plugin doesn't exist");
182
		}
179 183
		pluginToInstallIndex = index;
180 184
	}
181 185

  
......
183 187
		return this.manager;
184 188
	}
185 189

  
186
	public void setPluginToInstall(String code) {
187
		pluginToInstallIndex = -1;
190
	public void setPluginToInstall(String code) throws InstallerCreationServiceException {
191
		int selectedCode = -1;
188 192
		for (int i=0 ; i<getPluginsSize() ; i++){
189 193
			if (installerInfos.get(i).getCode().equals(code)){
190
				pluginToInstallIndex = i;
194
				selectedCode = i;
195
				break;
191 196
			}
192 197
		}
198
		if (selectedCode == -1){
199
			throw new InstallerCreationServiceException("The plugin doesn't exist");		
200
		}
201
		pluginToInstallIndex = selectedCode;
193 202
	}
194 203

  
195 204
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/wizard/ProgressWizard.java
32 32
import javax.swing.JPanel;
33 33

  
34 34
import org.gvsig.installer.lib.api.InstallerInfo;
35
import org.gvsig.installer.lib.api.creation.InstallerCreationServiceException;
35 36
import org.gvsig.installer.lib.api.execution.InstallerExecutionService;
36 37
import org.gvsig.installer.lib.api.execution.InstallerExecutionServiceException;
37 38
import org.gvsig.installer.swing.impl.InstallerWizardPanel;
......
90 91
			setFinishedText();
91 92
		}catch(InstallerExecutionServiceException e){
92 93
			setExceptionText(e);
94
		} catch (InstallerCreationServiceException e) {
95
			setExceptionText(e);
93 96
		}	
94 97
		setProgress(100);
95 98
	}

Also available in: Unified diff