diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml
index fb5ab31de1..a1b78152ca 100644
--- a/config/alfresco/bootstrap-context.xml
+++ b/config/alfresco/bootstrap-context.xml
@@ -27,6 +27,9 @@
+
+
+
diff --git a/config/alfresco/extension/restore-context.xml.sample b/config/alfresco/extension/restore-context.xml.sample
index bdfae1b719..5a0c7e25ca 100644
--- a/config/alfresco/extension/restore-context.xml.sample
+++ b/config/alfresco/extension/restore-context.xml.sample
@@ -3,6 +3,12 @@
+
+
+ alfresco/extension/restore/export_systeminfo.xml
+
+
+
@@ -39,6 +45,17 @@
true
+
+
+
+
+ /
+ alfresco/extension/restore/export_spaces_archive.acp
+
+
+
+
+
diff --git a/config/alfresco/import-export-context.xml b/config/alfresco/import-export-context.xml
index 5a9a8dfc36..80e746bd7e 100644
--- a/config/alfresco/import-export-context.xml
+++ b/config/alfresco/import-export-context.xml
@@ -94,6 +94,9 @@
+
+
+
@@ -108,6 +111,10 @@
${spaces.store}
spaces
+
+ ${spaces.archive.store}
+ spaces_archive
+
workspace://lightWeightVersionStore
versions
@@ -116,6 +123,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${system.store}
+
+
+
diff --git a/config/alfresco/messages/action-config.properties b/config/alfresco/messages/action-config.properties
index f788ae24ee..90302d5319 100644
--- a/config/alfresco/messages/action-config.properties
+++ b/config/alfresco/messages/action-config.properties
@@ -69,7 +69,8 @@ export.title=Export a Space
export.description=Exports a Space and optionally it's children to an Alfresco export package.
export.package.description=Alfresco content package for Space ''{0}''.
export.root.package.description=Alfresco content package for complete Repository.
-export.store.package.description=Alfresco export of store ''{0}''.
+export.store.package.description=Alfresco Repository export of store ''{0}''.
+export.generic.package.description=Alfresco Repository export.
export.package.error=Failed to find temporary file for export
script.title=Execute a script
diff --git a/project-build.xml b/project-build.xml
index 7b6a586e43..dd7b4cf75b 100644
--- a/project-build.xml
+++ b/project-build.xml
@@ -9,9 +9,12 @@
-
+
+
+
+
diff --git a/project.properties b/project.properties
index 937e555f8c..278df21ebb 100644
--- a/project.properties
+++ b/project.properties
@@ -1,4 +1,5 @@
-file.jibx.binding=${dir.src.java}/org/alfresco/repo/dictionary/m2binding.xml
+file.jibx.binding.m2=${dir.src.java}/org/alfresco/repo/dictionary/m2binding.xml
+file.jibx.binding.systeminfo=${dir.src.java}/org/alfresco/repo/importer/system/systeminfo.xml
dir.javadoc.api.service=${dir.docs}/java-public-service-api
tck.webinf.lib.excludes=${webinf.lib.excludes},jcr-1.0.jar
diff --git a/source/java/org/alfresco/repo/domain/VersionCount.java b/source/java/org/alfresco/repo/domain/VersionCount.java
index 759b7d1832..05dbc69478 100644
--- a/source/java/org/alfresco/repo/domain/VersionCount.java
+++ b/source/java/org/alfresco/repo/domain/VersionCount.java
@@ -56,4 +56,11 @@ public interface VersionCount
* @see #incrementVersionCount()
*/
public int getVersionCount();
+
+ /**
+ * Sets the current version counter
+ *
+ * @param versionCount the new version counter
+ */
+ public void setVersionCount(int versionCount);
}
diff --git a/source/java/org/alfresco/repo/domain/hibernate/VersionCountImpl.java b/source/java/org/alfresco/repo/domain/hibernate/VersionCountImpl.java
index 4be08aa2e2..c8c4e930e5 100644
--- a/source/java/org/alfresco/repo/domain/hibernate/VersionCountImpl.java
+++ b/source/java/org/alfresco/repo/domain/hibernate/VersionCountImpl.java
@@ -85,7 +85,7 @@ public class VersionCountImpl implements VersionCount
/**
* For Hibernate use
*/
- private void setVersionCount(int versionCount)
+ public void setVersionCount(int versionCount)
{
this.versionCount = versionCount;
}
diff --git a/source/java/org/alfresco/repo/domain/hibernate/VersionCounterDaoComponentImpl.java b/source/java/org/alfresco/repo/domain/hibernate/VersionCounterDaoComponentImpl.java
index 4283639417..a64a572228 100644
--- a/source/java/org/alfresco/repo/domain/hibernate/VersionCounterDaoComponentImpl.java
+++ b/source/java/org/alfresco/repo/domain/hibernate/VersionCounterDaoComponentImpl.java
@@ -179,4 +179,22 @@ public class VersionCounterDaoComponentImpl
// get an incremented count
versionCounter.resetVersionCount();
}
+
+ /**
+ * Sets the version number for a specified store.
+ *
+ * WARNING: calling this method will completely reset the current
+ * version count for the specified store and cannot be undone.
+ *
+ * @param storeRef the store reference
+ * @param versionCount the new version count
+ */
+ public synchronized void setVersionNumber(StoreRef storeRef, int versionCount)
+ {
+ // get the version counter
+ VersionCount versionCounter = getVersionCounter(storeRef);
+ // get an incremented count
+ versionCounter.setVersionCount(versionCount);
+ }
+
}
diff --git a/source/java/org/alfresco/repo/exporter/RepositoryExporterComponent.java b/source/java/org/alfresco/repo/exporter/RepositoryExporterComponent.java
index ebbf004c60..1082f9f6ea 100644
--- a/source/java/org/alfresco/repo/exporter/RepositoryExporterComponent.java
+++ b/source/java/org/alfresco/repo/exporter/RepositoryExporterComponent.java
@@ -30,6 +30,7 @@ import java.util.Properties;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
+import org.alfresco.repo.importer.system.SystemExporterImporter;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
@@ -64,6 +65,7 @@ public class RepositoryExporterComponent implements RepositoryExporterService
private ExporterService exporterService;
private MimetypeService mimetypeService;
private FileFolderService fileFolderService;
+ private SystemExporterImporter systemExporterImporter;
private NodeService nodeService;
private List exportStores;
@@ -82,6 +84,11 @@ public class RepositoryExporterComponent implements RepositoryExporterService
{
this.fileFolderService = fileFolderService;
}
+
+ public void setSystemExporter(SystemExporterImporter systemExporterImporter)
+ {
+ this.systemExporterImporter = systemExporterImporter;
+ }
public void setNodeService(NodeService nodeService)
{
@@ -104,7 +111,7 @@ public class RepositoryExporterComponent implements RepositoryExporterService
return exportHandles.toArray(new FileExportHandle[exportHandles.size()]);
}
-
+
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.view.RepositoryExporterService#export(java.io.File)
@@ -136,14 +143,27 @@ public class RepositoryExporterComponent implements RepositoryExporterService
}
List exportHandles = exportStores(exportStores, packageName, new TempFileExporter());
+ Map mimetypeExtensions = mimetypeService.getExtensionsByMimetype();
List repoExportHandles = new ArrayList(exportHandles.size());
for (FileExportHandle exportHandle : exportHandles)
{
- String description = I18NUtil.getMessage("export.store.package.description", new Object[] { exportHandle.storeRef.getIdentifier() });
- NodeRef repoExportFile = addExportFile(repositoryDestination, exportHandle.packageName, description, exportHandle.exportFile);
+ String name = exportHandle.packageName + "." + mimetypeExtensions.get(exportHandle.mimeType);
+ String title = exportHandle.packageName;
+ String description;
+ if (exportHandle.storeRef != null)
+ {
+ description = I18NUtil.getMessage("export.store.package.description", new Object[] { exportHandle.storeRef.toString() });
+ }
+ else
+ {
+ description = I18NUtil.getMessage("export.generic.package.description");
+ }
+
+ NodeRef repoExportFile = addExportFile(repositoryDestination, name, title, description, exportHandle.mimeType, exportHandle.exportFile);
RepositoryExportHandle handle = new RepositoryExportHandle();
handle.storeRef = exportHandle.storeRef;
handle.packageName = exportHandle.packageName;
+ handle.mimeType = exportHandle.mimeType;
handle.exportFile = repoExportFile;
repoExportHandles.add(handle);
}
@@ -161,16 +181,15 @@ public class RepositoryExporterComponent implements RepositoryExporterService
* @param exportFile the .acp file
* @return node reference to import .acp file
*/
- private NodeRef addExportFile(NodeRef repoDestination, String packageName, String packageDescription, File exportFile)
+ private NodeRef addExportFile(NodeRef repoDestination, String name, String title, String description, String mimeType, File exportFile)
{
//
// import temp file into repository
//
// determine if file already exists
- String fileName = packageName + "." + ACPExportPackageHandler.ACP_EXTENSION;
List paths = new ArrayList();
- paths.add(fileName);
+ paths.add(name);
try
{
FileInfo fileInfo = fileFolderService.resolveNamePath(repoDestination, paths);
@@ -186,16 +205,16 @@ public class RepositoryExporterComponent implements RepositoryExporterService
NodeRef exportFileNodeRef = null;
try
{
- FileInfo fileInfo = fileFolderService.create(repoDestination, fileName, ContentModel.TYPE_CONTENT);
+ FileInfo fileInfo = fileFolderService.create(repoDestination, name, ContentModel.TYPE_CONTENT);
ContentWriter writer = fileFolderService.getWriter(fileInfo.getNodeRef());
- writer.setMimetype(MimetypeMap.MIMETYPE_ACP);
+ writer.setMimetype(mimeType);
writer.putContent(exportFile);
exportFileNodeRef = fileInfo.getNodeRef();
// add a title for Web Client viewing
Map titledProps = new HashMap(3, 1.0f);
- titledProps.put(ContentModel.PROP_TITLE, packageName);
- titledProps.put(ContentModel.PROP_DESCRIPTION, packageDescription);
+ titledProps.put(ContentModel.PROP_TITLE, title);
+ titledProps.put(ContentModel.PROP_DESCRIPTION, description);
nodeService.addAspect(exportFileNodeRef, ContentModel.ASPECT_TITLED, titledProps);
}
@@ -209,7 +228,7 @@ public class RepositoryExporterComponent implements RepositoryExporterService
/**
- * Contract for exporting a store
+ * Contract for exporting a repository
*
* @author davidc
*
@@ -218,6 +237,8 @@ public class RepositoryExporterComponent implements RepositoryExporterService
private interface ExportStore
{
public ExportHandleType exportStore(ExporterCrawlerParameters exportParameters, String packageName, Exporter progress);
+
+ public ExportHandleType exportSystem(String packageName);
}
@@ -231,7 +252,16 @@ public class RepositoryExporterComponent implements RepositoryExporterService
*/
private List exportStores(List stores, String packageName, ExportStore exportStore)
{
- List exportHandles = new ArrayList(stores.size());
+ List exportHandles = new ArrayList(stores.size() +1);
+
+ // export repository system info
+ {
+ String completePackageName = (packageName == null) ? "systeminfo" : packageName + "_systeminfo";
+ ExportHandleType systemInfoHandle = exportStore.exportSystem(completePackageName);
+ exportHandles.add(systemInfoHandle);
+ }
+
+ // export each store
for (Properties store : stores)
{
// retrieve store reference to export
@@ -319,9 +349,39 @@ public class RepositoryExporterComponent implements RepositoryExporterService
FileExportHandle handle = new FileExportHandle();
handle.storeRef = exportParameters.getExportFrom().getStoreRef();
handle.packageName = packageName;
+ handle.mimeType = MimetypeMap.MIMETYPE_ACP;
handle.exportFile = tempFile;
return handle;
- };
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.repo.exporter.RepositoryExporterComponent.ExportStore#exportSystem()
+ */
+ public FileExportHandle exportSystem(String packageName)
+ {
+ // create a temporary file to hold the system info export
+ File tempFile = TempFileProvider.createTempFile("repoExpSystemInfo", ".xml");
+
+ try
+ {
+ OutputStream outputStream = new FileOutputStream(tempFile);
+ systemExporterImporter.exportSystem(outputStream);
+ }
+ catch(FileNotFoundException e)
+ {
+ tempFile.delete();
+ throw new ExporterException("Failed to create temporary file for holding export of system info");
+ }
+
+ // return handle onto temp file
+ FileExportHandle handle = new FileExportHandle();
+ handle.storeRef = null;
+ handle.packageName = packageName;
+ handle.mimeType = MimetypeMap.MIMETYPE_XML;
+ handle.exportFile = tempFile;
+ return handle;
+ }
};
@@ -374,50 +434,40 @@ public class RepositoryExporterComponent implements RepositoryExporterService
FileExportHandle handle = new FileExportHandle();
handle.storeRef = exportParameters.getExportFrom().getStoreRef();
handle.packageName = packageName;
+ handle.mimeType = MimetypeMap.MIMETYPE_ACP;
handle.exportFile = file;
return handle;
- };
- };
-
-
- /**
- * Export a store to Repository File
- *
- * @author davidc
- */
- @SuppressWarnings("unused")
- private class RepositoryFileExporter implements ExportStore
- {
- private TempFileExporter tempFileExporter = new TempFileExporter();
- private NodeRef repoDestination;
-
- /**
- * Construct
- *
- * @param repoDestination destination within repository to create export file
- */
- public RepositoryFileExporter(NodeRef repoDestination)
- {
- this.repoDestination = repoDestination;
}
-
- /*
- * (non-Javadoc)
- * @see org.alfresco.repo.exporter.RepositoryExporterComponent.ExportStore#exportStore(org.alfresco.service.cmr.view.ExporterCrawlerParameters, java.lang.String, org.alfresco.service.cmr.view.Exporter)
- */
- public RepositoryExportHandle exportStore(ExporterCrawlerParameters exportParameters, String packageName, Exporter progress)
- {
- // export acp to temporary file
- FileExportHandle tempFile = tempFileExporter.exportStore(exportParameters, packageName, progress);
- String description = I18NUtil.getMessage("export.store.package.description", new Object[] { tempFile.storeRef.getIdentifier() });
- NodeRef repoExportFile = addExportFile(repoDestination, packageName, description, tempFile.exportFile);
- RepositoryExportHandle handle = new RepositoryExportHandle();
- handle.storeRef = exportParameters.getExportFrom().getStoreRef();
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.repo.exporter.RepositoryExporterComponent.ExportStore#exportSystem()
+ */
+ public FileExportHandle exportSystem(String packageName)
+ {
+ // create a temporary file to hold the system info export
+ File tempFile = TempFileProvider.createTempFile("repoExpSystemInfo", ".xml");
+
+ try
+ {
+ OutputStream outputStream = new FileOutputStream(tempFile);
+ systemExporterImporter.exportSystem(outputStream);
+ }
+ catch(FileNotFoundException e)
+ {
+ tempFile.delete();
+ throw new ExporterException("Failed to create temporary file for holding export of system info");
+ }
+
+ // return handle onto temp file
+ FileExportHandle handle = new FileExportHandle();
+ handle.storeRef = null;
handle.packageName = packageName;
- handle.exportFile = repoExportFile;
+ handle.mimeType = MimetypeMap.MIMETYPE_XML;
+ handle.exportFile = tempFile;
return handle;
}
};
+
}
diff --git a/source/java/org/alfresco/repo/exporter/RepositoryExporterComponentTest.java b/source/java/org/alfresco/repo/exporter/RepositoryExporterComponentTest.java
index 1172051986..e9f6378e20 100644
--- a/source/java/org/alfresco/repo/exporter/RepositoryExporterComponentTest.java
+++ b/source/java/org/alfresco/repo/exporter/RepositoryExporterComponentTest.java
@@ -64,13 +64,13 @@ public class RepositoryExporterComponentTest extends BaseSpringTest
{
FileExportHandle[] handles = repositoryService.export("test");
assertNotNull(handles);
- assertEquals(4, handles.length);
+ assertEquals(6, handles.length);
for (FileExportHandle tempFile : handles)
{
assertTrue(tempFile.exportFile.exists());
}
}
-
+
public void xtestRepositoryExport()
throws Exception
{
@@ -82,7 +82,7 @@ public class RepositoryExporterComponentTest extends BaseSpringTest
// Export stores
RepositoryExportHandle[] handles = repositoryService.export(container.getNodeRef(), "test");
assertNotNull(handles);
- assertEquals(4, handles.length);
+ assertEquals(6, handles.length);
for (RepositoryExportHandle handle : handles)
{
assertTrue(nodeService.exists(handle.exportFile));
diff --git a/source/java/org/alfresco/repo/importer/ImporterBootstrap.java b/source/java/org/alfresco/repo/importer/ImporterBootstrap.java
index c0b62d123e..12556807e0 100644
--- a/source/java/org/alfresco/repo/importer/ImporterBootstrap.java
+++ b/source/java/org/alfresco/repo/importer/ImporterBootstrap.java
@@ -55,7 +55,6 @@ import org.apache.log4j.Logger;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
-import org.springframework.core.io.ClassPathResource;
import org.springframework.util.FileCopyUtils;
/**
diff --git a/source/java/org/alfresco/repo/importer/system/PatchInfo.java b/source/java/org/alfresco/repo/importer/system/PatchInfo.java
new file mode 100644
index 0000000000..92568d7959
--- /dev/null
+++ b/source/java/org/alfresco/repo/importer/system/PatchInfo.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */
+package org.alfresco.repo.importer.system;
+
+import java.util.Date;
+
+/**
+ * Data holder of patch information that's to be exported and imported
+ *
+ * @author davidc
+ */
+public class PatchInfo
+{
+ public String id = null;
+ public String description = null;
+ public Integer fixesFromSchema = null;
+ public Integer fixesToSchema = null;
+ public Integer targetSchema = null;
+ public Integer appliedToSchema = null;
+ public String appliedToServer = null;
+ public Date appliedOnDate = null;
+ public Boolean wasExecuted = null;
+ public Boolean succeeded = null;
+ public String report = null;
+}
diff --git a/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java b/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java
new file mode 100644
index 0000000000..20a3271d59
--- /dev/null
+++ b/source/java/org/alfresco/repo/importer/system/SystemExporterImporter.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */
+package org.alfresco.repo.importer.system;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+
+import org.alfresco.repo.admin.patch.PatchDaoService;
+import org.alfresco.repo.domain.AppliedPatch;
+import org.alfresco.repo.domain.hibernate.VersionCounterDaoComponentImpl;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.repository.StoreRef;
+
+
+/**
+ * Exporter and Importer of Repository System Information
+ *
+ * @author davidc
+ */
+public class SystemExporterImporter
+{
+ // dependencies
+ private NodeService nodeService;
+ private PatchDaoService patchDao;
+ private VersionCounterDaoComponentImpl versionCounterDao;
+
+
+ public void setNodeService(NodeService nodeService)
+ {
+ this.nodeService = nodeService;
+ }
+
+ public void setPatchDao(PatchDaoService patchDaoService)
+ {
+ this.patchDao = patchDaoService;
+ }
+
+ public void setVersionDao(VersionCounterDaoComponentImpl versionCounterDao)
+ {
+ this.versionCounterDao = versionCounterDao;
+ }
+
+
+ /**
+ * Export Repository System Information
+ *
+ * @param exportStream output stream to export to
+ */
+ public void exportSystem(OutputStream exportStream)
+ {
+ SystemInfo systemInfo = new SystemInfo();
+
+ // capture applied patches
+ List patches = patchDao.getAppliedPatches();
+ for (AppliedPatch patch : patches)
+ {
+ PatchInfo patchInfo = new PatchInfo();
+ patchInfo.appliedOnDate = patch.getAppliedOnDate();
+ patchInfo.appliedToSchema = patch.getAppliedToSchema();
+ patchInfo.appliedToServer = patch.getAppliedToServer();
+ patchInfo.description = patch.getDescription();
+ patchInfo.fixesFromSchema = patch.getFixesFromSchema();
+ patchInfo.fixesToSchema = patch.getFixesToSchema();
+ patchInfo.id = patch.getId();
+ patchInfo.report = patch.getReport();
+ patchInfo.succeeded = patch.getSucceeded();
+ patchInfo.targetSchema = patch.getTargetSchema();
+ patchInfo.wasExecuted = patch.getWasExecuted();
+ systemInfo.patches.add(patchInfo);
+ }
+
+ // capture version counters
+ List storeRefs = nodeService.getStores();
+ for (StoreRef storeRef : storeRefs)
+ {
+ VersionCounterInfo versionCounterInfo = new VersionCounterInfo();
+ int versionCount = versionCounterDao.currentVersionNumber(storeRef);
+ versionCounterInfo.storeRef = storeRef.toString();
+ versionCounterInfo.count = versionCount;
+ systemInfo.versionCounters.add(versionCounterInfo);
+ }
+
+ systemInfo.toXML(exportStream);
+ }
+
+
+ /**
+ * Import Repository System Information
+ *
+ * @param importStream input stream to import from
+ */
+ public void importSystem(InputStream importStream)
+ {
+ SystemInfo systemInfo = SystemInfo.createSystemInfo(importStream);
+
+ // apply patch info
+ for (PatchInfo patchInfo : systemInfo.patches)
+ {
+ AppliedPatch patch = patchDao.newAppliedPatch(patchInfo.id);
+ patch.setAppliedOnDate(patchInfo.appliedOnDate);
+ patch.setAppliedToSchema(patchInfo.appliedToSchema);
+ patch.setAppliedToServer(patchInfo.appliedToServer);
+ patch.setDescription(patchInfo.description);
+ patch.setFixesFromSchema(patchInfo.fixesFromSchema);
+ patch.setFixesToSchema(patchInfo.fixesToSchema);
+ patch.setReport(patchInfo.report);
+ patch.setSucceeded(patchInfo.succeeded);
+ patch.setTargetSchema(patchInfo.targetSchema);
+ patch.setWasExecuted(patchInfo.wasExecuted);
+ }
+
+ // apply version counters
+ for (VersionCounterInfo versionCounterInfo : systemInfo.versionCounters)
+ {
+ StoreRef storeRef = new StoreRef(versionCounterInfo.storeRef);
+ versionCounterDao.setVersionNumber(storeRef, versionCounterInfo.count);
+ }
+ }
+
+}
diff --git a/source/java/org/alfresco/repo/importer/system/SystemInfo.java b/source/java/org/alfresco/repo/importer/system/SystemInfo.java
new file mode 100644
index 0000000000..88b831ea2d
--- /dev/null
+++ b/source/java/org/alfresco/repo/importer/system/SystemInfo.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */
+package org.alfresco.repo.importer.system;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.alfresco.service.cmr.dictionary.DictionaryException;
+import org.jibx.runtime.BindingDirectory;
+import org.jibx.runtime.IBindingFactory;
+import org.jibx.runtime.IMarshallingContext;
+import org.jibx.runtime.IUnmarshallingContext;
+import org.jibx.runtime.JiBXException;
+
+
+/**
+ * Root data holder of Repository system information to be exported and imported
+ *
+ * @author davidc
+ */
+public class SystemInfo
+{
+ public List patches = new ArrayList();
+ public List versionCounters = new ArrayList();
+
+ /**
+ * Create System Info from XML representation
+ *
+ * @param xml xml representation of system info
+ * @return the System Info
+ */
+ public static SystemInfo createSystemInfo(InputStream xml)
+ {
+ try
+ {
+ IBindingFactory factory = BindingDirectory.getFactory(SystemInfo.class);
+ IUnmarshallingContext context = factory.createUnmarshallingContext();
+ Object obj = context.unmarshalDocument(xml, null);
+ return (SystemInfo)obj;
+ }
+ catch(JiBXException e)
+ {
+ throw new DictionaryException("Failed to parse System Info", e);
+ }
+ }
+
+ /**
+ * Create XML representation of System Info
+ *
+ * @param xml xml representation of system info
+ */
+ public void toXML(OutputStream xml)
+ {
+ try
+ {
+ IBindingFactory factory = BindingDirectory.getFactory(SystemInfo.class);
+ IMarshallingContext context = factory.createMarshallingContext();
+ context.setIndent(4);
+ context.marshalDocument(this, "UTF-8", null, xml);
+ }
+ catch(JiBXException e)
+ {
+ throw new DictionaryException("Failed to create System Info", e);
+ }
+ }
+
+}
+
+
diff --git a/source/java/org/alfresco/repo/importer/system/SystemInfoBootstrap.java b/source/java/org/alfresco/repo/importer/system/SystemInfoBootstrap.java
new file mode 100644
index 0000000000..e764c2e751
--- /dev/null
+++ b/source/java/org/alfresco/repo/importer/system/SystemInfoBootstrap.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */package org.alfresco.repo.importer.system;
+
+import java.io.InputStream;
+import java.util.List;
+
+import javax.transaction.UserTransaction;
+
+import org.alfresco.error.AlfrescoRuntimeException;
+import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.repository.StoreRef;
+import org.alfresco.service.cmr.view.ImporterException;
+import org.alfresco.service.transaction.TransactionService;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+
+
+/**
+ * Repository System Information bootstrap
+ *
+ * @author davidc
+ */
+public class SystemInfoBootstrap implements ApplicationListener
+{
+ // dependencies
+ private TransactionService transactionService;
+ private NodeService nodeService;
+ private AuthenticationComponent authenticationComponent;
+ private SystemExporterImporter systemImporter;
+
+ private List mustNotExistStoreUrls = null;
+ private String bootstrapView = null;
+
+
+ /**
+ * Sets the Transaction Service
+ *
+ * @param userTransaction the transaction service
+ */
+ public void setTransactionService(TransactionService transactionService)
+ {
+ this.transactionService = transactionService;
+ }
+
+ /**
+ * Sets the node service
+ *
+ * @param nodeService the node service
+ */
+ public void setNodeService(NodeService nodeService)
+ {
+ this.nodeService = nodeService;
+ }
+
+ /**
+ * Set the authentication component
+ *
+ * @param authenticationComponent
+ */
+ public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
+ {
+ this.authenticationComponent = authenticationComponent;
+ }
+
+ /**
+ * Set the System Importer
+ *
+ * @param systemImporter
+ */
+ public void setSystemImporter(SystemExporterImporter systemImporter)
+ {
+ this.systemImporter = systemImporter;
+ }
+
+ /**
+ * If any of the store urls exist, the bootstrap does not take place
+ *
+ * @param storeUrls the list of store urls to check
+ */
+ public void setMustNotExistStoreUrls(List storeUrls)
+ {
+ this.mustNotExistStoreUrls = storeUrls;
+ }
+
+ /**
+ * Set the bootstrap view containing the system information
+ *
+ * @param bootstrapView
+ */
+ public void setBootstrapView(String bootstrapView)
+ {
+ this.bootstrapView = bootstrapView;
+ }
+
+ /**
+ * Bootstrap
+ */
+ public void bootstrap()
+ {
+ UserTransaction userTransaction = transactionService.getUserTransaction();
+ authenticationComponent.setSystemUserAsCurrentUser();
+
+ try
+ {
+ userTransaction.begin();
+
+ // check the repository exists, create if it doesn't
+ if (performBootstrap())
+ {
+ InputStream viewStream = getClass().getClassLoader().getResourceAsStream(bootstrapView);
+ if (viewStream == null)
+ {
+ throw new ImporterException("Could not find system info file " + bootstrapView);
+ }
+ try
+ {
+ systemImporter.importSystem(viewStream);
+ }
+ finally
+ {
+ viewStream.close();
+ }
+ }
+ userTransaction.commit();
+ }
+ catch(Throwable e)
+ {
+ // rollback the transaction
+ try { if (userTransaction != null) {userTransaction.rollback();} } catch (Exception ex) {}
+ try {authenticationComponent.clearCurrentSecurityContext(); } catch (Exception ex) {}
+ throw new AlfrescoRuntimeException("System Info Bootstrap failed", e);
+ }
+ finally
+ {
+ authenticationComponent.clearCurrentSecurityContext();
+ }
+ }
+
+ /**
+ * Determine if bootstrap should take place
+ *
+ * @return true => yes, it should
+ */
+ private boolean performBootstrap()
+ {
+ if (bootstrapView == null || bootstrapView.length() == 0)
+ {
+ return false;
+ }
+ if (mustNotExistStoreUrls != null)
+ {
+ for (String storeUrl : mustNotExistStoreUrls)
+ {
+ StoreRef storeRef = new StoreRef(storeUrl);
+ if (nodeService.exists(storeRef))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent)
+ */
+ public void onApplicationEvent(ApplicationEvent event)
+ {
+ if (event instanceof ContextRefreshedEvent)
+ {
+ bootstrap();
+ }
+ }
+
+}
diff --git a/source/java/org/alfresco/repo/importer/system/VersionCounterInfo.java b/source/java/org/alfresco/repo/importer/system/VersionCounterInfo.java
new file mode 100644
index 0000000000..2ca2825839
--- /dev/null
+++ b/source/java/org/alfresco/repo/importer/system/VersionCounterInfo.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */
+package org.alfresco.repo.importer.system;
+
+
+/**
+ * Data holder of Version information to be exported and imported
+ *
+ * @author davidc
+ */
+public class VersionCounterInfo
+{
+ public String storeRef = null;
+ public Integer count = null;
+}
diff --git a/source/java/org/alfresco/repo/importer/system/systeminfo.xml b/source/java/org/alfresco/repo/importer/system/systeminfo.xml
new file mode 100644
index 0000000000..ef23080d82
--- /dev/null
+++ b/source/java/org/alfresco/repo/importer/system/systeminfo.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/java/org/alfresco/service/cmr/view/RepositoryExporterService.java b/source/java/org/alfresco/service/cmr/view/RepositoryExporterService.java
index 29d8bfad6c..99bb20042c 100644
--- a/source/java/org/alfresco/service/cmr/view/RepositoryExporterService.java
+++ b/source/java/org/alfresco/service/cmr/view/RepositoryExporterService.java
@@ -70,6 +70,7 @@ public interface RepositoryExporterService
{
public StoreRef storeRef;
public String packageName;
+ public String mimeType;
}
/**