You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by tp...@apache.org on 2015/03/13 23:09:53 UTC
svn commit: r1666596 [1/2] - in /tika/trunk: ./
tika-server/src/main/java/org/apache/tika/server/
tika-server/src/main/java/org/apache/tika/server/resource/
tika-server/src/main/java/org/apache/tika/server/writer/
tika-server/src/test/java/org/apache/t...
Author: tpalsulich
Date: Fri Mar 13 22:09:52 2015
New Revision: 1666596
URL: http://svn.apache.org/r1666596
Log:
TIKA-1564. Move tika-server resources and writers to their own packages.
Added:
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/DetectorResource.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/DetectorResource.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/MetadataResource.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/MetadataResource.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/RecursiveMetadataResource.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/RecursiveMetadataResource.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TarWriter.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TarWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaDetectors.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaDetectors.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaMimeTypes.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaMimeTypes.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaParsers.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaParsers.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaResource.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaVersion.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaVersion.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaWelcome.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaWelcome.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/UnpackerResource.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/UnpackerResource.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/
tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/CSVMessageBodyWriter.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/CSVMessageBodyWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/JSONMessageBodyWriter.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/JSONMessageBodyWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/MetadataListMessageBodyWriter.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/MetadataListMessageBodyWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/TextMessageBodyWriter.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TextMessageBodyWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/XMPMessageBodyWriter.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/XMPMessageBodyWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/ZipWriter.java
- copied, changed from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/ZipWriter.java
Removed:
tika/trunk/tika-server/src/main/java/org/apache/tika/server/CSVMessageBodyWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/DetectorResource.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/JSONMessageBodyWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/MetadataListMessageBodyWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/MetadataResource.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/RecursiveMetadataResource.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TarWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TextMessageBodyWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaDetectors.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaMimeTypes.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaParsers.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaVersion.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaWelcome.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/UnpackerResource.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/XMPMessageBodyWriter.java
tika/trunk/tika-server/src/main/java/org/apache/tika/server/ZipWriter.java
Modified:
tika/trunk/CHANGES.txt
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaServerCli.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/CXFTestBase.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/DetectorResourceTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/MetadataResourceTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/RecursiveMetadataResourceTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/StackTraceOffTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/StackTraceTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/TikaDetectorsTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/TikaMimeTypesTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/TikaParsersTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/TikaResourceTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/TikaVersionTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/TikaWelcomeTest.java
tika/trunk/tika-server/src/test/java/org/apache/tika/server/UnpackerResourceTest.java
Modified: tika/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/tika/trunk/CHANGES.txt?rev=1666596&r1=1666595&r2=1666596&view=diff
==============================================================================
--- tika/trunk/CHANGES.txt (original)
+++ tika/trunk/CHANGES.txt Fri Mar 13 22:09:52 2015
@@ -1,5 +1,8 @@
Release 1.8 - Current Development
+ * Move Tika server resources and writers to separate
+ org.apache.tika.server.resource and writer packages (TIKA-1564).
+
* Upgrade UCAR dependencies to 4.5.5 (TIKA-1571)
* Fix Paths in Tika server welcome page (TIKA-1567).
Modified: tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaServerCli.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaServerCli.java?rev=1666596&r1=1666595&r2=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaServerCli.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaServerCli.java Fri Mar 13 22:09:52 2015
@@ -37,6 +37,23 @@ import org.apache.cxf.jaxrs.lifecycle.Re
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
import org.apache.tika.Tika;
import org.apache.tika.config.TikaConfig;
+import org.apache.tika.server.resource.DetectorResource;
+import org.apache.tika.server.resource.MetadataResource;
+import org.apache.tika.server.resource.RecursiveMetadataResource;
+import org.apache.tika.server.resource.TarWriter;
+import org.apache.tika.server.resource.TikaDetectors;
+import org.apache.tika.server.resource.TikaMimeTypes;
+import org.apache.tika.server.resource.TikaParsers;
+import org.apache.tika.server.resource.TikaResource;
+import org.apache.tika.server.resource.TikaVersion;
+import org.apache.tika.server.resource.TikaWelcome;
+import org.apache.tika.server.resource.UnpackerResource;
+import org.apache.tika.server.writer.CSVMessageBodyWriter;
+import org.apache.tika.server.writer.JSONMessageBodyWriter;
+import org.apache.tika.server.writer.MetadataListMessageBodyWriter;
+import org.apache.tika.server.writer.TextMessageBodyWriter;
+import org.apache.tika.server.writer.XMPMessageBodyWriter;
+import org.apache.tika.server.writer.ZipWriter;
public class TikaServerCli {
public static final int DEFAULT_PORT = 9998;
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/DetectorResource.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/DetectorResource.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/DetectorResource.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/DetectorResource.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/DetectorResource.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/DetectorResource.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/DetectorResource.java Fri Mar 13 22:09:52 2015
@@ -1,26 +1,26 @@
-/**
- * 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.
- */
+/**
+ * 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.
+ */
-package org.apache.tika.server;
+package org.apache.tika.server.resource;
import javax.ws.rs.Consumes;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
+import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.UriInfo;
@@ -30,11 +30,11 @@ import java.io.InputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.tika.config.TikaConfig;
-import org.apache.tika.io.TikaInputStream;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.mime.MediaType;
-
+import org.apache.tika.config.TikaConfig;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.mime.MediaType;
+
@Path("/detect")
public class DetectorResource {
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/MetadataResource.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/MetadataResource.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/MetadataResource.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/MetadataResource.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/MetadataResource.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/MetadataResource.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/MetadataResource.java Fri Mar 13 22:09:52 2015
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.resource;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/RecursiveMetadataResource.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/RecursiveMetadataResource.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/RecursiveMetadataResource.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/RecursiveMetadataResource.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/RecursiveMetadataResource.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/RecursiveMetadataResource.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/RecursiveMetadataResource.java Fri Mar 13 22:09:52 2015
@@ -1,29 +1,29 @@
-/*
- * 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.
- */
+/*
+ * 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.
+ */
-package org.apache.tika.server;
+package org.apache.tika.server.resource;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -39,6 +39,7 @@ import org.apache.tika.parser.AutoDetect
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.RecursiveParserWrapper;
import org.apache.tika.sax.BasicContentHandlerFactory;
+import org.apache.tika.server.MetadataList;
import org.xml.sax.helpers.DefaultHandler;
@Path("/rmeta")
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TarWriter.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TarWriter.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TarWriter.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TarWriter.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/TarWriter.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/TarWriter.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TarWriter.java Fri Mar 13 22:09:52 2015
@@ -1,21 +1,21 @@
-/*
- * 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.
- */
+/*
+ * 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.
+ */
-package org.apache.tika.server;
+package org.apache.tika.server.resource;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaDetectors.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaDetectors.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaDetectors.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaDetectors.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaDetectors.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaDetectors.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaDetectors.java Fri Mar 13 22:09:52 2015
@@ -1,20 +1,20 @@
-/*
- * 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.
+/*
+ * 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.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -28,7 +28,8 @@ import java.util.Map;
import org.apache.tika.config.TikaConfig;
import org.apache.tika.detect.CompositeDetector;
import org.apache.tika.detect.Detector;
-import org.eclipse.jetty.util.ajax.JSON;
+import org.apache.tika.server.HTMLHelper;
+import org.eclipse.jetty.util.ajax.JSON;
/**
* <p>Provides details of all the {@link Detector}s registered with
@@ -47,9 +48,9 @@ public class TikaDetectors {
@GET
@Produces("text/html")
public String getDectorsHTML() {
- StringBuffer h = new StringBuffer();
- html.generateHeader(h, "Detectors available to Apache Tika");
- detectorAsHTML(tika.getDetector(), h, 2);
+ StringBuffer h = new StringBuffer();
+ html.generateHeader(h, "Detectors available to Apache Tika");
+ detectorAsHTML(tika.getDetector(), h, 2);
html.generateFooter(h);
return h.toString();
}
@@ -63,8 +64,8 @@ public class TikaDetectors {
html.append("</h");
html.append(level);
html.append(">");
- html.append("<p>Class: ");
- html.append(name);
+ html.append("<p>Class: ");
+ html.append(name);
html.append("</p>");
if (d instanceof CompositeDetector) {
html.append("<p>Composite Detector</p>");
@@ -101,7 +102,7 @@ public class TikaDetectors {
@GET
@Produces("text/plain")
public String getDetectorsPlain() {
- StringBuffer text = new StringBuffer();
+ StringBuffer text = new StringBuffer();
renderDetector(tika.getDetector(), text, 0);
return text.toString();
}
@@ -122,6 +123,6 @@ public class TikaDetectors {
renderDetector(sd, text, indent + 1);
}
} else {
- text.append("\n"); }
- }
+ text.append("\n"); }
+ }
}
\ No newline at end of file
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaMimeTypes.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaMimeTypes.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaMimeTypes.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaMimeTypes.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaMimeTypes.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaMimeTypes.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaMimeTypes.java Fri Mar 13 22:09:52 2015
@@ -1,20 +1,20 @@
-/*
- * 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.
+/*
+ * 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.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -29,10 +29,11 @@ import java.util.TreeMap;
import org.apache.tika.config.TikaConfig;
import org.apache.tika.mime.MediaType;
-import org.apache.tika.mime.MediaTypeRegistry;
-import org.apache.tika.parser.CompositeParser;
-import org.apache.tika.parser.Parser;
-import org.eclipse.jetty.util.ajax.JSON;
+import org.apache.tika.mime.MediaTypeRegistry;
+import org.apache.tika.parser.CompositeParser;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.server.HTMLHelper;
+import org.eclipse.jetty.util.ajax.JSON;
/**
* <p>Provides details of all the mimetypes known to Apache Tika,
@@ -64,8 +65,8 @@ public class TikaMimeTypes {
firstType.put(type.type.getType(), type.type.toString());
}
}
- h.append("<ul>");
- for (String section : firstType.keySet()) {
+ h.append("<ul>");
+ for (String section : firstType.keySet()) {
h.append("<li><a href=\"#").append(firstType.get(section)).append("\">").append(section).append("</a></li>\n");
}
h.append("</ul>");
@@ -85,8 +86,8 @@ public class TikaMimeTypes {
if (type.parser != null) {
h.append("<div>Parser: ").append(type.parser).append("</div>\n");
}
- }
-
+ }
+
html.generateFooter(h);
return h.toString();
}
@@ -101,11 +102,11 @@ public class TikaMimeTypes {
typeDets.put("alias", type.aliases);
if (type.supertype != null) {
- typeDets.put("supertype", type.supertype);
- }
- if (type.parser != null) {
- typeDets.put("parser", type.parser);
- }
+ typeDets.put("supertype", type.supertype);
+ }
+ if (type.parser != null) {
+ typeDets.put("parser", type.parser);
+ }
details.put(type.type.toString(), typeDets);
}
@@ -132,7 +133,7 @@ public class TikaMimeTypes {
if (type.parser != null) {
text.append(" parser: ").append(type.parser).append("\n");
}
- }
+ }
return text.toString();
}
@@ -170,7 +171,7 @@ public class TikaMimeTypes {
private static class MediaTypeDetails {
private MediaType type;
private MediaType[] aliases;
- private MediaType supertype;
- private String parser;
- }
-}
+ private MediaType supertype;
+ private String parser;
+ }
+}
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaParsers.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaParsers.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaParsers.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaParsers.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaParsers.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaParsers.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaParsers.java Fri Mar 13 22:09:52 2015
@@ -1,20 +1,20 @@
-/*
- * 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.
+/*
+ * 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.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -23,19 +23,20 @@ import javax.ws.rs.Produces;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.tika.config.TikaConfig;
import org.apache.tika.mime.MediaType;
import org.apache.tika.parser.CompositeParser;
-import org.apache.tika.parser.ParseContext;
-import org.apache.tika.parser.Parser;
-import org.apache.tika.parser.ParserDecorator;
-import org.eclipse.jetty.util.ajax.JSON;
+import org.apache.tika.parser.ParseContext;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.parser.ParserDecorator;
+import org.apache.tika.server.HTMLHelper;
+import org.eclipse.jetty.util.ajax.JSON;
/**
* <p>Provides details of all the {@link Parser}s registered with
@@ -79,17 +80,17 @@ public class TikaParsers {
private void parserAsHTML(ParserDetails p, boolean withMimeTypes, StringBuffer html, int level) {
html.append("<h");
html.append(level);
- html.append(">");
- html.append(p.shortName);
- html.append("</h");
- html.append(level);
- html.append(">");
- html.append("<p>Class: ");
- html.append(p.className);
- html.append("</p>");
- if (p.isDecorated) {
- html.append("<p>Decorated Parser</p>");
- }
+ html.append(">");
+ html.append(p.shortName);
+ html.append("</h");
+ html.append(level);
+ html.append(">");
+ html.append("<p>Class: ");
+ html.append(p.className);
+ html.append("</p>");
+ if (p.isDecorated) {
+ html.append("<p>Decorated Parser</p>");
+ }
if (p.isComposite) {
html.append("<p>Composite Parser</p>");
for (Parser cp : p.childParsers) {
@@ -97,13 +98,13 @@ public class TikaParsers {
}
} else if (withMimeTypes) {
html.append("<p>Mime Types:");
- html.append("<ul>");
- for (MediaType mt : p.supportedTypes) {
- html.append("<li>");
- html.append(mt.toString());
- html.append("</li>");
- }
- html.append("</ul>");
+ html.append("<ul>");
+ for (MediaType mt : p.supportedTypes) {
+ html.append("<li>");
+ html.append(mt.toString());
+ html.append("</li>");
+ }
+ html.append("</ul>");
html.append("</p>");
}
}
@@ -139,12 +140,12 @@ public class TikaParsers {
parserAsMap(new ParserDetails(cp), withMimeTypes, cdet);
c.add(cdet);
}
- details.put("children", c);
- } else if (withMimeTypes) {
- List<String> mts = new ArrayList<String>(p.supportedTypes.size());
- for (MediaType mt : p.supportedTypes) {
- mts.add(mt.toString());
- }
+ details.put("children", c);
+ } else if (withMimeTypes) {
+ List<String> mts = new ArrayList<String>(p.supportedTypes.size());
+ for (MediaType mt : p.supportedTypes) {
+ mts.add(mt.toString());
+ }
details.put("supportedTypes", mts);
}
}
@@ -174,23 +175,23 @@ public class TikaParsers {
text.append(indent);
text.append(p.className);
if (p.isDecorated) {
- text.append(" (Decorated Parser)");
- }
- if (p.isComposite) {
- text.append(" (Composite Parser):\n");
-
- for (Parser cp : p.childParsers) {
- renderParser(new ParserDetails(cp), withMimeTypes, text, nextIndent);
- }
- } else {
- text.append("\n");
- if (withMimeTypes) {
- for (MediaType mt : p.supportedTypes) {
- text.append(nextIndent);
- text.append("Supports: ");
- text.append(mt.toString());
- text.append("\n");
- }
+ text.append(" (Decorated Parser)");
+ }
+ if (p.isComposite) {
+ text.append(" (Composite Parser):\n");
+
+ for (Parser cp : p.childParsers) {
+ renderParser(new ParserDetails(cp), withMimeTypes, text, nextIndent);
+ }
+ } else {
+ text.append("\n");
+ if (withMimeTypes) {
+ for (MediaType mt : p.supportedTypes) {
+ text.append(nextIndent);
+ text.append("Supports: ");
+ text.append(mt.toString());
+ text.append("\n");
+ }
}
}
}
@@ -198,7 +199,7 @@ public class TikaParsers {
private static class ParserDetails {
private String className;
private String shortName;
- private boolean isComposite;
+ private boolean isComposite;
private boolean isDecorated;
private Set<MediaType> supportedTypes;
private List<Parser> childParsers;
@@ -221,14 +222,14 @@ public class TikaParsers {
((CompositeParser) p).getParsers(EMPTY_PC).values());
// Sort it by class name
childParsers = new ArrayList<Parser>(children);
- Collections.sort(childParsers, new Comparator<Parser>() { @Override
- public int compare(Parser p1, Parser p2) {
- return p1.getClass().getName().compareTo(p2.getClass().getName());
- }
- });
- } else {
- supportedTypes = p.getSupportedTypes(EMPTY_PC);
- }
- }
- }
+ Collections.sort(childParsers, new Comparator<Parser>() { @Override
+ public int compare(Parser p1, Parser p2) {
+ return p1.getClass().getName().compareTo(p2.getClass().getName());
+ }
+ });
+ } else {
+ supportedTypes = p.getSupportedTypes(EMPTY_PC);
+ }
+ }
+ }
}
\ No newline at end of file
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaResource.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaResource.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaResource.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaResource.java Fri Mar 13 22:09:52 2015
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.resource;
import javax.mail.internet.ContentDisposition;
import javax.mail.internet.ParseException;
@@ -70,6 +70,8 @@ import org.apache.tika.parser.ocr.Tesser
import org.apache.tika.parser.pdf.PDFParserConfig;
import org.apache.tika.sax.BodyContentHandler;
import org.apache.tika.sax.ExpandedTitleContentHandler;
+import org.apache.tika.server.RichTextContentHandler;
+import org.apache.tika.server.TikaServerParseException;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaVersion.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaVersion.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaVersion.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaVersion.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaVersion.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaVersion.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaVersion.java Fri Mar 13 22:09:52 2015
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -23,17 +23,17 @@ import javax.ws.rs.Produces;
import org.apache.tika.Tika;
import org.apache.tika.config.TikaConfig;
-@Path("/version")
-public class TikaVersion {
- private Tika tika;
-
- public TikaVersion(TikaConfig tika) {
- this.tika = new Tika(tika);
- }
-
- @GET
- @Produces("text/plain")
- public String getVersion() {
- return tika.toString();
- }
-}
+@Path("/version")
+public class TikaVersion {
+ private Tika tika;
+
+ public TikaVersion(TikaConfig tika) {
+ this.tika = new Tika(tika);
+ }
+
+ @GET
+ @Produces("text/plain")
+ public String getVersion() {
+ return tika.toString();
+ }
+}
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaWelcome.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaWelcome.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaWelcome.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaWelcome.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaWelcome.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaWelcome.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/TikaWelcome.java Fri Mar 13 22:09:52 2015
@@ -13,21 +13,21 @@
* 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.
- */
-package org.apache.tika.server;
-
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.OPTIONS;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
+ */
+package org.apache.tika.server.resource;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HEAD;
+import javax.ws.rs.OPTIONS;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
@@ -35,74 +35,75 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
-import org.apache.tika.Tika;
-import org.apache.tika.config.TikaConfig;
-
-/**
- * <p>Provides a basic welcome to the Apache Tika Server.</p>
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.tika.Tika;
+import org.apache.tika.config.TikaConfig;
+import org.apache.tika.server.HTMLHelper;
+
+/**
+ * <p>Provides a basic welcome to the Apache Tika Server.</p>
*/
-@Path("/")
-public class TikaWelcome {
- private static final String DOCS_URL = "https://wiki.apache.org/tika/TikaJAXRS";
-
- private static final Map<Class<? extends Annotation>, String> HTTP_METHODS =
- new HashMap<Class<? extends Annotation>, String>();
-
- static {
- HTTP_METHODS.put(DELETE.class, "DELETE");
- HTTP_METHODS.put(GET.class, "GET");
- HTTP_METHODS.put(HEAD.class, "HEAD");
- HTTP_METHODS.put(OPTIONS.class, "OPTIONS");
- HTTP_METHODS.put(POST.class, "POST");
- HTTP_METHODS.put(PUT.class, "PUT");
- }
-
- private Tika tika;
- private HTMLHelper html;
- private List<Class<?>> endpoints = new LinkedList<Class<?>>();
-
- public TikaWelcome(TikaConfig tika, List<ResourceProvider> rCoreProviders) {
- this.tika = new Tika(tika);
- this.html = new HTMLHelper();
+@Path("/")
+public class TikaWelcome {
+ private static final String DOCS_URL = "https://wiki.apache.org/tika/TikaJAXRS";
+
+ private static final Map<Class<? extends Annotation>, String> HTTP_METHODS =
+ new HashMap<Class<? extends Annotation>, String>();
+
+ static {
+ HTTP_METHODS.put(DELETE.class, "DELETE");
+ HTTP_METHODS.put(GET.class, "GET");
+ HTTP_METHODS.put(HEAD.class, "HEAD");
+ HTTP_METHODS.put(OPTIONS.class, "OPTIONS");
+ HTTP_METHODS.put(POST.class, "POST");
+ HTTP_METHODS.put(PUT.class, "PUT");
+ }
+
+ private Tika tika;
+ private HTMLHelper html;
+ private List<Class<?>> endpoints = new LinkedList<Class<?>>();
+
+ public TikaWelcome(TikaConfig tika, List<ResourceProvider> rCoreProviders) {
+ this.tika = new Tika(tika);
+ this.html = new HTMLHelper();
for (ResourceProvider rp : rCoreProviders) {
- this.endpoints.add(rp.getResourceClass());
- }
- }
-
- protected List<Endpoint> identifyEndpoints() {
- List<Endpoint> found = new ArrayList<Endpoint>();
- for (Class<?> endpoint : endpoints) {
+ this.endpoints.add(rp.getResourceClass());
+ }
+ }
+
+ protected List<Endpoint> identifyEndpoints() {
+ List<Endpoint> found = new ArrayList<Endpoint>();
+ for (Class<?> endpoint : endpoints) {
Path p = endpoint.getAnnotation(Path.class);
String basePath = null;
if (p != null)
basePath = p.value().endsWith("/") ? p.value().substring(0, p.value().length()-2):p.value();
for (Method m : endpoint.getMethods()) {
- String httpMethod = null;
- String methodPath = null;
- String[] produces = null;
-
- for (Annotation a : m.getAnnotations()) {
- for (Class<? extends Annotation> httpMethAnn : HTTP_METHODS.keySet()) {
- if (httpMethAnn.isInstance(a)) {
+ String httpMethod = null;
+ String methodPath = null;
+ String[] produces = null;
+
+ for (Annotation a : m.getAnnotations()) {
+ for (Class<? extends Annotation> httpMethAnn : HTTP_METHODS.keySet()) {
+ if (httpMethAnn.isInstance(a)) {
httpMethod = HTTP_METHODS.get(httpMethAnn);
- }
- }
- if (a instanceof Path) {
- methodPath = ((Path) a).value();
- }
- if (a instanceof Produces) {
- produces = ((Produces) a).value();
- }
- }
-
- if (httpMethod != null) {
- String mPath = basePath;
- if (mPath == null) {
+ }
+ }
+ if (a instanceof Path) {
+ methodPath = ((Path) a).value();
+ }
+ if (a instanceof Produces) {
+ produces = ((Produces) a).value();
+ }
+ }
+
+ if (httpMethod != null) {
+ String mPath = basePath;
+ if (mPath == null) {
mPath = "";
}
if (methodPath != null) {
@@ -129,21 +130,21 @@ public class TikaWelcome {
}
return res;
}
- });
- return found;
- }
-
- @GET
- @Produces("text/html")
- public String getWelcomeHTML() {
+ });
+ return found;
+ }
+
+ @GET
+ @Produces("text/html")
+ public String getWelcomeHTML() {
StringBuffer h = new StringBuffer();
- String tikaVersion = tika.toString();
-
- html.generateHeader(h, "Welcome to the " + tikaVersion + " Server");
-
- h.append("<p>For endpoints, please see <a href=\"");
- h.append(DOCS_URL);
- h.append("\">");
+ String tikaVersion = tika.toString();
+
+ html.generateHeader(h, "Welcome to the " + tikaVersion + " Server");
+
+ h.append("<p>For endpoints, please see <a href=\"");
+ h.append(DOCS_URL);
+ h.append("\">");
h.append(DOCS_URL);
h.append("</a>");
@@ -189,19 +190,19 @@ public class TikaWelcome {
}
@GET
- @Produces("text/plain")
- public String getWelcomePlain() {
- StringBuffer text = new StringBuffer();
-
- text.append(tika.toString());
- text.append("\n");
- text.append("For endpoints, please see ");
- text.append(DOCS_URL);
- text.append("\n\n");
-
- for (Endpoint e : identifyEndpoints()) {
- text.append(e.httpMethod);
- text.append(" ");
+ @Produces("text/plain")
+ public String getWelcomePlain() {
+ StringBuffer text = new StringBuffer();
+
+ text.append(tika.toString());
+ text.append("\n");
+ text.append("For endpoints, please see ");
+ text.append(DOCS_URL);
+ text.append("\n\n");
+
+ for (Endpoint e : identifyEndpoints()) {
+ text.append(e.httpMethod);
+ text.append(" ");
text.append(e.path);
text.append("\n");
for (String produces : e.produces) {
@@ -210,20 +211,20 @@ public class TikaWelcome {
text.append("\n");
}
}
-
- return text.toString();
- }
-
- protected class Endpoint {
- public final String className;
- public final String methodName;
- public final String path;
- public final String httpMethod;
- public final List<String> produces;
-
- protected Endpoint(Class<?> endpoint, Method method, String path,
- String httpMethod, String[] produces) {
- this.className = endpoint.getCanonicalName();
+
+ return text.toString();
+ }
+
+ protected class Endpoint {
+ public final String className;
+ public final String methodName;
+ public final String path;
+ public final String httpMethod;
+ public final List<String> produces;
+
+ protected Endpoint(Class<?> endpoint, Method method, String path,
+ String httpMethod, String[] produces) {
+ this.className = endpoint.getCanonicalName();
this.methodName = method.getName();
this.path = path;
this.httpMethod = httpMethod;
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/UnpackerResource.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/UnpackerResource.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/UnpackerResource.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/UnpackerResource.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/UnpackerResource.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/UnpackerResource.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/resource/UnpackerResource.java Fri Mar 13 22:09:52 2015
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.resource;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
@@ -59,6 +59,7 @@ import org.apache.tika.parser.AutoDetect
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.microsoft.OfficeParser;
import org.apache.tika.sax.BodyContentHandler;
+import org.apache.tika.server.RichTextContentHandler;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/CSVMessageBodyWriter.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/CSVMessageBodyWriter.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/CSVMessageBodyWriter.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/CSVMessageBodyWriter.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/CSVMessageBodyWriter.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/CSVMessageBodyWriter.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/CSVMessageBodyWriter.java Fri Mar 13 22:09:52 2015
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.writer;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
@@ -37,34 +37,34 @@ import org.apache.tika.io.IOUtils;
import org.apache.tika.metadata.Metadata;
@Provider
-@Produces("text/csv")
-public class CSVMessageBodyWriter implements MessageBodyWriter<Metadata> {
-
- public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
- return Metadata.class.isAssignableFrom(type);
- }
-
- public long getSize(Metadata data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
- return -1;
- }
-
- @Override
- @SuppressWarnings("resource")
- public void writeTo(Metadata metadata, Class<?> type, Type genericType, Annotation[] annotations,
- MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException,
- WebApplicationException {
-
- CSVWriter writer = new CSVWriter(new OutputStreamWriter(entityStream, IOUtils.UTF_8));
-
- for (String name : metadata.names()) {
- String[] values = metadata.getValues(name);
- ArrayList<String> list = new ArrayList<String>(values.length + 1);
- list.add(name);
- list.addAll(Arrays.asList(values));
- writer.writeNext(list.toArray(values));
- }
-
- // Don't close, just flush the stream
- writer.flush();
- }
-}
+@Produces("text/csv")
+public class CSVMessageBodyWriter implements MessageBodyWriter<Metadata> {
+
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return Metadata.class.isAssignableFrom(type);
+ }
+
+ public long getSize(Metadata data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ @SuppressWarnings("resource")
+ public void writeTo(Metadata metadata, Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException,
+ WebApplicationException {
+
+ CSVWriter writer = new CSVWriter(new OutputStreamWriter(entityStream, IOUtils.UTF_8));
+
+ for (String name : metadata.names()) {
+ String[] values = metadata.getValues(name);
+ ArrayList<String> list = new ArrayList<String>(values.length + 1);
+ list.add(name);
+ list.addAll(Arrays.asList(values));
+ writer.writeNext(list.toArray(values));
+ }
+
+ // Don't close, just flush the stream
+ writer.flush();
+ }
+}
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/JSONMessageBodyWriter.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/JSONMessageBodyWriter.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/JSONMessageBodyWriter.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/JSONMessageBodyWriter.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/JSONMessageBodyWriter.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/JSONMessageBodyWriter.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/JSONMessageBodyWriter.java Fri Mar 13 22:09:52 2015
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.writer;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
@@ -37,28 +37,28 @@ import org.apache.tika.metadata.Metadata
import org.apache.tika.metadata.serialization.JsonMetadata;
@Provider
-@Produces(MediaType.APPLICATION_JSON)
-public class JSONMessageBodyWriter implements MessageBodyWriter<Metadata> {
-
- public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
- return Metadata.class.isAssignableFrom(type);
- }
-
- public long getSize(Metadata data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
- return -1;
- }
-
- @Override
- public void writeTo(Metadata metadata, Class<?> type, Type genericType, Annotation[] annotations,
- MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException,
- WebApplicationException {
- try {
- Writer writer = new OutputStreamWriter(entityStream, IOUtils.UTF_8);
- JsonMetadata.toJson(metadata, writer);
+@Produces(MediaType.APPLICATION_JSON)
+public class JSONMessageBodyWriter implements MessageBodyWriter<Metadata> {
+
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return Metadata.class.isAssignableFrom(type);
+ }
+
+ public long getSize(Metadata data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(Metadata metadata, Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException,
+ WebApplicationException {
+ try {
+ Writer writer = new OutputStreamWriter(entityStream, IOUtils.UTF_8);
+ JsonMetadata.toJson(metadata, writer);
writer.flush();
} catch (TikaException e) {
- throw new IOException(e);
- }
- entityStream.flush();
- }
-}
+ throw new IOException(e);
+ }
+ entityStream.flush();
+ }
+}
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/MetadataListMessageBodyWriter.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/MetadataListMessageBodyWriter.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/MetadataListMessageBodyWriter.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/MetadataListMessageBodyWriter.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/MetadataListMessageBodyWriter.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/MetadataListMessageBodyWriter.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/MetadataListMessageBodyWriter.java Fri Mar 13 22:09:52 2015
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.writer;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
@@ -34,33 +34,34 @@ import java.lang.reflect.Type;
import org.apache.tika.exception.TikaException;
import org.apache.tika.io.IOUtils;
import org.apache.tika.metadata.serialization.JsonMetadataList;
+import org.apache.tika.server.MetadataList;
@Provider
-@Produces(MediaType.APPLICATION_JSON)
-public class MetadataListMessageBodyWriter implements MessageBodyWriter<MetadataList> {
-
- public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
- if (!MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
- return false;
- }
- return type.isAssignableFrom(MetadataList.class);
- }
-
- public long getSize(MetadataList data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
- return -1;
- }
-
- @Override
- public void writeTo(MetadataList list, Class<?> type, Type genericType, Annotation[] annotations,
- MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException,
- WebApplicationException {
- try {
- Writer writer = new OutputStreamWriter(entityStream, IOUtils.UTF_8);
- JsonMetadataList.toJson(list.getMetadata(), writer);
+@Produces(MediaType.APPLICATION_JSON)
+public class MetadataListMessageBodyWriter implements MessageBodyWriter<MetadataList> {
+
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ if (!MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
+ return false;
+ }
+ return type.isAssignableFrom(MetadataList.class);
+ }
+
+ public long getSize(MetadataList data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(MetadataList list, Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException,
+ WebApplicationException {
+ try {
+ Writer writer = new OutputStreamWriter(entityStream, IOUtils.UTF_8);
+ JsonMetadataList.toJson(list.getMetadata(), writer);
writer.flush();
} catch (TikaException e) {
- throw new IOException(e);
- }
- entityStream.flush();
- }
-}
+ throw new IOException(e);
+ }
+ entityStream.flush();
+ }
+}
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/TextMessageBodyWriter.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/TextMessageBodyWriter.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/TextMessageBodyWriter.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/TextMessageBodyWriter.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/TextMessageBodyWriter.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/TextMessageBodyWriter.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/TextMessageBodyWriter.java Fri Mar 13 22:09:52 2015
@@ -1,40 +1,40 @@
-/*
- * 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.
- */
-
-package org.apache.tika.server;
-
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.Provider;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import org.apache.tika.io.IOUtils;
-import org.apache.tika.metadata.Metadata;
-
-/**
+/*
+ * 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.
+ */
+
+package org.apache.tika.server.writer;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import org.apache.tika.io.IOUtils;
+import org.apache.tika.metadata.Metadata;
+
+/**
* Returns simple text string for a particular metadata value.
* This assumes that the metadata object only has one key;
* if there is more than one key or no keys, this will throw a webapp exception.
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/XMPMessageBodyWriter.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/XMPMessageBodyWriter.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/XMPMessageBodyWriter.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/XMPMessageBodyWriter.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/XMPMessageBodyWriter.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/XMPMessageBodyWriter.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/XMPMessageBodyWriter.java Fri Mar 13 22:09:52 2015
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.tika.server;
+package org.apache.tika.server.writer;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
@@ -49,19 +49,19 @@ public class XMPMessageBodyWriter implem
public long getSize(Metadata data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return -1;
}
-
- @Override
- public void writeTo(Metadata metadata, Class<?> type, Type genericType, Annotation[] annotations,
- MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException,
- WebApplicationException {
- try {
- Writer writer = new OutputStreamWriter(entityStream, IOUtils.UTF_8);
- XMPMetadata xmp = new XMPMetadata(metadata);
- writer.write(xmp.toString());
- writer.flush();
- } catch (TikaException e) {
- throw new IOException(e);
- }
- entityStream.flush();
- }
-}
+
+ @Override
+ public void writeTo(Metadata metadata, Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException,
+ WebApplicationException {
+ try {
+ Writer writer = new OutputStreamWriter(entityStream, IOUtils.UTF_8);
+ XMPMetadata xmp = new XMPMetadata(metadata);
+ writer.write(xmp.toString());
+ writer.flush();
+ } catch (TikaException e) {
+ throw new IOException(e);
+ }
+ entityStream.flush();
+ }
+}
Copied: tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/ZipWriter.java (from r1665746, tika/trunk/tika-server/src/main/java/org/apache/tika/server/ZipWriter.java)
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/ZipWriter.java?p2=tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/ZipWriter.java&p1=tika/trunk/tika-server/src/main/java/org/apache/tika/server/ZipWriter.java&r1=1665746&r2=1666596&rev=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/ZipWriter.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/writer/ZipWriter.java Fri Mar 13 22:09:52 2015
@@ -1,21 +1,21 @@
-/*
- * 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.
- */
+/*
+ * 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.
+ */
-package org.apache.tika.server;
+package org.apache.tika.server.writer;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
@@ -27,10 +27,10 @@ import javax.ws.rs.ext.Provider;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Map;
-import java.util.UUID;
-import java.util.zip.CRC32;
+import java.lang.reflect.Type;
+import java.util.Map;
+import java.util.UUID;
+import java.util.zip.CRC32;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipOutputStream;
Modified: tika/trunk/tika-server/src/test/java/org/apache/tika/server/CXFTestBase.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/test/java/org/apache/tika/server/CXFTestBase.java?rev=1666596&r1=1666595&r2=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/test/java/org/apache/tika/server/CXFTestBase.java (original)
+++ tika/trunk/tika-server/src/test/java/org/apache/tika/server/CXFTestBase.java Fri Mar 13 22:09:52 2015
@@ -1,22 +1,22 @@
-/*
- * 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.
- */
-
-package org.apache.tika.server;
-
+/*
+ * 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.
+ */
+
+package org.apache.tika.server;
+
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -24,24 +24,25 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.ArchiveInputStream;
-import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
-import org.apache.commons.compress.archivers.zip.ZipFile;
-import org.apache.cxf.binding.BindingFactoryManager;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.jaxrs.JAXRSBindingFactory;
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.tika.config.TikaConfig;
-import org.apache.tika.io.IOUtils;
-import org.junit.After;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.JAXRSBindingFactory;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.tika.config.TikaConfig;
+import org.apache.tika.io.IOUtils;
+import org.apache.tika.server.resource.UnpackerResource;
+import org.junit.After;
import org.junit.Before;
public abstract class CXFTestBase {
@@ -105,11 +106,11 @@ public abstract class CXFTestBase {
/**
* Have the test do {@link JAXRSServerFactoryBean#setProviders(java.util.List)}, if needed
*/
- protected abstract void setUpProviders(JAXRSServerFactoryBean sf);
-
- @After
- public void tearDown() throws Exception {
- server.stop();
+ protected abstract void setUpProviders(JAXRSServerFactoryBean sf);
+
+ @After
+ public void tearDown() throws Exception {
+ server.stop();
server.destroy();
}
@@ -150,13 +151,13 @@ public abstract class CXFTestBase {
Map<String, String> data = new HashMap<String, String>();
while (true) {
ArchiveEntry entry = zip.getNextEntry();
- if (entry == null) {
- break;
- }
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- IOUtils.copy(zip, bos);
- data.put(entry.getName(), DigestUtils.md5Hex(bos.toByteArray()));
+ if (entry == null) {
+ break;
+ }
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ IOUtils.copy(zip, bos);
+ data.put(entry.getName(), DigestUtils.md5Hex(bos.toByteArray()));
}
return data;
Modified: tika/trunk/tika-server/src/test/java/org/apache/tika/server/DetectorResourceTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/test/java/org/apache/tika/server/DetectorResourceTest.java?rev=1666596&r1=1666595&r2=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/test/java/org/apache/tika/server/DetectorResourceTest.java (original)
+++ tika/trunk/tika-server/src/test/java/org/apache/tika/server/DetectorResourceTest.java Fri Mar 13 22:09:52 2015
@@ -1,22 +1,22 @@
-/**
- * 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.
- */
-
-package org.apache.tika.server;
-
+/**
+ * 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.
+ */
+
+package org.apache.tika.server;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -28,8 +28,11 @@ import java.util.List;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
-import org.junit.Test;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.tika.server.resource.DetectorResource;
+import org.apache.tika.server.resource.TarWriter;
+import org.apache.tika.server.writer.ZipWriter;
+import org.junit.Test;
public class DetectorResourceTest extends CXFTestBase {
Modified: tika/trunk/tika-server/src/test/java/org/apache/tika/server/MetadataResourceTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/test/java/org/apache/tika/server/MetadataResourceTest.java?rev=1666596&r1=1666595&r2=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/test/java/org/apache/tika/server/MetadataResourceTest.java (original)
+++ tika/trunk/tika-server/src/test/java/org/apache/tika/server/MetadataResourceTest.java Fri Mar 13 22:09:52 2015
@@ -38,6 +38,11 @@ import org.apache.cxf.jaxrs.client.WebCl
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.serialization.JsonMetadata;
+import org.apache.tika.server.resource.MetadataResource;
+import org.apache.tika.server.writer.CSVMessageBodyWriter;
+import org.apache.tika.server.writer.JSONMessageBodyWriter;
+import org.apache.tika.server.writer.TextMessageBodyWriter;
+import org.apache.tika.server.writer.XMPMessageBodyWriter;
import org.junit.Assert;
import org.junit.Test;
Modified: tika/trunk/tika-server/src/test/java/org/apache/tika/server/RecursiveMetadataResourceTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/test/java/org/apache/tika/server/RecursiveMetadataResourceTest.java?rev=1666596&r1=1666595&r2=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/test/java/org/apache/tika/server/RecursiveMetadataResourceTest.java (original)
+++ tika/trunk/tika-server/src/test/java/org/apache/tika/server/RecursiveMetadataResourceTest.java Fri Mar 13 22:09:52 2015
@@ -14,40 +14,42 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-package org.apache.tika.server;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import javax.ws.rs.core.Response;
-
-import java.io.InputStream;
+
+package org.apache.tika.server;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import javax.ws.rs.core.Response;
+
+import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
import org.apache.tika.io.IOUtils;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.metadata.serialization.JsonMetadataList;
-import org.junit.Test;
-
-public class RecursiveMetadataResourceTest extends CXFTestBase {
- private static final String META_PATH = "/rmeta";
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.metadata.serialization.JsonMetadataList;
+import org.apache.tika.server.resource.RecursiveMetadataResource;
+import org.apache.tika.server.writer.MetadataListMessageBodyWriter;
+import org.junit.Test;
+
+public class RecursiveMetadataResourceTest extends CXFTestBase {
+ private static final String META_PATH = "/rmeta";
private static final String TEST_RECURSIVE_DOC = "test_recursive_embedded.docx";
@Override
- protected void setUpResources(JAXRSServerFactoryBean sf) {
- sf.setResourceClasses(RecursiveMetadataResource.class);
- sf.setResourceProvider(RecursiveMetadataResource.class,
- new SingletonResourceProvider(new RecursiveMetadataResource(tika)));
- }
-
- @Override
+ protected void setUpResources(JAXRSServerFactoryBean sf) {
+ sf.setResourceClasses(RecursiveMetadataResource.class);
+ sf.setResourceProvider(RecursiveMetadataResource.class,
+ new SingletonResourceProvider(new RecursiveMetadataResource(tika)));
+ }
+
+ @Override
protected void setUpProviders(JAXRSServerFactoryBean sf) {
List<Object> providers = new ArrayList<Object>();
providers.add(new MetadataListMessageBodyWriter());
@@ -75,24 +77,24 @@ public class RecursiveMetadataResourceTe
Response response = WebClient
.create(endPoint + META_PATH)
.type("application/vnd.ms-excel")
- .accept("application/json")
- .put(ClassLoader
- .getSystemResourceAsStream(TikaResourceTest.TEST_PASSWORD_PROTECTED));
-
- // Won't work, no password given
- assertEquals(500, response.getStatus());
-
- // Try again, this time with the password
- response = WebClient
- .create(endPoint + META_PATH)
+ .accept("application/json")
+ .put(ClassLoader
+ .getSystemResourceAsStream(TikaResourceTest.TEST_PASSWORD_PROTECTED));
+
+ // Won't work, no password given
+ assertEquals(500, response.getStatus());
+
+ // Try again, this time with the password
+ response = WebClient
+ .create(endPoint + META_PATH)
.type("application/vnd.ms-excel")
- .accept("application/json")
- .header("Password", "password")
- .put(ClassLoader.getSystemResourceAsStream(TikaResourceTest.TEST_PASSWORD_PROTECTED));
-
- // Will work
- assertEquals(200, response.getStatus());
-
+ .accept("application/json")
+ .header("Password", "password")
+ .put(ClassLoader.getSystemResourceAsStream(TikaResourceTest.TEST_PASSWORD_PROTECTED));
+
+ // Will work
+ assertEquals(200, response.getStatus());
+
// Check results
Reader reader = new InputStreamReader((InputStream) response.getEntity(), IOUtils.UTF_8);
List<Metadata> metadataList = JsonMetadataList.fromJson(reader);
Modified: tika/trunk/tika-server/src/test/java/org/apache/tika/server/StackTraceOffTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/test/java/org/apache/tika/server/StackTraceOffTest.java?rev=1666596&r1=1666595&r2=1666596&view=diff
==============================================================================
--- tika/trunk/tika-server/src/test/java/org/apache/tika/server/StackTraceOffTest.java (original)
+++ tika/trunk/tika-server/src/test/java/org/apache/tika/server/StackTraceOffTest.java Fri Mar 13 22:09:52 2015
@@ -31,6 +31,15 @@ import org.apache.cxf.jaxrs.JAXRSServerF
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.tika.server.resource.DetectorResource;
+import org.apache.tika.server.resource.MetadataResource;
+import org.apache.tika.server.resource.RecursiveMetadataResource;
+import org.apache.tika.server.resource.TikaResource;
+import org.apache.tika.server.resource.UnpackerResource;
+import org.apache.tika.server.writer.CSVMessageBodyWriter;
+import org.apache.tika.server.writer.JSONMessageBodyWriter;
+import org.apache.tika.server.writer.TextMessageBodyWriter;
+import org.apache.tika.server.writer.XMPMessageBodyWriter;
import org.junit.Assert;
import org.junit.Test;