[INST] Remove zip4j and sevenzip library 18/19818/1
authorMoonkyu Kang <moonkyu82.kang@samsung.com>
Mon, 21 Apr 2014 06:04:12 +0000 (15:04 +0900)
committerMoonkyu Kang <moonkyu82.kang@samsung.com>
Mon, 21 Apr 2014 06:04:12 +0000 (15:04 +0900)
Change-Id: I2f0ffa47f5adcd4e102ad00220025c59f65329c1
Signed-off-by: Moonkyu Kang <moonkyu82.kang@samsung.com>
InstallManager_java/lib/sevenzipjbinding-AllPlatforms.jar [deleted file]
InstallManager_java/lib/sevenzipjbinding.jar [deleted file]
InstallManager_java/lib/zip4j_1.3.2.jar [deleted file]
InstallManager_java/src/org/tizen/installmanager/lib/linux/LinuxSDKPackageFormat.java
InstallManager_java/src/org/tizen/installmanager/util/unzip/ApacheUnzipThread.java
InstallManager_java/src/org/tizen/installmanager/util/unzip/SevenZipSdkUnzip.java [deleted file]
InstallManager_java/src/org/tizen/installmanager/util/unzip/Zip4jSdkUnzip.java [deleted file]
InstallManager_java/src/org/tizen/installmanager/util/unzip/Zip4jUnzipThread.java [deleted file]

diff --git a/InstallManager_java/lib/sevenzipjbinding-AllPlatforms.jar b/InstallManager_java/lib/sevenzipjbinding-AllPlatforms.jar
deleted file mode 100644 (file)
index 7a42df8..0000000
Binary files a/InstallManager_java/lib/sevenzipjbinding-AllPlatforms.jar and /dev/null differ
diff --git a/InstallManager_java/lib/sevenzipjbinding.jar b/InstallManager_java/lib/sevenzipjbinding.jar
deleted file mode 100644 (file)
index 2181a7c..0000000
Binary files a/InstallManager_java/lib/sevenzipjbinding.jar and /dev/null differ
diff --git a/InstallManager_java/lib/zip4j_1.3.2.jar b/InstallManager_java/lib/zip4j_1.3.2.jar
deleted file mode 100644 (file)
index 66a19e4..0000000
Binary files a/InstallManager_java/lib/zip4j_1.3.2.jar and /dev/null differ
index 727c62d..777ff8d 100644 (file)
@@ -79,10 +79,6 @@ public class LinuxSDKPackageFormat extends SDKPackageFormat {
                int exitValue = ERROR;\r
 \r
                if (checkExtension == PackageType.ZIP){\r
-//                     UnzipSDK unzipSdk = new Zip4jSdkUnzip();\r
-//                     return unzipSdk.unzipPackageFile(fileFullPath.getAbsolutePath(), targetDir.getAbsolutePath(),monitor);\r
-//                     UnzipSDK unzipSdk = new SevenZipSdkUnzip();\r
-//                     return unzipSdk.unzipPackageFile(fileFullPath.getAbsolutePath(), targetDir.getAbsolutePath(),monitor);\r
                        UnzipSDK unzipSdk = new ApacheSdkUnzip();\r
                        return unzipSdk.unzipPackageFile(fileFullPath.getAbsolutePath(), targetDir.getAbsolutePath(),monitor);                  \r
                        \r
index 86670ea..e8ef222 100644 (file)
@@ -44,10 +44,12 @@ public class ApacheUnzipThread implements Runnable{
                try {
                        fos = new FileOutputStream(targetFile);
                        inputStream = zipFile.getInputStream(element);
-                       IOUtils.copy(inputStream, fos);
+                       long copy = IOUtils.copy(inputStream, fos);
+                       System.out.println("Copy : " + copy);
                        if ((element.getUnixMode() & 0100) != 0) {
                                targetFile.setExecutable(true);                                         
                        }
+                       
                } catch (FileNotFoundException e) {
                        e.printStackTrace();
                        return ERROR;
diff --git a/InstallManager_java/src/org/tizen/installmanager/util/unzip/SevenZipSdkUnzip.java b/InstallManager_java/src/org/tizen/installmanager/util/unzip/SevenZipSdkUnzip.java
deleted file mode 100644 (file)
index 8ddf310..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-package org.tizen.installmanager.util.unzip;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-
-import org.tizen.installmanager.lib.IIMProgressMonitor;
-import org.tizen.installmanager.util.ISdkConstant;
-
-import net.sf.sevenzipjbinding.ExtractAskMode;
-import net.sf.sevenzipjbinding.ExtractOperationResult;
-import net.sf.sevenzipjbinding.IArchiveExtractCallback;
-import net.sf.sevenzipjbinding.ISequentialOutStream;
-import net.sf.sevenzipjbinding.ISevenZipInArchive;
-import net.sf.sevenzipjbinding.PropID;
-import net.sf.sevenzipjbinding.SevenZip;
-import net.sf.sevenzipjbinding.SevenZipException;
-import net.sf.sevenzipjbinding.impl.RandomAccessFileInStream;
-import net.sf.sevenzipjbinding.simple.ISimpleInArchive;
-import net.sf.sevenzipjbinding.simple.ISimpleInArchiveItem;
-/**
- * 
- * @author Moonkyu Kang <moonkyu82.kang@samsung.com>
- *
- */
-public class SevenZipSdkUnzip extends UnzipSDK {
-       
-       private String filterRegex = filterToRegex("*");
-       
-       
-       static class ExtractionException extends Exception {
-               private static final long serialVersionUID = -5108931481040742838L;
-               ExtractionException(String msg) {
-                       super(msg);
-               }
-               public ExtractionException(String msg, Exception e) {
-                       super(msg, e);
-               }
-       }
-       class ExtractCallback implements IArchiveExtractCallback {
-               private ISevenZipInArchive inArchive;
-               private int index;
-               private OutputStream outputStream;
-               private File file;
-               private ExtractAskMode extractAskMode;
-               private boolean isFolder;
-               private String outputDirectoryFile;
-               ExtractCallback(ISevenZipInArchive inArchive,String outputDirectoryFile) {
-                       this.inArchive = inArchive;
-                       this.outputDirectoryFile = outputDirectoryFile;
-               }
-               @Override
-               public void setTotal(long total) throws SevenZipException {
-               }
-               @Override
-               public void setCompleted(long completeValue) throws SevenZipException {
-               }
-               @Override
-               public ISequentialOutStream getStream(int index,
-                               ExtractAskMode extractAskMode) throws SevenZipException {
-                       closeOutputStream();
-                       this.index = index;
-                       this.extractAskMode = extractAskMode;
-                       this.isFolder = (Boolean) inArchive.getProperty(index,
-                                       PropID.IS_FOLDER);
-                       if (extractAskMode != ExtractAskMode.EXTRACT) {
-                               // Skipped files or files being tested
-                               return null;
-                       }
-                       String path = (String) inArchive.getProperty(index, PropID.PATH);
-                       file = new File(outputDirectoryFile, path);
-                       if (isFolder) {
-                               createDirectory(file);
-                               return null;
-                       }
-                       createDirectory(file.getParentFile());
-                       try {
-                               outputStream = new FileOutputStream(file);
-                       } catch (FileNotFoundException e) {
-                               throw new SevenZipException("Error opening file: "
-                                               + file.getAbsolutePath(), e);
-                       }
-                       ISimpleInArchive simpleInterface = inArchive.getSimpleInterface();
-                       ISimpleInArchiveItem item = simpleInterface.getArchiveItem(index);
-                       String binaryString = Integer.toBinaryString(item.getAttributes());
-                       if(binaryString.charAt(9) == '1'){
-                               file.setExecutable(true);
-                       }
-
-                       return new ISequentialOutStream() {
-                               public int write(byte[] data) throws SevenZipException {
-                                       try {
-                                               outputStream.write(data);
-                                       } catch (IOException e) {
-                                               throw new SevenZipException("Error writing to file: "
-                                                               + file.getAbsolutePath());
-                                       }
-                                       
-                                       return data.length; // Return amount of consumed data
-                               }
-                       };
-                       
-               }
-               private void createDirectory(File parentFile) throws SevenZipException {
-                       File test = new File(parentFile.getAbsolutePath());
-                       
-                       if (!test.exists()) {
-                               if (!test.mkdirs()) {   
-                                       if(!test.exists()){
-                                               throw new SevenZipException("Error creating directory: "
-                                                               + test.getAbsolutePath());
-                                       }
-                               }
-                       }
-               }
-               private void closeOutputStream() throws SevenZipException {
-                       if (outputStream != null) {
-                               try {
-                                       outputStream.close();
-                                       outputStream = null;
-                               } catch (IOException e) {
-                                       throw new SevenZipException("Error closing file: "
-                                                       + file.getAbsolutePath());
-                               }
-                       }
-               }
-               @Override
-               public void prepareOperation(ExtractAskMode extractAskMode)
-                               throws SevenZipException {
-               }
-               @Override
-               public void setOperationResult(
-                               ExtractOperationResult extractOperationResult)
-                               throws SevenZipException {
-                       closeOutputStream();
-                       String path = (String) inArchive.getProperty(index, PropID.PATH);
-                       if (extractOperationResult != ExtractOperationResult.OK) {
-                               throw new SevenZipException("Invalid file: " + path);
-                       }       
-                       if (!isFolder) {
-                               switch (extractAskMode) {
-                               case EXTRACT:
-                                       //System.out.println("Extracted " + path);
-                                       break;
-                               case TEST:
-                                       System.out.println("Tested " + path);
-                               default:
-                               }
-                       }
-               }
-       }
-       
-       
-       
-
-       @Override
-       public long unzipPackageFile(String fileFullPath, String targetFullPath,IIMProgressMonitor monitor) {
-       
-               long startTime = System.currentTimeMillis();
-               // Target Directory!!!
-               final File sdkTempDirFile = new File(targetFullPath);
-               if (!sdkTempDirFile.exists()) {
-                       sdkTempDirFile.mkdirs();
-               }
-               try {
-                       checkArchiveFile(fileFullPath);
-               } catch (ExtractionException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
-               try {
-                       prepareOutputDirectory(targetFullPath);
-               } catch (ExtractionException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
-               try {
-                       extractArchive(fileFullPath,targetFullPath);
-               } catch (ExtractionException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
-               
-               long finishedTime = System.currentTimeMillis();
-               System.out.println("extracting time : "+ (finishedTime - startTime));
-               return ISdkConstant.SUCCESS;
-       }
-       
-       private String filterToRegex(String string) {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       private void checkArchiveFile(String archive) throws ExtractionException {
-               if (!new File(archive).exists()) {
-                       throw new ExtractionException("Archive file not found: " + archive);
-               }
-               if (!new File(archive).canRead()) {
-                       System.out.println("Can't read archive file: " + archive);
-               }
-       }
-       
-       private void prepareOutputDirectory(String outputDirectory) throws ExtractionException {
-               File outputDirectoryFile = new File(outputDirectory);
-               if (!outputDirectoryFile.exists()) {
-                       outputDirectoryFile.mkdirs();
-               } 
-       }
-       
-       public void extractArchive(String archive,String targetPath) throws ExtractionException {
-               RandomAccessFile randomAccessFile;
-               boolean ok = false;
-               try {
-                       randomAccessFile = new RandomAccessFile(archive, "r");
-               } catch (FileNotFoundException e) {
-                       throw new ExtractionException("File not found", e);
-               }
-               try {
-                       extractArchive(randomAccessFile,targetPath);
-                       ok = true;
-               } finally {
-                       try {
-                               randomAccessFile.close();
-                       } catch (Exception e) {
-                               if (ok) {
-                                       throw new ExtractionException("Error closing archive file",
-                                                       e);
-                               }
-                       }
-               }
-       }
-       private void extractArchive(RandomAccessFile file,String targetPath)
-                       throws ExtractionException {
-               ISevenZipInArchive inArchive;
-               boolean ok = false;
-               try {
-                       inArchive = SevenZip.openInArchive(null,
-                                       new RandomAccessFileInStream(file));
-               } catch (SevenZipException e) {
-                       throw new ExtractionException("Error opening archive", e);
-               }
-               try {
-                       
-                       int[] ids = null; // All items
-                       if (filterRegex != null) {
-                               ids = filterIds(inArchive, filterRegex);
-                       }
-                       inArchive.extract(ids, false, new ExtractCallback(inArchive,targetPath));
-                       
-                       ok = true;
-               } catch (SevenZipException e) {
-                       StringBuilder stringBuilder = new StringBuilder();
-                       stringBuilder.append("Error extracting archive '");
-                       stringBuilder.append(targetPath);
-                       stringBuilder.append("': ");
-                       stringBuilder.append(e.getMessage());
-                       if (e.getCause() != null) {
-                               stringBuilder.append(" (");
-                               stringBuilder.append(e.getCause().getMessage());
-                               stringBuilder.append(')');
-                       }
-                       String message = stringBuilder.toString();
-                       throw new ExtractionException(message, e);
-               } finally {
-                       try {
-                               inArchive.close();
-                       } catch (SevenZipException e) {
-                               if (ok) {
-                                       throw new ExtractionException("Error closing archive", e);
-                               }
-                       }
-               }
-       }
-       private static int[] filterIds(ISevenZipInArchive inArchive, String regex) throws SevenZipException {
-               List<Integer> idList = new ArrayList<Integer>();
-               
-               int numberOfItems = inArchive.getNumberOfItems();
-               
-               Pattern pattern = Pattern.compile(regex);
-               for (int i = 0; i < numberOfItems; i++) {
-                       String path = (String) inArchive.getProperty(i, PropID.PATH);
-                       String fileName = new File(path).getName();
-                       if (pattern.matcher(fileName).matches()) {
-                               idList.add(i);
-                       }
-               }
-               
-               int[] result = new int[idList.size()];
-               for (int i = 0; i < result.length; i++) {
-                       result[i] = idList.get(i);
-               }
-               return result ;
-       }
-       
-
-
-
-}
diff --git a/InstallManager_java/src/org/tizen/installmanager/util/unzip/Zip4jSdkUnzip.java b/InstallManager_java/src/org/tizen/installmanager/util/unzip/Zip4jSdkUnzip.java
deleted file mode 100644 (file)
index dbe5a85..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.tizen.installmanager.util.unzip;
-
-import java.io.File;
-import java.util.List;
-
-import net.lingala.zip4j.core.ZipFile;
-import net.lingala.zip4j.exception.ZipException;
-import net.lingala.zip4j.model.FileHeader;
-
-import org.tizen.installmanager.lib.IIMProgressMonitor;
-import org.tizen.installmanager.lib.Log;
-import org.tizen.installmanager.util.ISdkConstant;
-
-public class Zip4jSdkUnzip extends UnzipSDK {
-
-       @Override
-       public long unzipPackageFile(String fileFullPath, String targetFullPath,IIMProgressMonitor monitor) {
-               try {                   
-                       ZipFile zipfile = new ZipFile(fileFullPath);
-                       long startTime = System.currentTimeMillis();
-                       @SuppressWarnings("unchecked")
-                       List<FileHeader> fileHeaders = (List<FileHeader>)zipfile.getFileHeaders();
-                       if(fileHeaders != null){                                
-                               for (FileHeader fileHeader : fileHeaders) {                                     
-                                       unzip(targetFullPath, zipfile, fileHeader);
-                               }
-                               long finishedTime = System.currentTimeMillis();
-                               System.out.println("extracting time : "+ (finishedTime - startTime));
-                       }else{                                  
-                               return ISdkConstant.ERROR;
-                       }                       
-               } catch (ZipException e) {
-                       Log.ExceptionLog(e);
-                       return ISdkConstant.ERROR;
-               }
-               return ISdkConstant.SUCCESS;            
-       }
-
-       private void unzip(String targetFullPath, ZipFile zipfile,
-                       FileHeader fileHeader) throws ZipException {
-               zipfile.extractFile(fileHeader, targetFullPath);
-               if(!fileHeader.isDirectory()){
-                       byte[] externalFileAttr = fileHeader.getExternalFileAttr();
-                       if(externalFileAttr != null && externalFileAttr.length > 0){
-                               short bytesToShort = BytesToShort(externalFileAttr,
-                                               Little_EDIAN);
-                               if ((bytesToShort & 0100) != 0) {
-                                       File f = new File(targetFullPath,
-                                                       fileHeader.getFileName());
-                                       f.setExecutable(true);
-                               }
-                       }
-               }
-       }
-
-}
diff --git a/InstallManager_java/src/org/tizen/installmanager/util/unzip/Zip4jUnzipThread.java b/InstallManager_java/src/org/tizen/installmanager/util/unzip/Zip4jUnzipThread.java
deleted file mode 100644 (file)
index 4e4c4ab..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.tizen.installmanager.util.unzip;
-import java.io.File;
-
-import net.lingala.zip4j.core.ZipFile;
-import net.lingala.zip4j.exception.ZipException;
-import net.lingala.zip4j.model.FileHeader;
-
-/**
- * Cannot use thread in zip4j
- * @author kahros2
- *
- */
-
-public class Zip4jUnzipThread implements Runnable{
-
-       protected final static int ERROR = -1;
-       protected final static int SUCCESS = 1;
-       protected final static int BIG_EDIAN = 1;
-       protected final static int Little_EDIAN = 2;
-
-       private String targetFullPath;
-       ZipFile zipFile;
-       FileHeader fileHeader;
-       
-       public Zip4jUnzipThread(String targetFullPath, ZipFile zipfile,
-                       FileHeader fileHeader){
-               this.targetFullPath = targetFullPath;
-               this.fileHeader = fileHeader;
-               this.zipFile = zipfile;
-       }
-       
-
-       @Override
-       public void run() {             
-               unZipFile();            
-       }
-       
-       private long unZipFile(){
-               try {
-                       zipFile.extractFile(fileHeader, targetFullPath);
-                       if(!fileHeader.isDirectory()){
-                               byte[] externalFileAttr = fileHeader.getExternalFileAttr();
-                               if(externalFileAttr != null && externalFileAttr.length > 0){
-                                       short bytesToShort = BytesToShort(externalFileAttr,
-                                                       Little_EDIAN);
-                                       if ((bytesToShort & 0100) != 0) {
-                                               File f = new File(targetFullPath,
-                                                               fileHeader.getFileName());
-                                               f.setExecutable(true);
-                                       }
-                               }
-                       }                       
-               } catch (ZipException e) {
-                       System.out.println("Error!!!!");
-                       System.out.println(e.getMessage());
-                       return ERROR;
-               }
-               
-               return SUCCESS;
-       }
-       
-       private short BytesToShort(byte[] Value,int Order)
-        {
-         short newValue = 0;
-         byte[] temp = Value;
-         
-         temp = ChangeByteOrder(temp,Order);
-         
-            newValue |= (((short)temp[0])<<8)&0xFF00;
-            newValue |= (((short)temp[1]))&0xFF;
-         return newValue;
-        };
-       
-       private byte[] ChangeByteOrder(byte[] value, int Order) {
-               int idx = value.length;
-               byte[] Temp = new byte[idx];
-
-               if (Order == BIG_EDIAN) {
-                       Temp = value;
-               }
-
-               else if (Order == Little_EDIAN) {
-                       for (int i = 0; i < idx; i++) {
-                               Temp[i] = value[idx - (i + 1)];
-                       }
-               }
-               return Temp;
-       };
-       
-
-}