From caf1092e6ed6743bc1f8db1133678e66746ce75d Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 6 Dec 2012 15:01:07 +0000 Subject: [PATCH] applet not anymore used in new ui so remove from build. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1417927 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-web/archiva-applet/pom.xml | 89 ----------- .../apache/archiva/applet/ChecksumApplet.java | 144 ------------------ 2 files changed, 233 deletions(-) delete mode 100644 archiva-modules/archiva-web/archiva-applet/pom.xml delete mode 100644 archiva-modules/archiva-web/archiva-applet/src/main/java/org/apache/archiva/applet/ChecksumApplet.java diff --git a/archiva-modules/archiva-web/archiva-applet/pom.xml b/archiva-modules/archiva-web/archiva-applet/pom.xml deleted file mode 100644 index a776fd911..000000000 --- a/archiva-modules/archiva-web/archiva-applet/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - 4.0.0 - - org.apache.archiva - archiva-web - 1.4-M4-SNAPSHOT - - archiva-applet - Archiva Web :: Applet - - Applet for performing local operations on files such as creating a checksum of an artifact - before uploading it. - - - - - org.codehaus.mojo - keytool-maven-plugin - 1.0-beta-1 - - - generate-resources - - clean - genkey - - - - - ${basedir}/target/keystore - cn=Brett Porter, ou=Archiva, L=Sydney, ST=NSW, o=Apache Software Foundation, c=AU - password - password - 10000 - - - - org.apache.maven.plugins - maven-jarsigner-plugin - 1.2 - - ${basedir}/target/keystore - mykey - password - password - - - - - sign - - - - - - org.codehaus.mojo - cobertura-maven-plugin - - - - - **/** - - - - - - - diff --git a/archiva-modules/archiva-web/archiva-applet/src/main/java/org/apache/archiva/applet/ChecksumApplet.java b/archiva-modules/archiva-web/archiva-applet/src/main/java/org/apache/archiva/applet/ChecksumApplet.java deleted file mode 100644 index 3122ab629..000000000 --- a/archiva-modules/archiva-web/archiva-applet/src/main/java/org/apache/archiva/applet/ChecksumApplet.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.apache.archiva.applet; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.applet.Applet; -import java.awt.BorderLayout; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.security.AccessController; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.PrivilegedAction; - -import javax.swing.JLabel; -import javax.swing.JProgressBar; - -/** - * Applet that takes a file on the local filesystem and checksums it for sending to the server. - * - */ -public class ChecksumApplet - extends Applet -{ - private static final int CHECKSUM_BUFFER_SIZE = 8192; - - private static final int BYTE_MASK = 0xFF; - - private JProgressBar progressBar; - - public void init() - { - setLayout( new BorderLayout() ); - progressBar = new JProgressBar(); - progressBar.setStringPainted( true ); - add( progressBar, BorderLayout.CENTER ); - JLabel label = new JLabel( "Checksum progress: " ); - add( label, BorderLayout.WEST ); - } - - public String generateMd5( final String file ) - throws IOException, NoSuchAlgorithmException - { - return AccessController.doPrivileged( new PrivilegedAction() - { - public String run() - { - try - { - return checksumFile( file ); - } - catch ( NoSuchAlgorithmException e ) - { - return "Error checksumming file: " + e.getMessage(); - } - catch ( FileNotFoundException e ) - { - return "Couldn't find the file: " + e.getMessage(); - } - catch ( IOException e ) - { - return "Error reading file: " + e.getMessage(); - } - } - } ); - } - - protected String checksumFile( String file ) - throws NoSuchAlgorithmException, IOException - { - MessageDigest digest = MessageDigest.getInstance( "MD5" ); - - File f = new File( file ); - long total = f.length(); - InputStream fis = new FileInputStream( f ); - try - { - long totalRead = 0; - byte[] buffer = new byte[CHECKSUM_BUFFER_SIZE]; - int numRead; - do - { - numRead = fis.read( buffer ); - if ( numRead > 0 ) - { - digest.update( buffer, 0, numRead ); - totalRead += numRead; - progressBar.setValue( (int) ( totalRead * progressBar.getMaximum() / total ) ); - } - } - while ( numRead != -1 ); - } - finally - { - fis.close(); - } - - return byteArrayToHexStr( digest.digest() ); - } - - protected static String byteArrayToHexStr( byte[] data ) - { - StringBuilder output = new StringBuilder( "" ); - - for ( int cnt = 0; cnt < data.length; cnt++ ) - { - //Deposit a byte into the 8 lsb of an int. - int tempInt = data[cnt] & BYTE_MASK; - - //Get hex representation of the int as a string. - String tempStr = Integer.toHexString( tempInt ); - - //Append a leading 0 if necessary so that each hex string will contain 2 characters. - if ( tempStr.length() == 1 ) - { - tempStr = "0" + tempStr; - } - - //Concatenate the two characters to the output string. - output.append( tempStr ); - } - - return output.toString().toUpperCase(); - } -}