Is there a way how to retrieve, using the Logback API, the Logback path location pragmatically? - backlog

I have a Java/C++ application, the java part uses Backlog and I need to put the C++ part log files into the same path location as Backlog. Is there a way how to retrieve, using the Logback API, the Logback path location pragmatically (the fileNamePattern value in logback.xml) ?
Thanks

Related

How to write a path that points outside a JAR file

I am facing a problem while developing a standalone web application compiled with Maven.
I am using a third-party software (Tom Sawyer) inside the program that needs to be pointed to a file outside the JAR file. Besides, I am only able to feed it a File location (ie. C:path/to/file.json or /../../file.json) via a user interface.
However, whatever I feed the software I get an error FileNotFound :
java.io.FileNotFoundException: JAR entry project/..\..\..\..\modelData.json not found in C:\Users\victor\Desktop\ea-prototype\Workspace\3_WEB\CSM\webappCSM_v0.1\target\Model-1.0.6-SNAPSHOT.jar!/BOOT-INF/classes
at org.springframework.boot.loader.jar.JarURLConnection.throwFileNotFound(JarURLConnection.java:178) ~[Model-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.springframework.boot.loader.jar.JarURLConnection.connect(JarURLConnection.java:101) ~[Model-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.springframework.boot.loader.jar.JarURLConnection.getInputStream(JarURLConnection.java:165) ~[Model-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at java.base/java.net.URL.openStream(URL.java:1152) ~[na:na]
I would like to know if the JarURLConnection is able to process a file from outside the Jar, and if yes, will /.. or /. allow the software to 'climb out' of the Jar ?
Thanks
I have found the solution to my problem. It is very specific to the related sofware I am using. Anyway here it goes :
I checked the option 'URL' instead of 'File Path' and wrote a file URL location ie.
file:///C:/path/to/my/file.json
Though, it will only work with absolute paths and not with relative paths.

Is it possible to exclude paths in Openapi code generation?

We are using a large third party API with many optional features. There are 27 endpoints and we need only a few of these from Maven. We are using server side generation.
If you are interested the API is here: https://github.com/mjeffrey/psd2
Ideally we would only generate and expose the ones we support.
Is it possible to just generate a list of API endpoints or exclude ones we don't want to support?
I see there is the possibility to generate only certain models but that is not what we need. the -D apis parameter seems tor be treated as a boolean in the source code.
https://github.com/OpenAPITools/openapi-generator#3---usage
https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#selective-generation
I'm also considering a pre-processor so we don't need to manually edit the yaml file (which is updated regularly). Any suggestions for preprocessing the yaml file?
The way to do this is to use the environment variable apis and provide a comma separated list of the root path-segment. Unfortunately in our case the root is /v1 so we get only one "api" generated and we can't select individual paths.
Stripping off the /v1 from all the paths we can then use:
Command line
java -Dapis="consents,{payment-service},accounts"
Maven
<configuration>
<environmentVariables>
<apis>consents,{payment-service},accounts</apis>
</environmentVariables>
</configuration>

How to get the project base path in Spring mvc web application?

I have spring mvc web application which is deployed on a tomcat server. On that project, I want to create folders and files in the runtime. currently I can create folders in the server root by using System.getProperty("catalina.base"). But when I deployed the project in a externel server I cant create folders on the root level of the tomcat server beacuse I don't have permissions. Intead of that I decided to create folders in following directory.
tomcat_dirctory/webapps/myproject_directory
so I need to create folders and files in side the myproject_directory in the runtime. Can anyone tell me what is the path for that. May be I can hardocde that as follows.
System.getProperty("catalina.base") + File.separator + "webapps"+File.separator+"myproject_directory"
But Instead of hard coding I prefer to know is there any alternative way to obtain my project path.
You can use getServletContext().getRealPath("/");
Gets the real path corresponding to the given virtual path.
For example, if path is equal to /index.html, this method will return the absolute file path on the server's filesystem to which a request of the form http://://index.html would be mapped, where corresponds to the context path of this ServletContext.
The real path returned will be in a form appropriate to the computer and operating system on which the servlet container is running, including the proper path separators.
Resources inside the /META-INF/resources directories of JAR files bundled in the application's /WEB-INF/lib directory must be considered only if the container has unpacked them from their containing JAR file, in which case the path to the unpacked location must be returned.
This method returns null if the servlet container is unable to translate the given virtual path to a real path.

how to deploy flex app using different web service urls?

Is there some sort of configuration settings in FlashBuilder 4.5 where you can easily switch between webservice urls? Right now I have to delete and recreate the web service every time I switch from local to production and vice versa.
The need/requirement is this – Since I work in a startup, we keep changing servers, and their IP addresses. And being a service oriented application – I need to be able to edit the webservice endpoints in my Flex application in a easy manner every time this happens.
My Solution for this -
Assumption is that my webservice endpoint looks like this -
http:////ListAllServices/
1) Create a file config.xml in a folder named “settings” that sits in the root folder of your Flex application – outside the “src” folder. And the config.xml will be a simple xml file of the following format -
localhostTestFlexApp
At the end of this exercise the directory structure of your flex source code will look like this -
flex_src(root of the source code)
-com(some source folder)
–testapp
—view
—
-images
-settings
–config.xml
-appName.mxml
2) Now in your application code, setup a HTTPService object either in mxml or action script. Set the url of that object to this value- “settings/config.xml” – And the above xml fiel containing the current settings will be loaded into memory .
Now you can store these values in a singleton object and construct your Webservice call at runtime.
And whenever you want to move this to a new server in production, edit the tag of your config.xml and you should be good to go.
And this can be automated as well via the EnvGen ant task.
This is not the best way but yes it is very helpful while switching among servers.
Alrighty... The way I was doing it before in fact worked. The problem was browser caching.
For the benefit of others I modified the subsclass for the generated service and replace the wsdl variable with whatever endpoint I need.

Generate webservice from wsdl

This is maybe a really simple question, but I couldn't locate an answer:
For a client I need to HOST a webservice. The client has sent me a wsdl file that the webservice should 'implement'. How do I go about that? I've generated any number of client-rpoxies but this is the other way around. I can use both ASP.NET 2.0 webservices or Windows Communication Foundation.
wsdl.exe /server.
Generates an abstract class for an XML
Web service based on the contracts.
The default is to generate client
proxy classes. When using the
/parameters option, this value is a
element that contains
"server".
You can do a similar thing with svcutil.exe for WCF- something like:
svcutil.exe thewsdl.wsdl /language:c# /out:ITheInterface.cs (I've not tested this).
Edit- John Saunders makes a good point in his answer to favour the WCF approach- I recommend this too.
Actually, you should do this with svcutil.exe, not with wsdl.exe. WSDL.EXE is part of the ASMX web service technology that Microsoft now considers to be "legacy" code, which will not have bugs fixed.
You can do plenty with that WSDL (wissd'le) file.
From doing the WS Class manually to use the Auto Generated class from wsdl.exe
let's imagine that, for your example, you have this WDSL (tooked from WebServiceX.Net)
to create a C# auto generated proxy you go to your command prompt and write:
wsdl /language:cs /protocol:soap /out:C:\myProxyScripts http://www.webservicex.net/TranslateService.asmx?wsdl
Note: inside your C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin folder you will find wsdl.exe or just do a dir /s inside your C:\Program Files\
if you want in Visual Basic, just use /language:vb or /l:vb
/language:
The language to use for the generated proxy class. Choose from 'CS',
'VB', 'JS', 'VJS', 'CPP' or provide a fully-qualified name for a class implementing System.CodeDom.Compiler.CodeDomProvider.
The default
language is 'CS' (CSharp). Short form is '/l:'.
This command will put inside your C:\myProxyScripts the auto generated proxy.
if your using the WSDL file in your computer, just change the URL to your full path, for example
wsdl /language:cs /protocol:soap /out:C:\myProxyScripts C:\myProxyScripts\myWsdlFile.wsdl
Note: your Generated proxy will be called the Service Name, the one you have specified, in our example, as:
<wsdl:service name="TranslateService">
I hope this helps you, understand the WSDL, the Auto Generated Proxies and that you can manage now everything in your end to fulfill your client wishes.
You can use the wsdl utility from microsoft to generate the server interfaces and implement them
Here is a short description of the WSDL utility.
wsdl.exe -
Utility to generate code for xml web service clients and xml web
services
using ASP.NET from WSDL contract files, XSD schemas and .discomap
discovery documents. This tool can be used in conjunction with disco.exe.

Resources