How to externalize rest-messages.properties in Spring Data REST? - spring-data-rest

Is it possible to externalize rest-messages.properties in SDR?
I tried to move it to ./config folder, for example, but it didn't work.

The rest-messages.properties (used to add custom details to your ALPS descriptions) goes to the same location where you would put custom application-*.properties or messages-*.properties file.
For instance, for a Spring Boot project the .properties file are located in the src/main/resources/ directory.
You can also set custom config locations for your .properties file.
Edit after the OP's comment: However, I tried using a custom rest-messages.properties outside of the project .jar (as I usually do with my application.properties), and it does not seem to work.

Related

Rapidoid custom config file is ignored

I'm very new to Rapidoid and I'm experiencing problem with initial configuration of the application. I'm using Rapidoid 5.5.5 with following Rapidoid modules defined in pom:
rapidoid-commons
rapidoid-http-server
rapidoid-web
Java 11 is used to run the application.
I've prepared a custom config-develop.yml file where I've changed value for port to use from default 8080 to 18888 and added some menu items in gui: section however when I start application none of my changes were used: generated log does not have any data about accepting/use of parameters from my file and configuration files are the files that are included into rapidoid-commons Maven artefact.
Also, the log shows that classpath used is limited to /target/classes folder (I'm using Maven as build tool). So, these are my questions:
What are the rules for merging configuration information when multiple config-*.yml files are present in search path?
How I can tell Rapidoid to ignore some configuration files?
Is it possible to specify explicit name for configuration file as part of initialisation process?
I'm happy to provide additional information if this will help to find an answer to the questions above.
With best regards,
Nick

What is the file structure of the Share Webscript extensions for Alfresco 4.0.3+

I've been reading David Drapers' blog on the new feature - the extension of share webscripts, but I didn't find any working examples. What is the file naming and structure convention?
From what I gather, I have a module configuration file, and I don't know how to name it or where to put it (share/WEB-INF/classes/alfresco?)
Also, I understood that my custom client side resources (.js and .css files) go to META-INF/custom-dashlet/extension/ in the JAR file. Is this correct? Finally, the *.get.js and *.get.html.ftl go to webscripts/com/mycompany/mypackage/*?
So I have now:
*share/WEB-INF/lib/mypackage.jar*
and in it:
*META-INF/mypackage/extension/myfile.js
webscripts/com/mycompany/mypackage/myfile.get.js
webscripts/com/mycompany/mypackage/myfile.get.html.ftl
*
and the
*share/WEB-INF/classes/alfresco/something.xml*
This question was also posted to the Alfresco forums here: https://forums.alfresco.com/en/viewtopic.php?f=48&t=46438
The answer provided was as follows:
An extension module a Surf configuration object so you should place XML files containing module configuration in any of the locations where Surf config gets picked up... e.g. <web-server>/webapps/share/WEB-INF/classes/alfresco/site-data (there are lots of places where Surf configuration gets picked up, but alfresco/site-data on the classpath is the most common). Extension config files should be placed in the extensions folder within the directory. So you could place an extension config file in: alfresco/site-data/extensions or alfresco/web-extension/site-data/extensions, for example.
You could create a JAR file containing this folder structure. Everything that the extension refers to (e.g. WebScripts, other Surf config objects such as Pages, Template-Instances, Components, etc) should just be placed in their normal location. These can also be built into a JAR file.
If you want to access resources (e.g. CSS, images, JS) from a JAR file then place them in the META-INF folder of the JAR. You should place your JAR file in the <web-server>/webapps/share/WEB-INF/lib directory (obviously your server will need to be restarted to pick up new JAR contents).
WebScripts should be in (on the classpath):
alfresco/site-webscripts
alfresco/web-extension/site-webscripts
webscripts
You can also configure other locations in the Surf configuration from which to load Surf config objects/WebScripts. It's pretty much endlessly customizable but you should probably just stick to the default locations configured for Share.

How can I write into a file within an Eclipse bundle?

I have an xml configuration file located into my plugin resources. I want to update this file whenever in the plugin happens some event. I found some methods to find and read the contents of a file located my plugin classpath, but I'm looking for a way to write into such a file.
Is there any way?
Many thanks.
That location (the install directory) is intended to be read-only since it may be shared in a network install scenario. I suggest you instead write the XML file to your plugin's state location which is intended for just this purpose:
String path = Activator.getDefault().getStateLocation().toString();
I should add that this gives you a fully qualified path to the directory created by Eclipse for any files your plugin wants to store. This directory is unique to your plugin.

Howto modify Sandcastle presentation style without changing the default installation files

My project uses Sandcastle and Sandcastle Help File Builder to generate documentation.
We're using a customized version of script_manifold.js that persists the user's language preference across pages (the default version resets the language preference with each page).
Currently, the script is located in the Sandcastle\presentation\VS2005\scripts folder.
Is there a way to override this script with a custom version, without having to mess with the Sandcastle installation? That is, can I have a file that is checked into source control along with my source code, and somehow have that file used by SHFB instead of the default Sandcastle one?
Never mind, I found the answer!
In the SHFB project explorer window, you can just create a folder with the same name as the presentation style content you wish to override. This works with any stock content, such as HTML, CSS or JS files. So in my situation, I needed to override the script_manifold.js file which lives in the Scripts folder of the VS2005 presentation style.
So I needed to create a folder called Scripts in my SHFB project, then put my script_manifold.js in that folder.
It all works perfectly. Excellent!

How can I make deployed resources editable with Maven 2?

I have a project where I create a JAR which contains a bunch of classes with main() plus a set of scripts which set the environment to invoke them. Most of those are long running processes which log a lot (~10-20GB).
This means I have a pretty complex log4j.xml file which, being in src/main/resources/, goes into the JAR. When something breaks in the production system, I'd like to modify the logging on the fly for a single run.
So I came up with the idea to have a conf/ directory on the production and put that into the classpath, first. Then, I thought that it would be great if M2 would put the config files in there (instead of the JAR). But that would overwrite any manual changes during an automated deployment which I strongly dislike. I'm also not fond of timestamps and things like that.
So my next ideas was this: M2 should leave the config files in the JAR but create copies of the files with the name *.tpl in the conf/ directory. The admin could then copy a template to the basename to override the files in the JARs. .tpl-Files would be overwritten but that wouldn't hurt. Admins would have full control over which version of the log was active and they could run a diff to see whether any important changes were made.
Now the question: Has someone seen a plugin which automates this process? That is which creates a conf/ directory with all or a selected subset of everything in src/main/resources/ and which renames the files?
Best practice in Maven handling config files is to place them in a separate conf directory, and pack them in a binary assembly using the assembly plugin. Placing configuration files, like log4j.xml in the src/main/resources doesn't make sense, since it is not a true application resource, but more of a configuration file.
We cope with the overwriting, by packing the configuration files with the posfix .def. For example: myapp.properties is packed into the assembly as myapp.properties.def. When the person who uses the assembly unpacks it, it will not overwrite his original files. After unpacking he simply merges them by an external tool (we use meld in Fedora Core).
I may be missing something and this doesn't answer directly the question but did you consider producing a zip assembly of the exploded content of required artifacts (to be unzipped on the target environment)?
Sounds like you're attacking the problem the wrong way. Why not just run the application with -Dlog4j.configuration=/some/where/my-log4j.properties? If you want, you can add a command line flag to main() which invokes the PropertyConfigurator directly.