Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2975 - development/main/depot/install/src/main/net/dpml/depot/install

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2975 - development/main/depot/install/src/main/net/dpml/depot/install
  • Date: Mon, 04 Jul 2005 23:48:52 -0400

Author: mcconnell AT dpml.net
Date: Mon Jul 4 23:48:52 2005
New Revision: 2975

Modified:

development/main/depot/install/src/main/net/dpml/depot/install/ZipInstaller.java
Log:
o add unpacking of a platform neutral DPML distribution

Modified:
development/main/depot/install/src/main/net/dpml/depot/install/ZipInstaller.java
==============================================================================
---
development/main/depot/install/src/main/net/dpml/depot/install/ZipInstaller.java
(original)
+++
development/main/depot/install/src/main/net/dpml/depot/install/ZipInstaller.java
Mon Jul 4 23:48:52 2005
@@ -18,11 +18,15 @@

import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
import java.net.URL;
-import java.net.URISyntaxException;
-import java.rmi.RemoteException;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipEntry;
+import java.util.Enumeration;

import net.dpml.depot.profile.DepotProfile;
import net.dpml.depot.profile.ApplicationProfile;
@@ -30,12 +34,8 @@
import net.dpml.transit.Transit;
import net.dpml.transit.artifact.Artifact;
import net.dpml.transit.artifact.ArtifactNotFoundException;
-import net.dpml.transit.artifact.UnsupportedSchemeException;
-import net.dpml.transit.artifact.MissingGroupException;
-import net.dpml.transit.model.TransitRegistryModel;
import net.dpml.transit.model.Logger;
-import net.dpml.transit.unit.TransitStorageHome;
-import net.dpml.transit.model.DefaultTransitRegistryModel;
+import net.dpml.transit.util.StreamUtils;

/**
* Table model that maps table rows to child nodes of a supplied preferences
node.
@@ -72,6 +72,12 @@
System.out.println( "\n loading: " + url );
File file = (File) url.getContent( new Class[]{ File.class } );
System.out.println( " cached to: " + file );
+ ZipFile zip = new ZipFile( file );
+ int size = zip.size();
+ System.out.println( " unpacking " + size + " entries" );
+
+ unpack( zip );
+
}
catch( ArtifactNotFoundException e )
{
@@ -79,4 +85,68 @@
throw new HandledException();
}
}
+
+ private void unpack( ZipFile zip ) throws Exception
+ {
+ Enumeration entries = zip.entries();
+ while( entries.hasMoreElements() )
+ {
+ ZipEntry entry = (ZipEntry) entries.nextElement();
+ if( false == entry.isDirectory() )
+ {
+ unpackEntry( zip, entry );
+ }
+ }
+ }
+
+ private void unpackEntry( ZipFile zip, ZipEntry entry ) throws Exception
+ {
+ File out = getDestination( entry );
+ File parent = out.getParentFile();
+ parent.mkdirs();
+ InputStream input = zip.getInputStream( entry );
+ OutputStream output = new FileOutputStream( out );
+ System.out.println( "" + out );
+ StreamUtils.copyStream( input, output, true );
+ }
+
+ private File getDestination( ZipEntry entry )
+ {
+ String name = entry.getName();
+ if( name.startsWith( "share/" ) )
+ {
+ //
+ // shared resources go into into DPML_SYSTEM
+ //
+
+ String path = name.substring( 6 );
+ return new File( Transit.DPML_SYSTEM, path );
+ }
+ else if( name.startsWith( "data/" ) )
+ {
+ //
+ // data resources go into into DPML_DATA
+ //
+
+ String path = name.substring( 5 );
+ return new File( Transit.DPML_DATA, path );
+ }
+ else if( name.startsWith( "prefs/" ) )
+ {
+ //
+ // preferences resources go into into DPML_PREFS
+ //
+
+ String path = name.substring( 6 );
+ return new File( Transit.DPML_PREFS, path );
+ }
+ else
+ {
+ //
+ // otherwise use DPML_HOME
+ //
+
+ return new File( Transit.DPML_HOME, name );
+ }
+ }
}



  • svn commit: r2975 - development/main/depot/install/src/main/net/dpml/depot/install, mcconnell, 07/04/2005

Archive powered by MHonArc 2.6.24.

Top of Page