|
From: <bob...@us...> - 2004-01-16 04:26:38
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler
In directory sc8-pr-cvs1:/tmp/cvs-serv4371/src/hk/hku/cecid/phoenix/message/handler
Modified Files:
DiagTool.java Export.java FilePersistenceHandler.java
MessageServer.java RepositoryPersistenceHandler.java
Added Files:
ArchivablePersistenceHandler.java
BackupablePersistenceHandler.java
Log Message:
Add BackupablePersistenceHandler and ArchivablePersistenceHandler
for backup and archive interfaces.
make persistence support in backup, restore and archive.
--- NEW FILE: ArchivablePersistenceHandler.java ---
/*
* Copyright(c) 2002 Center for E-Commerce Infrastructure Development, The
* University of Hong Kong (HKU). All Rights Reserved.
*
* This software is licensed under the Academic Free License Version 1.0
*
* Academic Free License
* Version 1.0
*
* This Academic Free License applies to any software and associated
* documentation (the "Software") whose owner (the "Licensor") has placed the
* statement "Licensed under the Academic Free License Version 1.0" immediately
* after the copyright notice that applies to the Software.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of the Software (1) to use, copy, modify, merge, publish, perform,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, and (2) under patent
* claims owned or controlled by the Licensor that are embodied in the Software
* as furnished by the Licensor, to make, use, sell and offer for sale the
* Software and derivative works thereof, subject to the following conditions:
*
* - Redistributions of the Software in source code form must retain all
* copyright notices in the Software as furnished by the Licensor, this list
* of conditions, and the following disclaimers.
* - Redistributions of the Software in executable form must reproduce all
* copyright notices in the Software as furnished by the Licensor, this list
* of conditions, and the following disclaimers in the documentation and/or
* other materials provided with the distribution.
* - Neither the names of Licensor, nor the names of any contributors to the
* Software, nor any of their trademarks or service marks, may be used to
* endorse or promote products derived from this Software without express
* prior written permission of the Licensor.
*
* DISCLAIMERS: LICENSOR WARRANTS THAT THE COPYRIGHT IN AND TO THE SOFTWARE IS
* OWNED BY THE LICENSOR OR THAT THE SOFTWARE IS DISTRIBUTED BY LICENSOR UNDER
* A VALID CURRENT LICENSE. EXCEPT AS EXPRESSLY STATED IN THE IMMEDIATELY
* PRECEDING SENTENCE, THE SOFTWARE IS PROVIDED BY THE LICENSOR, CONTRIBUTORS
* AND COPYRIGHT OWNERS "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* LICENSOR, CONTRIBUTORS OR COPYRIGHT OWNERS BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE.
*
* This license is Copyright (C) 2002 Lawrence E. Rosen. All rights reserved.
* Permission is hereby granted to copy and distribute this license without
* modification. This license may not be modified without the express written
* permission of its copyright owner.
*/
/* =====
*
* $Header: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/ArchivablePersistenceHandler.java,v 1.1 2004/01/16 04:26:34 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2004-01-14]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.message.handler;
import java.io.File;
/**
* ArchivablePersistenceHandler is an extension of PersistenceHandler
* which support archive operation.
* @author pykoon
* @version $Revision: 1.1 $
*/
public interface ArchivablePersistenceHandler extends PersistenceHandler {
/**
* archive the data referenced by the name to the destinationFolder.
* @param name the name referenced the data in the Persistence Handler to be
* archived.
* @param destinationFolder the destination folder to store the archived
* data
* @throws ExportException throw if error occur during achriving.
*/
public void archive(String name, File destinationFolder)
throws ExportException;
}
--- NEW FILE: BackupablePersistenceHandler.java ---
/*
* Copyright(c) 2002 Center for E-Commerce Infrastructure Development, The
* University of Hong Kong (HKU). All Rights Reserved.
*
* This software is licensed under the Academic Free License Version 1.0
*
* Academic Free License
* Version 1.0
*
* This Academic Free License applies to any software and associated
* documentation (the "Software") whose owner (the "Licensor") has placed the
* statement "Licensed under the Academic Free License Version 1.0" immediately
* after the copyright notice that applies to the Software.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of the Software (1) to use, copy, modify, merge, publish, perform,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, and (2) under patent
* claims owned or controlled by the Licensor that are embodied in the Software
* as furnished by the Licensor, to make, use, sell and offer for sale the
* Software and derivative works thereof, subject to the following conditions:
*
* - Redistributions of the Software in source code form must retain all
* copyright notices in the Software as furnished by the Licensor, this list
* of conditions, and the following disclaimers.
* - Redistributions of the Software in executable form must reproduce all
* copyright notices in the Software as furnished by the Licensor, this list
* of conditions, and the following disclaimers in the documentation and/or
* other materials provided with the distribution.
* - Neither the names of Licensor, nor the names of any contributors to the
* Software, nor any of their trademarks or service marks, may be used to
* endorse or promote products derived from this Software without express
* prior written permission of the Licensor.
*
* DISCLAIMERS: LICENSOR WARRANTS THAT THE COPYRIGHT IN AND TO THE SOFTWARE IS
* OWNED BY THE LICENSOR OR THAT THE SOFTWARE IS DISTRIBUTED BY LICENSOR UNDER
* A VALID CURRENT LICENSE. EXCEPT AS EXPRESSLY STATED IN THE IMMEDIATELY
* PRECEDING SENTENCE, THE SOFTWARE IS PROVIDED BY THE LICENSOR, CONTRIBUTORS
* AND COPYRIGHT OWNERS "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* LICENSOR, CONTRIBUTORS OR COPYRIGHT OWNERS BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE.
*
* This license is Copyright (C) 2002 Lawrence E. Rosen. All rights reserved.
* Permission is hereby granted to copy and distribute this license without
* modification. This license may not be modified without the express written
* permission of its copyright owner.
*/
/* =====
*
* $Header: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/BackupablePersistenceHandler.java,v 1.1 2004/01/16 04:26:34 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2004-01-14]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.message.handler;
import java.io.IOException;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
/**
* BackupablePersistenceHandler is an extension of PersistenceHandler
* which support backup and restore function.
*
* @author pykoon
* @version $Revision: 1.1 $
*/
public interface BackupablePersistenceHandler extends PersistenceHandler {
/**
* set the backup directory for the Persistence Handler.
* It will be used on common backup() and restore() process to see which
* directory should be read and write from the Zip stream.
* @param backupDirectory the backup directory
*/
public void setBackupDirectory(String backupDirectory);
/**
* backup all the data in the Persistence Handler to the zip output stream.
* The backup data should be able to be restore using restore() function.
*
* In order to avoid conflict for the backup between different persistence
* handler, it is highly recommended to store the data based on the
* backup directory set by setBackupDirectory().
*
* @param zos The Zip Outupt Stream to back the Persistence Handler
* @param baseDirectoryName
* @throws IOException throw if there are errors during backup.
*/
public void backup(ZipOutputStream zos) throws IOException;
/**
* restore all the data to the Persistence Handler using the data in
* ZipInputStream. The Zip Input Stream should contain the valid backup
* data.
*
* @param zis The Zip Input Stream that contains the backup data
* @throws IOException throw if there are errors during restore.
*/
public void restore(ZipInputStream zis) throws IOException;
}
Index: DiagTool.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/DiagTool.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** DiagTool.java 11 Dec 2003 06:41:29 -0000 1.15
--- DiagTool.java 16 Jan 2004 04:26:34 -0000 1.16
***************
*** 307,311 ****
mshLogFile = new File(logPath);
mshLogFilePattern = logFile;
! mshRepository = new File(repository);
}
--- 307,316 ----
mshLogFile = new File(logPath);
mshLogFilePattern = logFile;
! //mshRepository = new File(repository);
! try {
! PersistenceManager.configure(mshProperty);
! } catch (Exception e) {
! throw new DiagnosisException(e.getMessage());
! }
}
Index: Export.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/Export.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** Export.java 11 Dec 2003 06:41:29 -0000 1.26
--- Export.java 16 Jan 2004 04:26:34 -0000 1.27
***************
*** 86,89 ****
--- 86,92 ----
import java.util.StringTokenizer;
import java.util.TreeSet;
+
+ import javax.activation.DataSource;
+
import org.apache.log4j.Logger;
import org.jdom.Element;
***************
*** 585,590 ****
--- 588,612 ----
// Copy the files in the repository to the destDir directory
Iterator it = filenameSet.iterator();
+ PersistenceHandler handler
+ = PersistenceManager.getRepositoryPersistenceHandler();
+ if (!(handler instanceof ArchivablePersistenceHandler)) {
+ String err = ErrorMessages.getMessage(
+ ErrorMessages.ERR_HERMES_INIT_ERROR,
+ "Persistence Handler does not support archive");
+ logger.error(err);
+ throw new ExportException(err);
+ }
+ ArchivablePersistenceHandler archiveHandler
+ = (ArchivablePersistenceHandler) handler;
while (it.hasNext()) {
String filename = (String)it.next();
+ try {
+ archiveHandler.archive(filename, destDir);
+ } catch (ExportException e) {
+ logger.error("Error on archiving " + filename
+ + " : " + e.getMessage());
+ throw e;
+ }
+ /*
File parentFile = new File(filename).getParentFile();
***************
*** 631,634 ****
--- 653,657 ----
}
}
+ */
}
}
***************
*** 678,683 ****
unionMap(reasonMap, critResult[2]);
! Map [] archiveResult = archiveMessages
! (connection, srcDir, destDir, acceptedMap, filenameSet, true);
intersectMap(acceptedMap, archiveResult[0]);
unionMap(rejectedMap, archiveResult[1]);
--- 701,706 ----
unionMap(reasonMap, critResult[2]);
! Map [] archiveResult = archiveMessages(connection, //srcDir,
! destDir, acceptedMap, filenameSet, true);
intersectMap(acceptedMap, archiveResult[0]);
unionMap(rejectedMap, archiveResult[1]);
***************
*** 722,727 ****
Map reasonMap = critResult[2];
! Map [] archiveResult = archiveMessages
! (connection, srcDir, destDir, acceptedMap, filenameSet, false);
intersectMap(acceptedMap, archiveResult[0]);
unionMap(rejectedMap, archiveResult[1]);
--- 745,750 ----
Map reasonMap = critResult[2];
! Map [] archiveResult = archiveMessages(connection, //srcDir,
! destDir, acceptedMap, filenameSet, false);
intersectMap(acceptedMap, archiveResult[0]);
unionMap(rejectedMap, archiveResult[1]);
***************
*** 808,813 ****
Map reasonMap = critResult[2];
! Map [] archiveResult = archiveMessages
! (connection, srcDir, destDir, acceptedMap, filenameSet, true);
intersectMap(acceptedMap, archiveResult[0]);
unionMap(rejectedMap, archiveResult[1]);
--- 831,836 ----
Map reasonMap = critResult[2];
! Map [] archiveResult = archiveMessages(connection, //srcDir,
! destDir, acceptedMap, filenameSet, true);
intersectMap(acceptedMap, archiveResult[0]);
unionMap(rejectedMap, archiveResult[1]);
***************
*** 1365,1369 ****
* @throws ExportException
*/
! private static Map [] archiveMessages(Connection connection, File srcDir,
File destDir, Map acMsgIdMap, Set filenameSet, boolean finalStateOnly)
throws ExportException {
--- 1388,1392 ----
* @throws ExportException
*/
! private static Map [] archiveMessages(Connection connection, //File srcDir,
File destDir, Map acMsgIdMap, Set filenameSet, boolean finalStateOnly)
throws ExportException {
***************
*** 1390,1393 ****
--- 1413,1418 ----
new String [] { DbTableManager.ATTRIBUTE_MESSAGE_ID },
new int [] { DbTableManager.EQUAL }, null);
+ PersistenceHandler handler
+ = PersistenceManager.getRepositoryPersistenceHandler();
while (it.hasNext()) {
***************
*** 1402,1413 ****
// Extract relevant information
int state = 0;
! File file = null;
if (resultSet.next()) {
state = resultSet.getInt
(DbTableManager.ATTRIBUTE_STATE);
file = new File(srcDir, resultSet.getString
(DbTableManager.ATTRIBUTE_FILE_NAME));
! }
! else {
Set set = (Set)rejectedMap.get(appContext);
if (set == null) {
--- 1427,1444 ----
// Extract relevant information
int state = 0;
! //File file = null;
! DataSource dataSource = null;
! String name = null;
if (resultSet.next()) {
state = resultSet.getInt
(DbTableManager.ATTRIBUTE_STATE);
+ name = resultSet.getString(
+ DbTableManager.ATTRIBUTE_FILE_NAME);
+ dataSource = handler.getObject(name);
+ /*
file = new File(srcDir, resultSet.getString
(DbTableManager.ATTRIBUTE_FILE_NAME));
! */
! } else {
Set set = (Set)rejectedMap.get(appContext);
if (set == null) {
***************
*** 1431,1436 ****
reasonMap.put(msgId,
"The message is not in final state");
! }
! else if (!file.exists()) {
Set set = (Set) rejectedMap.get(appContext);
if (set == null) {
--- 1462,1466 ----
reasonMap.put(msgId,
"The message is not in final state");
! } else if (dataSource != null) {
Set set = (Set) rejectedMap.get(appContext);
if (set == null) {
***************
*** 1439,1444 ****
}
set.add(msgId);
! reasonMap.put(msgId, "Message file=<" + file.
! getCanonicalPath() + "> does not exist");
}
else {
--- 1469,1474 ----
}
set.add(msgId);
! reasonMap.put(msgId, "Message =<" + name
! + "> does not exist");
}
else {
Index: FilePersistenceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/FilePersistenceHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** FilePersistenceHandler.java 5 Jan 2004 11:24:08 -0000 1.4
--- FilePersistenceHandler.java 16 Jan 2004 04:26:34 -0000 1.5
***************
*** 74,77 ****
--- 74,81 ----
import java.io.FileOutputStream;
import java.io.FileInputStream;
+ import java.util.zip.ZipEntry;
+ import java.util.zip.ZipInputStream;
+ import java.util.zip.ZipOutputStream;
+
import javax.activation.DataSource;
//import org.apache.commons.codec.digest.DigestUtils;
***************
*** 82,86 ****
* @version $Revision$
*/
! public class FilePersistenceHandler implements PersistenceHandler {
/**
* the content type for the data source constructed.
--- 86,91 ----
* @version $Revision$
*/
! public class FilePersistenceHandler implements BackupablePersistenceHandler,
! ArchivablePersistenceHandler {
/**
* the content type for the data source constructed.
***************
*** 92,95 ****
--- 97,105 ----
*/
private File currentDirectory;
+
+ /**
+ * The backup directory
+ */
+ private String backupDirectory = "";
/**
***************
*** 228,231 ****
--- 238,452 ----
return true;
}
+
+ /**
+ * set the backup directory for the Persistence Handler.
+ * It will be used on common backup() and restore() process to see which
+ * directory should be read and write from the Zip stream.
+ * @param backupDirectory the backup directory
+ */
+ public void setBackupDirectory(String backupDirectory) {
+ this.backupDirectory = backupDirectory;
+ }
+ /**
+ * backup all the data in the Persistence Handler to the zip output stream.
+ * The backup data should be able to be restore using restore() function.
+ *
+ * @param zos The Zip Outupt Stream to back the Persistence Handler
+ * @throws IOException throw if there are errors during backup.
+ */
+ public synchronized void backup(ZipOutputStream zos) throws IOException {
+ backupFile(zos, getCurrentDirectory(), backupDirectory);
+ }
+
+ /**
+ * backup the specify file to the zip output stream using the path specified
+ * as the zip entry.
+ * If the specify file is a directory, it will backup the files in the
+ * sub-directory.
+ *
+ * @param zos The Zip Outupt Stream to back the Persistence Handler
+ * @param currentFile The specify file to backup.
+ * @param path the path it should be on the zip entry
+ * @throws IOException throw if error occur on storing the data.
+ */
+ private void backupFile(ZipOutputStream zos, File currentFile, String path)
+ throws IOException {
+ if (currentFile.isDirectory()) {
+ File[] fileLists = currentFile.listFiles();
+ for (int i = 0; i < fileLists.length; i++) {
+ backupFile(zos, fileLists[i],
+ path + File.separator + fileLists[i].getName());
+ }
+ } else if (currentFile.isFile()) {
+ InputStream fis = null;
+ zos.putNextEntry(new ZipEntry(path));
+ try {
+ fis = new FileInputStream(currentFile);
+ byte[] buffer = new byte[2048];
+ int read = fis.read(buffer);
+ while (read != -1) {
+ zos.write(buffer, 0, read);
+ read = fis.read(buffer);
+ }
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ zos.closeEntry();
+ }
+ }
+ }
+
+
+ /**
+ * restore all the data to the Persistence Handler using the data in
+ * ZipInputStream. The Zip Input Stream should contain the valid backup
+ * data.
+ *
+ * @param zis The Zip Input Stream that contains the backup data
+ * @throws IOException throw if there are errors during restore.
+ */
+ public synchronized void restore(ZipInputStream zis) throws IOException {
+ for (ZipEntry entry = zis.getNextEntry(); entry != null;
+ entry = zis.getNextEntry()) {
+ String entryName = entry.getName();
+ if (entryName.startsWith(backupDirectory)) {
+ entryName = entryName.substring(backupDirectory.length() + 1);
+ int index = entryName.lastIndexOf(File.separatorChar);
+ if (index != -1) {
+ File dir = new File(getCurrentDirectory(),
+ entryName.substring(0, index));
+ if (dir.exists() == false) {
+ dir.mkdirs();
+ }
+ }
+ OutputStream fos = null;
+ try {
+ fos = new FileOutputStream(new File(getCurrentDirectory(),
+ entryName));
+ byte[] buffer = new byte[2048];
+ int read = zis.read(buffer);
+ while (read != -1) {
+ fos.write(buffer, 0, read);
+ read = zis.read(buffer);
+ }
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ if (fos != null) {
+ fos.close();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * archive the data referenced by the name to the destinationFolder.
+ * @param name the name referenced the data in the Persistence Handler to be
+ * archived.
+ * @param destinationFolder the destination folder to store the archived
+ * data
+ * @throws ExportException throw if error occur during achriving.
+ */
+ public synchronized void archive(String name, File destinationFolder)
+ throws ExportException {
+ File resultFile = getFileFromName(name);
+ try {
+ copyFile(resultFile, getCurrentDirectory(), destinationFolder);
+ } catch (IOException e) {
+ throw new ExportException(e.getMessage());
+ }
+ }
+
+ /**
+ * copy the source file to the destination folder with all directory
+ * structure copied, base on the base directory.
+ * for example,
+ *
+ * The source File is
+ * \ebxmlms\messageRepository\r0000\a.txt
+ *
+ * The base directory is
+ * \ebxmlms\messageRepository
+ *
+ * The destination Folder is
+ * \temp
+ *
+ * And then the file will be copy to destination folder with the
+ * path:
+ * \temp\r0000\a.txt
+ *
+ * And this path will be returned.
+ *
+ * @param sourceFile The source file to be copied
+ * @param baseDirectory The base directory for copying the directory
+ * structure
+ * @param destinationFolder The destination folder to copy the file
+ * @return The path that the file is copied.
+ * @throws IOException throw if error occur on copying.
+ */
+ private static File copyFile(File sourceFile, File baseDirectory,
+ File destinationFolder) throws IOException {
+ File parentFile = sourceFile.getParentFile();
+ if (parentFile.equals(baseDirectory)) {
+ return copyFile(sourceFile, destinationFolder);
+ } else {
+ File outputFile = copyFile(parentFile, baseDirectory,
+ destinationFolder);
+ return copyFile(sourceFile, outputFile);
+ }
+ }
+
+ /**
+ * copy the file from the source to the destination directory.
+ *
+ * @param sourceFile the source file
+ * @param destDir the destination directory
+ * @return the path the file is copied.
+ * @throws IOException throw if error occur during copying.
+ */
+ private static File copyFile(File sourceFile, File destDir)
+ throws IOException {
+ String name = sourceFile.getName();
+ File newFile = new File(destDir, name);
+ if (newFile.exists()) {
+ if (newFile.isFile() || sourceFile.isFile()) {
+ throw new IOException("File exist");
+ }
+ }
+
+ if (sourceFile.isDirectory()) {
+ if (!newFile.mkdir()) {
+ throw new IOException("Cannot create directory");
+ }
+ } else if (sourceFile.isFile()) {
+ InputStream istream = null;
+ OutputStream ostream = null;
+ byte[] buffer = new byte[2048];
+ try {
+ istream = new FileInputStream(sourceFile);
+ ostream = new FileOutputStream(newFile);
+ int read = istream.read(buffer);
+ while (read != -1) {
+ ostream.write(buffer, 0, read);
+ read = istream.read(buffer);
+ }
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ if (istream != null) {
+ istream.close();
+ }
+ if (ostream != null) {
+ ostream.close();
+ }
+ }
+ }
+ return newFile;
+ }
+
/**
* The self implemented FileDataSource
Index: MessageServer.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/MessageServer.java,v
retrieving revision 1.146
retrieving revision 1.147
diff -C2 -d -r1.146 -r1.147
*** MessageServer.java 13 Jan 2004 10:41:58 -0000 1.146
--- MessageServer.java 16 Jan 2004 04:26:34 -0000 1.147
***************
*** 867,870 ****
--- 867,906 ----
exception = null;
+ PersistenceHandler repositoryHandler
+ = PersistenceManager.getRepositoryPersistenceHandler();
+ PersistenceHandler objectStoreHandler
+ = PersistenceManager.getObjectStorePersistenceHandler();
+ try {
+ if (!(repositoryHandler instanceof BackupablePersistenceHandler)) {
+ throw new IOException("backup not supported on "
+ + "Repository Persistence handler");
+ }
+ BackupablePersistenceHandler backupRepositoryHandler
+ = (BackupablePersistenceHandler) repositoryHandler;
+ backupRepositoryHandler.setBackupDirectory(
+ SEPARATOR_MESSAGE_REPOSITORY);
+ backupRepositoryHandler.backup(zos);
+ if (!(objectStoreHandler instanceof BackupablePersistenceHandler)) {
+ throw new IOException("backup not supported on "
+ + "Object store Persistence handler");
+ }
+ BackupablePersistenceHandler backupObjectStoreHandler
+ = (BackupablePersistenceHandler) objectStoreHandler;
+ backupObjectStoreHandler.setBackupDirectory(SEPARATOR_OBJECT_STORE);
+ backupObjectStoreHandler.backup(zos);
+ } catch (IOException ioe) {
+ // error already logged
+ logger.error(exception.getMessage());
+ exception = ioe;
+ } finally {
+ try {
+ zos.close();
+ } catch (IOException ioe) {}
+
+ if (exception != null) {
+ throw new MessageServerException(exception.getMessage());
+ }
+ }
+ /*
try {
backupFiles(new File(messageRepository), zos);
***************
*** 882,885 ****
--- 918,922 ----
}
}
+ */
logger.debug("<= MessageServer.backup");
***************
*** 921,928 ****
exception = null;
try {
! restoreFiles(zis);
} catch (IOException ioe) {
// error already logged
exception = ioe;
} finally {
--- 958,986 ----
exception = null;
+ PersistenceHandler repositoryHandler
+ = PersistenceManager.getRepositoryPersistenceHandler();
+ PersistenceHandler objectStoreHandler
+ = PersistenceManager.getObjectStorePersistenceHandler();
try {
! if (!(repositoryHandler instanceof BackupablePersistenceHandler)) {
! throw new IOException("backup not supported on "
! + "Repository Persistence handler");
! }
! BackupablePersistenceHandler backupRepositoryHandler
! = (BackupablePersistenceHandler) repositoryHandler;
! backupRepositoryHandler.setBackupDirectory(
! SEPARATOR_MESSAGE_REPOSITORY);
! backupRepositoryHandler.restore(zis);
! if (!(objectStoreHandler instanceof BackupablePersistenceHandler)) {
! throw new IOException("backup not supported on "
! + "Object store Persistence handler");
! }
! BackupablePersistenceHandler backupObjectStoreHandler
! = (BackupablePersistenceHandler) objectStoreHandler;
! backupObjectStoreHandler.setBackupDirectory(SEPARATOR_OBJECT_STORE);
! backupObjectStoreHandler.restore(zis);
} catch (IOException ioe) {
// error already logged
+ logger.error(exception.getMessage());
exception = ioe;
} finally {
***************
*** 935,939 ****
--- 993,1012 ----
}
}
+ /*
+ try {
+ restoreFiles(zis);
+ } catch (IOException ioe) {
+ // error already logged
+ exception = ioe;
+ } finally {
+ try {
+ zis.close();
+ } catch (IOException ioe) {}
+ if (exception != null) {
+ throw new MessageServerException(exception.getMessage());
+ }
+ }
+ */
logger.debug("<= MessageServer.restore");
}
Index: RepositoryPersistenceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/RepositoryPersistenceHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** RepositoryPersistenceHandler.java 13 Jan 2004 10:41:58 -0000 1.3
--- RepositoryPersistenceHandler.java 16 Jan 2004 04:26:35 -0000 1.4
***************
*** 250,254 ****
/**
! * get the max number of file per sub directory
* @return
*/
--- 250,254 ----
/**
! * get the max number of file per sub directory
* @return
*/
|