summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-09-15 15:45:49 +0000
committerOlivier Lamy <olamy@apache.org>2011-09-15 15:45:49 +0000
commit4579f684aa761897191c06736b7fd4f12b2e1369 (patch)
treef9ec58d4aa5b4177a78ec6904e302decaeb7a4cb /archiva-modules/archiva-web
parent4298c23f6d50cde1b1737454c218c597f2415042 (diff)
downloadarchiva-4579f684aa761897191c06736b7fd4f12b2e1369.tar.gz
archiva-4579f684aa761897191c06736b7fd4f12b2e1369.zip
fix quick search which returns artifacts with classifier too : hackhish solution currently as I can't find a way to say in a Lucene query this field must empty or null
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1171151 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web')
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java35
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/searchfilter/ArtifactFiler.java32
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/searchfilter/NoClassifierArtifactFiler.java42
3 files changed, 6 insertions, 103 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
index 744842389..3f79041d1 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
@@ -30,8 +30,6 @@ import org.apache.archiva.rest.api.model.Dependency;
import org.apache.archiva.rest.api.model.SearchRequest;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.SearchService;
-import org.apache.archiva.rest.services.searchfilter.ArtifactFiler;
-import org.apache.archiva.rest.services.searchfilter.NoClassifierArtifactFiler;
import org.apache.archiva.security.AccessDeniedException;
import org.apache.archiva.security.ArchivaSecurityException;
import org.apache.archiva.security.PrincipalNotFoundException;
@@ -80,7 +78,7 @@ public class DefaultSearchService
SearchResults searchResults =
repositorySearch.search( getPrincipal(), getObservableRepos(), queryString, limits,
Collections.<String>emptyList() );
- return getArtifacts( searchResults, new ArrayList<ArtifactFiler>( NoClassifierArtifactFiler.LIST ) );
+ return getArtifacts( searchResults);
}
catch ( RepositorySearchException e )
@@ -105,7 +103,7 @@ public class DefaultSearchService
try
{
SearchResults searchResults = repositorySearch.search( getPrincipal(), searchField, null );
- return getArtifacts( searchResults, Collections.<ArtifactFiler>emptyList() );
+ return getArtifacts( searchResults );
}
catch ( RepositorySearchException e )
{
@@ -127,7 +125,7 @@ public class DefaultSearchService
try
{
SearchResults searchResults = repositorySearch.search( getPrincipal(), searchField, limits );
- return getArtifacts( searchResults, Collections.<ArtifactFiler>emptyList() );
+ return getArtifacts( searchResults );
}
catch ( RepositorySearchException e )
{
@@ -182,7 +180,7 @@ public class DefaultSearchService
: redbackRequestInformation.getUser().getUsername() );
}
- protected List<Artifact> getArtifacts( SearchResults searchResults, List<ArtifactFiler> artifactFilers )
+ protected List<Artifact> getArtifacts( SearchResults searchResults )
{
if ( searchResults == null || searchResults.isEmpty() )
{
@@ -226,34 +224,13 @@ public class DefaultSearchService
if ( StringUtils.isNotBlank( version ) )
{
versionned.setVersion( version );
- if ( applyFiltering( versionned, artifactFilers, artifacts ) )
- {
+
artifacts.add( versionned );
- }
+
}
}
}
}
return artifacts;
}
-
- protected boolean applyFiltering( Artifact artifact, List<ArtifactFiler> artifactFilers, List<Artifact> artifacts )
- {
- if ( artifact == null )
- {
- return false;
- }
- if ( artifactFilers == null || artifactFilers.isEmpty() )
- {
- return true;
- }
- for ( ArtifactFiler filter : artifactFilers )
- {
- if ( !filter.addArtifactInResult( artifact, artifacts ) )
- {
- return false;
- }
- }
- return true;
- }
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/searchfilter/ArtifactFiler.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/searchfilter/ArtifactFiler.java
deleted file mode 100644
index b07071ef7..000000000
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/searchfilter/ArtifactFiler.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.apache.archiva.rest.services.searchfilter;
-/*
- * 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 org.apache.archiva.rest.api.model.Artifact;
-
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- * @since 1.4
- */
-public interface ArtifactFiler
-{
- boolean addArtifactInResult( Artifact artifact, List<Artifact> currentResult );
-}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/searchfilter/NoClassifierArtifactFiler.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/searchfilter/NoClassifierArtifactFiler.java
deleted file mode 100644
index 7a92b124c..000000000
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/searchfilter/NoClassifierArtifactFiler.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.apache.archiva.rest.services.searchfilter;
-/*
- * 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.sun.org.apache.bcel.internal.generic.INSTANCEOF;
-import org.apache.archiva.rest.api.model.Artifact;
-import org.apache.commons.lang.StringUtils;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-public class NoClassifierArtifactFiler
- implements ArtifactFiler
-{
- public static final NoClassifierArtifactFiler INSTANCE = new NoClassifierArtifactFiler();
-
- public static final List<? extends ArtifactFiler> LIST = Arrays.asList( INSTANCE );
-
- public boolean addArtifactInResult( Artifact artifact, List<Artifact> currentResult )
- {
- return StringUtils.isBlank( artifact.getClassifier() );
- }
-}