Help SiteVision 4

XML import - importing RDF content

If you have existing content that you want to import into SiteVision, either only once or regularly, there is a WebService available that will allow you to upload content in RDF/XML format, and which will generate SiteVision objects and content corresponding to the given data.

To use this you need the Java client which can be used to invoke the Web Service and a RDF/XML document with the appropriate content. If you want to upload content to a remote server you will also need the system account login info in order to authenticate yourself to the WebService.

Content generation support

The following content types can be created or set by the RDF import service:

  • Pages
  • Articles
  • Files
  • Images
  • Text portlets
  • Image portlets
  • Table portlets
  • Layouts
  • Metadata
  • Publishing information ("created on date", "published on date", etc.)
  • User information ("created by", "published by", etc.)

Pages and articles can be created and updated, but not removed. It is however possible to unpublish existing pages and articles.

Resource id mappings

For each created object the import service will save a mapping between the RDF resource id and the internal SiteVision object. When the import service finds an RDF resource id that it has not previously handled - a new SiteVision object is created, such as a page or article, and is then associated with the resource id. If an RDF document with the same resource id is sent to SiteVision this is then considered an update of existing data.

As implied above, it is very important to specify unique resource id's for each individual object. To avoid id duplication, it is recommended that every importer uses it's own specific namespace (for example: rdf:about="myapplication:startpagearchive:id_1").

If the created page is removed the association will be lost, and the next RDF import with the resource id will create a new corresponding object. If the object is manually updated, such as changing the content, an import of RDF content with the corresponding resource id will not cause the object to be updated unless you specify so (sv:force="true"). This makes it possible to do post-import changes to an object before publishing it without having those changes overwritten on subsequent imports.

RDF/XML format

A comprehensive example of the supported RDF/XML format is available hereXML (xml, 12.7 kB).

Using the Java client

One way to call the RDF import WebService is to use a RDF import tool. The tool is available in the senselogic maven repository link, opens in new window (more information about the repository can be found here). The client can be used both to add and update content.

To use the Java client you will typically perform the following:

RdfUploader rdfUploader = new RdfUploader("http://localhost");
rdfUploader.setUsername("system"); // System account username
rdfUploader.setPassword("system"); // System account password
This will upload the RDF content to the SiteVision server running on localhost. Whether or not the username and password of the system account are required depends on how your Web Services settings are configured. These decide if the remote address (IP) the client are using is allowed to upload or not, and if login is required. (If the client code is implemented in a Web Application running in SiteVision you'll need to allow IP

If the import succeeds the upload() method call will return silently. If it fails an UploadException, or one of its subexceptions, will be thrown. Catch this if you want to customize your error handling.

All Log4j events that were created as a side-effect of the import will be reposted in the client's Log4j API. This means that you can either look in your log for reasons the import failed, or you can add your own appender if you want to catch and handle certain events in a more customized fashion.

Using the command-line tool

The RDF upload client can also be invoked on the command-line. This is done by using the following command (in this example the uploader jar name is "rdfimport-onejar-1.3.jar", you might find other versions in our Maven repository):
java -jar rdfimport-onejar-1.3.jar [options]

For a full list of options you can run the tool with no parameters, which will print out the available options.

A typical example of how to upload an RDF file to the local server would be the following:

java -jar rdfimport-onejar-1.3.jar -url http://localhost
-file rdfcontent.xml -username system -password system
-threshold info

This will upload the RDF file rdfcontent.xml to the SiteVision instance running on localhost. If the import succeeds the tool will end with exit code "0". If any warnings occurred the exit code will be "2" and if any errors occurred it will be "3".

Logging and error handling

For general logging and error handling, all log messages generated on the server during the import will be sent to the client. They will then be output either through log4j or as XML, in the Log4J XML logging format, to system out. The default is log4j, but you can specify what method to use by adding the "-output xml" or "-output log4j" parameter.

If you choose to use log4j as output you can add your own log appenders and filters in order to handle the messages. The below log4j.xml configuration example will show how to capture log events and send them to a log file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="">
   <appender name="File" class="org.apache.log4j.DailyRollingFileAppender">
      <param name="File" value="import.log"/>
      <param name="Threshold" value="INFO"/>

      <param name="Append" value="true"/>
      <param name="DatePattern" value="'.'yyyy-MM-dd'.log'"/>

      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d{HH:mm:ss} %-5p [%c{1}] %m%n"/>
      <appender-ref ref="File"/>

Use your custom configuration by specifying the "-log4j <configFile.xml>" parameter if you use the command-line tool.
SiteVision edition! This function requires the Portal or Enterprise edition of SiteVision (or a Developer license).

The page published: 2012-05-02

Find us!

SiteVision AB (Headquarter)
Vasagatan 10
702 10 Orebro

Info: +46 19-17 30 30
Support: +46 19-17 30 39