Revision 32333

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/InstallerLocator.java
32 32
import org.gvsig.tools.locator.LocatorException;
33 33

  
34 34
/**
35
 * This Locator provides the entry point for the gvSIG 
36
 * {@link InstallerManager}
37
 * @see Locator
35
 * This Locator provides the entry point for the gvSIG {@link InstallerManager}
36
 * 
37
 * @see {@link Locator}
38 38
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
39 39
 */
40 40
public class InstallerLocator extends AbstractLocator {
......
87 87
	 *            implementing the InstallerManager interface
88 88
	 */
89 89
	public static void registerInstallerManager(Class clazz) {
90
		
90 91
		getInstance().register(INSTALLER_MANAGER_NAME, 
91 92
				INSTALLER_MANAGER_DESCRIPTION,
92 93
				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
 * 
34 35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
35 36
 */
36 37
public class InstallerLibrary extends AbstractLibrary{
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
31 31
import java.io.InputStream;
32 32

  
33 33
import org.gvsig.installer.lib.api.InstallerInfo;
34
import org.gvsig.installer.lib.api.creation.InstallerCreationService;
34 35

  
35 36
/**
37
 * <p>
38
 * This service is used to execute an installer file and install the
39
 * plugins contained in it. It has methods to set the installer file,
40
 * to read the plugins that can be installed, to select the plugins
41
 * to install and to install them.  
42
 * </p>
43
 * <p>
44
 * The installer stream is a normally a file that has been created using
45
 * the {@link InstallerCreationService} service. It is possible to create
46
 * an installer manually, but it has to have the structure defined by the
47
 * {@link InstallerCreationService} class.
48
 * </p>
36 49
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
37 50
 */
38 51
public interface InstallerExecutionService {
39 52
	
53
	/**
54
	 * Sets the stream that contains the installer that contains the 
55
	 * information to install some plugins. This stream is a zip file
56
	 * that has to have the structure defined in the {@link InstallerCreationService}
57
	 * documentation.	 * 
58
	 * @param inputStream
59
	 * The stream that contains the installer information.
60
	 * @throws InstallerExecutionServiceException
61
	 * It is thrown if there is an exception reading the stream
62
	 */
40 63
	public void setInstaller(InputStream inputStream) throws InstallerExecutionServiceException;
41 64
	
65
	/**
66
	 * It 
67
	 * @param outputDirectory
68
	 * @throws InstallerExecutionServiceException
69
	 */
42 70
	public void executeInstaller(File outputDirectory) throws InstallerExecutionServiceException;
43 71
	
44 72
	public void selectPluginToInstall(int index);
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/InstallerCreationService.java
33 33
import org.gvsig.installer.lib.api.InstallerInfo;
34 34

  
35 35
/**
36
 * <p>
37
 * This service is used to create an installer for a gvSIG plugin. It 
38
 * supports just one plugin for every installer. It contains a method to
39
 * set the plugin path and some methods to set the installer information.
40
 * </p>
41
 * 
42
 * <p>
43
 * It has also methods to load the current installation information (if exists)
44
 * and methods to create the installer file from an {@link OutputStream}.
45
 * </p>
46
 * 
47
 * <p>
48
 * An installer is just a compressed zip file that has a compressed zip file
49
 * for every plugin to install. In this first version it only has a plugin, but
50
 * in a future it is possible to create installers with more that one plugin.
51
 * The structure of an installation file is:
52
 * </p>
53
 * <pre>
54
 * - installer.zip
55
 * 		- org.gvsig.myplugin-[version]-[build].zip
56
 * 			- org.gvsig.myplugin
57
 * 			  	- install.info
58
 *  			- install.xml
59
 *  			- files
60
 *  				- org.gvsig.otherplugin
61
 *  					- file1
62
 *  					- file2
63
 * </pre>
64
 * <p>
65
 * installer.zip is the installer file name that has a zip file that 
66
 * contains the plugin to install (org.gvsig.myplugin-[version]-[build].zip).
67
 * This second file has a root directory with the plugin content and with
68
 * some extra files with the installer information. These files are:
69
 * </p>
70
 *  
71
 * <lu>
72
 * <li><b>install.info</b>: file that contains the installer information</li>
73
 * <li><b>install.xml</b>: ant file that is executed in the execution of the installer
74
 * to do some extra actions in the installation process. One of these actions
75
 * is copy all the files located in the files directory</li>
76
 * <li><b>files directory</b>: it contains some files of other extensions that have
77
 * to be copied using the ant script.</li> 
78
 * </lu>
79
 *  
80
 * <p>
81
 * The usage of the ant script to copy files from other plugins is not recommended 
82
 * because it is possible that different installers overrides the same file. The 
83
 * suggestion it that one plugin has to have all the files that it needs to work
84
 * inside the plugin and it never has to override some external files. 
85
 * </p>
36 86
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
37 87
 */
38 88
public interface InstallerCreationService {
39 89
	
90
	/**
91
	 * It returns an instance of an {@link InstallerInfo} class, that is a 
92
	 * class that contains all the installer information (plugin name, plugin
93
	 * version...).
94
	 * @return
95
	 * The installer information.
96
	 */
40 97
	public InstallerInfo getInstallerInfo();
41 98
	
99
	/**
100
	 * It sets the directory where the plugin is located, that it has to
101
	 * be a valid gvSIG plugin directory. 	
102
	 * @param pluginDirectory
103
	 * The directory where the gvSIG plugin is located.
104
	 * @throws InstallerCreationServiceException
105
	 * This exception is thrown when the directory doesn't exist or the directory is
106
	 * not a valid gvSIG plugin directory.
107
	 */
42 108
	public void setPluginDirectory(File pluginDirectory) throws InstallerCreationServiceException;
43 109
	
110
	/**
111
	 * This method reads the install.info file and loads the installation information
112
	 * into the current installer creation process. It also reads the information to 
113
	 * copy some external files and add them to the current installer creation execution.
114
	 * @throws InstallerCreationServiceException
115
	 * This exception is thrown when the directory is not valid gvSIG plugin directory.
116
	 */
44 117
	public void loadInstallInfoFromDirectory() throws InstallerCreationServiceException;
45 118
	
119
	/**
120
	 * It creates the installer file and copy it in the stream received like
121
	 * an argument.
122
	 * @param installerStream
123
	 * The stream where the the installer is created
124
	 * @throws InstallerCreationServiceException
125
	 * It is thrown when there is an exception creating the installer.
126
	 */
46 127
	public void createInstaller(OutputStream installerStream) throws InstallerCreationServiceException;	
47 128

  
48 129
}
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/InstallerManager.java
33 33
import org.gvsig.installer.lib.api.execution.InstallerExecutionServiceException;
34 34

  
35 35
/**
36
 * <p>
37
 * This manager is used to register and create the services that are used
38
 * to manage the plugin installers. The services that offers are basically
39
 * two: the creation of installers service and the execution of installers
40
 * service.
41
 * </p>
42
 * 
36 43
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
37 44
 */
38 45
public interface InstallerManager {
39 46
	
40
//	public void registerInstallerInfoResource(Class clazz);
41
//	
42
//	public InstallerInfoResource createInstallerInfoResource() throws CreateInstallerInfoResourceException;
43
//	
44
//	public InstallerInfoResource readInstallerInfoResource(InputStream is) throws InstallerInfoFileException, CreateInstallerInfoResourceException;
45
//	
46
//	public void writeInstallerInfoResource(InstallerInfoResource installerInfoResource, OutputStream os) throws InstallerInfoFileException;
47
//	
48
//	public void compressPlugin(File directory, OutputStream os) throws CompressionPluginException;
49
//	
50
//	public void decompressPlugin(InputStream is, File directory) throws CompressionPluginException;
51
	
52
	
53
	
47
	/**
48
	 * It registers a class that implements the service for the creation of
49
	 * installers. It has to implement the {@link InstallerCreationService} interface.
50
	 * 
51
	 * @param clazz
52
	 * Class that implements the {@link InstallerCreationService} interface.
53
	 */
54
	@SuppressWarnings(value = "unchecked")
54 55
	public void registerInstallerCreationService(Class clazz);
55 56
	
57
	/**
58
	 * It creates and returns an object that is used to create an installer for
59
	 * a selected plugin. All the parameters are set using the {@link InstallerCreationService} 
60
	 * interface.
61
	 * 
62
	 * @return
63
	 * An object that is used to create a plugin installer 
64
	 * @throws InstallerCreationServiceException
65
	 * When there is a problem creating the service
66
	 */
56 67
	public InstallerCreationService getInstallerCreationService() throws InstallerCreationServiceException;
57 68
	
58
	
69
	/**
70
	 * It registers a class that implements the service for the execution of
71
	 * installers. It has to implement the {@link InstallerExecutionService} interface.
72
	 * 
73
	 * @param clazz
74
	 * Class that implements the {@link InstallerExecutionService} interface.
75
	 */
76
	@SuppressWarnings("unchecked")
59 77
	public void registerInstallerExecutionService(Class clazz);
60 78
	
79
	/**
80
	 * It creates and returns an object that is used to execute an installer for
81
	 * the installation of plugins in gvSIG. All the parameters are set using the
82
	 * {@link InstallerExecutionService} interface.
83
	 * 
84
	 * @return
85
	 * An object that is used to install the installer file 
86
	 * @throws InstallerExecutionServiceException
87
	 * When there is a problem creating the service
88
	 */
61 89
	public InstallerExecutionService getInstallerExecutionService() throws InstallerExecutionServiceException;
62
	
63
	
64 90
}
65 91

  
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
62 62
	public boolean isOfficial();
63 63
	
64 64
	public void setOfficial(boolean official);
65
	
66
	public boolean isAdvancedMode();
67
	
68
	public void setAdvancedMode(boolean isAdvancedMode);
69 65
		
70 66
	public void addFileToCopy(File file);
71 67
	
......
78 74
	public void setAnScript(String antScript);
79 75
	
80 76
	public String getAntScript();
77
	
78
	public String getType();
79
	
80
	public void setType(String type);
81 81

  
82 82
}
83 83

  
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/DefaultInstallerInfo.java
46 46
	protected boolean official;
47 47
	protected List<File> selectedFiles = null;
48 48
	protected String antScript = null;
49
	protected boolean isAdvancedMode;
50
	
49
	protected String type = null;
50

  
51 51
	public DefaultInstallerInfo() {
52 52
		super();
53 53
		selectedFiles = new ArrayList<File>();
......
133 133
		this.antScript = antScript;		
134 134
	}
135 135

  
136
	public boolean isAdvancedMode() {
137
		return isAdvancedMode;
136
	public String getType() {
137
		return type;
138 138
	}
139 139

  
140
	public void setAdvancedMode(boolean isAdvancedMode) {
141
		this.isAdvancedMode = isAdvancedMode;		
140
	public void setType(String type) {
141
		this.type = type;
142 142
	}
143

  
144 143
}
145 144

  
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/creation/DefaultInstallerCreationService.java
63 63
		//Write the install.info file
64 64
		writeInstallInfo();
65 65

  
66
		if (isAdvancedMode){
66
		//if (isAdvancedMode){
67 67
			//Create the ant file
68 68
			if (antScript != null){
69 69
				writeAntFile();
......
74 74
				}catch(IOException e){
75 75
					throw new InstallerCreationServiceException("Exception copying the ant file");
76 76
				}			
77
			}
77
			//}
78 78

  
79 79
			//Copy the selected files
80 80
			writeSelectedFiles();
......
249 249
		if (super.getAntScript() != null){
250 250
			return super.getAntScript();
251 251
		}
252
		if (isAdvancedMode){
252
		//if (isAdvancedMode){
253 253
			try {
254 254
				loadAntFile(new File(getClass().getClassLoader().getResource(ANT_FILE_NAME).getFile()));
255 255
				return antScript;
256 256
			} catch (IOException e) {
257 257
				logger.error("reading the ant script model", e);
258 258
			}
259
		}
259
		//}
260 260
		return null;
261 261
	}
262 262

  
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/info/InstallerInfoFileWriter.java
87 87
			properties.setProperty(InstallerInfoTags.VERSION, installInfo.getVersion());
88 88
			properties.setProperty(InstallerInfoTags.BUILD, new Integer(installInfo.getBuild()).toString());
89 89
			properties.setProperty(InstallerInfoTags.STATE, installInfo.getState());
90
			properties.setProperty(InstallerInfoTags.OFFCICIAL, new Boolean(installInfo.isOfficial()).toString());			
90
			properties.setProperty(InstallerInfoTags.OFFCICIAL, new Boolean(installInfo.isOfficial()).toString());		
91
			properties.setProperty(InstallerInfoTags.TYPE, installInfo.getType());
91 92
			properties.store(os, "");
92 93
			os.close();
93 94
		} catch (IOException e) {
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/info/InstallerInfoTags.java
37 37
	public static final String BUILD = "build";
38 38
	public static final String STATE = "state";
39 39
	public static final String OFFCICIAL = "oficial";
40
	public static final String TYPE = "type";
40 41
}
41 42

  
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/info/InstallerInfoFileReader.java
110 110
		installerInfoResource.setName(properties.getProperty(InstallerInfoTags.NAME));
111 111
		installerInfoResource.setDescription(properties.getProperty(InstallerInfoTags.DESCRIPCTION));
112 112
		installerInfoResource.setVersion(properties.getProperty(InstallerInfoTags.VERSION));
113
		installerInfoResource.setType(properties.getProperty(InstallerInfoTags.TYPE));
113 114
		String build = properties.getProperty(InstallerInfoTags.BUILD);
114 115
		try{
115 116
			installerInfoResource.setBuild(Integer.parseInt(properties.getProperty(InstallerInfoTags.BUILD)));
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/creation/wizard/AdvancedModeSelectionWizard.java
59 59

  
60 60
	public void nextPanel() {
61 61
		installerCreationWizard.setAdvancedModeSelected(isAdvancedModeSelected());	
62
		installerCreationWizard.getInstallerCreationService().getInstallerInfo().
63
			setAdvancedMode(isAdvancedModeSelected());
62
//		installerCreationWizard.getInstallerCreationService().getInstallerInfo().
63
//			setAdvancedMode(isAdvancedModeSelected());
64 64
	}
65 65

  
66 66
	public void updatePanel() {

Also available in: Unified diff