diff options
author | adrianocrestani <adrianocrestani@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-17 06:24:15 +0000 |
---|---|---|
committer | adrianocrestani <adrianocrestani@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-17 06:24:15 +0000 |
commit | 53c043ac18ca8dd9d7f823bf7a399058c305003d (patch) | |
tree | 5b8184792065accca1e5a68092d0960db455cda6 /branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ZipDocumentProcessor.java | |
parent | a4f020f2df42181bf54587acddb3b748ff5f698f (diff) |
committing domain-search changes from patch tuscany_2552_phillipe_ramalho_08_16_2009.patch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@804871 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ZipDocumentProcessor.java | 99 |
1 files changed, 53 insertions, 46 deletions
diff --git a/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ZipDocumentProcessor.java b/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ZipDocumentProcessor.java index e6eeba0e37..2337c40fc1 100644 --- a/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ZipDocumentProcessor.java +++ b/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ZipDocumentProcessor.java @@ -31,66 +31,73 @@ import org.apache.tuscany.sca.domain.search.DocumentProcessor; * @version $Rev$ $Date$ */ public class ZipDocumentProcessor implements DocumentProcessor { - - public Object getDocumentKey(Object object) { - if (object instanceof File) { - File file = (File) object; - String path = file.getPath(); + public Object getDocumentKey(Object object) { - if (path != null && path.length() == 0) { - return null; - } + if (object instanceof File) { + File file = (File)object; + String path = file.getPath(); - return path; + if (path != null && path.length() == 0) { + return null; + } - } + return path; - throw new IllegalArgumentException(); + } - } + throw new IllegalArgumentException(); - public Document process(DocumentProcessor parentProcessor, - DocumentMap documents, Object object, Document document, - String parent) { + } - if (object instanceof SystemFileContent) { - SystemFileContent file = (SystemFileContent) object; + public Document process(DocumentProcessor parentProcessor, + DocumentMap documents, + Object object, + Document document, + String parent) { - try { - ZipFile zip = new ZipFile(file.getFile()); - - if (document == null) { - document = documents.get(file.getPath()); - } + if (object instanceof SystemFileContent) { + SystemFileContent file = (SystemFileContent)object; - parent += DomainPathAnalyzer.PATH_SEPARATOR - + SearchFields.ARTIFACT_FIELD - + DomainPathAnalyzer.TYPE_SEPARATOR + "jar:file:" + file.getPath() + DomainPathAnalyzer.ARCHIVE_SEPARATOR + '/' + file.getName() - + DomainPathAnalyzer.URI_SEPARATOR + file.getName(); - - document.add(new Field(SearchFields.ARTIFACT_FIELD, file.getName(), Field.Store.YES, - Field.Index.ANALYZED)); + try { + ZipFile zip = new ZipFile(file.getFile()); - ZipFileContent[] zipFiles = ZipFileContent.createZipFileContent(zip); + if (document == null) { + document = documents.get(file.getPath()); + } - for (ZipFileContent zipFile : zipFiles) { - - parentProcessor.process(parentProcessor, documents, - zipFile, document, parent); - - } - - return document; + parent += + DomainPathAnalyzer.PATH_SEPARATOR + SearchFields.ARTIFACT_FIELD + + DomainPathAnalyzer.TYPE_SEPARATOR + + "jar:file:" + + file.getPath() + + DomainPathAnalyzer.ARCHIVE_SEPARATOR + + '/' + + file.getName() + + DomainPathAnalyzer.URI_SEPARATOR + + file.getName(); - } catch (IOException e) { - // ignore file - } + document.add(new Field(SearchFields.ARTIFACT_FIELD, file.getName(), Field.Store.YES, + Field.Index.ANALYZED)); - } - - return null; + ZipFileContent[] zipFiles = ZipFileContent.createZipFileContent(zip); - } + for (ZipFileContent zipFile : zipFiles) { + + parentProcessor.process(parentProcessor, documents, zipFile, document, parent); + + } + + return document; + + } catch (IOException e) { + // ignore file + } + + } + + return null; + + } } |