Apache tika custom parser - apache-tika

<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-server-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parser-audiovideo-module</artifactId>
<version>2.3.0</version>
</dependency>
I have my own parser class also meta/services/ ... parser.Parser files
When i NOT use audio module -> i see my custom parser
When i add audio dependency -> i see audio parser, but dont see my custom
I think problem in audio module manifest file, which rewrite my own manifest file
How i can fix it???

Related

OpenApi hide a model property in the request

I know we can use this #ApiModelProperty annotation from this link to hide an id from the request when we use Swagger-Ui
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
But I am using this spring doc OpenApi dependency
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.2.32</version>
</dependency>
I am not getting this annotation #ApiModelProperty when I used springdoc-openapi-ui. What could be the annotation for this?
You have to replace swagger 2 annotations with swagger 3 annotations (it is already included with springdoc-openapi-ui dependency). Package for swagger 3 annotations is io.swagger.v3.oas.annotations.
It's all explained here:
https://springdoc.org/migrating-from-springfox.html

Type grid does not have type parameters

I began to study Vaadin and wrote the code as stated in the tutorial:
List<PatientEntity> personList = new ArrayList<>();
Grid<PatientEntity> grid = new Grid<>(PatientEntity.class);
I got errors in the second line
Type 'com.vaadin.ui.Grid' does not have type parameters" () and "Diamond operator is not applicable for non-parametrized types" (<>)
Dependencies from pom.xml:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>13.0.11</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-core</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
Type 'com.vaadin.ui.Grid' does not have type parameters
This is not the correct package. I think this is the grid from Vaadin 8. Try com.vaadin.flow.component.grid.Grid
Edit: adding #Tazavoo's comment into my answer, as it might very well solve your problem.
Have you added a Vaadin dependency to your pom.xml? Adding it to <dependencyManagement> does not actually add it as a dependency. You should keep the vaadin-bom there, as it will control the versions, but move vaadin-core to your actual <dependencies> tag.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>13.0.11</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-core</artifactId>
</dependency>
</dependencies>
With this pom structure your IDE should automatically suggest the correct Grid import to you (after you remove the incorrect import statement of course)
I'm not sure but you should try to remove the PatientEntity.class from the constructor
(as in the second exemple of vaadin)

Jersey 1.19 Grizzly 2.3.25 and Umlaute in URL - JUnit tests does not work while browser access does

In a RESTFul Jersey solution I am trying to receive URLs that contain German Umlaut characters e.g.
http://localhost:8085/hello/hello/echo/ÄÖÜßööü
When I enter such URLs with a browser I get correct results.
When I test things with a JUnit test it doesn't work.
org.junit.ComparisonFailure: expected:<[ÄÖÜßäöü]> but was:<[ÃÃÃÃäöü]>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.bitplan.rest.test.TestHello.testUmlaute(TestHello.java:43)
the debug output is:
http://localhost:8085/hello/hello/echo/%C3%84%C3%96%C3%9C%C3%9F%C3%A4%C3%B6%C3%BC
http://localhost:8085/hello/hello/echo/ÄÖÜßäöü
GET:hello/echo/ÃÃÃÃäöü
and so it seems the url is not handled correctly by Grizzly/Jersey.
How can I fix this or work around it?
I found: https://github.com/javaee/grizzly/issues/1377 and tried different encodings e.g. as proposed in https://stackoverflow.com/a/9542781/1497139 but that didn't make any difference.
I also set
server.getServerConfiguration().setDefaultQueryEncoding(Charsets.UTF8_CHARSET);
as outlined in https://github.com/javaee/grizzly/issues/1450 but still no luck
JUnit Test
see https://github.com/BITPlan/com.bitplan.simplerest/blob/master/src/test/java/com/bitplan/rest/test/TestHello.java#L42
#Test
public void testUmlaute() throws Exception {
super.startServer();
URI uri=new URI("http://localhost:8085/hello/hello/echo/ÄÖÜßäöü");
System.out.println(uri.toASCIIString());
System.out.println(uri.toString());
WebResource wrs = Client.create().resource(uri);
String result= wrs.accept("text/html; charset=utf-8").get(String.class);
assertEquals("ÄÖÜßäöü",result);
}
"Hello/Echo" Resource
package com.bitplan.hello.resources;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;
#Path("/hello")
/**
* Simple Hello Resource
* #author wf
*
*/
public class HelloResource {
#Context
UriInfo uriInfo;
#Context
Request request;
#GET
public String getHello() {
return "Hello";
}
#GET
#Produces("text/html")
#Path("echo/{value}")
public String getEcho(#PathParam("value") String value) {
System.out.println(request.getMethod()+":"+uriInfo.getPath());
return value;
}
}
maven dependencies
<properties>
<!-- jersey version -->
<!-- <jersey.version>2.22.2</jersey.version> -->
<jersey.version>1.19.1</jersey.version>
<!-- http://grizzly.java.net/ -->
<grizzly.version>2.3.25</grizzly.version>
...
</properties>
...
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>${jersey.version}</version>
</dependency>
<!-- Grizzly server -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-grizzly2</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-grizzly2-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-server</artifactId>
<version>${grizzly.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-servlet</artifactId>
<version>${grizzly.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http</artifactId>
<version>${grizzly.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>

Swagger-ui doesn't provide how i pass MediaType.APPLICATION_OCTET_STREAM content

Actually i am facing a problem that Swagger-ui can't show me input for MediaType.APPLICATION_OCTET_STREAM, so lets imagine this next service:
#PUT
#Path("/performAudioQuery")
#Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response performAudioQuery(InputStream audioInputStream){
//Impl of the service
}
and here are the dependencies
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.22.2</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
and i am using wildfly 9.x
So what should i do to make it possible for Swagger-ui working good with this previous service?
The current version of the Swagger/OpenAPI specification (2.0) doesn't deal kindly with file uploads as what's known as body parameter. We've formulated a workable solution that is covered at https://github.com/OAI/OpenAPI-Specification/issues/50 - however that solution is currently not fully supported by swagger-core and not supported at all in swagger-ui.

Portlet preferences

I'm trying to store portlet preferences in a backing bean (JSF) as mentioned in this tutorial
But, I can not understand how they imported Preference class here
Map<String, Preference> mutablePreferenceMap =
(Map<String, Preference>) elResolver.getValue(
facesContext.getELContext(), null, elExpression);
the package javax.portlet.* don't contain faces.preference.Preference
Anyone has an idea about that, specially how to save portlet preferences
thanks in advance
You have to add the Liferay Faces Bridge JAR to your project.
Add the following dependencies:
<dependencies>
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>liferay-faces-alloy</artifactId>
<version>3.1.0-ga1</version>
</dependency>
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>liferay-faces-bridge-impl</artifactId>
<version>3.1.0-ga1</version>
</dependency>
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>liferay-faces-portal</artifactId>
<version>3.1.0-ga1</version>
</dependency>
</dependencies>
and the liferay-faces-bridge-api jar which is a dependency for liferay-faces-bridge-impl has this Preference interface.
More info:
http://www.liferay.com/community/liferay-projects/liferay-faces/download

Resources