Grails Spring Security Plugin - Where is the plugin directory? - spring

I am relatively new to Grails and currently I busy myself with the Spring-Security UI plugin. After reading the documentation I want to make some adjustments at the property file grails-app/i18n/messages.spring-security-ui.properties, but I can't find the properties file. Neither in the project-directory, either in the plugins directory.
I have even tried to search it with the unix-command find in my project. (find . -name 'messages.spring-security-ui.properties')
Do I have to use the s2ui-override command to generate the spring-security-ui directory and its properties files?
I have installed the ui-plugin by modifying the BuildConfig.groovy (compile ":spring-security-ui:0.2") and using the command grails compile.
Thank you in advance.
Best

The plugins are installed on your local user folder, example:
~/.grails/2.0.4/projects/grailsdevs/plugins/
where:
grailsdevs = project name
By the way, you can override the messages properties in your project ones.
check the messages you can use:
http://grails-plugins.github.com/grails-spring-security-core/docs/manual/guide/25%20Internationalization.html
You don't have to override the plugin because the plugin is installed locally, if you run the app in another computer the plugin will be installed from the repository. So the best way you can do this is add the messages in your i18n resource bundle.
Go to your project... under folder: grails-app/i18n/
Hope this help you

Don't edit plugin files.
If you want a different I18N message for a key, add that line to your application's messages.properties (and the other locale files if you support multiple languages). The application's files take precedence over plugin files
Just use the same key and whatever message you want to display.

Related

How to customize FreeMarker template by using Jar?

Some times ago, I used Alfresco 5.2 Community Edition. When I needed to develop some kind of customization, I used the Alfresco Maven SDK with three different Maven archetypes, it was:
Alfresco Repository AMP;
Alfresco Share AMP;
Alfresco all-in-one (AIO).
By using this SDK I developed AMP files that overlaid on either the alfresco.war or share.war by using the module management tool.
Now I am using Alfresco 4.2.2 Enterprise Edition and the problem is that all the customizations over the years have been performed directly on the servers in the exploded WAR's.
This approach is described here: Packaging Approaches
Unpackaged Files or ZIP
Many development environments employ a build process that can execute
a script to move unpackaged modified files from source control into
the web application's exploded WAR file. Ant, bash, or some scripting
language can all be good ways to do this ...
Moving unpackaged files has the advantage of being quick and easy to
understand ...
And further:
Deployment Locations
One solution is to use a permanently exploded deployment (instead of
deploying an Alfresco WAR file under /webapps). Create a directory
called alfresco under the webapps directory and extract the contents
of alfresco.war into it. Then copy your files to
../webapps/alfresco/WEB-INF/ and restart Tomcat ...
Thus, I can't use AMP-customizations(otherwise all previous developments will be deleted). As far as I know, I can use an alternative- JAR-customization.
As described in the same document:
JAR
As of v3.4, the Share web application supports overrides that are
packaged as JAR files. This allows multiple customizations to be
isolated from each other, and order of selection can be predicted.
Static files such as JavaScript, CSS, or image files that would
normally be placed in the web root of the Share application can also
be packaged into these JARs ...
While it's possible to avoid the overwriting problem (at least in
Tomcat) by placing these JAR files in tomcat/shared/lib ...
However, I can not take advantage of this approach either. For example, I need to override the FreeMarker template:
/opt/tomcat7/webapps/share/WEB-INF/classes/alfresco/web-extension/site-webscripts/components/form/service-note/service-note-order-things.ftl
I create the appropriate directory structure in IDE, change the template in some way, and build the Jar file. Then I put it in tomcat7/shared/lib (I also placed it in tomcat7/webapps/share/WEB-INF/lib, but also without success) and restart the application server.
After restarting, I don't see my changes - the template remained the same. Moreover, if I try to add another template to the same directory (.../service-note/...), a new template there does not appear.
In my Tomcat installation shared classloader is configured properly.
What am I doing wrong? How to override static resources by using JAR?
I would be very grateful for the information. Thanks to all.
It is necessary to use the SurfBug debugging tool to identify the template file (Template Type property).
Then develop the Spring Surf extension module - "are the preferred way of customizing many of the Alfresco Share user interface features" - and pack it into the Jar.
Then I should use the Module deployment which is available through the web-
script at:
http://host:port/share/service/modules/deploy
The FTL can be customizing as follows:
Place the new content before/ after the certain #region;
Replace the content of the certain #region with the new content;
Remove the certain #region completely.
In the file system, we will have the same unmodified template, because Spring Surf writes to an in-memory model and then allows extensions to manipulate that model before the model is flushed to the output stream.
See also:
Customize Alfresco Share FreeMarker templates
About FreeMarker extensibility directives

Spring STS not recognizing project structure with Gradle

I'm trying to do this getting started guide from Spring. So I cloned the project using git from the command line. As I'm working with Gradle, I removed the Maven files from the repository to clean the project.
After that I open my STS and go to File -> Open Projects from File System and navigate to the /initial folder of the repository. The project is imported correctly but when I try to add some "java stuff" (packages, classes, etc.) I get several errors and I can only add folders and files, which is quite annoying for working.
To be more descriptive, I'll add some images so you can see what's happening. This is the project initially imported into STS as I described above:
Then I try to add some java stuff, let's say for example a source folder. So Right Click on library -> New -> Source folder and this is the result:
And in the properties of library I have the following:
So the question is: how can I tell to STS to recognize the library folder as a Java Project (or Gradle module, I don't know how to call it) instead of a plain folder so I can add my packages and classes?
Thanks in advance for your answers.
In case you would like to work with Gradle, you should use the Gradle integration for Eclipse (project Buildship) and install that into your STS environment. After that, you should be able to import the projects either from disc as existing Gradle project (not as file system) or via the wizard that integrates the spring guides into STS (Import Getting Started Content). The wizard for the guides also let you choose between the Maven and the Gradle variant, so you don't need to close and delete stuff yourself.
Hope this helps!!!

Add log4j.properites as an external file (ouside of jar) in an Eclipse RCP application

I want to build an Eclipse RCP application in a way so that the the end user can configure log levels. I want to do it by exposing the log4j.properties file.
Currently that file gets bundled into a jar that is placed under MyApplication\plugins\MyApplication.jar. While I want it to be directly under MyApplication folder where MyApplication.exe is.
I saw some threads about the subject like Proper way to include log4j in an Eclipse 4 (RCP/SWT/OSGi) application but I couldn't find a good answer there. If I create a fragment project for loading the properties, they will still be jarred up, won't they?
I want to know what I can change in my manifest file or Maven pom files so that the log4j.properties file will be taken out of the jar.
By using the so-called "root files" configuration, you can bring additional files into the installation of your RCP application. In order to do this you need the following steps:
Add an eclipse-feature project to your build (or use an existing one)
In the feature project, create the files you want to have included in the RCP application installation. In your case, you could for example check in the initial log4j.properties at the location src/root/log4j.properties
Edit the build.properties of the feature project and add the line
root = file:src/root/**
Include the feature in your RCP application product.
Then, all files and folders that you have placed in the src/root/ directory in the feature project will be added to the root of the RCP application installation.

Eclipse Plugin project: manage external files

I'm developing a plugin for Eclipse (4.2 on windows) that uses a bunch of external files (batch scripts, xml files, ecc).
I'm asking if there is a good method to manage those files inside the project in order to:
keep all the plugin resources inside the project for version control in SVN
possibly have an automated plugin installation (including those files outside the plugin jar)
Edit: Can an additional "Feature Project" be a solution?
Instead of having a project I would manage two: one for the plugin and one for the "feature" that references the plugin and gathers the non-plugin data.
In that case, I see that eclipse "Features" have an "installation" section (in "feature.xml"). How could I specify for each "non-plugin" file the install path location?
I'm using nested projects for this.
Create a parent project that will contain everything. For each sub-project, deactivate the default location when you create it and select the parent project's root folder instead.
Here is an example: http://git.eclipse.org/c/tmf/org.eclipse.xtext.git/tree/
It doesn't have a .project file in the root but having one doesn't hurt.
Just remember to import the sub-projects before you start working on them. Otherwise, you and Eclipse might get confused.

how to make checkstyle ignore xml files in my application

i've configured my checkstyle plugin with customized checkstyle.xml and it works fine with the java classes but having a lot of warnings with the xml files can anyone suggest how to disable the check style from any xml file in my application.
thanks in advance.
I can think of two ways to do that:
You could suppress findings from non-Java files. This works very well inside and outside of your IDE.
If you are using Eclipse, you can also configure Eclipse not to feed the non-Java files to Checkstyle. In order to do that, right-click your project and click Checkstyle. Uncheck use simple configuration. Specify a file set using \.java$ as regexp. You will see the list of files in the bottom half of the dialog window change to only Java files.
In earlier versions of Checkstyle, I think I remember that there also was a file name filter in the configuration XML, but I can't seem to find it in the docs now, so maybe that feature is no more.
There is a basedir property at the start of the Checker module in the check style config file. Uncomment it if it is commented.
Set it's value to the folder you want to apply your checkstyle rules to.
E.g. src folder of any eclipse project only contains java files.
<!-- If you set the basedir property below, then all reported file names
will be relative to the specified directory. See http://checkstyle.sourceforge.net/5.x/config.html#Checker -->
<property name="basedir" value="/MyEclipeProject/src"/>

Resources