Revision 37479

View differences:

tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.gvsig.installer</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
	</buildSpec>
9
	<natures>
10
	</natures>
11
</projectDescription>
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/org.gvsig.plugin2
1
#
2
#Wed Apr 28 12:22:40 CEST 2010
3
version=1.0.0
4
oficial=true
5
name=myplugin
6
type=plugin
7
description=Test
8
code=org.gvsig.myplugin2
9
state=RC1
10
build=1
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/org.gvsig.plugin3
1
#
2
#Wed Apr 28 12:10:48 CEST 2010
3
version=1.0.0
4
oficial=false
5
name=myplugin
6
type=plugin
7
description=Test
8
code=org.gvsig.plugin3
9
state=RC1
10
build=1
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/execution/InstallPackageWizardFromDefaultDirectoryLauncher.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.main.execution;
29

  
30
import java.io.IOException;
31

  
32
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
33
import org.gvsig.installer.main.DefaultLauncher;
34
import org.gvsig.installer.swing.api.execution.InstallPackageWizardException;
35
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
36
import org.gvsig.tools.locator.LocatorException;
37

  
38
/**
39
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
40
 */
41
public class InstallPackageWizardFromDefaultDirectoryLauncher extends
42
    DefaultLauncher {
43

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

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

  
55
        InstallPackageServiceFrame frame =
56
            new InstallPackageServiceFrame(getApplicationFolder(),
57
                getPluginsFolder(), getInstallFolder());
58
        frame.installFromDefaultDirectory();
59
        frame.setVisible(true);
60
    }
61
}
0 62

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/execution/InstallPackageWizardLauncher.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.main.execution;
29

  
30
import java.io.IOException;
31

  
32
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
33
import org.gvsig.installer.main.DefaultLauncher;
34
import org.gvsig.installer.swing.api.execution.InstallPackageWizardException;
35
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
36
import org.gvsig.tools.locator.LocatorException;
37

  
38
/**
39
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
40
 */
41
public class InstallPackageWizardLauncher extends DefaultLauncher {
42

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

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

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

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/execution/InstallPackageServiceFrame.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.main.execution;
29

  
30
import java.io.File;
31

  
32
import javax.swing.JFrame;
33

  
34
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
35
import org.gvsig.installer.main.utils.FrameWizardListener;
36
import org.gvsig.installer.swing.api.SwingInstallerLocator;
37
import org.gvsig.installer.swing.api.execution.AbstractInstallPackageWizard;
38
import org.gvsig.installer.swing.api.execution.InstallPackageWizardException;
39
import org.gvsig.tools.locator.LocatorException;
40

  
41
/**
42
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
43
 */
44
public class InstallPackageServiceFrame extends JFrame {
45

  
46
    private static final long serialVersionUID = -5107758157530922356L;
47
    private AbstractInstallPackageWizard installerExecutionWizard;
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
    }
63

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

  
69
}
0 70

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/creation/MakePluginPackageWizardLauncher.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.main.creation;
29

  
30
import java.io.IOException;
31

  
32
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
33
import org.gvsig.installer.main.DefaultLauncher;
34
import org.gvsig.installer.swing.api.creation.MakePluginPackageWizardException;
35
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
36
import org.gvsig.tools.locator.LocatorException;
37

  
38
/**
39
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
40
 */
41
public class MakePluginPackageWizardLauncher extends DefaultLauncher {
42

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

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

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

  
60
}
0 61

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/creation/MakePluginPackageFrame.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.main.creation;
29

  
30
import java.io.File;
31

  
32
import javax.swing.JFrame;
33

  
34
import org.gvsig.installer.main.utils.FrameWizardListener;
35
import org.gvsig.installer.swing.api.SwingInstallerLocator;
36
import org.gvsig.installer.swing.api.creation.MakePluginPackageWizard;
37
import org.gvsig.installer.swing.api.creation.MakePluginPackageWizardException;
38
import org.gvsig.tools.locator.LocatorException;
39

  
40
/**
41
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
42
 */
43
public class MakePluginPackageFrame extends JFrame {
44

  
45
    private static final long serialVersionUID = 4144834319158286247L;
46
    private MakePluginPackageWizard installerCreationWizard;
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
    }
62

  
63
}
0 64

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/DefaultLauncher.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.main;
29

  
30
import java.io.File;
31
import java.io.FileInputStream;
32
import java.io.FileOutputStream;
33
import java.io.IOException;
34
import java.io.InputStream;
35
import java.io.OutputStream;
36

  
37
/**
38
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
39
 */
40
public class DefaultLauncher {
41

  
42
    private File appFolder;
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");
52

  
53
            copy(templateFile, appFolder);
54
        }
55

  
56
        return appFolder;
57
    }
58

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

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

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

  
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();
81

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

  
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
    }
95
}
0 96

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/utils/CreateBoundleFrame.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.main.utils;
29

  
30
import java.awt.HeadlessException;
31
import java.awt.event.ActionEvent;
32
import java.awt.event.ActionListener;
33
import java.awt.event.WindowEvent;
34
import java.awt.event.WindowListener;
35
import java.io.File;
36
import java.io.FileOutputStream;
37
import java.util.ArrayList;
38
import java.util.List;
39

  
40
import javax.swing.JFrame;
41
import javax.swing.JOptionPane;
42

  
43
import org.gvsig.gui.beans.openfile.FileTextField;
44
import org.gvsig.installer.lib.impl.utils.Compress;
45

  
46
/**
47
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
48
 */
49
public class CreateBoundleFrame extends JFrame implements WindowListener,
50
    ActionListener {
51

  
52
    /**
53
     * 
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;
61

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

  
69
    private void initializeComponents() {
70
        java.awt.GridBagConstraints gridBagConstraints;
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();
77

  
78
        setLayout(new java.awt.GridBagLayout());
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);
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);
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);
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);
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);
123

  
124
    }
125

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

  
129
    }
130

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

  
134
    }
135

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

  
139
    }
140

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

  
144
    }
145

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

  
149
    }
150

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

  
154
    }
155

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

  
159
    }
160

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

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

  
171
        if (outputFile.exists()) {
172
            outputFile.delete();
173
        }
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
    }
192
}
0 193

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/utils/CreateBundleLauncher.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.main.utils;
29

  
30
/**
31
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
32
 */
33
public class CreateBundleLauncher {
34

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

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

  
46
}
0 47

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/utils/FrameWizardListener.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.main.utils;
29

  
30
import javax.swing.JFrame;
31

  
32
import org.gvsig.installer.swing.api.wizard.InstallerWizardActionListener;
33
import org.gvsig.installer.swing.api.wizard.InstallerWizardPanel;
34

  
35
/**
36
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
37
 */
38
public class FrameWizardListener implements InstallerWizardActionListener {
39

  
40
    private JFrame frame = null;
41

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

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

  
51
    }
52

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

  
58
}
0 59

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2
	<modelVersion>4.0.0</modelVersion>
3
	<artifactId>org.gvsig.installer.main</artifactId>
4
	<packaging>jar</packaging>
5
	<name>org.gvsig.installer.main</name>
6
	<parent>
7
		<groupId>org.gvsig</groupId>
8
		<artifactId>org.gvsig.installer</artifactId>
9
		<version>1.0.1-SNAPSHOT</version>
10
	</parent>
11
	<dependencies>
12
		<dependency>
13
			<groupId>org.gvsig</groupId>
14
			<artifactId>org.gvsig.installer.lib.api</artifactId>
15
			<version>1.0.1-SNAPSHOT</version>
16
            <scope>compile</scope>
17
		</dependency>
18
		<dependency>
19
			<groupId>org.gvsig</groupId>
20
			<artifactId>org.gvsig.installer.lib.spi</artifactId>
21
			<version>1.0.1-SNAPSHOT</version>
22
            <scope>compile</scope>
23
		</dependency>
24
		<dependency>
25
			<groupId>org.gvsig</groupId>
26
			<artifactId>org.gvsig.installer.lib.impl</artifactId>
27
			<version>1.0.1-SNAPSHOT</version>
28
			<!-- The scope is not runtime because there is an utility that uses the Compress class directly
29
			     It will be runtime the day that the API supports this functionality
30
			-->
31
			 <scope>compile</scope>
32
		</dependency>
33
		<dependency>
34
			<groupId>org.gvsig</groupId>
35
			<artifactId>org.gvsig.installer.prov.plugin</artifactId>
36
			<version>1.0.1-SNAPSHOT</version>
37
		</dependency>
38
		<dependency>
39
			<groupId>org.gvsig</groupId>
40
			<artifactId>org.gvsig.installer.swing.api</artifactId>
41
			<version>1.0.1-SNAPSHOT</version>
42
            <scope>compile</scope>
43
		</dependency>
44
        <dependency>
45
            <groupId>org.gvsig</groupId>
46
            <artifactId>org.gvsig.installer.swing.impl</artifactId>
47
            <version>1.0.1-SNAPSHOT</version>
48
        </dependency>
49
        <dependency>
50
            <groupId>org.gvsig</groupId>
51
            <artifactId>org.gvsig.tools.lib</artifactId>
52
            <scope>compile</scope>
53
        </dependency>
54
		<dependency>
55
			<groupId>org.gvsig</groupId>
56
			<artifactId>org.gvsig.ui</artifactId>
57
            <scope>compile</scope>
58
		</dependency>
59
	</dependencies>
60
</project>
0 61

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.main/org.gvsig.wcs
1
#
2
#Wed Apr 28 12:13:53 CEST 2010
3
version=1.0.0
4
oficial=true
5
name=myplugin
6
type=plugin
7
description=Test
8
code=org.gvsig.wcs
9
state=RC1
10
build=1
0 11

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/resources/org/gvsig/installer/lib/impl/creation/install.xml
1
<project name="org.gvsig.plugin1" default="main" basedir=".">
2
	<!--
3
		Predefined properties:
4
		gvsig_dir = gvSIG application root installation directory
5
		extensions_dir = gvSIG extensions directory
6
	-->
7
	<taskdef resource="net/sf/antcontrib/antlib.xml">
8
		<classpath>
9
			<pathelement location="${gvsig_dir}/lib/ant-contrib-1.0b3.jar" />
10
		</classpath>
11
	</taskdef>
12
	<target name="main" depends="copy_files"/>
13
    <target name="copy_files">
14
    	<copy todir="${gvsig_dir}">
15
    		<fileset dir="./files" includes="**"/>
16
		</copy>
17
	</target>
18
</project>
0 19

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.installer.lib.impl.DefaultInstallerLibrary
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/utils/Compress.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.lib.impl.utils;
29

  
30
import java.io.BufferedInputStream;
31
import java.io.BufferedOutputStream;
32
import java.io.File;
33
import java.io.FileInputStream;
34
import java.io.IOException;
35
import java.io.OutputStream;
36
import java.util.ArrayList;
37
import java.util.List;
38
import java.util.zip.ZipEntry;
39
import java.util.zip.ZipOutputStream;
40

  
41
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
42
import org.gvsig.installer.lib.spi.InstallerProviderLocator;
43

  
44
/**
45
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
46
 */
47
public class Compress {
48

  
49
//    private static final int BUFFER = 2048;
50

  
51
    public void compressPluginAsPackageSet(File file, String fileName,
52
        OutputStream os) throws MakePluginPackageServiceException {
53
        List<File> files = new ArrayList<File>();
54
        List<String> fileNames = new ArrayList<String>();
55
        files.add(file);
56
        fileNames.add(fileName);
57
        compressPluginsAsPackageSet(files, fileNames, os);
58
    }
59

  
60
    public void compressPluginsAsPackageSet(File directory, OutputStream os)
61
        throws MakePluginPackageServiceException {
62
        File[] files = directory.listFiles();
63
        List<File> filesArray = new ArrayList<File>();
64
        List<String> fileNamesArray = new ArrayList<String>();
65
        for (int i = 0; i < files.length; i++) {
66
            filesArray.add(files[i]);
67
            fileNamesArray.add(files[i].getName());
68
        }
69
        compressPluginsAsPackageSet(filesArray, fileNamesArray, os);
70
    }
71

  
72
    public void compressPluginsAsPackageSet(List<File> files,
73
        List<String> fileNames, OutputStream os)
74
        throws MakePluginPackageServiceException {
75
        try {
76
            ZipOutputStream zos =
77
                new ZipOutputStream(new BufferedOutputStream(os));
78

  
79
            for (int i = 0; i < files.size(); i++) {
80
                ZipEntry zipEntry = new ZipEntry(fileNames.get(i));
81
                zos.putNextEntry(zipEntry);
82
                compressPluginFiles(files.get(i), zos);
83
                zos.closeEntry();
84
            }
85
            zos.close();
86
        } catch (Exception e) {
87
            throw new MakePluginPackageServiceException(
88
                "Error compressing as package set the plugin files: " + files,
89
                e);
90
        }
91
    }
92

  
93
    public void compressPluginAsPackage(File folder, OutputStream os)
94
        throws MakePluginPackageServiceException {
95
        ZipOutputStream zos = new ZipOutputStream(os);
96
        try {
97
            int parentFileLenght = folder.getParentFile().toString().length();
98
            compressPluginFile(folder, parentFileLenght, zos);
99
            zos.flush();
100
            zos.close();
101
        } catch (IOException e) {
102
            throw new MakePluginPackageServiceException(
103
                "Error compressing as package the plugin folder: " + folder, e);
104
        }
105
    }
106

  
107
    public void compressPluginAsPackageIndex(File folder, OutputStream os)
108
        throws MakePluginPackageServiceException {
109
        ZipOutputStream zos = new ZipOutputStream(os);
110
        try {
111
            int parentFileLength = folder.getParentFile().toString().length();
112
            String folderName =
113
                folder.toString()
114
                    .substring(parentFileLength + 1, folder.toString().length());
115
            
116
            File infoFile =
117
                new File(folder, getPackageInfoFileName() + ".index");
118
            if( !infoFile.exists() ) {
119
                infoFile = new File(folder, getPackageInfoFileName());
120
            }
121

  
122
            byte[] buf = new byte[1024];
123
            int len;
124

  
125
            ZipEntry zipEntry =
126
                new ZipEntry(folderName + File.separator
127
                    + getPackageInfoFileName());
128
            zos.putNextEntry(zipEntry);
129

  
130
            FileInputStream fin = new FileInputStream(infoFile);
131
            BufferedInputStream in = new BufferedInputStream(fin);
132
            while ((len = in.read(buf)) >= 0) {
133
                zos.write(buf, 0, len);
134
            }
135
            in.close();
136
            zos.closeEntry();
137
            zos.flush();
138
            zos.close();
139
        } catch (IOException e) {
140
            throw new MakePluginPackageServiceException(
141
                "Error compressing as package index the plugin folder: "
142
                    + folder, e);
143
        }
144
    }
145

  
146
    private void compressPluginFiles(File fileOrFolder, ZipOutputStream zos)
147
        throws IOException {
148
        int parentFileLenght = fileOrFolder.getParentFile().toString().length();
149
        ZipOutputStream zosPlugin = new ZipOutputStream(zos);
150
        compressPluginFile(fileOrFolder, parentFileLenght, zosPlugin);
151
        zosPlugin.finish();
152
    }
153

  
154
    private void compressPluginFile(File file, int parenFileLength,
155
        ZipOutputStream zosPlugin) throws IOException {
156
        String fileName =
157
            file.toString()
158
                .substring(parenFileLength, file.toString().length());
159
        if (File.separatorChar != '/') {
160
            fileName = fileName.replace(File.separatorChar, '/');
161
        }
162

  
163
        if (file.isDirectory()) {
164
            // Remove the subversion folders
165
            if (!file.getName().toUpperCase().equals(".SVN")) {
166
                // Adding the files
167
                String[] fileNames = file.list();
168
                if (fileNames != null) {
169
                    for (int i = 0; i < fileNames.length; i++) {
170
                        compressPluginFile(new File(file, fileNames[i]),
171
                            parenFileLength, zosPlugin);
172
                    }
173
                }
174
            }
175
        } else {
176
            byte[] buf = new byte[1024];
177
            int len;
178

  
179
            ZipEntry zipEntry = new ZipEntry(fileName);
180
            zosPlugin.putNextEntry(zipEntry);
181

  
182
            FileInputStream fin = new FileInputStream(file);
183
            BufferedInputStream in = new BufferedInputStream(fin);
184
            while ((len = in.read(buf)) >= 0) {
185
                zosPlugin.write(buf, 0, len);
186
            }
187
            in.close();
188
            zosPlugin.closeEntry();
189
        }
190
    }
191

  
192
    private String getPackageInfoFileName() {
193
        return InstallerProviderLocator.getProviderManager()
194
            .getPackageInfoFileName();
195
    }
196
}
0 197

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/utils/DeleteFile.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.lib.impl.utils;
23

  
24
import java.io.File;
25

  
26

  
27
/**
28
 * @author gvSIG Team
29
 * @version $Id$
30
 *
31
 */
32
public class DeleteFile {
33

  
34
    
35
    public DeleteFile() {
36

  
37
    }
38
    
39
    public boolean delete(File dir) {
40
        if (dir.isDirectory()) {
41
            String[] children = dir.list();
42
            for (int i = 0; i < children.length; i++) {
43
                boolean success = delete(new File(dir, children[i]));
44
                if (!success) {
45
                    return false;
46
                }
47
            }
48
        }
49
        return dir.delete();
50
    }
51
    
52
}
0 53

  
tags/v2_0_0_Build_2042/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/utils/Decompress.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

  
28
package org.gvsig.installer.lib.impl.utils;
29

  
30
import java.io.ByteArrayInputStream;
31
import java.io.ByteArrayOutputStream;
32
import java.io.File;
33
import java.io.FileOutputStream;
34
import java.io.IOException;
35
import java.io.InputStream;
36
import java.util.ArrayList;
37
import java.util.List;
38
import java.util.Map;
39
import java.util.zip.ZipEntry;
40
import java.util.zip.ZipException;
41
import java.util.zip.ZipInputStream;
42

  
43
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
45

  
46
import org.gvsig.installer.lib.api.PackageInfo;
47
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
48
import org.gvsig.installer.lib.impl.DefaultPackageInfo;
49
import org.gvsig.installer.lib.impl.info.InstallerInfoFileReader;
50
import org.gvsig.installer.lib.spi.InstallerInfoFileException;
51
import org.gvsig.installer.lib.spi.InstallerProviderLocator;
52
import org.gvsig.tools.ToolsLocator;
53
import org.gvsig.tools.service.ServiceException;
54
import org.gvsig.tools.task.SimpleTaskStatus;
55
import org.gvsig.tools.task.TaskStatusManager;
56

  
57
/**
58
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
59
 */
60
public class Decompress {
61

  
62
    private static final int OPTION_DECOMPRESS = 1;
63
    private static final int OPTION_READ_INSTALLINFO = 2;
64
    private static final int OPTION_INSTALL = 3;
65

  
66
    private int option = 0;
67

  
68
    private int BUFFER = 2048;
69

  
70
    private static final Logger logger =
71
        LoggerFactory.getLogger(Decompress.class);
72

  
73
    private List<PackageInfo> readedIinstallerInfos = null;
74
    private File outputDirectory = null;
75
    private List<PackageInfo> selectedInstallerInfos = null;
76
    private Map<PackageInfo, String> zipEntriesMap = null;
77
    private List<String> defaultSelectedPackets = null;
78

  
79
    public Decompress() {
80

  
81
    }
82

  
83
    public void decompressPlugins(InputStream is, File outputDirectory)
84
        throws InstallPackageServiceException {
85
        option = OPTION_DECOMPRESS;
86
        this.outputDirectory = outputDirectory;
87

  
88
        decompressFolderOfPlugins(is);
89
    }
90

  
91
    public void readPackageSetInstallInfos(InputStream is,
92
        List<PackageInfo> installerInfos, Map<PackageInfo, String> zipEntriesMap)
93
        throws InstallPackageServiceException {
94
        option = OPTION_READ_INSTALLINFO;
95
        this.readedIinstallerInfos = installerInfos;
96
        this.zipEntriesMap = zipEntriesMap;
97
        decompressFolderOfPlugins(is);
98
    }
99

  
100
    public void readPackageInstallInfo(InputStream is,
101
        List<PackageInfo> installerInfos,
102
        Map<PackageInfo, String> zipEntriesMap, String name)
103
        throws InstallPackageServiceException {
104
        option = OPTION_READ_INSTALLINFO;
105
        this.readedIinstallerInfos = installerInfos;
106
        this.zipEntriesMap = zipEntriesMap;
107
        decompressFolderOfPluginFromPackage(is, name);
108
    }
109

  
110
    public class InstallerPluginReadException extends
111
        InstallPackageServiceException {
112

  
113
        private static final long serialVersionUID = -6065359474790792680L;
114

  
115
        private static final String message = "Error reading the plugin";
116

  
117
        private static final String KEY = "_Error_reading_the_plugin";
118

  
119
        public InstallerPluginReadException(ServiceException e) {
120
            super(message, e, KEY, serialVersionUID);
121
        }
122

  
123
    }
124

  
125
    public void decompressPlugin(InputStream is, File outputDirectory)
126
        throws InstallPackageServiceException {
127
        try {
128
            option = OPTION_DECOMPRESS;
129
            this.outputDirectory = outputDirectory;
130
            decompressPlugin(is);
131
        } catch (Exception e) {
132
            throw new InstallPackageServiceException(e);
133
        }
134
    }
135

  
136
    public class InstallerPluginReadErrorException extends
137
        InstallPackageServiceException {
138

  
139
        private static final long serialVersionUID = 4505298394252120334L;
140

  
141
        private static final String message =
142
            "Error reading the plugin '%(name)s'";
143

  
144
        private static final String KEY = "_Error_reading_the_plugin";
145

  
146
        public InstallerPluginReadErrorException(Exception e, String packageName) {
147
            super(message, e, KEY, serialVersionUID);
148
            setValue("name", packageName);
149
        }
150

  
151
    }
152

  
153
    public InputStream searchPlugin(InputStream is, String zipEntry)
154
        throws InstallPackageServiceException {
155
        ZipEntry entry = null;
156
        String name = "";
157

  
158
        try {
159
            ZipInputStream zipInputStream = new ZipInputStream(is);
160

  
161
            while ((entry = zipInputStream.getNextEntry()) != null) {
162
                name = entry.getName();
163
                if (entry.getName().equals(zipEntry)) {
164
                    return zipInputStream;
165
                }
166
                zipInputStream.closeEntry();
167
            }
168
            zipInputStream.closeEntry();
169

  
170
            zipInputStream.close();
171
        } catch (Exception e) {
172
            throw new InstallerPluginReadErrorException(e, name);
173
        }
174
        return null;
175
    }
176

  
177
    public void installFromStream(InputStream is, PackageInfo installerInfo)
178
        throws InstallPackageServiceException {
179
        option = OPTION_INSTALL;
180
        this.selectedInstallerInfos = new ArrayList<PackageInfo>();
181
        this.selectedInstallerInfos.add(installerInfo);
182
        decompressFolderOfPlugins(is);
183
    }
184

  
185
    public void installFromStream(InputStream is,
186
        List<PackageInfo> installerInfos) throws InstallPackageServiceException {
187
        option = OPTION_INSTALL;
188
        this.selectedInstallerInfos = installerInfos;
189
        decompressFolderOfPlugins(is);
190
    }
191

  
192
    private void decompressFolderOfPlugins(InputStream is)
193
        throws InstallPackageServiceException {
194
        ZipInputStream zipInputStream = new ZipInputStream(is);
195
        ZipEntry entry = null;
196

  
197
        String name = "";
198

  
199
        try {
200
            while ((entry = zipInputStream.getNextEntry()) != null) {
201
                name = entry.getName();
202
                if (entry.getName().equals("defaultPackages")
203
                    || entry.getName().equals("defaultSelection")) {
204
                    int count;
205
                    byte data[] = new byte[BUFFER];
206
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
207

  
208
                    while ((count = zipInputStream.read(data, 0, BUFFER)) != -1) {
209
                        out.write(data, 0, count);
210
                    }
211

  
212
                    String str = out.toString();
213
                    String lineas[] = str.split("\\n");
214
                    List<String> defaultPackagesList = new ArrayList<String>();
215

  
216
                    for (int i = 0; i < lineas.length; i++) {
217
                        defaultPackagesList.add(lineas[i]);
218
                    }
219

  
220
                    defaultSelectedPackets = defaultPackagesList;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff