info.magnolia.module.data.util
Class ImportUtil

java.lang.Object
  extended by info.magnolia.module.data.util.ImportUtil

public class ImportUtil
extends Object

Data import related utility methods.

Version:
$Revision: $ ($Author: $)
Author:
had

Constructor Summary
ImportUtil()
           
 
Method Summary
static info.magnolia.cms.core.Content getContentIfNew(info.magnolia.cms.core.Content node, String name)
          Gets new content from import (if any) or null when no new content is found.
static boolean isOld(info.magnolia.cms.core.Content node)
          Checks whether given node is old or new.
static void saveFile(info.magnolia.cms.core.Content node, String propertyName, String fileName, InputStream fileStream)
          Saves file as a child of provided node.
static void saveFile(info.magnolia.cms.core.Content node, String propertyName, String fileName, InputStream fileStream, Calendar modDate)
          Saves binary file as a data node of given parent node.
static void saveFile(info.magnolia.cms.core.Content node, String propertyName, String fileName, ZipFile files)
          Extracts and saves the content of the zip file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImportUtil

public ImportUtil()
Method Detail

saveFile

public static void saveFile(info.magnolia.cms.core.Content node,
                            String propertyName,
                            String fileName,
                            ZipFile files)
                     throws IOException
Extracts and saves the content of the zip file.

Parameters:
node - Parent node.
fileName - Name of file form zip archive to be saved.
files - Zip archive.
Throws:
IOException - When zip file is corrupted or can't be read.

saveFile

public static void saveFile(info.magnolia.cms.core.Content node,
                            String propertyName,
                            String fileName,
                            InputStream fileStream)
                     throws IOException
Saves file as a child of provided node.

Parameters:
node - Parent node.
propertyName - Name for newly created binary property.
fileName - File name.
fileStream - File data.
Throws:
IOException - When file data stream is corrupted.

saveFile

public static void saveFile(info.magnolia.cms.core.Content node,
                            String propertyName,
                            String fileName,
                            InputStream fileStream,
                            Calendar modDate)
                     throws IOException
Saves binary file as a data node of given parent node. For images (jpg, gif) also extracts width/height.

Parameters:
node - Parent node.
propertyName - Name for newly created binary property.
fileName - File name.
fileStream - File data.
modDate - File last modification date.
Throws:
IOException - When file data stream is corrupted.

getContentIfNew

public static info.magnolia.cms.core.Content getContentIfNew(info.magnolia.cms.core.Content node,
                                                             String name)
Gets new content from import (if any) or null when no new content is found.

Parameters:
node - Parent node.
name - New content node name.
Returns:
First identified new node or null when no new content is found.

isOld

public static boolean isOld(info.magnolia.cms.core.Content node)
Checks whether given node is old or new.

Parameters:
node - Content node in question.
Returns:
True when provided node is old, false otherwise.


Copyright © 2012 Magnolia International Ltd.. All Rights Reserved.