]> source.dussan.org Git - archiva.git/commitdiff
use a better name for this class
authorOlivier Lamy <olamy@apache.org>
Mon, 18 Nov 2013 05:48:39 +0000 (05:48 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 18 Nov 2013 05:48:39 +0000 (05:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1542902 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/DeflateStringSerializer.java [new file with mode: 0644]
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/HugeStringSerializer.java [deleted file]
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/MetadataFacetModel.java
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Project.java
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Repository.java

index fbb7d95f9c89978ee82cd7f419c608477466b8a9..6c3a636ec018d9b204618d7cef9e5c3c99eccb8d 100644 (file)
@@ -41,31 +41,31 @@ public class ArtifactMetadataModel
 
     // repositoryId + namespaceId + project + projectVersion + id
     @Id
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String artifactMetadataModelId;
 
     @Column( name = "id" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String id;
 
     @Column( name = "repositoryId" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String repositoryId;
 
     @Column( name = "namespace" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String namespace;
 
     @Column( name = "project" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String project;
 
     @Column( name = "projectVersion" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String projectVersion;
 
     @Column( name = "version" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String version;
 
     @Column( name = "fileLastModified" )
@@ -77,11 +77,11 @@ public class ArtifactMetadataModel
     private long size;
 
     @Column( name = "md5" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String md5;
 
     @Column( name = "sha1" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String sha1;
 
     @Column( name = "whenGathered" )
diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/DeflateStringSerializer.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/DeflateStringSerializer.java
new file mode 100644 (file)
index 0000000..d8b17a2
--- /dev/null
@@ -0,0 +1,149 @@
+package org.apache.archiva.metadata.repository.cassandra.model;
+
+/*
+ * 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 com.netflix.astyanax.serializers.AbstractSerializer;
+import com.netflix.astyanax.serializers.ComparatorType;
+import org.apache.commons.codec.binary.StringUtils;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.util.zip.Deflater;
+import java.util.zip.DeflaterOutputStream;
+import java.util.zip.InflaterInputStream;
+
+
+/**
+ * For Huge String we use a deflate compression
+ * @author Olivier Lamy
+ * @since 2.0.0
+ */
+public class DeflateStringSerializer
+    extends AbstractSerializer<String>
+{
+
+    private Logger logger = LoggerFactory.getLogger( getClass() );
+
+    private static final String UTF_8 = "UTF-8";
+
+    private static final DeflateStringSerializer instance = new DeflateStringSerializer();
+
+    private static final Charset charset = Charset.forName( UTF_8 );
+
+    public static DeflateStringSerializer get()
+    {
+        return instance;
+    }
+
+    @Override
+    public ByteBuffer toByteBuffer( String obj )
+    {
+        if ( obj == null )
+        {
+            return null;
+        }
+
+        try
+        {
+            byte[] bytes = compressWithDeflate( StringUtils.getBytesUtf8( obj ) );
+            return ByteBuffer.wrap( bytes );
+        }
+        catch ( IOException e )
+        {
+            throw new RuntimeException( "Fail to compress column data", e );
+        }
+    }
+
+    @Override
+    public String fromByteBuffer( ByteBuffer byteBuffer )
+    {
+        if ( byteBuffer == null )
+        {
+            return null;
+        }
+
+        ByteBuffer dup = byteBuffer.duplicate();
+        try
+        {
+            String str = getFromDeflateBytes( dup.array() );
+            return str;
+        }
+        catch ( IOException e )
+        {
+            throw new RuntimeException( "Fail to decompress column data", e );
+        }
+
+    }
+
+    public String getFromDeflateBytes( byte[] bytes )
+        throws IOException
+    {
+        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( bytes );
+        InflaterInputStream inflaterInputStream = new InflaterInputStream( byteArrayInputStream );
+        return IOUtils.toString( inflaterInputStream );
+    }
+
+    public byte[] compressWithDeflate( byte[] unCompress )
+        throws IOException
+    {
+        try
+        {
+            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+            DeflaterOutputStream out = new DeflaterOutputStream( buffer, new Deflater( Deflater.BEST_COMPRESSION ) );
+            out.write( unCompress );
+            out.finish();
+            ByteArrayInputStream bais = new ByteArrayInputStream( buffer.toByteArray() );
+            byte[] res = IOUtils.toByteArray( bais );
+            return res;
+        }
+        catch ( IOException e )
+        {
+            logger.debug( "IOException in compressStringWithDeflate", e );
+            throw e;
+        }
+
+    }
+
+    @Override
+    public ComparatorType getComparatorType()
+    {
+        return ComparatorType.BYTESTYPE;
+    }
+
+    @Override
+    public ByteBuffer fromString( String str )
+    {
+        return instance.fromString( str );
+    }
+
+    @Override
+    public String getString( ByteBuffer byteBuffer )
+    {
+        return instance.getString( byteBuffer );
+    }
+
+}
diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/HugeStringSerializer.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/HugeStringSerializer.java
deleted file mode 100644 (file)
index 50f19bd..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-package org.apache.archiva.metadata.repository.cassandra.model;
-
-/*
- * 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 com.netflix.astyanax.serializers.AbstractSerializer;
-import com.netflix.astyanax.serializers.ComparatorType;
-import org.apache.cassandra.db.marshal.UTF8Type;
-import org.apache.commons.codec.binary.StringUtils;
-import org.apache.commons.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.util.zip.Deflater;
-import java.util.zip.DeflaterInputStream;
-import java.util.zip.DeflaterOutputStream;
-import java.util.zip.InflaterInputStream;
-
-
-/**
- * For Huge String we use a  compression
- * @author Olivier Lamy
- */
-public class HugeStringSerializer
-    extends AbstractSerializer<String>
-{
-
-    private Logger logger = LoggerFactory.getLogger( getClass() );
-
-    private static final String UTF_8 = "UTF-8";
-
-    private static final HugeStringSerializer instance = new HugeStringSerializer();
-
-    private static final Charset charset = Charset.forName( UTF_8 );
-
-    public static HugeStringSerializer get()
-    {
-        return instance;
-    }
-
-    @Override
-    public ByteBuffer toByteBuffer( String obj )
-    {
-        if ( obj == null )
-        {
-            return null;
-        }
-
-        try
-        {
-            byte[] bytes = compressWithDeflate( StringUtils.getBytesUtf8( obj ) );
-            return ByteBuffer.wrap( bytes );
-        }
-        catch ( IOException e )
-        {
-            throw new RuntimeException( "Fail to compress column data", e );
-        }
-    }
-
-    @Override
-    public String fromByteBuffer( ByteBuffer byteBuffer )
-    {
-        if ( byteBuffer == null )
-        {
-            return null;
-        }
-
-        ByteBuffer dup = byteBuffer.duplicate();
-        try
-        {
-            String str = getFromDeflateBytes( dup.array() );
-            return str;
-        }
-        catch ( IOException e )
-        {
-            throw new RuntimeException( "Fail to decompress column data", e );
-        }
-
-    }
-
-    public String getFromDeflateBytes( byte[] bytes )
-        throws IOException
-    {
-        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( bytes );
-        InflaterInputStream inflaterInputStream = new InflaterInputStream( byteArrayInputStream );
-        return IOUtils.toString( inflaterInputStream );
-    }
-
-    public byte[] compressWithDeflate( byte[] unCompress )
-        throws IOException
-    {
-        try
-        {
-            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-            DeflaterOutputStream out = new DeflaterOutputStream( buffer, new Deflater( Deflater.BEST_COMPRESSION ) );
-            out.write( unCompress );
-            out.finish();
-            ByteArrayInputStream bais = new ByteArrayInputStream( buffer.toByteArray() );
-            byte[] res = IOUtils.toByteArray( bais );
-            return res;
-        }
-        catch ( IOException e )
-        {
-            logger.debug( "IOException in compressStringWithDeflate", e );
-            throw e;
-        }
-
-    }
-
-    @Override
-    public ComparatorType getComparatorType()
-    {
-        return ComparatorType.BYTESTYPE;
-    }
-
-    @Override
-    public ByteBuffer fromString( String str )
-    {
-        return instance.fromString( str );
-    }
-
-    @Override
-    public String getString( ByteBuffer byteBuffer )
-    {
-        return instance.getString( byteBuffer );
-    }
-
-    /*
-    private static final String UTF_8 = "UTF-8";
-    private static final HugeStringSerializer instance = new HugeStringSerializer();
-    private static final Charset charset = Charset.forName(UTF_8);
-
-    public static HugeStringSerializer get() {
-        return instance;
-    }
-
-    @Override
-    public ByteBuffer toByteBuffer(String obj) {
-        if (obj == null) {
-            return null;
-        }
-        return ByteBuffer.wrap(obj.getBytes(charset));
-    }
-
-    @Override
-    public String fromByteBuffer(ByteBuffer byteBuffer) {
-        if (byteBuffer == null) {
-            return null;
-        }
-        final ByteBuffer dup = byteBuffer.duplicate();
-        return charset.decode(dup).toString();
-    }
-
-    @Override
-    public ComparatorType getComparatorType() {
-        return ComparatorType.UTF8TYPE;
-    }
-
-    @Override
-    public ByteBuffer fromString(String str) {
-        return UTF8Type.instance.fromString(str);
-    }
-
-    @Override
-    public String getString(ByteBuffer byteBuffer) {
-        return UTF8Type.instance.getString(byteBuffer);
-    }
-    */
-}
index a77c29ddae93f60dff3c57a9eb2fd0716baee02a..e49d31f16055172f7b6671f0679049b219c8faa6 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.archiva.metadata.repository.cassandra.model;
  */
 
 import com.netflix.astyanax.entitystore.Serializer;
-import com.netflix.astyanax.serializers.GzipStringSerializer;
 import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
 
 import javax.persistence.Column;
@@ -38,26 +37,26 @@ public class MetadataFacetModel
     // id is repositoryId + namespaceId + projectId + facetId + name + mapKey
     @Id
     @Column( name = "id" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String id;
 
     @Column( name = "artifactMetadataModel" )
     private ArtifactMetadataModel artifactMetadataModel;
 
     @Column( name = "facetId" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String facetId;
 
     @Column( name = "key" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String key;
 
     @Column( name = "name" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String name;
 
     @Column( name = "value" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String value;
 
     public MetadataFacetModel()
index c5eb24d613e504febb7effd84bf7452043ec0adc..391eb7a964ef80b7b15671fd2de99df4ff7a1a92 100644 (file)
@@ -39,11 +39,11 @@ public class Namespace
 
     @Id
     @Column( name = "id" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String id;
 
     @Column( name = "name" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String name;
 
     @Column( name = "repository" )
index 4ac0a0ad9c12cf179f5b05b41702024d9841832d..741e6cd708f10341741ed12ba15eed405cc7266d 100644 (file)
@@ -36,11 +36,11 @@ public class Project
 {
     @Id
     @Column( name = "projectKey" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String projectKey;
 
     @Column( name = "projectId" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String projectId;
 
 
index 8d8b57b1acaab61b1c6e7cee7558df70b4cf2d41..8b8805b195fb11cc1cfa48b9af797d096936b20e 100644 (file)
@@ -43,7 +43,7 @@ public class ProjectVersionMetadataModel
 {
     // repositoryId + namespace + projectId + id (version)
     @Id
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String rowId;
 
     @Column( name = "namespace" )
@@ -53,23 +53,23 @@ public class ProjectVersionMetadataModel
      * id is the version
      */
     @Column( name = "id" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String id;
 
     @Column( name = "projectId" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String projectId;
 
     @Column( name = "url" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String url;
 
     @Column( name = "name" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String name;
 
     @Column( name = "description" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String description;
 
     @Column( name = "organization" )
index b3c684c0ea44359740d7f9ae32ed2e25096f8efd..87d5dea1080b12514026260e53847221d35328fe 100644 (file)
@@ -26,8 +26,6 @@ import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.Table;
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
 
 
 /**
@@ -41,11 +39,11 @@ public class Repository
 
     @Id
     @Column( name = "id" )
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String id;
 
     @Column(name = "name")
-    @Serializer( HugeStringSerializer.class )
+    @Serializer( DeflateStringSerializer.class )
     private String name;
 
     //private transient List<Namespace> namespaces = new ArrayList<Namespace>();