[Title] common-eplugin: updated SignCommand for removement of old signatures
authorJihoon Song <jihoon80.song@samsung.com>
Thu, 14 Mar 2013 14:51:57 +0000 (23:51 +0900)
committerJihoon Song <jihoon80.song@samsung.com>
Thu, 14 Mar 2013 14:51:57 +0000 (23:51 +0900)
[Desc.] The incremental sign for RDS require removement of old signatures
[Issue]

Change-Id: I32efecf75d9df8725aab5001e34cf04a6565df45

org.tizen.common.sign/src/org/tizen/common/sign/command/SignCommand.java
org.tizen.common/src/org/tizen/common/file/EclipseFileHandler.java

index 257b12a..795327f 100755 (executable)
@@ -35,10 +35,13 @@ import org.tizen.common.core.command.file.FileHandlingCommand;
 import org.tizen.common.core.command.policy.MessagePolicy;
 import org.tizen.common.file.FileHandler;
 import org.tizen.common.file.FileHandler.Attribute;
+import org.tizen.common.file.FileHandler.Type;
 import org.tizen.common.sign.exception.CertificationException;
 import org.tizen.common.sign.preferences.SigningProfileItem;
 import org.tizen.common.sign.signer.TizenSigner;
+import org.tizen.common.sign.util.SignatureUtility;
 import org.tizen.common.util.Assert;
+import org.tizen.common.util.FileUtil;
 import org.tizen.common.util.StringUtil;
 
 
@@ -90,6 +93,20 @@ public class SignCommand extends FileHandlingCommand<Object> {
         // categorize profile
         categorizeProfiles();
         
+        // remove old signatures
+        for ( String child : handler.list( appDirPath ) ) {
+            Object type = handler.get( child, Attribute.TYPE );
+            if ( Type.FILE.equals( type ) ) {
+                Object nameObj = handler.get( child, Attribute.NAME );
+                if ( nameObj instanceof String ) {
+                    String name = (String) nameObj;
+                    if ( SignatureUtility.isSignatureFile( name ) ) {
+                        handler.removeFile( child );
+                    }
+                }
+            }
+        }
+        
         StopWatch stopWatch = new StopWatch();
         try {
             stopWatch.start();
index 49c876b..d8bcac1 100755 (executable)
@@ -376,7 +376,18 @@ extends StandardFileHandler
 
        @Override
        public void removeFile(String path) throws IOException {
-               throw new UnsupportedOperationException();
+           final IResource file = getResource( path );
+           
+           if ( file.getType() != IResource.FILE ) 
+           {
+               throw new IOException();
+           }
+
+           try {
+            file.delete( true, null );
+        } catch (CoreException e) {
+            throw new IOException( e );
+        }
        }
 
        @Override
@@ -425,6 +436,10 @@ extends StandardFileHandler
                {
                        return file.isAccessible();
                }
+               else if ( Attribute.NAME.equals( name ) )
+               {
+                   return file.getName();
+               }
                else if ( Attribute.WRITABLE.equals( name ) )
                {
                        return file.isAccessible();