Spring RestTemplate GET: reading directories from Apache - spring

apache server is used for static contents. We are able to GET required resource having fully qualified path:(e.g. http://cmsTest.com/content/otp.txt). However, now we need to scan all folder available under
http://cmsTest.com/content
I need to access directories available at particular location via Spring REST GET api. When I am trying to access(http://cmsTest.com/content) it, getting 404 error.
Could you please provide suggestion for the same?

Related

Open API (Swagger) non working in Spring Boot when adding context path

I have a Spring Boot application exposing REST services that are easily called on addresses like
http://localhost:8080/<controller_mapping>/<service_mapping>.
I've been asked to modify my settings in order to add a context path and have my services to respond on
http://localhost:8080//gesev-mensa/<controller_mapping>/<service_mapping>.
Thus I edited my application.properties adding
server.servlet.context-path=/gesev-mensa
Everything works but I can't call Swagger on old address
http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
I get the error Failed to load remote configuration
As suggested, I tried to add property
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
but problem persists.
I guess Swagger should be reachable at
http://localhost:8080/gesev-mensa/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
but that doesn't work.
Any hint?
Thanks for support.
Try removing
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
from your properties,
And your swagger will be available in
http://localhost:8080/gesev-mensa/swagger-ui/index.html
As per your current configuration with,
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
Swagger will be available in
http://localhost:8080/gesev-mensa/gesev-mensa/swagger-ui/index.html

FF4J with Spring Boot in IBM WebSphere 8.5.11 server giving Error 500( SESN0008E) while accessing static resources(css,img)

I am using FF4J-Web as a maven jar dependency in my Spring Boot application. I am able to run the application in local environment without any issues( embedded tomcat and IBM Liberty Servers). However I am facing some issues in rendering view components when I promote the changes to development environment server(IBM WebSphere 8.5.X) which seems to be due to authorization issue. Please find below responses I got while accessing static contents.
Response Code 200: https://dummyserverlink.com/rootcontext/ff4j-web-console/static/js/jquery.dataTables.min.js
Response Code 500: https://dummyserverlink.com/rootcontext/ff4j-web-console/static/css/bootstrap.min.css
Response Code 500: https://dummyserverlink.com/rootcontext/ff4j-web-console/static/png/ff4j.png
As you can see above, .js files are downloading without any issues. But .css and .img files are not authorized and accessible in the browser(Error Code Status 500). But all resources are present under static folder only. Please note that since I have added FF4J as a maven dependency all the static contents are present inside WEB-INF/lib folder
So if I try to access the .css/.png resource directly from browser, I am getting error ‘Error 500: SESN0008E: A user authenticated as anonymous has attempted to access a session owned by loggedUserName.’
Disabling the security configuration in Websphere is not an option we can go with as the same server is used for multiple applications. Also I am using third party login API for authentication at server level.
Is there any other way that you can share you expertise to bypass the authorization error for static resources(css,img) that are inside the WEBINF folder?
Regards
Dinesh

Getting the upload folder in a Java servlet container

Could be a silly question, but...
I have a Spring-based WAR application that runs 80% of the installations on Tomcat and the rest 20% on WebSphere.
I need to simply get the path of the folder where Spring's MultipartFilter (using Commons multipart resolver) stores files being uploaded. I have never set it manually, and it actually belongs to the Catalina work directory as I found out in my Tomcat installations.
For the moment, I just need to get that path. I have control of my application so no one is going to change it without notice.
I would like to know if there is a server-agnostic way to know where my Spring-based application is going to store Multipart files.
E.g. from this question I can see I can use catalina.base, but in Tomcat... not in JBoss or WebSphere. It could cost me a couple of if/else statements...
Spring tries to do it already when no default value is set
WebUtils.getTempDir(servletContext)
Which simply does:
return ((File)servletContext.getAttribute("javax.servlet.context.tempdir"));
So simply if no one overrides that location in the filter properties (and that is my case) I can rely on the default.
More in general, one may have to inspect the instance of DiskItemFileFactory to get the path to the repository

How to set up a swagger-ui standalone server/application?

I would like to set up a standalone swagger-ui application, to view the different APIs from different servers in one central place.
In a second step I would like to customise swagger-ui to show multiple APIs at once.
I don't want to add swagger-ui to all the servers that provide swagger api-docs though.
To do so I would like to use spring boot and thought this should be an easy task. However, I have trouble getting it to work.
Here is what I did:
Generated a Spring Boot application using https://start.spring.io
included spring-boot-starter-web
added io.springfox:springfox-swagger-ui:2.3.1 dependency
When opening http://localhost:8080/swagger-ui.html I see a 404 error and UI seems broken:
Is there any reason for using Spring-boot instead of a simple web server for this?
See for example here with Nginx, including some basic authentication (pretty old link but still looking alright), or in the ReadMe of the swagger-ui github reposiory directly for easily serving with Connect/gulp-serve inside Docker (the setup can also be reproduced directly without Docker if wanted).
Also I have no idea why you're getting resources requested by the page on a different port... Just ask in case you still need help now on this topic.

Configuration issue with Mule ftpExt transport

I am using mule esb to transfer file from ftp to local directory. I am not using the standard FTP connector but the extended one.
I am getting an error:
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://localhost/schemaftpext/mule-ftpext.xsd'.
Actually I am new to Mule ESB, so i do not what is the url "http://localhost/schemaftpext/mule-ftpext.xsd" says that. I need to put anything in localhost?
FYI: I am using the example "http://code.google.com/p/mule-ftpext/source/browse/trunk/Test/mule-config.xml?spec=svn23&r=23". What should i do for that localhost URL?
http://localhost/schemaftpext/mule-ftpext.xsd is just a schema URI location: there is no need to have anything available there, it is just used as an identifier. Mule's configuration loader will resolve this URI to an actual location at load-up time. The actual location is within ftpExt-1.0-SNAPSHOT.jar.
Now this implies that you need to have is the ftpExt-1.0-SNAPSHOT.jar available in Mule's classpath. Is that the case?

Resources