From aaea9a7255e72725634af9f46bb59c4f61418776 Mon Sep 17 00:00:00 2001 From: adrianocrestani Date: Wed, 28 Oct 2009 06:38:34 +0000 Subject: applying patch tuscany_2552_phillipe_ramalho_09_30_2009.patch from TUSCANY-2552 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@830448 13f79535-47bb-0310-9956-ffa450edef68 --- .../search/impl/ArtifactDocumentProcessor.java | 121 ++++++++------------- 1 file changed, 47 insertions(+), 74 deletions(-) (limited to 'branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ArtifactDocumentProcessor.java') diff --git a/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ArtifactDocumentProcessor.java b/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ArtifactDocumentProcessor.java index 92aae110b4..fcfce34d88 100644 --- a/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ArtifactDocumentProcessor.java +++ b/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ArtifactDocumentProcessor.java @@ -28,107 +28,80 @@ import org.apache.tuscany.sca.domain.search.DocumentMap; import org.apache.tuscany.sca.domain.search.DocumentProcessor; /** - * * @version $Rev$ $Date$ */ public class ArtifactDocumentProcessor implements DocumentProcessor { - public Document process(DocumentProcessor parentProcessor, - DocumentMap documents, Object object, Document document, - String parent) { - - if (object instanceof Artifact) { - Artifact artifact = (Artifact) object; - // String uri = artifact.getURI(); + public Document process(DocumentProcessor parentProcessor, + DocumentMap documents, + Object object, + Document document, + String parent) { - // if (uri != null && uri.length() == 0) { - // uri = null; - // } - // - // if (uri != null) { - // - // if (uri.endsWith(".composite") - // || uri.endsWith(".component")) { - // - // parent += DomainPathAnalyzer.PATH_SEPARATOR - // + SearchFields.ARTIFACT_FIELD - // + DomainPathAnalyzer.TYPE_SEPARATOR + uri; - // - // if (document == null) { - // document = documents.get(uri); - // } - // - // document.add(new Field(SearchFields.ARTIFACT_FIELD, uri, - // Field.Store.YES, Field.Index.ANALYZED)); - // - // } - // - // } + if (object instanceof Artifact) { + Artifact artifact = (Artifact)object; - if (!(object instanceof Contribution)) { + if (!(object instanceof Contribution)) { - String location = artifact.getLocation(); + String location = artifact.getLocation(); - try { + try { - if (document == null) { - document = documents.get(SearchFields.ARTIFACT_FIELD + location); - } + if (document == null) { + document = documents.get(SearchFields.ARTIFACT_FIELD + location); + } - FileContent fileContent = new WrappedFileContent(new URL( - location)); + FileContent fileContent = new WrappedFileContent(new URL(location)); - document.add(new Field(SearchFields.ARTIFACT_FIELD, - fileContent.getName(), Field.Store.YES, - Field.Index.ANALYZED)); + document.add(new Field(SearchFields.ARTIFACT_FIELD, fileContent.getName(), Field.Store.YES, + Field.Index.ANALYZED)); - parent += DomainPathAnalyzer.PATH_SEPARATOR - + SearchFields.ARTIFACT_FIELD - + DomainPathAnalyzer.TYPE_SEPARATOR - + location + DomainPathAnalyzer.URI_SEPARATOR - + fileContent.getName(); + parent += + DomainPathAnalyzer.PATH_SEPARATOR + SearchFields.ARTIFACT_FIELD + + DomainPathAnalyzer.TYPE_SEPARATOR + + location + + DomainPathAnalyzer.URI_SEPARATOR + + fileContent.getName(); - // parent += DomainPathAnalyzer.PATH_SEPARATOR - // + SearchFields.FILE_FIELD - // + DomainPathAnalyzer.TYPE_SEPARATOR + location + - // DomainPathAnalyzer.URI_SEPARATOR + fileContent.getName(); + // parent += DomainPathAnalyzer.PATH_SEPARATOR + // + SearchFields.FILE_FIELD + // + DomainPathAnalyzer.TYPE_SEPARATOR + location + + // DomainPathAnalyzer.URI_SEPARATOR + fileContent.getName(); - Document fileDoc = parentProcessor.process(parentProcessor, - documents, fileContent, null, parent); + Document fileDoc = parentProcessor.process(parentProcessor, documents, fileContent, null, parent); - fileDoc.add(new Field(SearchFields.PARENT_FIELD, parent, - Field.Store.YES, Field.Index.ANALYZED)); + fileDoc.add(new Field(SearchFields.PARENT_FIELD, parent, Field.Store.YES, Field.Index.ANALYZED)); - } catch (IOException e) { - // ignore location - } + } catch (IOException e) { + // ignore location + } - } + } - return document == null ? FAKE_DOCUMENT : document; + return document == null ? FAKE_DOCUMENT : document; - } + } - throw new IllegalArgumentException(); + throw new IllegalArgumentException(); - } + } - public Object getDocumentKey(Object obj) { + public Object getDocumentKey(Object obj) { - if (obj instanceof Artifact) { - Artifact artifact = (Artifact) obj; - String uri = artifact.getLocation(); + if (obj instanceof Artifact) { + Artifact artifact = (Artifact)obj; + String uri = artifact.getLocation(); - if (uri != null && uri.length() == 0) { - return null; - } + if (uri != null && uri.length() == 0) { + return null; + } - return SearchFields.ARTIFACT_FIELD + uri; + return SearchFields.ARTIFACT_FIELD + uri; - } + } - throw new IllegalArgumentException(); + throw new IllegalArgumentException(); - } + } } -- cgit v1.2.3