Revision 37822

View differences:

branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/extension/Version.java
21 21
 */
22 22
package org.gvsig.app.extension;
23 23

  
24
import java.io.File;
25 24
import java.util.StringTokenizer;
26 25

  
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

  
30
import org.gvsig.andami.Launcher;
31
import org.gvsig.andami.PluginsLocator;
32 26
import org.gvsig.app.ApplicationLocator;
33 27
import org.gvsig.installer.lib.api.InstallerLocator;
34 28
import org.gvsig.installer.lib.api.PackageInfo;
35 29
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
36 32

  
37 33
/**
38 34
 * gvSIG application version information.
......
73 69
    public Version() {
74 70
        String[] versions = new String[] { "2", "0", "0" };
75 71
        try {
76
        	File pluginsFolder = PluginsLocator.getManager().getPluginsFolder().getAbsoluteFile();
77 72
            MakePluginPackageService packageService =
78 73
                InstallerLocator.getInstallerManager()
79
                    .getMakePluginPackageService(pluginsFolder);
74
                    .getMakePluginPackageService();
80 75

  
81 76
            PackageInfo info =
82 77
                packageService.getPluginPackageInfo(APP_PACKAGE_CODE);
branches/v2_0_0_prep/extensions/org.gvsig.installer.app/org.gvsig.installer.app.extension/src/main/java/org/gvsig/installer/app/extension/execution/InstallPackageExtension.java
28 28
package org.gvsig.installer.app.extension.execution;
29 29

  
30 30
import java.io.BufferedReader;
31
import java.io.IOException;
32 31
import java.io.InputStream;
33 32
import java.io.InputStreamReader;
34 33
import java.net.MalformedURLException;
......
54 53
			.getLogger(InstallPackageExtension.class);
55 54

  
56 55
	public void execute(String actionCommand) {
57
		// int resp = JOptionPane.showConfirmDialog(
58
		// null,
59
		// Messages.getText("install_package_extension_warning"),
60
		// Messages.getText("select_an_option"),
61
		// JOptionPane.YES_NO_OPTION);
62
		// if (resp!=JOptionPane.OK_OPTION){
63
		// return;
64
		// }
65

  
66 56
		PluginsManager manager = PluginsLocator.getManager();
67 57
		try {
68 58
			PluginServices.getMDIManager().addCentredWindow(
69 59
					new InstallPackageWindow(manager.getApplicationFolder(),
70
							manager.getPluginsFolder().getAbsoluteFile(),
71 60
							manager.getInstallFolder()));
72 61
		} catch (Error e) {
73 62
			LOG.error("Error creating the wizard to install a package ", e);
branches/v2_0_0_prep/extensions/org.gvsig.installer.app/org.gvsig.installer.app.extension/src/main/java/org/gvsig/installer/app/extension/execution/InstallPackageWindow.java
47 47
 */
48 48
public class InstallPackageWindow extends JPanel implements IWindow {
49 49

  
50
    private static final long serialVersionUID = 4719868181091291809L;
51
    WindowInfo windowInfo = null;
50
	private static final long serialVersionUID = 4719868181091291809L;
51
	WindowInfo windowInfo = null;
52 52

  
53
    public InstallPackageWindow(File applicationFolder, File pluginsFolder,
54
        File installFolder) throws LocatorException,
55
        InstallPackageWizardException {
56
        super();
57
        AbstractInstallPackageWizard installPackageWizard =
58
            SwingInstallerLocator.getSwingInstallerManager()
59
                .createInstallPackageWizard(applicationFolder, pluginsFolder,
60
                    installFolder);
61
        installPackageWizard
62
            .setWizardActionListener(new WindowInstallerListener(this));
63
        this.setLayout(new BorderLayout());
64
        add(installPackageWizard, BorderLayout.CENTER);
65
    }
53
	public InstallPackageWindow(File applicationFolder, File installFolder)
54
			throws LocatorException, InstallPackageWizardException {
55
		super();
56
		AbstractInstallPackageWizard installPackageWizard = SwingInstallerLocator
57
				.getSwingInstallerManager().createInstallPackageWizard(
58
						applicationFolder, installFolder);
59
		installPackageWizard
60
				.setWizardActionListener(new WindowInstallerListener(this));
61
		this.setLayout(new BorderLayout());
62
		add(installPackageWizard, BorderLayout.CENTER);
63
	}
66 64

  
67
    public WindowInfo getWindowInfo() {
68
        if (windowInfo == null) {
69
            windowInfo =
70
                new WindowInfo(WindowInfo.MODELESSDIALOG
71
                    | WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE);
72
            Dimension dim = getPreferredSize();
73
            windowInfo.setWidth((int) dim.getWidth());
74
            windowInfo.setHeight((int) dim.getHeight());
75
            windowInfo.setTitle(Messages.getText("install_package"));
76
        }
77
        return windowInfo;
78
    }
65
	public WindowInfo getWindowInfo() {
66
		if (windowInfo == null) {
67
			windowInfo = new WindowInfo(WindowInfo.MODELESSDIALOG
68
					| WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE);
69
			Dimension dim = getPreferredSize();
70
			windowInfo.setWidth((int) dim.getWidth());
71
			windowInfo.setHeight((int) dim.getHeight());
72
			windowInfo.setTitle(Messages.getText("install_package"));
73
		}
74
		return windowInfo;
75
	}
79 76

  
80
    public Object getWindowProfile() {
81
        return WindowInfo.DIALOG_PROFILE;
82
    }
77
	public Object getWindowProfile() {
78
		return WindowInfo.DIALOG_PROFILE;
79
	}
83 80

  
84 81
}
branches/v2_0_0_prep/extensions/org.gvsig.installer.app/org.gvsig.installer.app.extension/src/main/java/org/gvsig/installer/app/extension/creation/MakePluginPackageExtension.java
43 43
 */
44 44
public class MakePluginPackageExtension extends Extension {
45 45

  
46
    private static final Logger LOG = LoggerFactory
47
        .getLogger(MakePluginPackageExtension.class);
46
	private static final Logger LOG = LoggerFactory
47
			.getLogger(MakePluginPackageExtension.class);
48 48

  
49
    public void execute(String actionCommand) {
50
        PluginsManager manager = PluginsLocator.getManager();
49
	public void execute(String actionCommand) {
50
		PluginsManager manager = PluginsLocator.getManager();
51 51

  
52
        try {
53
            PluginServices.getMDIManager().addCentredWindow(
54
                new MakePluginPackageWindow(manager.getApplicationFolder(),
55
                    manager.getPluginsFolder().getAbsoluteFile(), manager
56
                        .getInstallFolder()));
57
        } catch (Exception e) {
58
            LOG.error("Error creating teh wizard to create an installer ", e);
59
        }
60
    }
52
		try {
53
			PluginServices.getMDIManager().addCentredWindow(
54
					new MakePluginPackageWindow(manager.getApplicationFolder(),
55
							manager.getInstallFolder()));
56
		} catch (Exception e) {
57
			LOG.error("Error creating teh wizard to create an installer ", e);
58
		}
59
	}
61 60

  
62
    public void initialize() {
61
	public void initialize() {
63 62

  
64
    }
63
	}
65 64

  
66
    @Override
67
    public void postInitialize() {
68
        super.postInitialize();
69
        Version version = ApplicationLocator.getManager().getVersion();
70
        SwingInstallerLocator.getSwingInstallerManager().setApplicationVersion(
71
            version.getFormat());
72
    }
65
	@Override
66
	public void postInitialize() {
67
		super.postInitialize();
68
		Version version = ApplicationLocator.getManager().getVersion();
69
		SwingInstallerLocator.getSwingInstallerManager().setApplicationVersion(
70
				version.getFormat());
71
	}
73 72

  
74
    public boolean isEnabled() {
75
        return true;
76
    }
73
	public boolean isEnabled() {
74
		return true;
75
	}
77 76

  
78
    public boolean isVisible() {
79
        return true;
80
    }
77
	public boolean isVisible() {
78
		return true;
79
	}
81 80

  
82 81
}
branches/v2_0_0_prep/extensions/org.gvsig.installer.app/org.gvsig.installer.app.extension/src/main/java/org/gvsig/installer/app/extension/creation/MakePluginPackageWindow.java
47 47
 */
48 48
public class MakePluginPackageWindow extends JPanel implements IWindow {
49 49

  
50
    private static final long serialVersionUID = 3423389124323013058L;
51
    WindowInfo windowInfo = null;
50
	private static final long serialVersionUID = 3423389124323013058L;
51
	WindowInfo windowInfo = null;
52 52

  
53
    public MakePluginPackageWindow(File applicationFolder, File pluginsFolder,
54
        File installFolder) throws LocatorException,
55
        MakePluginPackageWizardException {
56
        super();
57
        MakePluginPackageWizard makePluginPackageWizard =
58
            SwingInstallerLocator.getSwingInstallerManager()
59
                .createMakePluginPackageWizard(applicationFolder,
60
                    pluginsFolder, installFolder);
61
        makePluginPackageWizard
62
            .setWizardActionListener(new WindowInstallerListener(this));
63
        this.setLayout(new BorderLayout());
64
        add(makePluginPackageWizard, BorderLayout.CENTER);
65
    }
53
	public MakePluginPackageWindow(File applicationFolder, File installFolder)
54
			throws LocatorException, MakePluginPackageWizardException {
55
		super();
56
		MakePluginPackageWizard makePluginPackageWizard = SwingInstallerLocator
57
				.getSwingInstallerManager().createMakePluginPackageWizard(
58
						applicationFolder, installFolder);
59
		makePluginPackageWizard
60
				.setWizardActionListener(new WindowInstallerListener(this));
61
		this.setLayout(new BorderLayout());
62
		add(makePluginPackageWizard, BorderLayout.CENTER);
63
	}
66 64

  
67
    public WindowInfo getWindowInfo() {
68
        if (windowInfo == null) {
69
            windowInfo =
70
                new WindowInfo(WindowInfo.MODELESSDIALOG
71
                    | WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE);
72
            Dimension dim = getPreferredSize();
73
            windowInfo.setWidth((int) dim.getWidth());
74
            windowInfo.setHeight((int) dim.getHeight());
75
            windowInfo.setTitle(Messages.getText("make_plugin_package"));
76
        }
77
        return windowInfo;
78
    }
65
	public WindowInfo getWindowInfo() {
66
		if (windowInfo == null) {
67
			windowInfo = new WindowInfo(WindowInfo.MODELESSDIALOG
68
					| WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE);
69
			Dimension dim = getPreferredSize();
70
			windowInfo.setWidth((int) dim.getWidth());
71
			windowInfo.setHeight((int) dim.getHeight());
72
			windowInfo.setTitle(Messages.getText("make_plugin_package"));
73
		}
74
		return windowInfo;
75
	}
79 76

  
80
    public Object getWindowProfile() {
81
        return WindowInfo.DIALOG_PROFILE;
82
    }
77
	public Object getWindowProfile() {
78
		return WindowInfo.DIALOG_PROFILE;
79
	}
83 80
}
branches/v2_0_0_prep/extensions/org.gvsig.installer.app/org.gvsig.installer.app.extension/src/main/java/org/gvsig/installer/app/extension/utils/WindowInstallerListener.java
37 37
 */
38 38
public class WindowInstallerListener implements InstallerWizardActionListener {
39 39

  
40
    private IWindow window = null;
40
	private IWindow window = null;
41 41

  
42
    public WindowInstallerListener(IWindow window) {
43
        super();
44
        this.window = window;
45
    }
42
	public WindowInstallerListener(IWindow window) {
43
		super();
44
		this.window = window;
45
	}
46 46

  
47
    public void closeWizard() {
48
        PluginServices.getMDIManager().closeWindow(window);
49
    }
47
	public void closeWizard() {
48
		PluginServices.getMDIManager().closeWindow(window);
49
	}
50 50

  
51
    public void cancel(InstallerWizardPanel installerWizard) {
52
        PluginServices.getMDIManager().closeWindow(window);
53
    }
51
	public void cancel(InstallerWizardPanel installerWizard) {
52
		PluginServices.getMDIManager().closeWindow(window);
53
	}
54 54

  
55
    public void finish(InstallerWizardPanel installerWizard) {
56
        PluginServices.getMDIManager().closeWindow(window);
57
    }
55
	public void finish(InstallerWizardPanel installerWizard) {
56
		PluginServices.getMDIManager().closeWindow(window);
57
	}
58 58

  
59 59
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/execution/InstallPackageWizardLauncher.java
40 40
 */
41 41
public class InstallPackageWizardLauncher extends DefaultLauncher {
42 42

  
43
    public static void main(String[] args) throws LocatorException,
44
        InstallPackageServiceException, InstallPackageWizardException,
45
        IOException {
46
        new DefaultLibrariesInitializer().fullInitialize();
47
        new InstallPackageWizardLauncher();
48
    }
43
	public static void main(String[] args) throws LocatorException,
44
			InstallPackageServiceException, InstallPackageWizardException,
45
			IOException {
46
		new DefaultLibrariesInitializer().fullInitialize();
47
		new InstallPackageWizardLauncher();
48
	}
49 49

  
50
    public InstallPackageWizardLauncher() throws LocatorException,
51
        InstallPackageWizardException, InstallPackageServiceException,
52
        IOException {
50
	public InstallPackageWizardLauncher() throws LocatorException,
51
			InstallPackageWizardException, InstallPackageServiceException,
52
			IOException {
53 53

  
54
        InstallPackageServiceFrame frame =
55
            new InstallPackageServiceFrame(getApplicationFolder(),
56
                getPluginsFolder(), getInstallFolder());
57
        frame.setVisible(true);
58
    }
54
		InstallPackageServiceFrame frame = new InstallPackageServiceFrame(
55
				getApplicationFolder(), getInstallFolder());
56
		frame.setVisible(true);
57
	}
59 58
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/execution/InstallPackageServiceFrame.java
43 43
 */
44 44
public class InstallPackageServiceFrame extends JFrame {
45 45

  
46
    private static final long serialVersionUID = -5107758157530922356L;
47
    private AbstractInstallPackageWizard installerExecutionWizard;
46
	private static final long serialVersionUID = -5107758157530922356L;
47
	private AbstractInstallPackageWizard installerExecutionWizard;
48 48

  
49
    public InstallPackageServiceFrame(File applicationFolder,
50
        File pluginsFolder, File installFolder) throws LocatorException,
51
        InstallPackageWizardException {
52
        super();
53
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
54
        installerExecutionWizard =
55
            SwingInstallerLocator.getSwingInstallerManager()
56
                .createInstallPackageWizard(applicationFolder, pluginsFolder,
57
                    installFolder);
58
        installerExecutionWizard
59
            .setWizardActionListener(new FrameWizardListener(this));
60
        this.add(installerExecutionWizard);
61
        pack();
62
    }
49
	public InstallPackageServiceFrame(File applicationFolder, File installFolder)
50
			throws LocatorException, InstallPackageWizardException {
51
		super();
52
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
53
		installerExecutionWizard = SwingInstallerLocator
54
				.getSwingInstallerManager().createInstallPackageWizard(
55
						applicationFolder, installFolder);
56
		installerExecutionWizard
57
				.setWizardActionListener(new FrameWizardListener(this));
58
		this.add(installerExecutionWizard);
59
		pack();
60
	}
63 61

  
64
    public void installFromDefaultDirectory()
65
        throws InstallPackageServiceException {
66
        installerExecutionWizard.installFromDefaultDirectory();
67
    }
62
	public void installFromDefaultDirectory()
63
			throws InstallPackageServiceException {
64
		installerExecutionWizard.installFromDefaultDirectory();
65
	}
68 66

  
69 67
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/execution/InstallPackageWizardFromDefaultDirectoryLauncher.java
39 39
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
40 40
 */
41 41
public class InstallPackageWizardFromDefaultDirectoryLauncher extends
42
    DefaultLauncher {
42
		DefaultLauncher {
43 43

  
44
    public static void main(String[] args) throws LocatorException,
45
        InstallPackageServiceException, InstallPackageWizardException,
46
        IOException {
47
        new DefaultLibrariesInitializer().fullInitialize();
48
        new InstallPackageWizardFromDefaultDirectoryLauncher();
49
    }
44
	public static void main(String[] args) throws LocatorException,
45
			InstallPackageServiceException, InstallPackageWizardException,
46
			IOException {
47
		new DefaultLibrariesInitializer().fullInitialize();
48
		new InstallPackageWizardFromDefaultDirectoryLauncher();
49
	}
50 50

  
51
    public InstallPackageWizardFromDefaultDirectoryLauncher()
52
        throws LocatorException, InstallPackageWizardException,
53
        InstallPackageServiceException, IOException {
51
	public InstallPackageWizardFromDefaultDirectoryLauncher()
52
			throws LocatorException, InstallPackageWizardException,
53
			InstallPackageServiceException, IOException {
54 54

  
55
        InstallPackageServiceFrame frame =
56
            new InstallPackageServiceFrame(getApplicationFolder(),
57
                getPluginsFolder(), getInstallFolder());
58
        frame.installFromDefaultDirectory();
59
        frame.setVisible(true);
60
    }
55
		InstallPackageServiceFrame frame = new InstallPackageServiceFrame(
56
				getApplicationFolder(), getInstallFolder());
57
		frame.installFromDefaultDirectory();
58
		frame.setVisible(true);
59
	}
61 60
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/creation/MakePluginPackageWizardLauncher.java
40 40
 */
41 41
public class MakePluginPackageWizardLauncher extends DefaultLauncher {
42 42

  
43
    public static void main(String[] args) throws LocatorException,
44
        MakePluginPackageWizardException, IOException,
45
        MakePluginPackageServiceException {
46
        new DefaultLibrariesInitializer().fullInitialize();
47
        new MakePluginPackageWizardLauncher();
48
    }
43
	public static void main(String[] args) throws LocatorException,
44
			MakePluginPackageWizardException, IOException,
45
			MakePluginPackageServiceException {
46
		new DefaultLibrariesInitializer().fullInitialize();
47
		new MakePluginPackageWizardLauncher();
48
	}
49 49

  
50
    public MakePluginPackageWizardLauncher() throws LocatorException,
51
        MakePluginPackageWizardException, IOException,
52
        MakePluginPackageServiceException {
50
	public MakePluginPackageWizardLauncher() throws LocatorException,
51
			MakePluginPackageWizardException, IOException,
52
			MakePluginPackageServiceException {
53 53

  
54
        MakePluginPackageFrame frame =
55
            new MakePluginPackageFrame(getApplicationFolder(),
56
                getPluginsFolder(), getInstallFolder());
57
        frame.setVisible(true);
58
    }
54
		MakePluginPackageFrame frame = new MakePluginPackageFrame(
55
				getApplicationFolder(), getInstallFolder());
56
		frame.setVisible(true);
57
	}
59 58

  
60 59
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/creation/MakePluginPackageFrame.java
42 42
 */
43 43
public class MakePluginPackageFrame extends JFrame {
44 44

  
45
    private static final long serialVersionUID = 4144834319158286247L;
46
    private MakePluginPackageWizard installerCreationWizard;
45
	private static final long serialVersionUID = 4144834319158286247L;
46
	private MakePluginPackageWizard installerCreationWizard;
47 47

  
48
    public MakePluginPackageFrame(File applicationFolder, File pluginsFolder,
49
        File installFolder) throws LocatorException,
50
        MakePluginPackageWizardException {
51
        super();
52
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
53
        installerCreationWizard =
54
            SwingInstallerLocator.getSwingInstallerManager()
55
                .createMakePluginPackageWizard(applicationFolder,
56
                    pluginsFolder, installFolder);
57
        installerCreationWizard
58
            .setWizardActionListener(new FrameWizardListener(this));
59
        this.add(installerCreationWizard);
60
        pack();
61
    }
48
	public MakePluginPackageFrame(File applicationFolder, File installFolder)
49
			throws LocatorException, MakePluginPackageWizardException {
50
		super();
51
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
52
		installerCreationWizard = SwingInstallerLocator
53
				.getSwingInstallerManager().createMakePluginPackageWizard(
54
						applicationFolder, installFolder);
55
		installerCreationWizard
56
				.setWizardActionListener(new FrameWizardListener(this));
57
		this.add(installerCreationWizard);
58
		pack();
59
	}
62 60

  
63 61
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/DefaultLauncher.java
39 39
 */
40 40
public class DefaultLauncher {
41 41

  
42
    private File appFolder;
42
	private File appFolder;
43 43

  
44
    public File getApplicationFolder() throws IOException {
45
        if (appFolder == null) {
46
            File templateFile =
47
                new File(getClass().getClassLoader().getResource("application")
48
                    .getFile());
49
            appFolder =
50
                new File(System.getProperty("java.io.tmpdir") + File.separator
51
                    + "tmp_gvsig_installer");
44
	public File getApplicationFolder() throws IOException {
45
		if (appFolder == null) {
46
			File templateFile = new File(getClass().getClassLoader()
47
					.getResource("application").getFile());
48
			appFolder = new File(System.getProperty("java.io.tmpdir")
49
					+ File.separator + "tmp_gvsig_installer");
52 50

  
53
            copy(templateFile, appFolder);
54
        }
51
			copy(templateFile, appFolder);
52
		}
55 53

  
56
        return appFolder;
57
    }
54
		return appFolder;
55
	}
58 56

  
59
    public File getPluginsFolder() throws IOException {
60
        return new File(appFolder, "plugins");
61
    }
57
	public File getPluginsFolder() throws IOException {
58
		return new File(appFolder, "plugins");
59
	}
62 60

  
63
    public File getInstallFolder() throws IOException {
64
        return new File(appFolder, "install");
65
    }
61
	public File getInstallFolder() throws IOException {
62
		return new File(appFolder, "install");
63
	}
66 64

  
67
    public void copy(File sourceLocation, File targetLocation)
68
        throws IOException {
69
        if (sourceLocation.isDirectory()) {
70
            if (!targetLocation.exists()) {
71
                targetLocation.mkdir();
72
            }
65
	public void copy(File sourceLocation, File targetLocation)
66
			throws IOException {
67
		if (sourceLocation.isDirectory()) {
68
			if (!targetLocation.exists()) {
69
				targetLocation.mkdir();
70
			}
73 71

  
74
            String[] children = sourceLocation.list();
75
            for (int i = 0; i < children.length; i++) {
76
                copy(new File(sourceLocation, children[i]), new File(
77
                    targetLocation, children[i]));
78
            }
79
        } else {
80
            targetLocation.getParentFile().mkdirs();
72
			String[] children = sourceLocation.list();
73
			for (int i = 0; i < children.length; i++) {
74
				copy(new File(sourceLocation, children[i]), new File(
75
						targetLocation, children[i]));
76
			}
77
		} else {
78
			targetLocation.getParentFile().mkdirs();
81 79

  
82
            InputStream in = new FileInputStream(sourceLocation);
83
            OutputStream out = new FileOutputStream(targetLocation);
80
			InputStream in = new FileInputStream(sourceLocation);
81
			OutputStream out = new FileOutputStream(targetLocation);
84 82

  
85
            // Copy the bits from instream to outstream
86
            byte[] buf = new byte[1024];
87
            int len;
88
            while ((len = in.read(buf)) > 0) {
89
                out.write(buf, 0, len);
90
            }
91
            in.close();
92
            out.close();
93
        }
94
    }
83
			// Copy the bits from instream to outstream
84
			byte[] buf = new byte[1024];
85
			int len;
86
			while ((len = in.read(buf)) > 0) {
87
				out.write(buf, 0, len);
88
			}
89
			in.close();
90
			out.close();
91
		}
92
	}
95 93
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/utils/FrameWizardListener.java
37 37
 */
38 38
public class FrameWizardListener implements InstallerWizardActionListener {
39 39

  
40
    private JFrame frame = null;
40
	private JFrame frame = null;
41 41

  
42
    public FrameWizardListener(JFrame frame) {
43
        super();
44
        this.frame = frame;
45
    }
42
	public FrameWizardListener(JFrame frame) {
43
		super();
44
		this.frame = frame;
45
	}
46 46

  
47
    public void cancel(InstallerWizardPanel installerWizard) {
48
        frame.setVisible(false);
49
        System.exit(0);
47
	public void cancel(InstallerWizardPanel installerWizard) {
48
		frame.setVisible(false);
49
		System.exit(0);
50 50

  
51
    }
51
	}
52 52

  
53
    public void finish(InstallerWizardPanel installerWizard) {
54
        frame.setVisible(false);
55
        System.exit(0);
56
    }
53
	public void finish(InstallerWizardPanel installerWizard) {
54
		frame.setVisible(false);
55
		System.exit(0);
56
	}
57 57

  
58 58
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/utils/CreateBoundleFrame.java
47 47
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
48 48
 */
49 49
public class CreateBoundleFrame extends JFrame implements WindowListener,
50
    ActionListener {
50
		ActionListener {
51 51

  
52
    /**
52
	/**
53 53
     * 
54 54
     */
55
    private static final long serialVersionUID = -2128261599641241144L;
56
    private javax.swing.JButton executeButton;
57
    private javax.swing.JLabel inputLabel;
58
    private FileTextField inputText;
59
    private javax.swing.JLabel jLabel2;
60
    private FileTextField outputText;
55
	private static final long serialVersionUID = -2128261599641241144L;
56
	private javax.swing.JButton executeButton;
57
	private javax.swing.JLabel inputLabel;
58
	private FileTextField inputText;
59
	private javax.swing.JLabel jLabel2;
60
	private FileTextField outputText;
61 61

  
62
    public CreateBoundleFrame() throws HeadlessException {
63
        super();
64
        initializeComponents();
65
        this.addWindowListener(this);
66
        executeButton.addActionListener(this);
67
    }
62
	public CreateBoundleFrame() throws HeadlessException {
63
		super();
64
		initializeComponents();
65
		this.addWindowListener(this);
66
		executeButton.addActionListener(this);
67
	}
68 68

  
69
    private void initializeComponents() {
70
        java.awt.GridBagConstraints gridBagConstraints;
69
	private void initializeComponents() {
70
		java.awt.GridBagConstraints gridBagConstraints;
71 71

  
72
        inputLabel = new javax.swing.JLabel();
73
        executeButton = new javax.swing.JButton();
74
        inputText = new FileTextField();
75
        outputText = new FileTextField();
76
        jLabel2 = new javax.swing.JLabel();
72
		inputLabel = new javax.swing.JLabel();
73
		executeButton = new javax.swing.JButton();
74
		inputText = new FileTextField();
75
		outputText = new FileTextField();
76
		jLabel2 = new javax.swing.JLabel();
77 77

  
78
        setLayout(new java.awt.GridBagLayout());
78
		setLayout(new java.awt.GridBagLayout());
79 79

  
80
        inputLabel.setText("Input directory");
81
        gridBagConstraints = new java.awt.GridBagConstraints();
82
        gridBagConstraints.gridx = 0;
83
        gridBagConstraints.gridy = 0;
84
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
85
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
86
        add(inputLabel, gridBagConstraints);
80
		inputLabel.setText("Input directory");
81
		gridBagConstraints = new java.awt.GridBagConstraints();
82
		gridBagConstraints.gridx = 0;
83
		gridBagConstraints.gridy = 0;
84
		gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
85
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
86
		add(inputLabel, gridBagConstraints);
87 87

  
88
        executeButton.setText("Execute");
89
        gridBagConstraints = new java.awt.GridBagConstraints();
90
        gridBagConstraints.gridx = 1;
91
        gridBagConstraints.gridy = 2;
92
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
93
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
94
        add(executeButton, gridBagConstraints);
88
		executeButton.setText("Execute");
89
		gridBagConstraints = new java.awt.GridBagConstraints();
90
		gridBagConstraints.gridx = 1;
91
		gridBagConstraints.gridy = 2;
92
		gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
93
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
94
		add(executeButton, gridBagConstraints);
95 95

  
96
        gridBagConstraints = new java.awt.GridBagConstraints();
97
        gridBagConstraints.gridx = 1;
98
        gridBagConstraints.gridy = 0;
99
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
100
        gridBagConstraints.ipadx = 67;
101
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
102
        gridBagConstraints.weightx = 1.0;
103
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
104
        add(inputText, gridBagConstraints);
96
		gridBagConstraints = new java.awt.GridBagConstraints();
97
		gridBagConstraints.gridx = 1;
98
		gridBagConstraints.gridy = 0;
99
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
100
		gridBagConstraints.ipadx = 67;
101
		gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
102
		gridBagConstraints.weightx = 1.0;
103
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
104
		add(inputText, gridBagConstraints);
105 105

  
106
        gridBagConstraints = new java.awt.GridBagConstraints();
107
        gridBagConstraints.gridx = 1;
108
        gridBagConstraints.gridy = 1;
109
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
110
        gridBagConstraints.ipadx = 67;
111
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
112
        gridBagConstraints.weightx = 1.0;
113
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
114
        add(outputText, gridBagConstraints);
106
		gridBagConstraints = new java.awt.GridBagConstraints();
107
		gridBagConstraints.gridx = 1;
108
		gridBagConstraints.gridy = 1;
109
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
110
		gridBagConstraints.ipadx = 67;
111
		gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
112
		gridBagConstraints.weightx = 1.0;
113
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
114
		add(outputText, gridBagConstraints);
115 115

  
116
        jLabel2.setText("Output");
117
        gridBagConstraints = new java.awt.GridBagConstraints();
118
        gridBagConstraints.gridx = 0;
119
        gridBagConstraints.gridy = 1;
120
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
121
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
122
        add(jLabel2, gridBagConstraints);
116
		jLabel2.setText("Output");
117
		gridBagConstraints = new java.awt.GridBagConstraints();
118
		gridBagConstraints.gridx = 0;
119
		gridBagConstraints.gridy = 1;
120
		gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
121
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
122
		add(jLabel2, gridBagConstraints);
123 123

  
124
    }
124
	}
125 125

  
126
    public void windowActivated(WindowEvent arg0) {
127
        // TODO Auto-generated method stub
126
	public void windowActivated(WindowEvent arg0) {
127
		// TODO Auto-generated method stub
128 128

  
129
    }
129
	}
130 130

  
131
    public void windowClosed(WindowEvent arg0) {
132
        System.exit(0);
131
	public void windowClosed(WindowEvent arg0) {
132
		System.exit(0);
133 133

  
134
    }
134
	}
135 135

  
136
    public void windowClosing(WindowEvent arg0) {
137
        // TODO Auto-generated method stub
136
	public void windowClosing(WindowEvent arg0) {
137
		// TODO Auto-generated method stub
138 138

  
139
    }
139
	}
140 140

  
141
    public void windowDeactivated(WindowEvent arg0) {
142
        // TODO Auto-generated method stub
141
	public void windowDeactivated(WindowEvent arg0) {
142
		// TODO Auto-generated method stub
143 143

  
144
    }
144
	}
145 145

  
146
    public void windowDeiconified(WindowEvent arg0) {
147
        // TODO Auto-generated method stub
146
	public void windowDeiconified(WindowEvent arg0) {
147
		// TODO Auto-generated method stub
148 148

  
149
    }
149
	}
150 150

  
151
    public void windowIconified(WindowEvent arg0) {
152
        // TODO Auto-generated method stub
151
	public void windowIconified(WindowEvent arg0) {
152
		// TODO Auto-generated method stub
153 153

  
154
    }
154
	}
155 155

  
156
    public void windowOpened(WindowEvent arg0) {
157
        // TODO Auto-generated method stub
156
	public void windowOpened(WindowEvent arg0) {
157
		// TODO Auto-generated method stub
158 158

  
159
    }
159
	}
160 160

  
161
    public void actionPerformed(ActionEvent arg0) {
162
        File inputDirectory = inputText.getSelectedFile();
163
        File outputFile = outputText.getSelectedFile();
161
	public void actionPerformed(ActionEvent arg0) {
162
		File inputDirectory = inputText.getSelectedFile();
163
		File outputFile = outputText.getSelectedFile();
164 164

  
165
        if (!inputDirectory.exists()) {
166
            JOptionPane
167
                .showMessageDialog(this, "Input directory doesn't exist");
168
            return;
169
        }
165
		if (!inputDirectory.exists()) {
166
			JOptionPane
167
					.showMessageDialog(this, "Input directory doesn't exist");
168
			return;
169
		}
170 170

  
171
        if (outputFile.exists()) {
172
            outputFile.delete();
173
        }
171
		if (outputFile.exists()) {
172
			outputFile.delete();
173
		}
174 174

  
175
        Compress compress = new Compress();
176
        try {
177
            File[] files = inputDirectory.listFiles();
178
            List<File> filesArray = new ArrayList<File>();
179
            List<String> fileNamesArray = new ArrayList<String>();
180
            for (int i = 0; i < files.length; i++) {
181
                if (!files[i].getName().toUpperCase().equals(".SVN")) {
182
                    filesArray.add(files[i]);
183
                    fileNamesArray.add(files[i].getName());
184
                }
185
            }
186
            compress.compressPluginsAsPackageSet(filesArray, fileNamesArray,
187
                new FileOutputStream(outputFile));
188
        } catch (Exception e) {
189
            JOptionPane.showMessageDialog(this, e.toString());
190
        }
191
    }
175
		Compress compress = new Compress();
176
		try {
177
			File[] files = inputDirectory.listFiles();
178
			List<File> filesArray = new ArrayList<File>();
179
			List<String> fileNamesArray = new ArrayList<String>();
180
			for (int i = 0; i < files.length; i++) {
181
				if (!files[i].getName().toUpperCase().equals(".SVN")) {
182
					filesArray.add(files[i]);
183
					fileNamesArray.add(files[i].getName());
184
				}
185
			}
186
			compress.compressPluginsAsPackageSet(filesArray, fileNamesArray,
187
					new FileOutputStream(outputFile));
188
		} catch (Exception e) {
189
			JOptionPane.showMessageDialog(this, e.toString());
190
		}
191
	}
192 192
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/utils/CreateBundleLauncher.java
32 32
 */
33 33
public class CreateBundleLauncher {
34 34

  
35
    public static void main(String[] args) {
36
        new CreateBundleLauncher();
37
    }
35
	public static void main(String[] args) {
36
		new CreateBundleLauncher();
37
	}
38 38

  
39
    public CreateBundleLauncher() {
40
        super();
41
        CreateBoundleFrame createBoundleFrame = new CreateBoundleFrame();
42
        createBoundleFrame.setBounds(0, 0, 500, 150);
43
        createBoundleFrame.setVisible(true);
44
    }
39
	public CreateBundleLauncher() {
40
		super();
41
		CreateBoundleFrame createBoundleFrame = new CreateBoundleFrame();
42
		createBoundleFrame.setBounds(0, 0, 500, 150);
43
		createBoundleFrame.setVisible(true);
44
	}
45 45

  
46 46
}
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/MakePluginPackageService.java
89 89
public interface MakePluginPackageService extends Service {
90 90

  
91 91
	/**
92
	 * @return the directory when the gvSIG plugins are located.
93
	 */
94
	public File getPluginsDirectory();
95

  
96
	/**
97 92
	 * It creates a package set with a single plugin package inside.
98 93
	 * 
99 94
	 * @param packageInfo
......
129 124
	 * the ant build file and the additional external files to be included in
130 125
	 * the package.
131 126
	 * 
132
	 * @param packageInfo
133
	 *            the information of the plugin that has to be included in the
134
	 *            package
127
	 * @param newPackageInfo
128
	 *            the information of the new plugin.
129
	 * @param originalPackageInfo
130
	 *            the information of the original plugin.
135 131
	 * @throws MakePluginPackageServiceException
136 132
	 *             it is thrown when there is an exception preparing the package
137 133
	 */
138
	public void preparePackage(PackageInfo packageInfo)
134
	public void preparePackage(PackageInfo packageInfo,
135
			File originalPackageFolder)
139 136
			throws MakePluginPackageServiceException;
140 137

  
141 138
	/**
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/PackageInfo.java
246 246
	 *            the package owner
247 247
	 */
248 248
	public void setOwner(String owner);
249
	
249

  
250 250
	/**
251 251
	 * Returns the owner's url {@link URL}.
252 252
	 * 
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
30 30
import java.io.File;
31 31
import java.net.URL;
32 32
import java.text.MessageFormat;
33
import java.util.List;
33 34

  
34 35
import org.gvsig.installer.lib.api.creation.MakePackageService;
35 36
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
......
166 167
	public void registerMakePluginPackageService(
167 168
			Class<? extends MakePluginPackageService> clazz);
168 169

  
170
	// /**
171
	// * It creates and returns an object that is used to create a bundle that
172
	// * contains inside a package of type plugin. All the parameters are set
173
	// * using the {@link MakePluginPackageService} interface. *
174
	// *
175
	// * @return an object that is used to create a plugin installer
176
	// * @throws MakePluginPackageServiceException
177
	// * when there is a problem creating the service
178
	// */
179
	// public MakePluginPackageService getMakePluginPackageService(
180
	// File pluginsDirectory) throws MakePluginPackageServiceException;
181

  
169 182
	/**
170 183
	 * It creates and returns an object that is used to create a bundle that
171 184
	 * contains inside a package of type plugin. All the parameters are set
......
173 186
	 * 
174 187
	 * @return an object that is used to create a plugin installer
175 188
	 * @throws MakePluginPackageServiceException
189
	 * @throws MakePluginPackageServiceException
176 190
	 *             when there is a problem creating the service
177 191
	 */
178
	public MakePluginPackageService getMakePluginPackageService(
179
			File pluginsDirectory) throws MakePluginPackageServiceException;
192
	public MakePluginPackageService getMakePluginPackageService()
193
			throws MakePluginPackageServiceException;
180 194

  
181 195
	/**
182 196
	 * Returns a list of package infos for the already installed plugins.
......
192 206
			throws MakePluginPackageServiceException;
193 207

  
194 208
	/**
209
	 * Returns a list of package infos for the already installed plugins.
210
	 * 
211
	 * @return the list of package infos for the already installed plugins
212
	 * @throws MakePluginPackageServiceException
213
	 *             if there is an error loading the information of the installed
214
	 *             plugins
215
	 */
216
	public PackageInfo[] getInstalledPackages()
217
			throws MakePluginPackageServiceException;
218

  
219
	/**
195 220
	 * Returns the package bundle file name format.
196 221
	 * <p>
197 222
	 * The string has to use a suitable {@link MessageFormat} format, and the
......
345 370

  
346 371
	public String getVersion();
347 372

  
373
	/**
374
	 * Gets a List of all the folders where there might be addons folders
375
	 * (addons repositories).
376
	 * 
377
	 * @return list of repositories paths
378
	 */
379
	public List<File> getAddonRepositories();
380

  
381
	/**
382
	 * Adds an addon repository path to the manager list.
383
	 * 
384
	 * @param path
385
	 *            of the repository
386
	 */
387
	public void addAddonRepository(File path);
388

  
389
	/**
390
	 * Gets a List of all the addon folders. An addon folder is a folder inside
391
	 * any addon repository with a package.info file inside. (addons
392
	 * repositories).
393
	 * 
394
	 * @return list of addon paths folders.
395
	 */
396
	public List<File> getAddonFolders();
397

  
398
	/**
399
	 * Gets the folder of the addon with the code provided, or null if not
400
	 * found.
401
	 * 
402
	 * @param code
403
	 *            of the addon
404
	 * 
405
	 * @return File of the folder of the addon.
406
	 */
407
	public File getAddonFolder(String code);
408

  
409
	public void setDefaultAddonRepository(File defaultAddonsRepository);
410
	
411
	public File getDefaultAddonRepository();
412

  
348 413
}
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/DefaultInstallerProviderServices.java
140 140
	private void writePackageInfoFile(File directory, String fileName,
141 141
			PackageInfo installerInfo) throws InstallerInfoFileException {
142 142
		if (!directory.exists()) {
143
			throw new InstallerInfoFileException("The directory doesn't exist");
143
			// throw new
144
			// InstallerInfoFileException("The directory doesn't exist");
145
			directory.mkdir();
144 146
		}
145 147
		InstallerInfoFileWriter installerInfoFileWriter = new InstallerInfoFileWriter();
146 148
		installerInfoFileWriter.write(installerInfo, directory + File.separator
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/DefaultMakePluginPackageService.java
40 40
import java.net.URL;
41 41
import java.net.URLConnection;
42 42
import java.util.ArrayList;
43
import java.util.HashMap;
44 43
import java.util.List;
45
import java.util.Map;
46 44

  
47
import org.slf4j.Logger;
48
import org.slf4j.LoggerFactory;
49

  
50 45
import org.gvsig.installer.lib.api.InstallerManager;
51 46
import org.gvsig.installer.lib.api.PackageInfo;
52 47
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
......
56 51
import org.gvsig.installer.lib.spi.InstallPackageProviderServices;
57 52
import org.gvsig.installer.lib.spi.InstallerProviderLocator;
58 53
import org.gvsig.tools.service.Manager;
54
import org.slf4j.Logger;
55
import org.slf4j.LoggerFactory;
59 56

  
60 57
/**
61 58
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
......
68 65

  
69 66
	public static final String ANT_FILE_NAME = "install.xml";
70 67
	public static final String COPIED_FILES_DIRECTORY_NAME = "files";
71
	private File pluginsDirectory;
72 68
	private static final Logger logger = org.slf4j.LoggerFactory
73 69
			.getLogger(DefaultMakePluginPackageService.class);
74 70
	private final InstallerManager manager;
71
	private File tempDir;
75 72

  
76 73
	private List<PackageInfo> installerInfos = null;
77
	private Map<PackageInfo, String> directories = null;
78 74

  
79 75
	protected String antScript = null;
80 76
	private InstallPackageProviderServices installerProviderServices = null;
81 77

  
82
	public DefaultMakePluginPackageService(InstallerManager manager,
83
			File pluginsDirectory) throws MakePluginPackageServiceException {
78
	public DefaultMakePluginPackageService(InstallerManager manager)
79
			throws MakePluginPackageServiceException {
84 80
		super();
85 81
		this.manager = manager;
86
		installerInfos = new ArrayList<PackageInfo>();
87
		directories = new HashMap<PackageInfo, String>();
88
		installerProviderServices = InstallerProviderLocator
82
		this.installerInfos = new ArrayList<PackageInfo>();
83
		this.installerProviderServices = InstallerProviderLocator
89 84
				.getProviderManager().createInstallerProviderServices();
90
		initialize(pluginsDirectory);
85
		initialize();
91 86
	}
92 87

  
93
	private void initialize(File pluginsDirectory)
94
			throws MakePluginPackageServiceException {
95
		if (!pluginsDirectory.exists()) {
96
			pluginsDirectory.mkdirs();
97
			LOG.info("Plugins folder created: {}", pluginsDirectory);
98
		} else if (!pluginsDirectory.isDirectory()) {
88
	private void initialize() throws MakePluginPackageServiceException {
89

  
90
		List<File> addonFolders = manager.getAddonFolders();
91

  
92
		if (addonFolders == null) {
99 93
			throw new MakePluginPackageServiceException(
100
					"The plugins directory exists and not is a directory");
94
					"The addonFolders list is null");
101 95
		}
96
		// else if (addonFolders.size() <= 0) {
97
		// LOG.info("The addonFolders list is empty");
98
		// }
99
		else {
100
			// Read all the installed plugins
101
			for (int i = 0; i < addonFolders.size(); i++) {
102
				File pluginDirectoryFile = addonFolders.get(i);
102 103

  
103
		this.pluginsDirectory = pluginsDirectory;
104
				if (!pluginDirectoryFile.exists()) {
105
					pluginDirectoryFile.mkdirs();
106
					LOG.info("Plugins folder created: {}", pluginDirectoryFile);
107
				}
104 108

  
105
		// Read all the installed plugins
106
		String[] plugins = pluginsDirectory.list();
107

  
108
		if (plugins != null) {
109
			for (int i = 0; i < plugins.length; i++) {
110
				String pluginDirectoryName = plugins[i];
111
				File pluginDirectoryFile = getAbsolutePluginPackageDirectory(pluginDirectoryName);
112 109
				DefaultPackageInfo packageInfo = new DefaultPackageInfo();
113 110

  
114 111
				installerProviderServices.readPackageInfo(new File(
......
133 130
				}
134 131

  
135 132
				installerInfos.add(packageInfo);
136
				directories.put(packageInfo, pluginDirectoryName);
137 133
			}
138 134
		}
139 135
	}
......
152 148
					filesDirectory.getAbsolutePath().length(),
153 149
					file.getAbsolutePath().length());
154 150

  
155
			// Adding the root directory
156
			File pluginFile = new File(pluginsDirectory.getParentFile()
157
					.getParentFile().getAbsolutePath()
151
			File pluginFile = new File(System.getProperty("user.dir")
158 152
					+ pluginFileName);
159 153

  
160 154
			packageInfo.getFilesToCopy().add(pluginFile);
......
174 168
				packageStream);
175 169
	}
176 170

  
177
	public void preparePackage(PackageInfo packageInfo)
171
	public void preparePackage(PackageInfo packageInfo, File originalPluginDir)
178 172
			throws MakePluginPackageServiceException {
179 173

  
180 174
		LOG.debug("Preparing a package set of the package info: \n{0}",
181 175
				packageInfo);
176

  
177
		tempDir = new File(manager.getDefaultAddonRepository()
178
				.getAbsolutePath()
179
				+ File.separator + "temp");
180
		File destinationPluginDir = new File(tempDir.getAbsolutePath()
181
				+ File.separator + packageInfo.getCode());
182

  
183
		// TODO: create copy of original plugin?
184
		try {
185
			copy(originalPluginDir, destinationPluginDir);
186
		} catch (IOException e) {
187
			throw new MakePluginPackageServiceException(
188
					"Exception copying the files", e);
189
		}
190

  
182 191
		// Write the package.info file
183
		writePackageInfo(packageInfo);
192
		writePackageInfo(packageInfo, new File(tempDir.getAbsolutePath()
193
				+ File.separator + packageInfo.getCode()));
184 194

  
185 195
		if (packageInfo.getAntScript() != null) {
186 196
			// Create the ant file
......
196 206
			throws MakePluginPackageServiceException {
197 207
		LOG.debug("Creating package of the package info: \n{0}", packageInfo);
198 208

  
199
		installerProviderServices.compressPackage(
200
				getAbsolutePluginPackageDirectory(packageInfo), packageStream);
209
		// installerProviderServices.compressPackage(
210
		// getAbsolutePluginPackageDirectory(packageInfo), packageStream);
211

  
212
		File pluginPackagePath = new File(tempDir.getAbsolutePath()
213
				+ File.separator + packageInfo.getCode());
214
		installerProviderServices.compressPackage(pluginPackagePath,
215
				packageStream);
216

  
217
		// TODO: delete dir? si code diferente? si modificado?
218
		deleteDir(tempDir);
201 219
	}
202 220

  
203 221
	public void createPackageIndex(PackageInfo packageInfo,
......
212 230

  
213 231
	private void writePackageInfo(PackageInfo packageInfo)
214 232
			throws MakePluginPackageServiceException {
233
		// conseguir directorio destino
215 234
		writePackageInfo(packageInfo,
216 235
				getAbsolutePluginPackageDirectory(packageInfo));
217 236
	}
......
271 290

  
272 291
			// It works if the plugins directory is in the folder
273 292
			// "gvSIG/extensiones"
274
			String applicationDirectory = pluginsDirectory.getParentFile()
275
					.getParent();
293
			String applicationDirectory = System.getProperty("user.dir");
276 294

  
277 295
			List<File> files = packageInfo.getFilesToCopy();
278 296

  
......
307 325
		return (path.delete());
308 326
	}
309 327

  
310
	void copy(File sourceLocation, File targetLocation) throws IOException {
328
	private void copy(File sourceLocation, File targetLocation)
329
			throws IOException {
311 330
		if (sourceLocation.isDirectory()) {
312 331
			if (!targetLocation.exists()) {
313 332
				targetLocation.mkdir();
......
335 354
		}
336 355
	}
337 356

  
338
	private String getPluginPackageDirectory(PackageInfo packageInfo) {
339
		return directories.get(packageInfo);
340
	}
341

  
342
	// private String getCopiedFilesDirectoryName(PackageInfo packageInfo)
343
	// throws MakePluginPackageServiceException {
344
	// return getPluginPackageDirectory(packageInfo) + File.separator +
345
	// "install" + File.separator
346
	// + COPIED_FILES_DIRECTORY_NAME;
347
	// }
348

  
349 357
	private File getCopiedFilesDirectory(File pluginDirectory)
350 358
			throws MakePluginPackageServiceException {
351 359
		return new File(pluginDirectory.getAbsolutePath() + File.separator
......
359 367
				+ COPIED_FILES_DIRECTORY_NAME;
360 368
	}
361 369

  
362
	private String getAntFileName(PackageInfo packageInfo)
363
			throws MakePluginPackageServiceException {
364
		return getPluginPackageDirectory(packageInfo) + File.separator
365
				+ "install" + File.separator + ANT_FILE_NAME;
366
	}
367

  
368 370
	private File getAntFile(File pluginDirectory)
369 371
			throws MakePluginPackageServiceException {
370 372
		return new File(pluginDirectory.getAbsolutePath() + File.separator
......
373 375

  
374 376
	private File getAbsoluteAntFile(PackageInfo packageInfo)
375 377
			throws MakePluginPackageServiceException {
376
		return new File(pluginsDirectory.getAbsolutePath() + File.separator
377
				+ getAntFileName(packageInfo));
378
		String destinationFilePath = manager.getDefaultAddonRepository()
379
				.getAbsolutePath()
380
				+ File.separator + packageInfo.getCode();
381
		return new File(destinationFilePath + File.separator + ANT_FILE_NAME);
378 382
	}
379 383

  
380 384
	private File getAbsolutePluginPackageDirectory(PackageInfo packageInfo)
381 385
			throws MakePluginPackageServiceException {
382

  
383
		return new File(pluginsDirectory.getAbsolutePath() + File.separator
384
				+ getPluginPackageDirectory(packageInfo));
386
		String destinationFilePath = manager.getDefaultAddonRepository()
387
				.getAbsolutePath()
388
				+ File.separator + packageInfo.getCode();
389
		return new File(destinationFilePath);
385 390
	}
386 391

  
387
	private File getAbsolutePluginPackageDirectory(String pluginDirectory)
388
			throws MakePluginPackageServiceException {
389
		return new File(pluginsDirectory.getAbsolutePath() + File.separator
390
				+ pluginDirectory);
391
	}
392

  
393 392
	public Manager getManager() {
394 393
		return this.manager;
395 394
	}
......
457 456
		return fileData.toString();
458 457
	}
459 458

  
460
	public File getPluginsDirectory() {
461
		return pluginsDirectory;
462
	}
463

  
464 459
	public PackageInfo[] getInstalledPackages()
465 460
			throws MakePluginPackageServiceException {
466 461
		return installerInfos.toArray(new PackageInfo[installerInfos.size()]);
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
151 151
			}
152 152
			URL ownerURL = installInfo.getOwnerURL();
153 153
			if (ownerURL != null) {
154
				properties.setProperty(InstallerInfoTags.OWNER_URL,
155
						ownerURL.toString());
154
				properties.setProperty(InstallerInfoTags.OWNER_URL, ownerURL
155
						.toString());
156 156
			}
157 157
			properties.setProperty(InstallerInfoTags.MODEL_VERSION, installInfo
158 158
					.getModelVersion());
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
243 243
		} else {
244 244
			installerInfoResource.setWebURL(null);
245 245
		}
246
		
247
		String ownerURLStr = properties.getProperty(InstallerInfoTags.OWNER_URL);
246

  
247
		String ownerURLStr = properties
248
				.getProperty(InstallerInfoTags.OWNER_URL);
248 249
		if (ownerURLStr != null && !ownerURLStr.equals("")) {
249 250
			URL ownerUrl;
250 251
			try {
......
261 262

  
262 263
		String categories = properties
263 264
				.getProperty(InstallerInfoTags.CATEGORIES);
264
		if (categories != null) {
265
		if (categories != null && !categories.equals("")) {
265 266
			installerInfoResource.addCategoriesAsString(categories);
266 267
		}
267 268

  
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/DefaultInstallerManager.java
30 30
import java.io.File;
31 31
import java.net.URL;
32 32
import java.text.MessageFormat;
33
import java.util.ArrayList;
34
import java.util.List;
33 35

  
34 36
import org.gvsig.installer.lib.api.DependenciesCalculator;
35 37
import org.gvsig.installer.lib.api.Dependency;
......
67 69
			.getExtensionPointManager();
68 70

  
69 71
	private String packageSetNameFormat = "gvSIG-desktop-{0}-{1}-{2}-{4}-{5}-{6}-{7}.gvspks";
70

  
71 72
	private String packageNameFormat = "gvSIG-desktop-{0}-{1}-{2}-{4}-{5}-{6}-{7}.gvspkg";
72

  
73 73
	private String packageIndexNameFormat = "gvSIG-desktop-{0}-{1}-{2}-{4}-{5}-{6}-{7}.gvspki";
74 74

  
75 75
	private URL BaseDownloadURL = null;
76 76
	private String version = null;
77
	private List<File> repositoriesPathsList = null;
78
	private File defaultAddonRepository = null;
77 79

  
78 80
	public DefaultInstallerManager() {
79 81
		super(new DefaultInstallerProviderManager());
82
		repositoriesPathsList = new ArrayList<File>();
80 83
	}
81 84

  
82 85
	public String getPackageSetNameFormat() {
......
103 106
		this.packageIndexNameFormat = packageIndexNameFormat;
104 107
	}
105 108

  
106
	public MakePluginPackageService getMakePluginPackageService(
107
			File pluginsDirectory) throws MakePluginPackageServiceException {
109
	// public MakePluginPackageService getMakePluginPackageService(
110
	// File pluginsDirectory) throws MakePluginPackageServiceException {
111
	// ExtensionPoint ep = extensionPoints
112
	// .add(INSTALLER_MANAGER_EXTENSION_POINT);
113
	// try {
114
	// Object[] args = new Object[] { this, pluginsDirectory };
115
	// return (MakePluginPackageService) ep.create(
116
	// INSTALLER_CREATION_SERVICE_NAME, args);
117
	// } catch (Exception e) {
118
	// throw new MakePluginPackageServiceException(
119
	// "Exception creating the installer service to create installers",
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff