Issue Type: Improvement Improvement
Affects Versions: 1.7.4
Assignee: Philipp Bärfuss
Attachments: ImportHandler.patch
Created: 21/May/13 5:32 PM
Description:

In it's current version the ImportHandler standard implementation is limited to the data repository (otherwise you have to override the backup method) if you use the backup mechanism because the backup method uses a fixed name for the repository:

HierarchyManager hm = MgnlContext.getSystemContext().getHierarchyManager(DataModule.getRepository());

This should be like the rest of the code:

HierarchyManager hm = MgnlContext.getSystemContext().getHierarchyManager(repository);

It's even possible to remove the deprecated HierarchyManager in the backup method:

Replace

DataTransporter.executeExport(stream, false, false, hm.getWorkspace().getSession(), target.getTargetPath(), repository, ".gz");

with

DataTransporter.executeExport(stream, false, false, MgnlContext.getJCRSession(repository), target.getTargetPath(), repository, ".gz");

and catch the exception.

The full method could be like this:

protected void backup(ImportTarget target) throws ImportException {
File backupDir = new File(Path.getAppRootDir(), "backup");
backupDir.mkdir();
backupFile = new File(backupDir, target.name + "-" + FastDateFormat.getInstance("yyyy-MM-dd_hh-mm-ss").format(System.currentTimeMillis()) + ".gz");
OutputStream stream;
try

{ stream = new FileOutputStream(backupFile); }

catch (FileNotFoundException e)

{ throw new ImportException("can't create backup file [" + backupFile + "] "); }

// export data
try

{ DataTransporter.executeExport(stream, false, false, MgnlContext.getJCRSession(repository), target.getTargetPath(), repository, ".gz"); }

catch (RepositoryException e)

{ throw new ImportException("can't get JCR session for repository " + repository, e); }

catch (IOException e)

{ throw new ImportException("can't export data for backuping", e); }

IOUtils.closeQuietly(stream);
}

The use case is when you extend an ImportHandler and use a target workspace other than data (e. g. DMS). This currently works only if you also overwrite the backup method.

Fix Versions: 1.7.x
Project: Magnolia Data Module
Priority: Neutral Neutral
Reporter: Lars Fischer
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to