[Dspace-tech] Correct procedure to cutomize dspace xmlui from [dspace-source] folder

388 views
Skip to first unread message

Alexander Kocisky

unread,
Aug 26, 2015, 10:12:46 AM8/26/15
to dspac...@lists.sourceforge.net
Hi all,

i was trying to figure out how to customize the dspace-xmlui web app (for the logo and other small details) from the [dspace-source], build it and package it for a correct deployment to the [dspace] installation directory. 

i've tried to:

cd [dspace-source]/dspace-xmlui
[modify the code]
mvn package
cd [dspace-source]/dspace-xmlui/target/dspace-xmlui-webapp-1.8.2 
cp -rf * /usr/local/dspace/webapps/xmlui/
cp -r webapps/* ../tomcat/webapps/
../tomcat/bin/startup.sh

but i got this exception:

log4j:WARN No appenders could be found for logger (org.dspace.servicemanager.DSpaceKernelInit).
log4j:WARN Please initialize the log4j system properly.
INFO: Loading provided config file: ${dspace.dir}/config/dspace.cfg
FATAL: Can't load configuration: file:/usr/local/dspace-1.8.2/$%7Bdspace.dir%7D/config/dspace.cfg
java.io.FileNotFoundException: /usr/local/dspace-1.8.2/${dspace.dir}/config/dspace.cfg (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:137)
at java.io.FileInputStream.<init>(FileInputStream.java:96)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:87)

so i've tried to:

[root@repository xmlui]# pwd
/home/dspace/dspace-1.8.2-src-release/dspace/modules/xmlui
[root@repository xmlui]# vim ./target/xmlui-1.8.2/themes/Mirage/lib/css/style.css
[modify the code]
ant update_code           <- Update compiled code (bin, lib, and etc directories)
ant update_webapps  <- Update web applications

but no code in the xmlui was updated in the [dspace] installation directory nor in [dspace-source]/target folder

just to try i've modified directly:

[root@repository tomcat]# vim ./webapps/xmlui/themes/Mirage/lib/xsl/core/page-structure.xsl
[root@repository tomcat]# vim ../tomcat/webapps/xmlui/themes/Mirage/lib/css/style.css 

but obviously the changes get rewritten with fresh deployments. What is the correct procedure that enables me to update the code of the dspace-xmlui (or other modules) in order to deploy them to the [dspace] directory?

Thanks !!!
Alex

helix84

unread,
Aug 26, 2015, 10:12:47 AM8/26/15
to Alexander Kocisky, dspac...@lists.sourceforge.net
Hi Alexander,

it appears you're not running ant from the correct directory.

This article explains how to rebuild DSpace:

https://wiki.duraspace.org/display/DSPACE/Rebuild+DSpace

However, if you want to modify only the theme, you can modify it
directly in [dspace]/webapps/xmlui/themes and see changes to it
instantly (sometimes you may need to clear the Cocoon cache, see the
FAQ). Remember that the webapps directory will be moved to
webapps-[date] when you redeploy DSpace, so you may want to copy the
theme back to [dspace-source] when you're done.

If you want to make loca modifications to Java code, read about
overlays - it's the best way to do it, cut down on build time and make
porting easier during upgrades:
https://www.ideals.illinois.edu/handle/2142/11915


Regards,
~~helix84

Compulsory reading: DSpace Mailing List Etiquette
https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette

Alexander Kocisky

unread,
Aug 26, 2015, 10:13:18 AM8/26/15
to hel...@centrum.sk, dspac...@lists.sourceforge.net
Hi Helix,

thank you for your quick reply and also the links, the procedure in the wiki is a bit generic and i don't have a full understanding of maven apps!!
So i've made many tries but i still don't understand the correct procedure, in particular i've seen that the modules are available in the [dspace-source] path but also under [dspace-source]/dspace/modules, what is the relation between these to versions?

i though that packaging the source will update also the modules in  [dspace-source]/dspace/modules, so this is what i've done:

[root@repository dspace-xmlui]# pwd
/home/dspace/dspace-1.8.2-src-release/dspace-xmlui

vim ./dspace-xmlui-webapp/src/main/webapp/themes/Mirage/lib/xsl/core/page-structure.xsl 
changed: <span id="ds-header-logo-text">mirage</span> to <span id="ds-header-logo-text"></span>
mvn package
cd ../dspace
mvn package
cd ./target/dspace-1.8.2-build/
ant update
cd /usr/local/dspace
../tomcat/bin/shutdown.sh
cp -r webapps/* ../tomcat/webapps/
../tomcat/bin/startup.sh

i've tracked where the changes were made with: 

fgrep -R '<span id="ds-header-logo-text">mirage</span>' *

[root@repository dspace-1.8.2-src-release]# fgrep -R '<span id="ds-header-logo-text">mirage</span>' *
dspace/target/dspace-1.8.2-build/webapps/xmlui/themes/Mirage/lib/xsl/core/page-structure.xsl:                    <span id="ds-header-logo-text">mirage</span>
dspace/modules/xmlui/target/xmlui-1.8.2/themes/Mirage/lib/xsl/core/page-structure.xsl:                    <span id="ds-header-logo-text">mirage</span>
dspace/modules/xmlui/target/war/work/org.dspace/dspace-xmlui-webapp/themes/Mirage/lib/xsl/core/page-structure.xsl:                    <span id="ds-header-logo-text">mirage</span>
[root@repository dspace-1.8.2-src-release]# 

it still has the "mirage" text and from the grep it seems that its coming from:

dspace/modules/xmlui/target/xmlui-1.8.2/themes/Mirage/lib/xsl/core/page-structure.xsl

so i've modified that file but after the "mvn package" it's restored from the original, and it's not coming from:

/home/dspace/dspace-1.8.2-src-release/dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/Mirage/lib/xsl/core/page-structure.xsl

what am i missing?
many thanks!!

alex

helix84

unread,
Aug 26, 2015, 10:13:21 AM8/26/15
to Alexander Kocisky, dspac...@lists.sourceforge.net
On Thu, Dec 6, 2012 at 6:02 PM, Alexander Kocisky
<alexande...@gmail.com> wrote:
> in particular i've seen that the modules are available in the
> [dspace-source] path but also under [dspace-source]/dspace/modules, what is
> the relation between these to versions?

In my email I mentioned overlays. That's what the modules directory
contains. It duplicates the module structure and anything that the
overlay directory ([dspace-source]/dspace/modules/[module]) contains
will replace what the stock module ([dspace-source]/[module])
contains.

That's why this is a good place to keep local Java modifications. I
haven't tried putting a customized theme there, a different procedure
is recommended for theme customization, with the goal of reducing
headaches when upgrading:

https://wiki.duraspace.org/display/DSPACE/Manakin+theme+tutorial

Just create a new theme (i.e a new directory) in the themes directory.
Inside your theme import the contents of Mirage and overlay any
templates you want. The rest of the templates will thus fall back to
Mirage.

<xsl:import href="../Mirage/Mirage.xsl"/>

> i though that packaging the source will update also the modules in
> [dspace-source]/dspace/modules, so this is what i've done:
>
> [root@repository dspace-xmlui]# pwd
> /home/dspace/dspace-1.8.2-src-release/dspace-xmlui
>
> vim
> ./dspace-xmlui-webapp/src/main/webapp/themes/Mirage/lib/xsl/core/page-structure.xsl
> changed: <span id="ds-header-logo-text">mirage</span> to <span
> id="ds-header-logo-text"></span>
> mvn package

No, it doesn't work like that in Java (Maven). You can't expect to
build an individual module. You have to build from [dspace-source],
not from a module directory. I know it takes forever, I also have a
problem with that.

You have only 2 options, full build and quick build, and they should
be used exactly as described in the Building DSpace link I sent you.
In case quick build behaves strangely, you know you have to use full build.

> dspace/modules/xmlui/target/xmlui-1.8.2/themes/Mirage/lib/xsl/core/page-structure.xsl
>
> so i've modified that file but after the "mvn package" it's restored from
> the original, and it's not coming from:

Ignore the target directory, just like you ignore .o files when you're
compiling C code. It's only a temporary location for compiled code.
This is the grep command I generally use:

grep -RnI --exclude-dir=.git --exclude-dir=target 'foo' *

Alexander Kocisky

unread,
Aug 26, 2015, 10:13:27 AM8/26/15
to hel...@centrum.sk, dspac...@lists.sourceforge.net
Thanks again Helix84, i've created a new theme and rebuild everything and it worked!

- create new theme (copied Mirage and changed name)

cd /home/dspace/dspace-1.8.2-src-release/dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes
cp -r Mirage MyTheme
cd MyTheme

modified the following on sitemap.xmap:

<theme-path>MyTheme</theme-path>
<theme-name>MyTheme</theme-name>
<!-- <map:transform src="MyTheme.xsl"/> -->

mv Mirage.xsl MyTheme.xsl

vim ./lib/xsl/core/page-structure.xsl  (e.g. changed logo)
vim /home/dspace/dspace-1.8.2-src-release/dspace/config/xmlui.xconf :

and commented out the old theme and added:
<theme name="My Theme Theme" regex=".*" path="MyTheme/" />

cd /home/dspace/dspace-1.8.2-src-release/
mvn package
cd dspace/target/dspace-1.8.2-build/
ant update
cd /usr/local/dspace
../tomcat/bin/shutdown.sh
cp -r webapps/* ../tomcat/webapps/
../tomcat/bin/startup.sh

and the chages are effective, i suppose that when developing the changes will be made directly on the webapp running and applied back to the source afterwords.

Cheers,
alex

helix84

unread,
Aug 26, 2015, 10:13:28 AM8/26/15
to Alexander Kocisky, dspace-tech

Yep, everything is completely correct.

If you think the wiki pages are not quite clear at some point, please, feel free to correct them.

Reply all
Reply to author
Forward
0 new messages