git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@726963 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-1.2
@@ -1,50 +0,0 @@ | |||
package org.apache.maven.archiva.indexer.functors; | |||
/* | |||
* 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.collections.Transformer; | |||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; | |||
import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory; | |||
/** | |||
* BytecodeIndexTransformer | |||
* | |||
* @version $Id$ | |||
* | |||
* @plexus.component role="org.apache.commons.collections.Transformer" role-hint="bytecode" | |||
*/ | |||
public class BytecodeIndexTransformer | |||
implements Transformer | |||
{ | |||
/** | |||
* @plexus.requirement role-hint="lucene" | |||
*/ | |||
private RepositoryContentIndexFactory indexFactory; | |||
public Object transform( Object input ) | |||
{ | |||
if ( input instanceof ManagedRepositoryConfiguration ) | |||
{ | |||
return indexFactory.createBytecodeIndex( (ManagedRepositoryConfiguration) input ); | |||
} | |||
return input; | |||
} | |||
} |
@@ -1,50 +0,0 @@ | |||
package org.apache.maven.archiva.indexer.functors; | |||
/* | |||
* 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.collections.Transformer; | |||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; | |||
import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory; | |||
/** | |||
* FileContentIndexTransformer | |||
* | |||
* @version $Id$ | |||
* | |||
* @plexus.component role="org.apache.commons.collections.Transformer" role-hint="filecontent" | |||
*/ | |||
public class FileContentIndexTransformer | |||
implements Transformer | |||
{ | |||
/** | |||
* @plexus.requirement role-hint="lucene" | |||
*/ | |||
private RepositoryContentIndexFactory indexFactory; | |||
public Object transform( Object input ) | |||
{ | |||
if ( input instanceof ManagedRepositoryConfiguration ) | |||
{ | |||
return indexFactory.createFileContentIndex( (ManagedRepositoryConfiguration) input ); | |||
} | |||
return input; | |||
} | |||
} |
@@ -1,50 +0,0 @@ | |||
package org.apache.maven.archiva.indexer.functors; | |||
/* | |||
* 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.collections.Transformer; | |||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; | |||
import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory; | |||
/** | |||
* HashcodesIndexTransformer | |||
* | |||
* @version $Id$ | |||
* | |||
* @plexus.component role="org.apache.commons.collections.Transformer" role-hint="hashcodes" | |||
*/ | |||
public class HashcodesIndexTransformer | |||
implements Transformer | |||
{ | |||
/** | |||
* @plexus.requirement role-hint="lucene" | |||
*/ | |||
private RepositoryContentIndexFactory indexFactory; | |||
public Object transform( Object input ) | |||
{ | |||
if ( input instanceof ManagedRepositoryConfiguration ) | |||
{ | |||
return indexFactory.createHashcodeIndex( (ManagedRepositoryConfiguration) input ); | |||
} | |||
return input; | |||
} | |||
} |
@@ -1,60 +0,0 @@ | |||
package org.apache.maven.archiva.indexer.functors; | |||
/* | |||
* 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.collections.Predicate; | |||
import org.apache.maven.archiva.indexer.RepositoryContentIndex; | |||
import org.apache.maven.archiva.indexer.RepositoryIndexException; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
/** | |||
* Test the {@link RepositoryContentIndex} object for the existance of an index. | |||
* | |||
* @version $Id$ | |||
*/ | |||
public class IndexExistsPredicate | |||
implements Predicate | |||
{ | |||
private Logger log = LoggerFactory.getLogger( IndexExistsPredicate.class ); | |||
public boolean evaluate( Object object ) | |||
{ | |||
boolean satisfies = false; | |||
if ( object instanceof RepositoryContentIndex ) | |||
{ | |||
RepositoryContentIndex index = (RepositoryContentIndex) object; | |||
try | |||
{ | |||
satisfies = index.exists(); | |||
} | |||
catch ( RepositoryIndexException e ) | |||
{ | |||
log.info( | |||
"Repository Content Index [" + index.getId() + "] for repository [" | |||
+ index.getRepository().getId() + "] does not exist yet in [" | |||
+ index.getIndexDirectory().getAbsolutePath() + "]." ); | |||
} | |||
} | |||
return satisfies; | |||
} | |||
} |
@@ -1,57 +0,0 @@ | |||
package org.apache.maven.archiva.indexer.functors; | |||
/* | |||
* 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.collections.Transformer; | |||
import org.apache.maven.archiva.indexer.RepositoryIndexSearchException; | |||
import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentIndex; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
/** | |||
* SearchableTransformer | |||
* | |||
* @version $Id$ | |||
* | |||
* @plexus.component role="org.apache.commons.collections.Transformer" role-hint="searchable" | |||
*/ | |||
public class SearchableTransformer | |||
implements Transformer | |||
{ | |||
private Logger log = LoggerFactory.getLogger( SearchableTransformer.class ); | |||
public Object transform( Object input ) | |||
{ | |||
if ( input instanceof LuceneRepositoryContentIndex ) | |||
{ | |||
try | |||
{ | |||
LuceneRepositoryContentIndex index = (LuceneRepositoryContentIndex) input; | |||
return index.getSearchable(); | |||
} | |||
catch ( RepositoryIndexSearchException e ) | |||
{ | |||
log.warn("Unable to get searchable for index:" + e.getMessage(), e); | |||
} | |||
} | |||
return input; | |||
} | |||
} |
@@ -1,45 +0,0 @@ | |||
package org.apache.maven.archiva.indexer.functors; | |||
/* | |||
* 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.collections.Predicate; | |||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; | |||
/** | |||
* UserAllowedToSearchRepositoryPredicate | |||
* | |||
* @version $Id$ | |||
*/ | |||
public class UserAllowedToSearchRepositoryPredicate | |||
implements Predicate | |||
{ | |||
public boolean evaluate( Object object ) | |||
{ | |||
boolean satisfies = false; | |||
if ( object instanceof ManagedRepositoryConfiguration ) | |||
{ | |||
// TODO: perform check here. | |||
satisfies = true; // Everyone is allowed! (for now) | |||
} | |||
return satisfies; | |||
} | |||
} |