import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.indexer.search.SearchResultHit;
-import org.apache.maven.archiva.indexer.search.SearchResultLimits;
-import org.apache.maven.archiva.indexer.search.SearchResults;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.nexus.index.ArtifactInfo;
import java.util.List;
-import org.apache.maven.archiva.indexer.search.SearchResultLimits;
-import org.apache.maven.archiva.indexer.search.SearchResults;
public interface RepositorySearch
{
--- /dev/null
+package org.apache.archiva.indexer.search;
+
+/*
+ * 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.commons.lang.StringUtils;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * SearchResultHit
+ *
+ * @version $Id: SearchResultHit.java 740552 2009-02-04 01:09:17Z oching $
+ */
+public class SearchResultHit
+{
+ // The (optional) context for this result.
+ private String context;
+
+ // Basic hit, direct to non-artifact resource.
+ private String url;
+
+ // Advanced hit, reference to groupId.
+ private String groupId;
+
+ // Advanced hit, reference to artifactId.
+ private String artifactId;
+
+ // TODO: remove/deprecate this field!
+ private String version = "";
+
+ private String repositoryId = "";
+
+ private List<String> versions = new ArrayList();
+
+ private ArchivaArtifact artifact;
+
+ public String getContext()
+ {
+ return context;
+ }
+
+ public void setContext( String context )
+ {
+ this.context = context;
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public void setUrl( String url )
+ {
+ this.url = url;
+ }
+
+ public String getUrlFilename()
+ {
+ return this.url.substring( this.url.lastIndexOf( '/' ) );
+ }
+
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ public void setArtifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+ }
+
+ public void setArtifact( ArchivaArtifact artifact )
+ {
+ this.artifact = artifact;
+ final String ver = artifact.getVersion();
+
+ if ( !this.versions.contains( ver ) )
+ {
+ this.versions.add( ver );
+ }
+
+ if ( StringUtils.isBlank( this.groupId ) )
+ {
+ this.groupId = artifact.getGroupId();
+ }
+
+ if ( StringUtils.isBlank( this.artifactId ) )
+ {
+ this.artifactId = artifact.getArtifactId();
+ }
+
+ if ( StringUtils.isBlank( this.version ) )
+ {
+ this.version = ver;
+ }
+ }
+
+ public ArchivaArtifact getArtifact()
+ {
+ return artifact;
+ }
+
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion(String version)
+ {
+ this.version = version;
+ }
+
+ public List<String> getVersions()
+ {
+ return versions;
+ }
+
+ public void setVersions(List<String> versions)
+ {
+ this.versions = versions;
+ }
+
+ public String getRepositoryId()
+ {
+ return repositoryId;
+ }
+
+ public void setRepositoryId( String repositoryId )
+ {
+ this.repositoryId = repositoryId;
+ }
+
+ public void addVersion( String version )
+ {
+ if( versions == null )
+ {
+ versions = new ArrayList<String>();
+ }
+
+ versions.add( version );
+ }
+}
--- /dev/null
+package org.apache.archiva.indexer.search;
+
+/*
+ * 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.
+ */
+
+/**
+ * SearchResultLimits - used to provide the search some limits on how the results are returned.
+ * This can provide paging for the
+ *
+ * @version $Id: SearchResultLimits.java 718864 2008-11-19 06:33:35Z brett $
+ */
+public class SearchResultLimits
+{
+ /**
+ * Constant to use for {@link #setSelectedPage(int)} to indicate a desire to get ALL PAGES.
+ * USE WITH CAUTION!!
+ */
+ public static final int ALL_PAGES = ( -1 );
+
+ private int pageSize = 30;
+
+ private int selectedPage = 0;
+
+ public SearchResultLimits( int selectedPage )
+ {
+ this.selectedPage = selectedPage;
+ }
+
+ public int getPageSize()
+ {
+ return pageSize;
+ }
+
+ /**
+ * Set page size for maximum # of hits to return per page.
+ *
+ * @param pageSize size of page by # of hits. (maximum value is 200)
+ */
+ public void setPageSize( int pageSize )
+ {
+ this.pageSize = Math.min( 200, pageSize );
+ }
+
+ public int getSelectedPage()
+ {
+ return selectedPage;
+ }
+
+ public void setSelectedPage( int selectedPage )
+ {
+ this.selectedPage = selectedPage;
+ }
+}
--- /dev/null
+package org.apache.archiva.indexer.search;
+
+/*
+ * 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.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * SearchResults
+ *
+ * @version $Id: SearchResults.java 742859 2009-02-10 05:35:05Z jdumay $
+ */
+public class SearchResults
+{
+ private List repositories = new ArrayList();
+
+ private Map<String, SearchResultHit> hits = new HashMap();
+
+ private int totalHits;
+
+ private SearchResultLimits limits;
+
+ public SearchResults()
+ {
+ /* do nothing */
+ }
+
+ // for new RepositorySearch
+ public void addHit( String id, SearchResultHit hit )
+ {
+ hits.put( id, hit );
+ }
+
+ /**
+ * Get the list of {@link SearchResultHit} objects.
+ *
+ * @return the list of {@link SearchResultHit} objects.
+ */
+ public List<SearchResultHit> getHits()
+ {
+ return new ArrayList( hits.values() );
+ }
+
+ public Map<String, SearchResultHit> getHitsMap()
+ {
+ return hits;
+ }
+
+ public List getRepositories()
+ {
+ return repositories;
+ }
+
+ public boolean isEmpty()
+ {
+ return hits.isEmpty();
+ }
+
+ public void setRepositories( List repositories )
+ {
+ this.repositories = repositories;
+ }
+
+ public SearchResultLimits getLimits()
+ {
+ return limits;
+ }
+
+ public void setLimits( SearchResultLimits limits )
+ {
+ this.limits = limits;
+ }
+
+ public int getTotalHits()
+ {
+ return totalHits;
+ }
+
+ public void setTotalHits( int totalHits )
+ {
+ this.totalHits = totalHits;
+ }
+}
+++ /dev/null
-package org.apache.maven.archiva.indexer.search;
-
-/*
- * 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.commons.lang.StringUtils;
-import org.apache.maven.archiva.model.ArchivaArtifact;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * SearchResultHit
- *
- * @version $Id$
- */
-public class SearchResultHit
-{
- // The (optional) context for this result.
- private String context;
-
- // Basic hit, direct to non-artifact resource.
- private String url;
-
- // Advanced hit, reference to groupId.
- private String groupId;
-
- // Advanced hit, reference to artifactId.
- private String artifactId;
-
- // TODO: remove/deprecate this field!
- private String version = "";
-
- private String repositoryId = "";
-
- private List<String> versions = new ArrayList();
-
- private ArchivaArtifact artifact;
-
- public String getContext()
- {
- return context;
- }
-
- public void setContext( String context )
- {
- this.context = context;
- }
-
- public String getUrl()
- {
- return url;
- }
-
- public void setUrl( String url )
- {
- this.url = url;
- }
-
- public String getUrlFilename()
- {
- return this.url.substring( this.url.lastIndexOf( '/' ) );
- }
-
- public String getArtifactId()
- {
- return artifactId;
- }
-
- public void setArtifactId( String artifactId )
- {
- this.artifactId = artifactId;
- }
-
- public void setArtifact( ArchivaArtifact artifact )
- {
- this.artifact = artifact;
- final String ver = artifact.getVersion();
-
- if ( !this.versions.contains( ver ) )
- {
- this.versions.add( ver );
- }
-
- if ( StringUtils.isBlank( this.groupId ) )
- {
- this.groupId = artifact.getGroupId();
- }
-
- if ( StringUtils.isBlank( this.artifactId ) )
- {
- this.artifactId = artifact.getArtifactId();
- }
-
- if ( StringUtils.isBlank( this.version ) )
- {
- this.version = ver;
- }
- }
-
- public ArchivaArtifact getArtifact()
- {
- return artifact;
- }
-
- public String getGroupId()
- {
- return groupId;
- }
-
- public void setGroupId( String groupId )
- {
- this.groupId = groupId;
- }
-
- public String getVersion()
- {
- return version;
- }
-
- public void setVersion(String version)
- {
- this.version = version;
- }
-
- public List<String> getVersions()
- {
- return versions;
- }
-
- public void setVersions(List<String> versions)
- {
- this.versions = versions;
- }
-
- public String getRepositoryId()
- {
- return repositoryId;
- }
-
- public void setRepositoryId( String repositoryId )
- {
- this.repositoryId = repositoryId;
- }
-
- public void addVersion( String version )
- {
- if( versions == null )
- {
- versions = new ArrayList<String>();
- }
-
- versions.add( version );
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.indexer.search;
-
-/*
- * 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.
- */
-
-/**
- * SearchResultLimits - used to provide the search some limits on how the results are returned.
- * This can provide paging for the
- *
- * @version $Id$
- */
-public class SearchResultLimits
-{
- /**
- * Constant to use for {@link #setSelectedPage(int)} to indicate a desire to get ALL PAGES.
- * USE WITH CAUTION!!
- */
- public static final int ALL_PAGES = ( -1 );
-
- private int pageSize = 30;
-
- private int selectedPage = 0;
-
- public SearchResultLimits( int selectedPage )
- {
- this.selectedPage = selectedPage;
- }
-
- public int getPageSize()
- {
- return pageSize;
- }
-
- /**
- * Set page size for maximum # of hits to return per page.
- *
- * @param pageSize size of page by # of hits. (maximum value is 200)
- */
- public void setPageSize( int pageSize )
- {
- this.pageSize = Math.min( 200, pageSize );
- }
-
- public int getSelectedPage()
- {
- return selectedPage;
- }
-
- public void setSelectedPage( int selectedPage )
- {
- this.selectedPage = selectedPage;
- }
-}
+++ /dev/null
-package org.apache.maven.archiva.indexer.search;
-
-/*
- * 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.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * SearchResults
- *
- * @version $Id$
- */
-public class SearchResults
-{
- private List repositories = new ArrayList();
-
- private Map<String, SearchResultHit> hits = new HashMap();
-
- private int totalHits;
-
- private SearchResultLimits limits;
-
- public SearchResults()
- {
- /* do nothing */
- }
-
- // for new RepositorySearch
- public void addHit( String id, SearchResultHit hit )
- {
- hits.put( id, hit );
- }
-
- /**
- * Get the list of {@link SearchResultHit} objects.
- *
- * @return the list of {@link SearchResultHit} objects.
- */
- public List<SearchResultHit> getHits()
- {
- return new ArrayList( hits.values() );
- }
-
- public Map<String, SearchResultHit> getHitsMap()
- {
- return hits;
- }
-
- public List getRepositories()
- {
- return repositories;
- }
-
- public boolean isEmpty()
- {
- return hits.isEmpty();
- }
-
- public void setRepositories( List repositories )
- {
- this.repositories = repositories;
- }
-
- public SearchResultLimits getLimits()
- {
- return limits;
- }
-
- public void setLimits( SearchResultLimits limits )
- {
- this.limits = limits;
- }
-
- public int getTotalHits()
- {
- return totalHits;
- }
-
- public void setTotalHits( int totalHits )
- {
- this.totalHits = totalHits;
- }
-}
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.indexer.search.SearchResultHit;
-import org.apache.maven.archiva.indexer.search.SearchResultLimits;
-import org.apache.maven.archiva.indexer.search.SearchResults;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import org.easymock.MockControl;
import org.sonatype.nexus.index.ArtifactContext;
import org.apache.archiva.indexer.search.RepositorySearch;
import org.apache.archiva.indexer.search.RepositorySearchException;
import org.apache.archiva.indexer.search.SearchFields;
+import org.apache.archiva.indexer.search.SearchResultHit;
+import org.apache.archiva.indexer.search.SearchResultLimits;
+import org.apache.archiva.indexer.search.SearchResults;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.Constraint;
import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint;
-import org.apache.maven.archiva.indexer.RepositoryIndexException;
-import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
-import org.apache.maven.archiva.indexer.search.SearchResultLimits;
-import org.apache.maven.archiva.indexer.search.SearchResults;
import org.apache.maven.archiva.security.AccessDeniedException;
import org.apache.maven.archiva.security.ArchivaSecurityException;
import org.apache.maven.archiva.security.ArchivaXworkUser;
import com.opensymphony.xwork2.Preparable;
import org.apache.maven.archiva.common.utils.VersionUtil;
import org.apache.maven.archiva.database.constraints.UniqueVersionConstraint;
-import org.apache.maven.archiva.indexer.search.SearchResultHit;
import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
// advanced search MRM-90 -- filtered search
public String filteredSearch()
- throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
+ throws MalformedURLException
{
if ( ( groupId == null || "".equals( groupId ) ) &&
( artifactId == null || "".equals( artifactId ) ) && ( className == null || "".equals( className ) ) &&
}
public String quickSearch()
- throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
+ throws MalformedURLException
{
/* TODO: give action message if indexing is in progress.
* This should be based off a count of 'unprocessed' artifacts.
import org.apache.archiva.indexer.search.RepositorySearch;
import org.apache.archiva.indexer.search.SearchFields;
+import org.apache.archiva.indexer.search.SearchResultHit;
+import org.apache.archiva.indexer.search.SearchResultLimits;
+import org.apache.archiva.indexer.search.SearchResults;
import org.apache.archiva.indexer.util.SearchUtil;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint;
import org.apache.maven.archiva.database.constraints.UniqueVersionConstraint;
-import org.apache.maven.archiva.indexer.search.SearchResultHit;
-import org.apache.maven.archiva.indexer.search.SearchResultLimits;
-import org.apache.maven.archiva.indexer.search.SearchResults;
import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.security.ArchivaXworkUser;
import org.apache.maven.archiva.security.UserRepositories;
import java.util.List;
import org.apache.archiva.indexer.search.RepositorySearch;
+import org.apache.archiva.indexer.search.SearchResultHit;
+import org.apache.archiva.indexer.search.SearchResultLimits;
+import org.apache.archiva.indexer.search.SearchResults;
import org.apache.archiva.web.xmlrpc.api.SearchService;
import org.apache.archiva.web.xmlrpc.api.beans.Artifact;
import org.apache.archiva.web.xmlrpc.api.beans.Dependency;
import org.apache.maven.archiva.database.browsing.BrowsingResults;
import org.apache.maven.archiva.database.browsing.RepositoryBrowsing;
import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint;
-import org.apache.maven.archiva.indexer.search.SearchResultHit;
-import org.apache.maven.archiva.indexer.search.SearchResultLimits;
-import org.apache.maven.archiva.indexer.search.SearchResults;
import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import java.util.List;
import org.apache.archiva.indexer.search.RepositorySearch;
+import org.apache.archiva.indexer.search.SearchResultHit;
+import org.apache.archiva.indexer.search.SearchResultLimits;
+import org.apache.archiva.indexer.search.SearchResults;
import org.apache.archiva.indexer.util.SearchUtil;
import org.apache.archiva.web.xmlrpc.api.SearchService;
import org.apache.archiva.web.xmlrpc.api.beans.Artifact;
import org.apache.maven.archiva.database.browsing.BrowsingResults;
import org.apache.maven.archiva.database.browsing.RepositoryBrowsing;
import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint;
-import org.apache.maven.archiva.indexer.search.SearchResultHit;
-import org.apache.maven.archiva.indexer.search.SearchResultLimits;
-import org.apache.maven.archiva.indexer.search.SearchResults;
import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;