Blog fra februar, 2014

Busting the Work Confluence

Thursday night on the couch, having a day off friday, I decided to do some layout work on the Confluence we use at my workplace (just for the fun of it, as my work is my hobby - sort of anyway).

I had created a new User Macro, that I wanted to implement on the Dashboard, so I started editing in the Global Layouts in Confluence to place it on the Dashboard:

As part of the changing of the Dashboard code, I entered:

{html}<font size="4">Space Quick Select</font>{html}

pressed "Save" and:

the Confluence went down - just giving me a "Service Unavailable" from the Traffic Manager.

Shit, I restarted the instance- no improvement.....so starting to diagnose:

npn@docs01:~$ wget -O - localhost:8080
--2014-01-30 21:46:27--  http://localhost:8080/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:8080... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2014-01-30 21:46:28 ERROR 500: Internal Server Error.

npn@docs01:~$

 

Hm, error 500, diagnosting further:

root@docs01:/pack/confluence-data/logs# tail -f atlassian-confluence.log
caused by: java.lang.RuntimeException: Error rendering template for decorator global
at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:186)
caused by: org.apache.velocity.exception.ParseErrorException: Encountered "4" at /decorators/global.vmd[line 38, column 87]
Was expecting one of:
    "," ...
    ")" ...
    <WHITESPACE> ...

at org.apache.velocity.Template.process(Template.java:141)

 

So, It seems the code I put in the Global layout makes the Confluence crash totally, not just rendering the Dashboard, but TOTALLY!!!

I fired up for MySQL and looked at the DECORATORS table:

mysql> select DECORATORID,DECORATORNAME FROM DECORATOR;
+-------------+-----------------------+
| DECORATORID | DECORATORNAME         |
+-------------+-----------------------+
|    64913409 | decorators/global.vmd |
|    48300036 | decorators/page.vmd   |
|    59080705 | decorators/page.vmd   |
+-------------+-----------------------+
3 rows in set (0.00 sec)

mysql>

 

Now, 2 choises are available:

  1. Fix It
  2. Delete the DECORATORID=64913409 record.

All though I am pretty sure number 2 works (same as using "Reset Default"), I went for number 1:

 

First, I shut down Confluence completely.

Then I made a complete dump of the Confluence Database:

mysqldump -uconfluence -p confluence > confluence.sql

 

After securing the backup, I dumped the DECORATOR table:

mysqldump -uconfluence -p confluence DECORATOR > DECORATOR.sql

 

After that, I changed the DECORATOR.sql file i the "vim" editor - stripping off everything but the record for DECORATORID=64913409, and change the "INSERT INTO" to an "UPDATE"  so it looked like:

UPDATE DECORATORS SET body='### ...code...code...code.' WHERE  DECORATORID=64913409

And the whole point being that I removed the "{html}<font size=\"4\">Space Quick Select</font>{html}" from the body code.

 

Finally, I put back the decorator:

mysql -uconfluence -p confluence < DECORATOR.sql

 

And started the Confluence Instance:

 

 - up and running again

 

 

Fetched from https://confluence.atlassian.com/display/DOC/Include+Page+Macro

 

#set ($qString = $req.getQueryString())
#set ($titleStart = $qString.indexOf("title=")+6)
#set ($nextAmpIndex = $qString.indexOf("&",$titleStart))
#if ($nextAmpIndex == -1)
#set ($titleEnd = $qString.length())
#else
#set ($titleEnd = $nextAmpIndex)
#end
#set ($reqTitle = $qString.substring($titleStart, $titleEnd))

 

Very nice for getting the params from a QueryString - I am thinking of making a "Show Image" page in the Mos-Eisley Gallery, using QueryString params