Create new enumeration values from the Wiki?

Posts: 16
Joined: Tue Feb 26, 2008 2:24 pm
Location: Aachen, Germany

Create new enumeration values from the Wiki?

Postby gcueppers » Thu Jan 13, 2011 2:08 pm

Hallo all,

how is it possible to create new enumeration values from the Wiki?

We have developed an formular to entry an enumeartaion value "system" and press a "create" Button.
After this, the formular value should be configured automatically as an additional value within the system-enum.xml for the actual project. Unfortunately we did not find a way to do this by searching the javadoc help files.
A code example would be great!

Thanks in advance and kind regards..
kind regards,

Posts: 19
Joined: Wed Jan 19, 2011 8:40 am

Re: Create new enumeration values from the Wiki?

Postby Sandro_F » Wed Jan 19, 2011 8:57 am


well, you can create a Servlet:
- get the xml file
- parse it
- add some values
- commit the xml file

You can use SvnKit and JDOM librarys for this. You can also use the Interface "IRepositoryService" from Polarion, but I use SvnKit in this example:

Code: Select all

// Setup connection to Repository
SVNRepository repos = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(""));
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password);   

// Get xml file
String currentUrl = "path/to/enumfile";
SVNProperties fileProperties = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream( );
repos.getFile( currentUrl , -1 , fileProperties , baos );
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

// add value
SAXBuilder saxBuilder = new SAXBuilder();
Document document =;
Element rootElement = document.getRootElement();
List  listParentElements = rootElement.getChildren("option");
Element elNew = new Element("option");
elNew.setAttribute("id", optionValue);
elNew.setAttribute("name", optionValue);
listParentElements.add(0, elNew );

// commit file
XMLOutputter outp = new XMLOutputter();
// Save to file
file = new File("/path/to/a/tmp/file");
FileOutputStream fileOutput = new FileOutputStream(file);
outp.output(document, fileOutput);
InputStream fileReader = new FileInputStream(file);
ISVNEditor editor = repos.getCommitEditor("", new WorkspaceMediator());
SVNCommitInfo commitInfo = SVNUtils.modifyFile(editor, dirPath, currentUrl, fileReader, size);

Well, this code is not running out of the box. You have to adjust some objects and variables. Anyway, you need some Java-Experience for this.

Maybe I will publish a Extension for adding enum values over a Wiki page.

Sandro Frenzel

Posts: 1
Joined: Thu Jan 20, 2011 2:18 pm

Re: Create new enumeration values from the Wiki?

Postby gbonney » Thu Jan 20, 2011 2:49 pm

Hello there,

unfortunately i don't have SvnKit installed and my access levels wont allow me to change this.
So could you please give me a hint how to use the IRepositoryService from Polarion?

I'm actually accessing the repository this way:

#set($repoService = $polarionTool.repositoryService)
#set($connection = $repoService.getReadOnlyConnection($polarionTool.location))
#set($path = "/TT2/TT2TT2/.polarion/tracker/fields/environment-enum.xml")
#set($input = $connection.getContent($polarionTool.location.getLocation($path)))
#set($doc = $xmlTool.documentBuilderFactory.newDocumentBuilder().parse($input))

$path contains $doc.documentElement.getElementsByTagName("option").length options.

This works for me, $doc.documentElement.getElementsByTagName("option").length returns a number.

But when using $repoService.getConnection($polarionTool.location)) it fails with:

Error number 4001 in 4: Error while parsing velocity page project/TT2TT2/page/_default/Page2TestWiki Wrapped Exception: Invocation of method 'getConnection' in class $IRepositoryService_12d7b05114d threw exception class com.polarion.platform.service.repository.RepositoryException : Transaction problem: the connection can be created in active transaction context only

Any idea?

Tanks in advance and kind regards,

Posts: 19
Joined: Wed Jan 19, 2011 8:40 am

Re: Create new enumeration values from the Wiki?

Postby Sandro_F » Fri Jan 21, 2011 12:25 pm


well, SVNKit ist part of Polarion, so you don`t need to install it. When using servlets you are allowed to use every external library (also non Polarion libs).

However, I see that you want to use wiki code to solve your problem. I do not know whether DocumentBuilderFactory is able to write xml files. I think no!
But, to solve your exception you have to use ITransactionService interface like this $transactionService.beginTx() (see JavaDoc for further instructions). Just call it like $trackerService Interface.

Sandro Frenzel

Posts: 1
Joined: Thu Nov 28, 2013 7:55 am

Re: Create new enumeration values from the Wiki?

Postby Tina99 » Thu Nov 28, 2013 8:56 am

Hi everyone,
I guess I'm facing the same problem as Gregory two years ago:
I would like to create a new enumeration from a wiki page (with wiki code if possible) and add options to this enumeration.
Has anyone found a solution to this in the meantime or is an Extension for adding enum values over a Wiki page available by now?
Unfortunately I have not found any information regarding this.

Thanks in advance,

Best regards,

Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 7 guests