You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(44) |
Aug
(98) |
Sep
(97) |
Oct
(130) |
Nov
(118) |
Dec
(102) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(139) |
Feb
(74) |
Mar
(128) |
Apr
(104) |
May
(121) |
Jun
(32) |
Jul
(29) |
Aug
(9) |
Sep
(16) |
Oct
|
Nov
(11) |
Dec
(29) |
| 2004 |
Jan
(15) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(9) |
Sep
(2) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
| 2005 |
Jan
(1) |
Feb
(3) |
Mar
(3) |
Apr
|
May
(1) |
Jun
(5) |
Jul
|
Aug
(12) |
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2006 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
(1) |
Oct
(5) |
Nov
(5) |
Dec
|
| 2007 |
Jan
(2) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <bob...@us...> - 2004-01-16 06:52:46
|
Update of /cvsroot/ebxmlms/ebxmlms/conf
In directory sc8-pr-cvs1:/tmp/cvs-serv23886/conf
Modified Files:
msh.properties.xml
Log Message:
Add comment on msh.properties.xml
change the property key on the object store persistence handler
in Constants.java
Index: msh.properties.xml
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/conf/msh.properties.xml,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** msh.properties.xml 4 Nov 2003 07:00:26 -0000 1.28
--- msh.properties.xml 16 Jan 2004 06:52:42 -0000 1.29
***************
*** 205,208 ****
--- 205,218 ----
<!-- Directory where the archived data are placed -->
<ArchiveDirectory>/hermes/msh_archive</ArchiveDirectory>
+
+ <!-- Optional Property to allow the user to have customized
+ Persistence Handler for Message Repository. The value must be a class
+ name implemented PersistenceHandler. If the user want the support the
+ backup and archive, the class must also implement BackupPersistenceHandler
+ and ArchivablePersistenceHandler respectively.
+ If this field is not set, the default file based persistence handler will
+ be used.
+ <MessageRepositoryPersistHandler></MessageRepositoryPersistHandler>
+ -->
</Persistent>
***************
*** 211,214 ****
--- 221,234 ----
<TrustedRepository>/hermes/ebxmlms/trustedRepository1;/hermes/ebxmlms/trustedRepository2</TrustedRepository>
<ObjectStore>/hermes/ebxmlms/objectStore</ObjectStore>
+
+ <!-- Optional Property to allow the user to have customized
+ Persistence Handler for Message Repository. The value must be a class
+ name implemented PersistenceHandler. If the user want the support the
+ backup, the class must also implement BackupPersistenceHandler.
+ .
+ If this field is not set, the default file based persistence handler will
+ be used.
+ <ObjectStorePersistHandler></ObjectStorePersistHandler>
+ -->
</MessageListener>
</MSH>
|
|
From: <bob...@us...> - 2004-01-16 06:52:45
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler
In directory sc8-pr-cvs1:/tmp/cvs-serv23886/src/hk/hku/cecid/phoenix/message/handler
Modified Files:
Constants.java
Log Message:
Add comment on msh.properties.xml
change the property key on the object store persistence handler
in Constants.java
Index: Constants.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/Constants.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** Constants.java 31 Dec 2003 04:06:42 -0000 1.35
--- Constants.java 16 Jan 2004 06:52:42 -0000 1.36
***************
*** 514,518 ****
public static final String
PROPERTY_MESSAGE_LISTENER_OBJECT_STORE_PERSIST_HANDLER
! = "MSH/MessageListener/ObjectStore/PersistHandler";
/**
--- 514,518 ----
public static final String
PROPERTY_MESSAGE_LISTENER_OBJECT_STORE_PERSIST_HANDLER
! = "MSH/MessageListener/ObjectStorePersistHandler";
/**
|
|
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
*/
|
|
From: <bob...@us...> - 2004-01-16 04:26:38
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/message/handler
In directory sc8-pr-cvs1:/tmp/cvs-serv4371/src_junit/hk/hku/cecid/phoenix/test/message/handler
Modified Files:
FilePersistenceHandlerTest.java
Log Message:
Add BackupablePersistenceHandler and ArchivablePersistenceHandler
for backup and archive interfaces.
make persistence support in backup, restore and archive.
Index: FilePersistenceHandlerTest.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/message/handler/FilePersistenceHandlerTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FilePersistenceHandlerTest.java 5 Jan 2004 09:57:43 -0000 1.2
--- FilePersistenceHandlerTest.java 16 Jan 2004 04:26:35 -0000 1.3
***************
*** 73,80 ****
--- 73,86 ----
import junit.framework.TestCase;
import junit.framework.TestSuite;
+
+ import java.io.ByteArrayInputStream;
+ import java.io.ByteArrayOutputStream;
import java.io.File;
+ import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;
+ import java.util.zip.ZipInputStream;
+ import java.util.zip.ZipOutputStream;
/**
* The testing on File Persistence Handler
***************
*** 88,91 ****
--- 94,102 ----
*/
protected static final String TEST_PATH = "test/testFile";
+
+ /**
+ * The path used on testing the archive on FilePersistenceHandler
+ */
+ protected static final String TEST_ARCHIVE_PATH = "test/archive";
/**
***************
*** 125,129 ****
--- 136,146 ----
testPathFile.mkdir();
}
+ File testArchivePathFile = new File(TEST_ARCHIVE_PATH);
+ removeAllFiles(testArchivePathFile);
+ if (!testArchivePathFile.exists()) {
+ testArchivePathFile.mkdir();
+ }
handler = createFilePersistenceHandler();
+ handler.setBackupDirectory("temp");
}
***************
*** 143,146 ****
--- 160,168 ----
testPathFile.deleteOnExit();
}
+ File testArchivePathFile = new File(TEST_ARCHIVE_PATH);
+ removeAllFiles(testArchivePathFile);
+ if (testArchivePathFile.exists() && !testArchivePathFile.delete()) {
+ testArchivePathFile.deleteOnExit();
+ }
}
***************
*** 169,172 ****
--- 191,217 ----
return dataSource;
}
+
+ protected void verifyTestDataSource(String name) throws Exception {
+ DataSource gotDataSource = handler.getObject(name);
+ assertTrue(gotDataSource != null);
+ InputStream istream = null;
+ try {
+ istream = gotDataSource.getInputStream();
+ verifyTestDataSourceFromInputStream(istream);
+ } catch (IOException e) {
+ fail(e.toString());
+ } finally {
+ istream.close();
+ }
+ }
+
+ protected void verifyTestDataSourceFromInputStream(InputStream istream)
+ throws IOException {
+ for (int i = 0; i < FILE_CONTENT.length; i++) {
+ int read = istream.read();
+ assertTrue(read == FILE_CONTENT[i]);
+ }
+ assertTrue(-1 == istream.read());
+ }
/**
***************
*** 205,228 ****
public void testWriteAndRead() {
String name = null;
InputStream istream = null;
try {
DataSource dataSource = createTestDataSource();
name = dataSource.getName();
! DataSource gotDataSource = handler.getObject(name);
! assertTrue(gotDataSource != null);
! istream = gotDataSource.getInputStream();
! for (int i = 0; i < FILE_CONTENT.length; i++) {
! int read = istream.read();
! assertTrue(read == FILE_CONTENT[i]);
}
! assertTrue(-1 == istream.read());
} catch (Exception e) {
fail(e.toString());
} finally {
! if (istream != null) {
try {
! istream.close();
! } catch (IOException e) {
! fail("Fail on closing : " + e.toString());
}
}
--- 250,330 ----
public void testWriteAndRead() {
String name = null;
+ try {
+ DataSource dataSource = createTestDataSource();
+ name = dataSource.getName();
+ verifyTestDataSource(name);
+ } catch (Exception e) {
+ fail(e.toString());
+ }
+ try {
+ handler.removeObject(name);
+ } catch (Exception e) {
+ fail(e.toString());
+ }
+ }
+
+ /**
+ * test the backup and restore function.
+ */
+ public void testBackupRestore() {
+ String name = null;
InputStream istream = null;
+ InputStream bainstream = null;
+ ByteArrayOutputStream baostream = null;
+ ZipOutputStream zos = null;
+ /*
+ * Create a test data source and then badckup to a byte array
+ */
try {
DataSource dataSource = createTestDataSource();
name = dataSource.getName();
! baostream = new ByteArrayOutputStream();
! zos = new ZipOutputStream(baostream);
! handler.backup(zos);
! } catch (Exception e) {
! fail(e.toString());
! } finally {
! if (zos != null) {
! try {
! zos.close();
! } catch (Exception e) {
! fail(e.toString());
! }
}
! }
! byte[] result = baostream.toByteArray();
! try {
! baostream.close();
! } catch (Exception e) {
! fail(e.toString());
! }
! ZipInputStream zis = null;
! /*
! * remove the object and then restore the handler to see whether
! * it can be get back the object.
! */
! try {
! verifyTestDataSource(name);
! handler.removeObject(name);
! assertTrue(handler.getObject(name) == null);
! bainstream = new ByteArrayInputStream(result);
! zis = new ZipInputStream(bainstream);
! handler.restore(zis);
! assertTrue(handler.getObject(name) != null);
} catch (Exception e) {
fail(e.toString());
} finally {
! if (bainstream != null) {
try {
! bainstream.close();
! } catch (Exception e) {
! fail(e.toString());
! }
! }
! if (zis != null) {
! try {
! zis.close();
! } catch (Exception e) {
! fail(e.toString());
}
}
***************
*** 234,236 ****
--- 336,362 ----
}
}
+
+ public void testArchive() {
+ InputStream istream = null;
+ try {
+ DataSource dataSource = createTestDataSource();
+ File dir = new File(TEST_ARCHIVE_PATH);
+ String name = dataSource.getName();
+ handler.archive(name, dir);
+ File archivedFile = new File(dir, name);
+ assertTrue(archivedFile.isFile());
+ istream = new FileInputStream(archivedFile);
+ verifyTestDataSourceFromInputStream(istream);
+ } catch (Exception e) {
+ fail(e.toString());
+ } finally {
+ if (istream != null) {
+ try {
+ istream.close();
+ } catch (IOException e) {
+ fail(e.toString());
+ }
+ }
+ }
+ }
}
|
|
From: <bob...@us...> - 2004-01-13 10:42:02
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging
In directory sc8-pr-cvs1:/tmp/cvs-serv847/src/hk/hku/cecid/phoenix/message/packaging
Modified Files:
EbxmlMessage.java PKISignatureImpl.java
Log Message:
Change the MSH to support Customize Persistence Handler.
However, haven't changed the code on backup, archive and export yet.
Index: EbxmlMessage.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging/EbxmlMessage.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** EbxmlMessage.java 15 Dec 2003 09:51:34 -0000 1.40
--- EbxmlMessage.java 13 Jan 2004 10:41:58 -0000 1.41
***************
*** 70,73 ****
--- 70,74 ----
import hk.hku.cecid.phoenix.message.handler.MessageServer;
import hk.hku.cecid.phoenix.message.handler.MessageServerException;
+ import hk.hku.cecid.phoenix.message.handler.PersistenceHandler;
import hk.hku.cecid.phoenix.message.packaging.validation.EbxmlValidationException;
import hk.hku.cecid.phoenix.message.packaging.validation.SOAPValidationException;
***************
*** 189,193 ****
*/
private String filename;
!
/**
* Constructs an <code>EbxmlMessage</code> using the default JAXM
--- 190,202 ----
*/
private String filename;
!
! /**
! * Optional persistence name in which the message is persisted
! */
! private String persistenceName;
! /**
! * Optional persistence handler in which the message is persisted
! */
! private PersistenceHandler persistenceHandler;
/**
* Constructs an <code>EbxmlMessage</code> using the default JAXM
***************
*** 1596,1599 ****
--- 1605,1635 ----
this.soapEnvelopeBytes = soapEnvelopeBytes;
}
+
+ /**
+ * set the persistence info to the message
+ * @param persistenceName the name on the persistence handler
+ * @param handler the persistence handler
+ */
+ public void setPersistenceInfo(String persistenceName,
+ PersistenceHandler handler) {
+ this.persistenceName = persistenceName;
+ persistenceHandler = handler;
+ }
+
+ /**
+ * get the Persistence name if it is stored
+ * @return the persitence name
+ */
+ public String getPersistenceName() {
+ return persistenceName;
+ }
+
+ /**
+ * get the persistence handler if it is stored
+ * @return the persistence handler
+ */
+ public PersistenceHandler getPersistenceHandler() {
+ return persistenceHandler;
+ }
}
Index: PKISignatureImpl.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging/PKISignatureImpl.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** PKISignatureImpl.java 15 Dec 2003 09:51:35 -0000 1.13
--- PKISignatureImpl.java 13 Jan 2004 10:41:58 -0000 1.14
***************
*** 70,75 ****
import hk.hku.cecid.phoenix.message.handler.ErrorMessages;
- import hk.hku.cecid.phoenix.message.packaging.Signature;
- import hk.hku.cecid.phoenix.message.packaging.SignatureException;
import hk.hku.cecid.phoenix.message.packaging.validation.SOAPValidationException;
import hk.hku.cecid.phoenix.pki.ApacheXMLDSigner;
--- 70,73 ----
***************
*** 81,88 ****
--- 79,91 ----
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
+ import java.io.IOException;
+ import java.io.InputStream;
+ import java.io.OutputStream;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.util.Iterator;
+
+ import javax.activation.DataSource;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.SOAPElement;
***************
*** 248,251 ****
--- 251,290 ----
throw new Error("Not supported");
}
+
+ private int loadInputStreamToOutputStream(InputStream istream,
+ OutputStream ostream, int skipped, int expectedLength)
+ throws IOException {
+ int bufferSize = 2048;
+ byte[] buffer = new byte[bufferSize];
+ int skippedBytes = 0;
+ int read = 0;
+ while(read != -1 && skippedBytes < skipped) {
+ read = istream.read(buffer, 0,
+ calculateReadSize(skippedBytes, skipped, bufferSize));
+ if (read != -1) {
+ skippedBytes += read;
+ }
+ }
+ int length = 0;
+ read = 0;
+ while(read != -1 && length < expectedLength) {
+ read = istream.read(buffer, 0,
+ calculateReadSize(length, expectedLength, bufferSize));
+ if (read != -1) {
+ ostream.write(buffer, 0, read);
+ length += read;
+ }
+ }
+ return length;
+ }
+
+ private int calculateReadSize(int read, int expected, int bufferSize) {
+ int remain = expected - read;
+ if (remain > bufferSize) {
+ return bufferSize;
+ } else {
+ return remain;
+ }
+ }
boolean verify(char[] password, String keyStoreLocation,
***************
*** 255,263 ****
ByteArrayOutputStream baos = new ByteArrayOutputStream();
String fileName = ebxmlMessage.getFileName();
byte[] soapEnvelopeBytes = ebxmlMessage.getSoapEnvelopeBytes();
if (soapEnvelopeBytes != null) {
baos.write(soapEnvelopeBytes);
} else if (fileName != null) {
! FileInputStream fis = new FileInputStream(fileName);
int skipped = ebxmlMessage.getSOAPMessageFileOffset()[0];
byte[] buffer = new byte[skipped];
--- 294,323 ----
ByteArrayOutputStream baos = new ByteArrayOutputStream();
String fileName = ebxmlMessage.getFileName();
+ String persistenceName = ebxmlMessage.getPersistenceName();
byte[] soapEnvelopeBytes = ebxmlMessage.getSoapEnvelopeBytes();
if (soapEnvelopeBytes != null) {
baos.write(soapEnvelopeBytes);
+ } else if (persistenceName != null) {
+ DataSource dataSource
+ = ebxmlMessage.getPersistenceHandler().getObject(
+ persistenceName);
+ if (dataSource == null) {
+ throw new SignatureException(
+ "Inconsistence Persistence on ebxmlMessage");
+ }
+ InputStream istream = dataSource.getInputStream();
+ int[] soapMessageOffset
+ = ebxmlMessage.getSOAPMessageFileOffset();
+ try {
+ //istream = new FileInputStream(fileName);
+ loadInputStreamToOutputStream(istream, baos,
+ soapMessageOffset[0], soapMessageOffset[1]);
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ istream.close();
+ }
} else if (fileName != null) {
! /*
int skipped = ebxmlMessage.getSOAPMessageFileOffset()[0];
byte[] buffer = new byte[skipped];
***************
*** 279,284 ****
}
fis.close();
! }
! else {
final SOAPPart soapPart = ebxmlMessage.getSOAPMessage().
getSOAPPart();
--- 339,358 ----
}
fis.close();
! */
! InputStream istream = null;
! int[] soapMessageOffset
! = ebxmlMessage.getSOAPMessageFileOffset();
! try {
! istream = new FileInputStream(fileName);
! loadInputStreamToOutputStream(istream, baos,
! soapMessageOffset[0], soapMessageOffset[1]);
! } catch (IOException e) {
! throw e;
! } finally {
! if (istream != null) {
! istream.close();
! }
! }
! } else {
final SOAPPart soapPart = ebxmlMessage.getSOAPMessage().
getSOAPPart();
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler
In directory sc8-pr-cvs1:/tmp/cvs-serv847/src/hk/hku/cecid/phoenix/message/handler
Modified Files:
Command.java MessageServer.java MessageServiceHandler.java
MessageServiceHandlerConnection.java
RepositoryPersistenceHandler.java
Log Message:
Change the MSH to support Customize Persistence Handler.
However, haven't changed the code on backup, archive and export yet.
Index: Command.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/Command.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** Command.java 11 Dec 2003 06:41:29 -0000 1.22
--- Command.java 13 Jan 2004 10:41:58 -0000 1.23
***************
*** 71,80 ****
import hk.hku.cecid.phoenix.message.packaging.EbxmlMessage;
import java.io.File;
- import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Iterator;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
--- 71,82 ----
import hk.hku.cecid.phoenix.message.packaging.EbxmlMessage;
import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+ import java.io.OutputStream;
import java.io.Serializable;
import java.util.Iterator;
+
+ import javax.activation.DataSource;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
***************
*** 305,309 ****
--- 307,313 ----
String fileName = null;
+ OutputStream ostream = null;
try {
+ /*
fileName = DirectoryManager.getRepositoryFileName(messageId);
FileOutputStream fos = new FileOutputStream(fileName);
***************
*** 316,319 ****
--- 320,339 ----
ebxmlMessage = MessageServer.getMessageFromFile
(new File(fileName));
+ */
+ PersistenceHandler handler =
+ PersistenceManager.getRepositoryPersistenceHandler();
+ DataSource dataSource = handler.createNewObject();
+ fileName = dataSource.getName();
+ ostream = dataSource.getOutputStream();
+ byte[] buffer = new byte[65536];
+ int read = ois.read(buffer);
+ while (read != -1) {
+ ostream.write(buffer, 0, read);
+ read = ois.read(buffer);
+ }
+ ebxmlMessage = (EbxmlMessage)
+ MessageServer.getMessageFromDataSource(dataSource,
+ true);
+ ebxmlMessage.setPersistenceInfo(fileName, handler);
MimeHeaders headers = ebxmlMessage.getSOAPMessage().
getMimeHeaders();
***************
*** 324,329 ****
}
}
! }
! catch (Exception e) {
if (fileName != null) {
try {
--- 344,349 ----
}
}
! } catch (Exception e) {
! /*
if (fileName != null) {
try {
***************
*** 336,341 ****
--- 356,365 ----
System.err.println(e2.getMessage());
}
+ }*/
+ if (fileName != null) {
+
}
throw new IOException(e.getMessage());
+ } finally {
}
}
Index: MessageServer.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/MessageServer.java,v
retrieving revision 1.145
retrieving revision 1.146
diff -C2 -d -r1.145 -r1.146
*** MessageServer.java 5 Jan 2004 11:24:08 -0000 1.145
--- MessageServer.java 13 Jan 2004 10:41:58 -0000 1.146
***************
*** 1143,1146 ****
--- 1143,1147 ----
String fileName = resultSet.getString
(DbTableManager.ATTRIBUTE_FILE_NAME);
+ /*
fileName = fileName.replace('\\', File.separatorChar);
fileName = fileName.replace('/', File.separatorChar);
***************
*** 1158,1161 ****
--- 1159,1167 ----
refToMessage = getMessageFromFile(pathName);
+ */
+ PersistenceHandler handler
+ = PersistenceManager.getRepositoryPersistenceHandler();
+ refToMessage = (EbxmlMessage) getMessageFromDataSource(
+ handler.getObject(fileName), true);;
} catch (MessageServerException e) {
exception = e;
***************
*** 2157,2161 ****
/**
! * Description of the Method
*
* @param ebxmlMessage Description of the Parameter
--- 2163,2167 ----
/**
! * Store the states for the EbxmlMessage
*
* @param ebxmlMessage Description of the Parameter
***************
*** 2167,2171 ****
* @throws MessageServerException Description of the Exception
*/
! String store(EbxmlMessage ebxmlMessage, ApplicationContext appContext,
int state, boolean isDelivered, Transaction tx)
throws MessageServerException {
--- 2173,2177 ----
* @throws MessageServerException Description of the Exception
*/
! void store(EbxmlMessage ebxmlMessage, ApplicationContext appContext,
int state, boolean isDelivered, Transaction tx)
throws MessageServerException {
***************
*** 2180,2188 ****
}
logger.debug("final sequence number in store: " + seqNo);
! return store(ebxmlMessage, appContext, state, seqNo, tx);
}
/**
! * Description of the Method
*
* @param ebxmlMessage Description of the Parameter
--- 2186,2194 ----
}
logger.debug("final sequence number in store: " + seqNo);
! store(ebxmlMessage, appContext, state, seqNo, tx);
}
/**
! * Store the states for the EbxmlMessage
*
* @param ebxmlMessage Description of the Parameter
***************
*** 2194,2198 ****
* @throws MessageServerException Description of the Exception
*/
! String store(EbxmlMessage ebxmlMessage, ApplicationContext appContext,
int state, int sequenceNumber, Transaction tx)
throws MessageServerException {
--- 2200,2204 ----
* @throws MessageServerException Description of the Exception
*/
! void store(EbxmlMessage ebxmlMessage, ApplicationContext appContext,
int state, int sequenceNumber, Transaction tx)
throws MessageServerException {
***************
*** 2222,2225 ****
--- 2228,2233 ----
ResultSet resultSet = null;
Exception exception = null;
+ PersistenceHandler handler
+ = PersistenceManager.getRepositoryPersistenceHandler();
try {
if (refToMessageId != null) {
***************
*** 2243,2246 ****
--- 2251,2255 ----
PreparedStatement[] actions;
if (!resultSet.next()) {
+ /*
fileName = ebxmlMessage.getFileName();
if (fileName == null) {
***************
*** 2258,2262 ****
String fileNameInDB = fileName.substring(
messageRepoPath.length());
!
logger.debug("insert into messagestore database");
insert = DbTableManager.DBTABLE_MESSAGE_STORE.getInsertQuery
--- 2267,2293 ----
String fileNameInDB = fileName.substring(
messageRepoPath.length());
! */
! fileName = ebxmlMessage.getPersistenceName();
! if (fileName == null) {
! logger.debug("Message haven't persisted");
! DataSource dataSource = handler.createNewObject();
! fileName = dataSource.getName();
! logger.debug("Try to persist to " + fileName);
! OutputStream ostream = null;
! try {
! ostream = dataSource.getOutputStream();
! ebxmlMessage.writeTo(ostream);
! } catch (Exception e) {
! throw e;
! } finally {
! if (ostream != null) {
! ostream.close();
! }
! }
! logger.debug("Message Persisted to " + fileName
! + " on persitence handler");
! ebxmlMessage.setPersistenceInfo(fileName, handler);
! }
! String fileNameInDB = fileName;
logger.debug("insert into messagestore database");
insert = DbTableManager.DBTABLE_MESSAGE_STORE.getInsertQuery
***************
*** 2300,2304 ****
infoinsert =
! DbTableManager.DBTABLE_MESSAGE_INFO.getInsertQuery(tx.getConnection(),
new String[]{
DbTableManager.ATTRIBUTE_MESSAGE_ID,
--- 2331,2336 ----
infoinsert =
! DbTableManager.DBTABLE_MESSAGE_INFO.getInsertQuery(
! tx.getConnection(),
new String[]{
DbTableManager.ATTRIBUTE_MESSAGE_ID,
***************
*** 2315,2319 ****
if (state == STATE_SENT_STARTED) {
sendingStateInsert =
! DbTableManager.DBTABLE_SENDING_STATE.getInsertQuery(tx.getConnection(), new String[]
{DbTableManager.ATTRIBUTE_MESSAGE_ID,
DbTableManager.ATTRIBUTE_CURRENT_RETRY,
--- 2347,2352 ----
if (state == STATE_SENT_STARTED) {
sendingStateInsert =
! DbTableManager.DBTABLE_SENDING_STATE.getInsertQuery(
! tx.getConnection(), new String[]
{DbTableManager.ATTRIBUTE_MESSAGE_ID,
DbTableManager.ATTRIBUTE_CURRENT_RETRY,
***************
*** 2379,2383 ****
new String[]{messageId});
actions = new PreparedStatement[]{update};
! fileName = messageRepository + File.separator + fileName;
}
tx.executeUpdate(actions);
--- 2412,2416 ----
new String[]{messageId});
actions = new PreparedStatement[]{update};
! //fileName = messageRepository + File.separator + fileName;
}
tx.executeUpdate(actions);
***************
*** 2429,2448 ****
throw new MessageServerException(exception.getMessage());
}
!
if (ebxmlMessage.getFileName() == null) {
ebxmlMessage.setFileName(fileName);
}
}
logger.debug("<= MessageServer.store");
- return fileName;
}
/**
! * Description of the Method
*
! * @param mshConfig Description of the Parameter
! * @param tx Description of the Parameter
! * @throws MessageServerException Description of the Exception
*/
void store(MessageServiceHandlerConfig mshConfig, Transaction tx)
--- 2462,2484 ----
throw new MessageServerException(exception.getMessage());
}
! /*
if (ebxmlMessage.getFileName() == null) {
ebxmlMessage.setFileName(fileName);
+ }*/
+ if (ebxmlMessage.getPersistenceName() == null) {
+ ebxmlMessage.setPersistenceInfo(fileName, handler);
}
}
logger.debug("<= MessageServer.store");
}
/**
! * Update the database status on the msh config.
*
! * @param mshConfig The message service handler config
! * @param tx the transaction for this updating
! * @throws MessageServerException throw if there is error on udpating
! * the msh config
*/
void store(MessageServiceHandlerConfig mshConfig, Transaction tx)
***************
*** 2697,2700 ****
--- 2733,2743 ----
final MessageListener messageListener;
try {
+ logger.debug("loading object store with object name : "
+ + objectName);
+ DataSource source = handler.getObject(objectName);
+ if (source == null) {
+ throw new Exception("Cannot load the objectName : "
+ + objectName);
+ }
stream = handler.getObject(objectName).getInputStream();
objStream = new ObjectInputStream(stream);
***************
*** 3236,3239 ****
--- 3279,3283 ----
String fileName =
resultSet.getString(DbTableManager.ATTRIBUTE_FILE_NAME);
+ /*
fileName = fileName.replace('\\', File.separatorChar);
fileName = fileName.replace('/', File.separatorChar);
***************
*** 3248,3256 ****
}
final EbxmlMessage ebxmlMessage = getMessageFromFile(pathName);
! int currentRetry =
! resultSet.getInt(DbTableManager.ATTRIBUTE_CURRENT_RETRY);
! final long nextRetryTime =
! resultSet.getLong(DbTableManager.ATTRIBUTE_NEXT_RETRY_TIME);
final int retries = mshConfig.getRetries();
final long retryInterval =
--- 3292,3314 ----
}
final EbxmlMessage ebxmlMessage = getMessageFromFile(pathName);
+ */
+ PersistenceHandler handler
+ = PersistenceManager.getRepositoryPersistenceHandler();
+ DataSource dataSource = handler.getObject(fileName);
+ if (dataSource == null) {
+ String err = ErrorMessages.getMessage(
+ ErrorMessages.ERR_HERMES_UNKNOWN_ERROR,
+ "Cannot restore persisted message "
+ + "with messsage id <" + messageId + ">");
+ logger.error(err);
+ throw new MessageServerException(err);
+ }
+ final EbxmlMessage ebxmlMessage = (EbxmlMessage)
+ getMessageFromDataSource(dataSource, true);
! int currentRetry = resultSet.getInt(
! DbTableManager.ATTRIBUTE_CURRENT_RETRY);
! final long nextRetryTime = resultSet.getLong(
! DbTableManager.ATTRIBUTE_NEXT_RETRY_TIME);
final int retries = mshConfig.getRetries();
final long retryInterval =
Index: MessageServiceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/MessageServiceHandler.java,v
retrieving revision 1.182
retrieving revision 1.183
diff -C2 -d -r1.182 -r1.183
*** MessageServiceHandler.java 5 Jan 2004 09:57:43 -0000 1.182
--- MessageServiceHandler.java 13 Jan 2004 10:41:58 -0000 1.183
***************
*** 112,115 ****
--- 112,116 ----
import java.util.Stack;
import java.util.StringTokenizer;
+ import javax.activation.DataSource;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
***************
*** 637,646 ****
--- 638,656 ----
ArrayList results = msh.getUndeliveredMessages(
appContext, false);
+ PersistenceHandler handler
+ = PersistenceManager.getRepositoryPersistenceHandler();
for (int i=0 ; i<results.size() ; i++) {
tx = null;
try {
+ /*
String fileName = (String) results.get(i);
EbxmlMessage ebxmlMessage = MessageServer.
getMessageFromFile(new File(fileName));
+ */
+ String fileName = (String) results.get(i);
+ DataSource source = handler.getObject(fileName);
+ EbxmlMessage ebxmlMessage = (EbxmlMessage)
+ MessageServer.getMessageFromDataSource(
+ source, true);
messageListener.onMessage(ebxmlMessage);
tx = new Transaction(MessageServer.dbConnectionPool);
***************
*** 997,1000 ****
--- 1007,1011 ----
configure(prop);
logger.debug("=> MessageServiceHandler.MessageServiceHandler");
+ PersistenceManager.configure(prop);
DirectoryManager.configure(prop);
DirectoryManager.initObjects();
***************
*** 1005,1009 ****
HttpSender.configure(prop);
MailSender.configure(prop);
- PersistenceManager.configure(prop);
String className = prop.get(Constants.PROPERTY_CONFIG_LOCAL);
--- 1016,1019 ----
***************
*** 1560,1572 ****
try {
clientUrl = new URL(MessageListener.PROTOCOL_FILE +
MessageListener.PROTOCOL_SEPARATOR + messageRepository);
}
catch (MalformedURLException e) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_REGISTRATION_FAILED, e,
! "malformed URL: " + MessageListener.PROTOCOL_FILE
+ MessageListener.PROTOCOL_SEPARATOR
! + messageRepository);
logger.warn(err);
throw new MessageServiceHandlerException(err);
--- 1570,1586 ----
try {
+ /*
clientUrl = new URL(MessageListener.PROTOCOL_FILE +
MessageListener.PROTOCOL_SEPARATOR + messageRepository);
+ */
+ clientUrl = (new File(".")).toURL();
}
catch (MalformedURLException e) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_REGISTRATION_FAILED, e,
! "malformed URL: .");
! /* + MessageListener.PROTOCOL_FILE
+ MessageListener.PROTOCOL_SEPARATOR
! + messageRepository); */
logger.warn(err);
throw new MessageServiceHandlerException(err);
***************
*** 1765,1768 ****
--- 1779,1783 ----
}
catch (Exception e) {
+ /*
if (ebxmlMessage.getFileName() != null) {
try {
***************
*** 1777,1780 ****
--- 1792,1805 ----
logger.error(err);
}
+ }*/
+ if (ebxmlMessage.getPersistenceName() != null) {
+ try {
+ ebxmlMessage.getPersistenceHandler().removeObject(
+ ebxmlMessage.getPersistenceName());
+ } catch (Exception e2) {
+ String err = ErrorMessages.getMessage(
+ ErrorMessages.ERR_HERMES_UNKNOWN_ERROR, e2);
+ logger.error(err);
+ }
}
if (e instanceof MessageServiceHandlerException) {
***************
*** 1790,1796 ****
--- 1815,1827 ----
Transaction tx = new Transaction(MessageServer.dbConnectionPool);
+ /*
if (ebxmlMessage.getFileName() != null) {
tx.storeFileName(ebxmlMessage.getFileName());
}
+ */
+ if (ebxmlMessage.getPersistenceName() != null) {
+ tx.storePersistenceObject(ebxmlMessage.getPersistenceName(),
+ ebxmlMessage.getPersistenceHandler());
+ }
try {
mshConnection.send(ebxmlMessage, tx);
***************
*** 1944,1949 ****
--- 1975,1987 ----
return;
}
+ /*
EbxmlMessage ebxmlMessage = MessageServer.getMessageFromFile
(new File(messageRepository, fileName));
+ */
+ PersistenceHandler handler
+ = PersistenceManager.getRepositoryPersistenceHandler();
+ EbxmlMessage ebxmlMessage = (EbxmlMessage)
+ MessageServer.getMessageFromDataSource(
+ handler.getObject(fileName), true);
boolean shouldBeDelivered = true;
if (ebxmlMessage.getMessageOrder() != null) {
***************
*** 2404,2412 ****
String messageId = null;
! File messageFile = null;
final Map map = messageServer.getUndeliveredMessages
(appContext, tx);
final Set keys = map.keySet();
Iterator iter = keys.iterator();
while (iter.hasNext()) {
--- 2442,2453 ----
String messageId = null;
! //File messageFile = null;
! DataSource messageDataSource = null;
final Map map = messageServer.getUndeliveredMessages
(appContext, tx);
final Set keys = map.keySet();
Iterator iter = keys.iterator();
+ PersistenceHandler handler
+ = PersistenceManager.getRepositoryPersistenceHandler();
while (iter.hasNext()) {
***************
*** 2420,2424 ****
if (seqNo >= MessageServer.FIRST_MESSAGE_UNDELIVERED &&
seqNo < MessageServer.FIRST_MESSAGE_ORDER_UNDELIVERED) {
! messageFile = new File(messageRepository, fileName);
seqNo = messageServer.setFileDeliveryStatus
(fileName, true, tx);
--- 2461,2466 ----
if (seqNo >= MessageServer.FIRST_MESSAGE_UNDELIVERED &&
seqNo < MessageServer.FIRST_MESSAGE_ORDER_UNDELIVERED) {
! //messageFile = new File(messageRepository, fileName);
! messageDataSource = handler.getObject(fileName);
seqNo = messageServer.setFileDeliveryStatus
(fileName, true, tx);
***************
*** 2432,2436 ****
}
if (record.isNext(seqNo)) {
! messageFile = new File(messageRepository, fileName);
messageServer.setFileDeliveryStatus
(fileName, true, tx);
--- 2474,2479 ----
}
if (record.isNext(seqNo)) {
! //messageFile = new File(messageRepository, fileName);
! messageDataSource = handler.getObject(fileName);
messageServer.setFileDeliveryStatus
(fileName, true, tx);
***************
*** 2452,2464 ****
}
}
!
if (messageFile == null) {
logger.debug("<= MessageServiceHandler."
+ "getNextUndeliveredMessage with no message");
return null;
}
// Message found. Internalize the message and return
! EbxmlMessage msg = MessageServer.getMessageFromFile(messageFile);
if (msg == null) {
logger.debug("<= MessageServiceHandler."
--- 2495,2515 ----
}
}
! /*
if (messageFile == null) {
logger.debug("<= MessageServiceHandler."
+ "getNextUndeliveredMessage with no message");
return null;
+ }*/
+ if (messageDataSource == null ) {
+ logger.debug("<= MessageServiceHandler."
+ + "getNextUndeliveredMessage with no message");
+ return null;
}
// Message found. Internalize the message and return
! //EbxmlMessage msg = MessageServer.getMessageFromFile(messageFile);
! EbxmlMessage msg = (EbxmlMessage)
! MessageServer.getMessageFromDataSource(messageDataSource,
! true);
if (msg == null) {
logger.debug("<= MessageServiceHandler."
***************
*** 3635,3639 ****
throws MessageServiceHandlerException {
!
try {
ApplicationContext appContext = null;
--- 3686,3690 ----
throws MessageServiceHandlerException {
! logger.debug("=> MessageServiceHandler.processCommand");
try {
ApplicationContext appContext = null;
***************
*** 3726,3729 ****
--- 3777,3781 ----
monitor.endRequest();
}
+ logger.debug("<= MessageServiceHandler.processCommand");
return;
}
***************
*** 3768,3771 ****
--- 3820,3824 ----
}
catch (IOException e) {};
+ logger.debug("<= MessageServiceHandler.processCommand");
return;
}
***************
*** 3776,3779 ****
--- 3829,3833 ----
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
+ logger.debug("<= MessageServiceHandler.processCommand");
return;
}
***************
*** 3908,3911 ****
--- 3962,3966 ----
getMessage(appContext, response);
monitor.endRequest();
+ logger.debug("<= MessageServiceHandler.processCommand");
return;
case CommandConstants.GET_MESSAGE_ID:
***************
*** 3914,3917 ****
--- 3969,3973 ----
getUndeliveredMessageIds(appContext, response);
monitor.endRequest();
+ logger.debug("<= MessageServiceHandler.processCommand");
return;
case CommandConstants.GET_MESSAGE_BY_ID:
***************
*** 3921,3924 ****
--- 3977,3981 ----
getMessageById(messageId, response);
monitor.endRequest();
+ logger.debug("<= MessageServiceHandler.processCommand");
return;
case CommandConstants.QUERY_RESET_SEQUENCE_NUMBER:
***************
*** 3998,4001 ****
--- 4055,4059 ----
}
monitor.endRequest();
+ logger.debug("<= MessageServiceHandler.processCommand");
return;
}
***************
*** 4213,4216 ****
--- 4271,4275 ----
EbxmlMessage ebxmlMessage = new EbxmlMessage(soapMessage);
+ /*
File newFile = new File(DirectoryManager.getRepositoryFileName
(ebxmlMessage.getMessageId()));
***************
*** 4224,4233 ****
renamed = false;
}
soapMessage = null;
ebxmlMessage = null;
try {
- ebxmlMessage = MessageServer.getMessageFromFile(newFile);
if (!renamed) {
ebxmlMessage.setFileName(null);
}
}
--- 4283,4332 ----
renamed = false;
}
+ */
+ boolean renamed = true;
+ OutputStream ostream = null;
+ InputStream istream = null;
+ DataSource dataSource = null;
+ PersistenceHandler handler
+ = PersistenceManager.getRepositoryPersistenceHandler();
+ try {
+ dataSource = handler.createNewObject();
+ ostream = dataSource.getOutputStream();
+ istream = new FileInputStream(fileName);
+ byte[] buffer = new byte[2048];
+ int read = istream.read(buffer);
+ while (read != -1) {
+ ostream.write(buffer, 0, read);
+ read = istream.read(buffer);
+ }
+ logger.debug("Persist message to " + dataSource.getName()
+ + " on persistence handler");
+ renamed = true;
+ } catch (Exception e) {
+ if (dataSource != null) {
+ handler.removeObject(dataSource.getName());
+ }
+ throw e;
+ } finally {
+ if (ostream != null) {
+ ostream.close();
+ }
+ if (istream != null) {
+ istream.close();
+ }
+ }
soapMessage = null;
ebxmlMessage = null;
try {
if (!renamed) {
+ ebxmlMessage = MessageServer.getMessageFromFile(
+ new File(fileName));
ebxmlMessage.setFileName(null);
+ } else {
+ ebxmlMessage = (EbxmlMessage)
+ MessageServer.getMessageFromDataSource(dataSource,
+ true);
+ ebxmlMessage.setPersistenceInfo(dataSource.getName(),
+ handler);
}
}
Index: MessageServiceHandlerConnection.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/MessageServiceHandlerConnection.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** MessageServiceHandlerConnection.java 11 Dec 2003 06:41:29 -0000 1.25
--- MessageServiceHandlerConnection.java 13 Jan 2004 10:41:58 -0000 1.26
***************
*** 72,76 ****
import hk.hku.cecid.phoenix.message.packaging.EbxmlMessage;
import hk.hku.cecid.phoenix.message.packaging.EbxmlMessageFactory;
- import java.io.File;
import javax.xml.messaging.JAXMException;
import javax.xml.messaging.ProviderConnection;
--- 72,75 ----
***************
*** 268,271 ****
--- 267,271 ----
try {
+ /*
boolean stored = (ebxmlMessage.getFileName() != null ?
true : false);
***************
*** 282,285 ****
--- 282,306 ----
new MessageProcessor(MessageServer.getMessageFromFile
(new File(ebxmlMessage.getFileName())), mshConfig, msh));
+ */
+ String persistenceName = ebxmlMessage.getPersistenceName();
+ try {
+ messageServer.store(ebxmlMessage, mshConfig.
+ getApplicationContext(), MessageServer.STATE_SENT_STARTED,
+ true, tx);
+ }
+ catch (MessageServerException e) {
+ throw e;
+ }
+ MessageProcessor messageProcessor;
+ if (persistenceName != null) {
+ messageProcessor = new MessageProcessor(
+ (EbxmlMessage) MessageServer.getMessageFromDataSource(
+ ebxmlMessage.getPersistenceHandler().getObject(
+ persistenceName) , true),
+ mshConfig, msh);
+ } else {
+ messageProcessor = new MessageProcessor(ebxmlMessage,
+ mshConfig, msh);
+ }
msh.addSendThread(ebxmlMessage.getMessageId(), messageProcessor);
//messageProcessor.start();
Index: RepositoryPersistenceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/RepositoryPersistenceHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RepositoryPersistenceHandler.java 3 Jan 2004 09:53:40 -0000 1.2
--- RepositoryPersistenceHandler.java 13 Jan 2004 10:41:58 -0000 1.3
***************
*** 225,229 ****
try {
File resultFile = createUniqueFile(curSubDirectory, "message");
! return directoryName + File.separatorChar + resultFile.getName();
} catch (IOException e) {
throw new PersistenceException(e);
--- 225,230 ----
try {
File resultFile = createUniqueFile(curSubDirectory, "message");
! return curSubDirectory.getName()
! + File.separatorChar + resultFile.getName();
} catch (IOException e) {
throw new PersistenceException(e);
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler
In directory sc8-pr-cvs1:/tmp/cvs-serv28800/src/hk/hku/cecid/phoenix/message/handler
Modified Files:
FilePersistenceHandler.java MessageServer.java
ObjectStorePersistenceHandler.java Transaction.java
Log Message:
Change the MessageServer to store and read the Message Listener from
PersistenceHandler rather than object store.
Index: FilePersistenceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/FilePersistenceHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** FilePersistenceHandler.java 5 Jan 2004 09:57:43 -0000 1.3
--- FilePersistenceHandler.java 5 Jan 2004 11:24:08 -0000 1.4
***************
*** 220,223 ****
--- 220,232 ----
/**
+ * If this method return true, the output stream can only be gotten once
+ * from the datasource created
+ * @return the boolean to set whether to block output stream gotten twice
+ * from the data source.
+ */
+ protected boolean isBlockingOutputStream() {
+ return true;
+ }
+ /**
* The self implemented FileDataSource
* The reason to re-implement it is to support the getOutputStream()
***************
*** 288,292 ****
throw new IOException("Cannot get OutputStream");
}
! outputStreamGotten = true;
return new FileOutputStream(file);
}
--- 297,301 ----
throw new IOException("Cannot get OutputStream");
}
! setOutputStreamGetFail();
return new FileOutputStream(file);
}
***************
*** 297,301 ****
*/
private void setOutputStreamGetFail() {
! outputStreamGotten = true;
}
}
--- 306,312 ----
*/
private void setOutputStreamGetFail() {
! if (isBlockingOutputStream()) {
! outputStreamGotten = true;
! }
}
}
Index: MessageServer.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/MessageServer.java,v
retrieving revision 1.144
retrieving revision 1.145
diff -C2 -d -r1.144 -r1.145
*** MessageServer.java 15 Dec 2003 09:51:34 -0000 1.144
--- MessageServer.java 5 Jan 2004 11:24:08 -0000 1.145
***************
*** 84,87 ****
--- 84,90 ----
import java.io.IOException;
import java.io.InputStream;
+ import java.io.ObjectInputStream;
+ import java.io.ObjectOutputStream;
+ import java.io.OutputStream;
import java.io.PushbackInputStream;
import java.net.URL;
***************
*** 2505,2512 ****
--- 2508,2522 ----
resultSet = query.executeQuery();
final String objectName;
+ final DataSource dataSource;
+ PersistenceHandler handler
+ = PersistenceManager.getObjectStorePersistenceHandler();
if (!resultSet.next()) {
+ dataSource = handler.createNewObject();
+ objectName = dataSource.getName();
+ /*
objectName = DirectoryManager.getObjectStoreFileName
(appContext.getCpaId() + appContext.getConversationId()
+ appContext.getService() + appContext.getAction());
+ */
update =
DbTableManager.DBTABLE_MSH_CONFIG.getInsertQuery(tx.getConnection(),
***************
*** 2547,2550 ****
--- 2557,2561 ----
throw new MessageServerException(err);
}
+ dataSource = handler.getObject(objectName);
logger.debug("update MSHConfig");
update =
***************
*** 2578,2584 ****
);
}
!
String path = objectStore + File.separator + objectName;
tx.storeObject(messageListener, path);
tx.executeUpdate(new PreparedStatement[]{update});
} catch (MessageServerException e) {
--- 2589,2622 ----
);
}
! /**
String path = objectStore + File.separator + objectName;
tx.storeObject(messageListener, path);
+ */
+ OutputStream stream = null;
+ ObjectOutputStream objStream = null;
+ try {
+ stream = dataSource.getOutputStream();
+ objStream = new ObjectOutputStream(stream);
+ objStream.writeObject(messageListener);
+ objStream.flush();
+ } catch (IOException e) {
+ String err = ErrorMessages.getMessage(
+ ErrorMessages.ERR_HERMES_FILE_IO_ERROR, e,
+ "cannot store object to Persistence Handler "
+ + "using name : " + objectName);
+ throw new TransactionException(err);
+ } catch (Exception e) {
+ String err = ErrorMessages.getMessage(
+ ErrorMessages.ERR_HERMES_UNKNOWN_ERROR, e);
+ throw new TransactionException(err);
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
+ if (objStream != null) {
+ objStream.close();
+ }
+ }
+ tx.storePersistenceObject(objectName, handler);
tx.executeUpdate(new PreparedStatement[]{update});
} catch (MessageServerException e) {
***************
*** 2647,2654 ****
null : new URL(urlStr);
! final String objectName =
! resultSet.getString(DbTableManager.ATTRIBUTE_MESSAGE_LISTENER);
final MessageListener messageListener = (MessageListener)
! tx.readObject(objectStore + File.separator + objectName);
final MessageServiceHandlerConfig config =
--- 2685,2730 ----
null : new URL(urlStr);
! final String objectName = resultSet.getString(
! DbTableManager.ATTRIBUTE_MESSAGE_LISTENER);
! /*
final MessageListener messageListener = (MessageListener)
! tx.readObject(objectStore + File.separator + objectName);
! */
! PersistenceHandler handler
! = PersistenceManager.getObjectStorePersistenceHandler();
! InputStream stream = null;
! ObjectInputStream objStream = null;
! final MessageListener messageListener;
! try {
! stream = handler.getObject(objectName).getInputStream();
! objStream = new ObjectInputStream(stream);
! messageListener = (MessageListener) objStream.readObject();
! } catch (IOException e) {
! String err = ErrorMessages.getMessage(
! ErrorMessages.ERR_HERMES_FILE_IO_ERROR, e,
! "cannot read object to Persistence Handler "
! + "using name : " + objectName);
! logger.error(err);
! throw new TransactionException(err);
! } catch (ClassNotFoundException e) {
! String err = ErrorMessages.getMessage(
! ErrorMessages.ERR_HERMES_FILE_IO_ERROR, e,
! "cannot read object to Persistence Handler "
! + "using name : " + objectName);
! logger.error(err);
! throw new TransactionException(err);
! } catch (Exception e) {
! String err = ErrorMessages.getMessage(
! ErrorMessages.ERR_HERMES_UNKNOWN_ERROR, e);
! logger.error(err);
! throw new TransactionException(err);
! } finally {
! if (stream != null) {
! stream.close();
! }
! if (objStream != null) {
! objStream.close();
! }
! }
final MessageServiceHandlerConfig config =
Index: ObjectStorePersistenceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/ObjectStorePersistenceHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ObjectStorePersistenceHandler.java 31 Dec 2003 04:06:42 -0000 1.1
--- ObjectStorePersistenceHandler.java 5 Jan 2004 11:24:09 -0000 1.2
***************
*** 131,133 ****
--- 131,142 ----
setCurrentDirectory(objectDir);
}
+ /**
+ * If this method return true, the output stream can only be gotten once
+ * from the datasource created
+ * @return the boolean to set whether to block output stream gotten twice
+ * from the data source.
+ */
+ protected boolean isBlockingOutputStream() {
+ return false;
+ }
}
Index: Transaction.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/Transaction.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Transaction.java 5 Jan 2004 09:57:43 -0000 1.17
--- Transaction.java 5 Jan 2004 11:24:09 -0000 1.18
***************
*** 277,284 ****
--- 277,301 ----
}
+ /**
+ * store the persistence object to the transaction,
+ * will be removed if the transaction rollback.
+ * @param name the name of the persistence object
+ * @param handler the persistence handler of the persistence object
+ */
public void storePersistenceObject(String name,
PersistenceHandler handler) {
persistenceList.add(new PersistenceObject(handler, name));
}
+
+ /**
+ * remove the persistence object from the transaction,
+ * the object will not be affect if the transaction is rollback or commit.
+ * @param name the name of the persistence object
+ * @param handler the persistence handler of the persistence object
+ */
+ public void removePersistenceObject(String name,
+ PersistenceHandler handler) {
+ persistenceList.remove(new PersistenceObject(handler, name));
+ }
/**
***************
*** 590,598 ****
*
* @author pykoon
- * @version $Revision$
*/
private class PersistenceObject {
private PersistenceHandler handler;
private String name;
public PersistenceObject(PersistenceHandler handler, String name) {
this.name = name;
--- 607,628 ----
*
* @author pykoon
*/
private class PersistenceObject {
+
+ /**
+ * The PersistenceHandler associate with the Persistence object
+ */
private PersistenceHandler handler;
+
+ /**
+ * The name of the Persistence object
+ */
private String name;
+
+ /**
+ * Construct the Persistence Object
+ * @param handler the PersistecneHandler
+ * @param name the name of the Persistence Object
+ */
public PersistenceObject(PersistenceHandler handler, String name) {
this.name = name;
***************
*** 600,609 ****
--- 630,655 ----
}
+ /**
+ * get the PersistenceHandler
+ * @return the PersistenceHandler
+ */
public PersistenceHandler getPersistenceHandler() {
return handler;
}
+ /**
+ * get the name of Persistence Object
+ * @return the name of the Persistence Object
+ */
public String getName() {
return name;
+ }
+
+ public boolean equals(Object a) {
+ if (a instanceof PersistenceObject) {
+ PersistenceObject obj = (PersistenceObject) a;
+ return obj.handler == handler && name.equals(obj.name);
+ }
+ return false;
}
}
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/message/handler In directory sc8-pr-cvs1:/tmp/cvs-serv11896/src_junit/hk/hku/cecid/phoenix/test/message/handler Added Files: FilePersistenceHandlerTest.java ObjectStorePersistenceHandlerTest.java RepositoryPersistenceHandlerTest.java Log Message: Move the Test files out from b0931 and to folder without tag. Add storePersistenceObject() function to Transaction.java |
|
From: <bob...@us...> - 2004-01-05 09:57:53
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test In directory sc8-pr-cvs1:/tmp/cvs-serv11896/src_junit/hk/hku/cecid/phoenix/test Added Files: AllTests.java Log Message: Move the Test files out from b0931 and to folder without tag. Add storePersistenceObject() function to Transaction.java |
|
From: <bob...@us...> - 2004-01-05 09:57:53
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler
In directory sc8-pr-cvs1:/tmp/cvs-serv11896/src/hk/hku/cecid/phoenix/message/handler
Modified Files:
FilePersistenceHandler.java MessageServiceHandler.java
Transaction.java
Log Message:
Move the Test files out from b0931 and to folder without tag.
Add storePersistenceObject() function to Transaction.java
Index: FilePersistenceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/FilePersistenceHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FilePersistenceHandler.java 3 Jan 2004 09:53:40 -0000 1.2
--- FilePersistenceHandler.java 5 Jan 2004 09:57:43 -0000 1.3
***************
*** 205,209 ****
}
if (file.exists() && !file.delete()) {
! throw new PersistenceException("Object cannot be removed");
}
}
--- 205,210 ----
}
if (file.exists() && !file.delete()) {
! file.deleteOnExit();
! //throw new PersistenceException("Object cannot be removed");
}
}
Index: MessageServiceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/MessageServiceHandler.java,v
retrieving revision 1.181
retrieving revision 1.182
diff -C2 -d -r1.181 -r1.182
*** MessageServiceHandler.java 31 Dec 2003 04:06:42 -0000 1.181
--- MessageServiceHandler.java 5 Jan 2004 09:57:43 -0000 1.182
***************
*** 1005,1008 ****
--- 1005,1009 ----
HttpSender.configure(prop);
MailSender.configure(prop);
+ PersistenceManager.configure(prop);
String className = prop.get(Constants.PROPERTY_CONFIG_LOCAL);
Index: Transaction.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/Transaction.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Transaction.java 11 Dec 2003 06:41:29 -0000 1.16
--- Transaction.java 5 Jan 2004 09:57:43 -0000 1.17
***************
*** 172,175 ****
--- 172,176 ----
private final DbConnectionPool dbConnectionPool;
private final ArrayList filenameList;
+ private final ArrayList persistenceList;
private final ArrayList lockList;
private final ArrayList threadList;
***************
*** 188,191 ****
--- 189,193 ----
this.threadList = new ArrayList();
this.deliveryRecordList = new ArrayList();
+ this.persistenceList = new ArrayList();
}
***************
*** 274,277 ****
--- 276,284 ----
lockList.add(id);
}
+
+ public void storePersistenceObject(String name,
+ PersistenceHandler handler) {
+ persistenceList.add(new PersistenceObject(handler, name));
+ }
/**
***************
*** 449,452 ****
--- 456,460 ----
filenameList.clear();
deliveryRecordList.clear();
+ persistenceList.clear();
}
}
***************
*** 524,527 ****
--- 532,549 ----
}
filenameList.clear();
+
+ // Delete the persistence objects
+ for (Iterator i=filenameList.iterator() ; i.hasNext() ; ) {
+ PersistenceObject obj = (PersistenceObject) i.next();
+ try {
+ obj.getPersistenceHandler().removeObject(obj.getName());
+ } catch (PersistenceException e) {
+ String err = ErrorMessages.getMessage(
+ ErrorMessages.ERR_TX_CANNOT_ROLLBACK, e);
+ logger.error(err);
+ exception = new TransactionException(err);
+
+ }
+ }
logger.debug("<= Transaction.rollback");
***************
*** 561,564 ****
--- 583,609 ----
throw new TransactionException(e.getMessage());
}
+ }
+ }
+
+ /**
+ * PersistenceObject is the class to store on the persistence list
+ *
+ * @author pykoon
+ * @version $Revision$
+ */
+ private class PersistenceObject {
+ private PersistenceHandler handler;
+ private String name;
+ public PersistenceObject(PersistenceHandler handler, String name) {
+ this.name = name;
+ this.handler = handler;
+ }
+
+ public PersistenceHandler getPersistenceHandler() {
+ return handler;
+ }
+
+ public String getName() {
+ return name;
}
}
|
|
From: <bob...@us...> - 2004-01-05 09:36:01
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test
In directory sc8-pr-cvs1:/tmp/cvs-serv8298
Added Files:
Tag: b0931
AllTests.java
Log Message:
Add AllTests again for testing.
--- NEW FILE: AllTests.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_junit/hk/hku/cecid/phoenix/test/Attic/AllTests.java,v 1.1.4.1 2004/01/05 09:35:56 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2003-12-30]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.test;
import hk.hku.cecid.phoenix.test.message.handler.FilePersistenceHandlerTest;
import hk.hku.cecid.phoenix.test.message.handler.ObjectStorePersistenceHandlerTest;
import hk.hku.cecid.phoenix.test.message.handler.RepositoryPersistenceHandlerTest;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
/**
class to test all the test cases
@author pykoon
@version $revision$
*/
public class AllTests extends TestCase {
/**
construct the AllTests
@param name the name, see TestCase on JUnit
*/
public AllTests(String name) {
super(name);
}
/**
get the test suite
@return Test the test suite
*/
public static Test suite() {
TestSuite suite = new TestSuite(
"All hk.hku.cecid.phoenix.test JUnit Tests");
suite.addTest(FilePersistenceHandlerTest.suite());
suite.addTest(RepositoryPersistenceHandlerTest.suite());
suite.addTest(ObjectStorePersistenceHandlerTest.suite());
return suite;
}
/**
main method to run all the test cases
@param args arguments.. will not be used.
*/
public static void main(String[] args) {
TestRunner.run(suite());
}
}
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/message/handler
In directory sc8-pr-cvs1:/tmp/cvs-serv8706/src_junit/hk/hku/cecid/phoenix/test/message/handler
Modified Files:
Tag: b0931
FilePersistenceHandlerTest.java
Added Files:
Tag: b0931
ObjectStorePersistenceHandlerTest.java
RepositoryPersistenceHandlerTest.java
Log Message:
add test case for RepositoryPersistenceHandler
and ObjectStorePersistenceHandler
fix bug on RepositoryPersistenceHandler
--- NEW FILE: ObjectStorePersistenceHandlerTest.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_junit/hk/hku/cecid/phoenix/test/message/handler/Attic/ObjectStorePersistenceHandlerTest.java,v 1.1.2.1 2004/01/03 09:53:41 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2004-01-05]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.test.message.handler;
import java.io.File;
import java.io.IOException;
import junit.framework.Test;
import junit.framework.TestSuite;
import hk.hku.cecid.phoenix.common.util.Property;
import hk.hku.cecid.phoenix.common.util.XMLProperty;
import hk.hku.cecid.phoenix.message.handler.Constants;
import hk.hku.cecid.phoenix.message.handler.FilePersistenceHandler;
import hk.hku.cecid.phoenix.message.handler.ObjectStorePersistenceHandler;
/**
* Test case for ObjectStorePersistenceHandler
* @author pykoon
* @version $Revision: 1.1.2.1 $
*/
public class ObjectStorePersistenceHandlerTest
extends FilePersistenceHandlerTest {
/**
* The system property key for prop.home, the one to load Property
*/
private static final String SYSTEM_PROP_HOME_KEY = "prop.home";
/**
* The file name to store the property
*/
private static final String PROPERTY_FILE_NAME = "msh.properties.xml";
/**
* The system property prop.home gotten
*/
private String systemPropHomeProperty = null;
/**
* Construct the test case
* @param name
*/
public ObjectStorePersistenceHandlerTest(String name) {
super(name);
}
/**
* get the test suite
* @return Test the test suite
*/
public static Test suite() {
return new TestSuite(RepositoryPersistenceHandlerTest.class);
}
/**
* create the repository persistence handler for testing
* @return the repository persistence handler
*/
protected FilePersistenceHandler createFilePersistenceHandler()
throws Exception {
systemPropHomeProperty = System.getProperty(SYSTEM_PROP_HOME_KEY);
return new ObjectStorePersistenceHandler();
}
/**
* method called when the test case is tear down
* @throws Exception thrown when error occur on tear down
*/
protected void tearDown() throws Exception {
super.tearDown();
if (systemPropHomeProperty != null) {
System.setProperty(SYSTEM_PROP_HOME_KEY, systemPropHomeProperty);
} else {
System.getProperties().remove(SYSTEM_PROP_HOME_KEY);
}
}
/**
* setup the Property which will be loaded by RepositoryPersistenceHandler
* @param maxFileNumber the max number of file in sub-directory
* @throws IOException thrown if there is exception in setting up the
* Property
*/
private void setupProperty() throws IOException {
Property property = new XMLProperty();
property.set(Constants.PROPERTY_MESSAGE_LISTENER_OBJECT_STORE,
TEST_PATH);
File propertyLocation = new File(TEST_PATH);
propertyLocation = new File(propertyLocation, PROPERTY_FILE_NAME);
String locationString = propertyLocation.getCanonicalPath();
property.save(locationString);
System.setProperty(SYSTEM_PROP_HOME_KEY, TEST_PATH);
}
}
--- NEW FILE: RepositoryPersistenceHandlerTest.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_junit/hk/hku/cecid/phoenix/test/message/handler/Attic/RepositoryPersistenceHandlerTest.java,v 1.1.2.1 2004/01/03 09:53:41 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2004-01-03]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.test.message.handler;
import java.io.File;
import java.io.IOException;
import javax.activation.DataSource;
import hk.hku.cecid.phoenix.common.util.Property;
import hk.hku.cecid.phoenix.common.util.XMLProperty;
import hk.hku.cecid.phoenix.message.handler.Constants;
import hk.hku.cecid.phoenix.message.handler.FilePersistenceHandler;
import hk.hku.cecid.phoenix.message.handler.RepositoryPersistenceHandler;
import junit.framework.Test;
import junit.framework.TestSuite;
/**
* RepositoryPersistenceHandlerTest is the test for the class
* RepositoryPersistenceHandler
*
* @author pykoon
* @version $Revision: 1.1.2.1 $
*/
public class RepositoryPersistenceHandlerTest
extends FilePersistenceHandlerTest {
/**
* Construct the test case
* @param name the name
*/
public RepositoryPersistenceHandlerTest(String name) {
super(name);
}
/**
* The system property key for prop.home, the one to load Property
*/
private static final String SYSTEM_PROP_HOME_KEY = "prop.home";
/**
* The file name to store the property
*/
private static final String PROPERTY_FILE_NAME = "msh.properties.xml";
/**
* The max number of file per sub-directory
*/
private static final int MAX_NUM_FILE = 1;
/**
* The system property prop.home gotten
*/
private String systemPropHomeProperty = null;
/**
* get the test suite
* @return Test the test suite
*/
public static Test suite() {
return new TestSuite(RepositoryPersistenceHandlerTest.class);
}
/**
* create the repository persistence handler for testing
* @return the repository persistence handler
*/
protected FilePersistenceHandler createFilePersistenceHandler()
throws Exception {
systemPropHomeProperty = System.getProperty(SYSTEM_PROP_HOME_KEY);
setupProperty(MAX_NUM_FILE);
return new RepositoryPersistenceHandler();
}
/**
* method called when the test case is tear down
* @throws Exception thrown when error occur on tear down
*/
protected void tearDown() throws Exception {
super.tearDown();
if (systemPropHomeProperty != null) {
System.setProperty(SYSTEM_PROP_HOME_KEY, systemPropHomeProperty);
} else {
System.getProperties().remove(SYSTEM_PROP_HOME_KEY);
}
}
/**
* setup the Property which will be loaded by RepositoryPersistenceHandler
* @param maxFileNumber the max number of file in sub-directory
* @throws IOException thrown if there is exception in setting up the
* Property
*/
private void setupProperty(int maxFileNumber) throws IOException {
Property property = new XMLProperty();
property.set(Constants.PROPERTY_MESSAGE_REPOSITORY, TEST_PATH);
property.set(Constants.PROPERTY_MAX_FILE_IN_SUBDIRECTORY,
Integer.toString(maxFileNumber));
File propertyLocation = new File(TEST_PATH);
propertyLocation = new File(propertyLocation, PROPERTY_FILE_NAME);
String locationString = propertyLocation.getCanonicalPath();
property.save(locationString);
System.setProperty(SYSTEM_PROP_HOME_KEY, TEST_PATH);
}
/**
* test whether the Repository Persistence Handler can
* create R0000 directory, and also test whether it can create
* new directory when max number of file is reached.
*/
public void testCreateDirectory() {
DataSource dataSource1 = null;
DataSource dataSource2 = null;
try {
dataSource1 = createTestDataSource();
} catch (Exception e) {
fail("Cannot create data source : " + e.toString());
}
File testPathFile = new File(TEST_PATH);
File r0000Dir = new File(testPathFile, "R0000");
assertTrue(r0000Dir.exists());
assertTrue(r0000Dir.listFiles().length == 1);
try {
dataSource2 = createTestDataSource();
} catch (Exception e) {
fail("Cannot create data source : " + e.toString());
}
File r0001Dir = new File(testPathFile, "R0001");
assertTrue(r0001Dir.exists());
assertTrue(r0001Dir.listFiles().length == 1);
try {
handler.removeObject(dataSource1.getName());
handler.removeObject(dataSource2.getName());
} catch (Exception e) {
fail("Cannot remove data source");
}
}
/**
* test whether it is initialized successfully
* create R0000 directory
*/
public void testInitialize() {
RepositoryPersistenceHandler rHandler
= (RepositoryPersistenceHandler) handler;
int number = rHandler.getMaxNumberOfFileInSubDirectory();
assertTrue(number == MAX_NUM_FILE);
}
/**
* test whether it can remove directory if the file in the directory is
* deleted
*/
public void testRemoveDirectory() {
testCreateAndRemove();
File testPathFile = new File(TEST_PATH);
File r0000Dir = new File(testPathFile, "R0000");
assertFalse(r0000Dir.exists());
}
}
Index: FilePersistenceHandlerTest.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/message/handler/Attic/FilePersistenceHandlerTest.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** FilePersistenceHandlerTest.java 31 Dec 2003 04:06:43 -0000 1.1.2.1
--- FilePersistenceHandlerTest.java 3 Jan 2004 09:53:41 -0000 1.1.2.2
***************
*** 83,107 ****
*/
public class FilePersistenceHandlerTest extends TestCase {
!
/**
The path used on testing the FilePersistenceHandler
*/
! private static final String TEST_PATH = "test/testFile";
!
/**
A sample content used to test on the FilePersistenceHandler
*/
! private static final int[] FILE_CONTENT = new int[]{0, 1, 2, 3};
!
! /**
! the dataSource used during testing
! */
! private DataSource dataSource;
!
/**
The file persistence handler used on testing
*/
! private FilePersistenceHandler handler;
!
/**
construct the FilePersistenceHandlerTest
--- 83,102 ----
*/
public class FilePersistenceHandlerTest extends TestCase {
!
/**
The path used on testing the FilePersistenceHandler
*/
! protected static final String TEST_PATH = "test/testFile";
!
/**
A sample content used to test on the FilePersistenceHandler
*/
! private static final int[] FILE_CONTENT = new int[] { 0, 1, 2, 3 };
!
/**
The file persistence handler used on testing
*/
! protected FilePersistenceHandler handler;
!
/**
construct the FilePersistenceHandlerTest
***************
*** 111,115 ****
super(name);
}
!
/**
get the test suite
--- 106,110 ----
super(name);
}
!
/**
get the test suite
***************
*** 119,123 ****
return new TestSuite(FilePersistenceHandlerTest.class);
}
!
/**
set up the test case.
--- 114,118 ----
return new TestSuite(FilePersistenceHandlerTest.class);
}
!
/**
set up the test case.
***************
*** 126,135 ****
protected void setUp() throws Exception {
File testPathFile = new File(TEST_PATH);
if (!testPathFile.exists()) {
testPathFile.mkdir();
}
! handler = new FilePersistenceHandler(new File(TEST_PATH));
}
/**
method called when the test case is tear down
--- 121,136 ----
protected void setUp() throws Exception {
File testPathFile = new File(TEST_PATH);
+ removeAllFiles(testPathFile);
if (!testPathFile.exists()) {
testPathFile.mkdir();
}
! handler = createFilePersistenceHandler();
}
+ protected FilePersistenceHandler createFilePersistenceHandler()
+ throws Exception {
+ return new FilePersistenceHandler(new File(TEST_PATH));
+ }
+
/**
method called when the test case is tear down
***************
*** 138,149 ****
protected void tearDown() throws Exception {
File testPathFile = new File(TEST_PATH);
! if (dataSource != null) {
! handler.removeObject(dataSource.getName());
! }
if (testPathFile.exists() && !testPathFile.delete()) {
testPathFile.deleteOnExit();
}
}
!
/**
create teh Test Data Source.
--- 139,162 ----
protected void tearDown() throws Exception {
File testPathFile = new File(TEST_PATH);
! removeAllFiles(testPathFile);
if (testPathFile.exists() && !testPathFile.delete()) {
testPathFile.deleteOnExit();
}
}
!
! /**
! * remove all the files in the specify directory
! * @param file
! * @throws IOException
! */
! protected static void removeAllFiles(File file) throws IOException {
! File[] files = file.listFiles();
! if (files != null) {
! for (int i = 0; i < files.length; i++) {
! removeAllFiles(files[i]);
! }
! }
! file.delete();
! }
/**
create teh Test Data Source.
***************
*** 151,160 ****
@throws Exception thrown when error occur on creating data source
*/
! private DataSource createTestDataSource() throws Exception {
DataSource dataSource = handler.createNewObject();
writeContent(dataSource);
return dataSource;
}
!
/**
write the content on DataSource
--- 164,173 ----
@throws Exception thrown when error occur on creating data source
*/
! protected DataSource createTestDataSource() throws Exception {
DataSource dataSource = handler.createNewObject();
writeContent(dataSource);
return dataSource;
}
!
/**
write the content on DataSource
***************
*** 169,173 ****
ostream.close();
}
!
/**
test to create a datasource and then remove from handler
--- 182,186 ----
ostream.close();
}
!
/**
test to create a datasource and then remove from handler
***************
*** 176,180 ****
String name = null;
try {
! dataSource = createTestDataSource();
name = dataSource.getName();
assertTrue(handler.getObject(name) != null);
--- 189,193 ----
String name = null;
try {
! DataSource dataSource = createTestDataSource();
name = dataSource.getName();
assertTrue(handler.getObject(name) != null);
***************
*** 185,189 ****
}
}
!
/**
test to create a data source, write data and then see if it
--- 198,202 ----
}
}
!
/**
test to create a data source, write data and then see if it
***************
*** 194,198 ****
InputStream istream = null;
try {
! dataSource = createTestDataSource();
name = dataSource.getName();
DataSource gotDataSource = handler.getObject(name);
--- 207,211 ----
InputStream istream = null;
try {
! DataSource dataSource = createTestDataSource();
name = dataSource.getName();
DataSource gotDataSource = handler.getObject(name);
|
|
From: <bob...@us...> - 2004-01-03 09:53:44
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler
In directory sc8-pr-cvs1:/tmp/cvs-serv8706/src/hk/hku/cecid/phoenix/message/handler
Modified Files:
FilePersistenceHandler.java HttpSender.java
RepositoryPersistenceHandler.java
Log Message:
add test case for RepositoryPersistenceHandler
and ObjectStorePersistenceHandler
fix bug on RepositoryPersistenceHandler
Index: FilePersistenceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/FilePersistenceHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** FilePersistenceHandler.java 31 Dec 2003 04:06:42 -0000 1.1
--- FilePersistenceHandler.java 3 Jan 2004 09:53:40 -0000 1.2
***************
*** 201,204 ****
--- 201,207 ----
throws PersistenceException {
File file = getFileFromName(name);
+ if (!file.exists()) {
+ throw new PersistenceException("File not exist : " + file.toString());
+ }
if (file.exists() && !file.delete()) {
throw new PersistenceException("Object cannot be removed");
Index: HttpSender.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/HttpSender.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** HttpSender.java 15 Dec 2003 09:51:34 -0000 1.17
--- HttpSender.java 3 Jan 2004 09:53:40 -0000 1.18
***************
*** 74,79 ****
import hk.hku.cecid.phoenix.message.transport.TransportException;
import java.net.URL;
- import javax.xml.soap.SOAPException;
- import javax.xml.soap.SOAPMessage;
import org.apache.log4j.Logger;
--- 74,77 ----
Index: RepositoryPersistenceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/RepositoryPersistenceHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RepositoryPersistenceHandler.java 31 Dec 2003 04:06:42 -0000 1.1
--- RepositoryPersistenceHandler.java 3 Jan 2004 09:53:40 -0000 1.2
***************
*** 161,165 ****
* a new persist object
*/
! public synchronized String createNewObject(File directory)
throws PersistenceException {
File repositoryDir = directory;
--- 161,165 ----
* a new persist object
*/
! public synchronized String createNewFileName(File directory)
throws PersistenceException {
File repositoryDir = directory;
***************
*** 187,191 ****
curSubDirectory = maxSubDir;
} else {
! curSubDirectory = new File(repositoryDir, "R0000");
if (!curSubDirectory.exists()) {
curSubDirectory.mkdir();
--- 187,192 ----
curSubDirectory = maxSubDir;
} else {
! directoryName = "R0000";
! curSubDirectory = new File(repositoryDir, directoryName);
if (!curSubDirectory.exists()) {
curSubDirectory.mkdir();
***************
*** 244,247 ****
--- 245,257 ----
file.delete();
}
+ }
+
+
+ /**
+ * get the max number of file per sub directory
+ * @return
+ */
+ public int getMaxNumberOfFileInSubDirectory() {
+ return maxNumFileInSubDir;
}
}
|
|
From: <bob...@us...> - 2004-01-03 09:53:44
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test
In directory sc8-pr-cvs1:/tmp/cvs-serv8706/src_junit/hk/hku/cecid/phoenix/test
Modified Files:
Tag: b0931
AllTests.java
Log Message:
add test case for RepositoryPersistenceHandler
and ObjectStorePersistenceHandler
fix bug on RepositoryPersistenceHandler
Index: AllTests.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/Attic/AllTests.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** AllTests.java 31 Dec 2003 04:06:42 -0000 1.1.2.1
--- AllTests.java 3 Jan 2004 09:53:41 -0000 1.1.2.2
***************
*** 69,72 ****
--- 69,74 ----
package hk.hku.cecid.phoenix.test;
import hk.hku.cecid.phoenix.test.message.handler.FilePersistenceHandlerTest;
+ import hk.hku.cecid.phoenix.test.message.handler.ObjectStorePersistenceHandlerTest;
+ import hk.hku.cecid.phoenix.test.message.handler.RepositoryPersistenceHandlerTest;
import junit.framework.Test;
import junit.framework.TestCase;
***************
*** 95,98 ****
--- 97,102 ----
"All hk.hku.cecid.phoenix.test JUnit Tests");
suite.addTest(FilePersistenceHandlerTest.suite());
+ suite.addTest(RepositoryPersistenceHandlerTest.suite());
+ suite.addTest(ObjectStorePersistenceHandlerTest.suite());
return suite;
}
|
|
From: <bob...@us...> - 2004-01-03 05:41:46
|
Update of /cvsroot/ebxmlms/ebxmlms/lib In directory sc8-pr-cvs1:/tmp/cvs-serv10093 Added Files: commons-codec-1.2.jar Log Message: Add common-codec.jar --- NEW FILE: commons-codec-1.2.jar --- (This appears to be a binary file; contents omitted.) |
|
From: <bob...@us...> - 2003-12-31 05:02:26
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/pki
In directory sc8-pr-cvs1:/tmp/cvs-serv9709/src/hk/hku/cecid/phoenix/pki
Modified Files:
ApacheXMLDSigner.java
Log Message:
fix compilation bug on ApacheXMLDSigner.java
Index: ApacheXMLDSigner.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/pki/ApacheXMLDSigner.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ApacheXMLDSigner.java 31 Dec 2003 04:06:42 -0000 1.13
--- ApacheXMLDSigner.java 31 Dec 2003 05:02:23 -0000 1.14
***************
*** 499,502 ****
--- 499,503 ----
Certificate[] certs = null;
+ double javaVersion = Version.getJDKVersion();
if (certResolver != null) {
certs = certResolver.resolve(obj);
***************
*** 504,513 ****
String err = "Certificates returned by certResolver is null";
logger.warn(err);
! throws new VerifyException(err);
}
} else if (trusted == null || javaVersion < 1.4) {
String err = "Cannot verify cert path, but certResolver is null";
logger.warn(err);
! throws new VerifyException;
}
KeyInfo keyInfo = null;
--- 505,514 ----
String err = "Certificates returned by certResolver is null";
logger.warn(err);
! throw new VerifyException(err);
}
} else if (trusted == null || javaVersion < 1.4) {
String err = "Cannot verify cert path, but certResolver is null";
logger.warn(err);
! throw new VerifyException(err);
}
KeyInfo keyInfo = null;
***************
*** 572,576 ****
logger.debug("checked signature value, result: " + ret);
- double javaVersion = Version.getJDKVersion();
if (ret == true && trusted != null && certs != null
--- 573,576 ----
|
|
From: <bob...@us...> - 2003-12-31 04:47:10
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/pki
In directory sc8-pr-cvs1:/tmp/cvs-serv7530/src/hk/hku/cecid/phoenix/pki
Modified Files:
Tag: b0931
ApacheXMLDSigner.java
Log Message:
fix compilation bug on ApacheXMLDSigner.java
Index: ApacheXMLDSigner.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/pki/ApacheXMLDSigner.java,v
retrieving revision 1.4.2.6
retrieving revision 1.4.2.7
diff -C2 -d -r1.4.2.6 -r1.4.2.7
*** ApacheXMLDSigner.java 31 Dec 2003 03:02:24 -0000 1.4.2.6
--- ApacheXMLDSigner.java 31 Dec 2003 04:47:07 -0000 1.4.2.7
***************
*** 473,476 ****
--- 473,477 ----
Certificate[] certs = null;
+ double javaVersion = Version.getJDKVersion();
if (certResolver != null) {
certs = certResolver.resolve(obj);
***************
*** 478,487 ****
String err = "Certificates returned by certResolver is null";
logger.warn(err);
! throws new VerifyException(err);
}
} else if (trusted == null || javaVersion < 1.4) {
String err = "Cannot verify cert path, but certResolver is null";
logger.warn(err);
! throws new VerifyException;
}
--- 479,488 ----
String err = "Certificates returned by certResolver is null";
logger.warn(err);
! throw new VerifyException(err);
}
} else if (trusted == null || javaVersion < 1.4) {
String err = "Cannot verify cert path, but certResolver is null";
logger.warn(err);
! throw new VerifyException(err);
}
***************
*** 547,551 ****
logger.debug("checked signature value, result: " + ret);
- double javaVersion = Version.getJDKVersion();
if (ret == true && trusted != null && certs != null
--- 548,551 ----
|
|
From: <bob...@us...> - 2003-12-31 04:06:46
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test
In directory sc8-pr-cvs1:/tmp/cvs-serv2011/src_junit/hk/hku/cecid/phoenix/test
Added Files:
Tag: b0931
AllTests.java
Log Message:
Add PersistenceHandler interface as the customize Persistence interface
Add RepositoryPersistenceHandler and ObjectStorePersistenceHandler,
which is the default persistence Handler for Repository and Object Store
Add PersistenceManager which will probably replace the DirectoryManager,
so that the persistence will not bound to File only.
Note that we haven't changed the logic on Hermes to use the PersistenceHandler
Interface yet...
Add a src_junit to add junit test case to this directory.
add test cases on testing the default persistence handler base class
Change build.xml to run the test cases.
--- NEW FILE: AllTests.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_junit/hk/hku/cecid/phoenix/test/Attic/AllTests.java,v 1.1.2.1 2003/12/31 04:06:42 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2003-12-30]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.test;
import hk.hku.cecid.phoenix.test.message.handler.FilePersistenceHandlerTest;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
/**
class to test all the test cases
@author pykoon
@version $revision$
*/
public class AllTests extends TestCase {
/**
construct the AllTests
@param name the name, see TestCase on JUnit
*/
public AllTests(String name) {
super(name);
}
/**
get the test suite
@return Test the test suite
*/
public static Test suite() {
TestSuite suite = new TestSuite(
"All hk.hku.cecid.phoenix.test JUnit Tests");
suite.addTest(FilePersistenceHandlerTest.suite());
return suite;
}
/**
main method to run all the test cases
@param args arguments.. will not be used.
*/
public static void main(String[] args) {
TestRunner.run(suite());
}
}
|
|
From: <bob...@us...> - 2003-12-31 04:06:46
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler
In directory sc8-pr-cvs1:/tmp/cvs-serv2011/src/hk/hku/cecid/phoenix/message/handler
Modified Files:
Constants.java DirectoryManager.java
MessageServiceHandler.java
Added Files:
FilePersistenceHandler.java ObjectStorePersistenceHandler.java
PersistenceException.java PersistenceHandler.java
PersistenceManager.java RepositoryPersistenceHandler.java
Log Message:
Add PersistenceHandler interface as the customize Persistence interface
Add RepositoryPersistenceHandler and ObjectStorePersistenceHandler,
which is the default persistence Handler for Repository and Object Store
Add PersistenceManager which will probably replace the DirectoryManager,
so that the persistence will not bound to File only.
Note that we haven't changed the logic on Hermes to use the PersistenceHandler
Interface yet...
Add a src_junit to add junit test case to this directory.
add test cases on testing the default persistence handler base class
Change build.xml to run the test cases.
--- NEW FILE: FilePersistenceHandler.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/FilePersistenceHandler.java,v 1.1 2003/12/31 04:06:42 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2003-12-17]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.message.handler;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import javax.activation.DataSource;
//import org.apache.commons.codec.digest.DigestUtils;
/**
* The Persistence Handler implementation using file system
* @author pykoon
* @version $Revision: 1.1 $
*/
public class FilePersistenceHandler implements PersistenceHandler {
/**
* the content type for the data source constructed.
*/
private static final String CONTENT_TYPE = "application/binary";
/**
* the current directory the persistence handler working on.
*/
private File currentDirectory;
/**
* Construct the File Persistence Handler which store files persistence on
* the given directory
* @param dir the directory to store those files.
* @throws InitializationException thrown if there is error on initializing
* the Persistence Handler
*/
public FilePersistenceHandler(File dir) throws InitializationException {
currentDirectory = dir;
}
/**
* get the current directory for the Persistence Handler
* @return the current directory for the Persistence Handler
*/
public File getCurrentDirectory() {
return currentDirectory;
}
/**
* set the current directory for the Persistence Handler
* @param directory the directory for the Persistence Handler
*/
protected void setCurrentDirectory(File directory) {
currentDirectory = directory;
}
/**
* create the DataSource which represent a new file.
* @return a new DataSource object, which user can get the OutputStream
* to store the object.
* @throws PersistenceException thrown when there is error on creating
* a new persist object
*/
public DataSource createNewObject() throws PersistenceException {
try {
String name = createNewFileName(getCurrentDirectory());
return new FileDataSource(name);
} catch (IOException e) {
throw new PersistenceException(e);
}
}
/**
* create a new file in a input directory, and the String represent the name
* for the new DataSource. The file created shiould be used as the new
* DataSource returned by createNewObject()
* @param directory which you want to create the file
* @return name to represent the DataSource point to the new file.
* @throws PersistenceException thrown when there is error on creating
* a new file
*/
protected String createNewFileName(File directory)
throws PersistenceException {
try {
File file = createUniqueFile(directory, "object");
return file.getName();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
/**
* Generates a unique file in the specified directory
*
* @param path the specified directory to search for unique file name
* @param id the id of the message/object
* @return the unique file name generated
* @throws IOException when there is error on creating a new file.
*/
static synchronized File createUniqueFile(File path, String id)
throws IOException {
File result = File.createTempFile(id, "", path);
return result;
}
/**
* get back the data stored in the persistence object using the given name
* @param name the name to access the object
* @return the DataSource which contains the object, or null if it doesn't
* exists.
* @throws PersistenceException if there are errors when getting the
* object from PersistenceHandler.
*/
public DataSource getObject(String name) throws PersistenceException {
try {
File file = getFileFromName(name);
if (!file.exists()) {
return null;
}
FileDataSource fds = new FileDataSource(name);
fds.setOutputStreamGetFail();
return fds;
} catch (IOException e) {
throw new PersistenceException(e);
}
}
/**
* remove the object from the persistence storage.
* @param name the name to access the object
* @throws PersistenceException if there are errors when removing the
* object from PersistenceHandler.
*/
public synchronized void removeObject(String name)
throws PersistenceException {
File file = getFileFromName(name);
if (file.exists() && !file.delete()) {
throw new PersistenceException("Object cannot be removed");
}
}
/**
* get the file from name
* @param name the name of the DataSource
* @return the file associate to the name
*/
protected File getFileFromName(String name) {
return new File(getCurrentDirectory(), name);
}
/**
* The self implemented FileDataSource
* The reason to re-implement it is to support the getOutputStream()
* for this DataSource, which seems failed on
* javax.activation.FileDataSource
*/
private class FileDataSource implements DataSource {
/**
* The file referenced on this FileDataSource
*/
private File file;
/**
* boolean to specify whether output stream is gotten by user
*/
private boolean outputStreamGotten;
/**
* The name of the FileDataSource
*/
private String name;
/**
* Construct the FileDataSource from file
* @param name the name for the data source
* @throws IOException throw if there is error to get the path from
* file
*/
public FileDataSource(String name) throws IOException {
this.name = name;
file = getFileFromName(name);
outputStreamGotten = false;
}
/**
* get the content type. Must return "application/binary"
* @return must return "application/binary"
*/
public String getContentType() {
return CONTENT_TYPE;
}
/**
* get the InputStream for the File
* @return the InputStream for the file.
* @throws IOException thrown when there is exception on opening
* the stream
*/
public InputStream getInputStream() throws IOException {
return new FileInputStream(file);
}
/**
* get the unique name from other FileDataSource.
* By default is the canonical file path
* @return the name for the FileDataSource
*/
public String getName() {
return name;
}
/**
* get the OutputStream for the File. Note that we only allow the
* user to get it once.
* @return the OutputStream for the file
* @throws IOException thrown when there is exception on opening the
* stream, or the OutputStream is opened once.
*/
public OutputStream getOutputStream() throws IOException {
if (outputStreamGotten) {
throw new IOException("Cannot get OutputStream");
}
outputStreamGotten = true;
return new FileOutputStream(file);
}
/**
* set the current FileDataSource to the state that the user cannot
* get the outputStream by getOutputStream()
*/
private void setOutputStreamGetFail() {
outputStreamGotten = true;
}
}
}
--- NEW FILE: ObjectStorePersistenceHandler.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/ObjectStorePersistenceHandler.java,v 1.1 2003/12/31 04:06:42 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2003-12-29]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.message.handler;
import hk.hku.cecid.phoenix.common.util.Property;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.IOException;
/**
* ObjectStorePersistenceHandler is the default Persistence Handler for the
* object store.
* It reads the property from msh.properties.xml and access the object through
* the specific directory.
* @author pykoon
* @version $Revision: 1.1 $
*/
public class ObjectStorePersistenceHandler extends FilePersistenceHandler {
/**
* logger for this class
*/
private static Logger logger = Logger.getLogger(
ObjectStorePersistenceHandler.class);
/**
* Construct the Object Store Persistence Handler
* @throws InitializationException thrown when there is error on
* initialize the ObjectStorePersistenceHandler.
*/
public ObjectStorePersistenceHandler() throws InitializationException {
super(null);
Property prop = null;
try {
prop = Property.load(Constants.MSH_SERVER_PROPERTY_FILE);
} catch (IOException e) {
throw new InitializationException("Cannot load property");
}
// Required object store attribute
String objectStore = prop.get
(Constants.PROPERTY_MESSAGE_LISTENER_OBJECT_STORE);
if (objectStore == null) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_INIT_ERROR,
Constants.PROPERTY_MESSAGE_LISTENER_OBJECT_STORE
+ " has not been set in property file");
logger.error(err);
throw new InitializationException(err);
}
File objectDir = new File(objectStore);
if (!objectDir.exists() && !objectDir.mkdirs()) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_INIT_ERROR,
"Object store \"" + objectDir + "\" does not "
+ "exist and cannot be created");
logger.error(err);
throw new InitializationException(err);
}
if (!objectDir.isDirectory() || !objectDir.canWrite()) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_INIT_ERROR,
"Object store \"" + objectDir + "\" is not "
+ "a directory or it is not writable");
logger.error(err);
throw new InitializationException(err);
}
setCurrentDirectory(objectDir);
}
}
--- NEW FILE: PersistenceException.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/PersistenceException.java,v 1.1 2003/12/31 04:06:42 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2003-12-17]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.message.handler;
/**
* Exception thrown when there is problem on getting or storing data from
* the persistence handler.
*
* @author pykoon
* @version $Revision: 1.1 $
*/
public class PersistenceException extends Exception {
/**
* Construct a persistence exception
*/
public PersistenceException() {
super();
}
/**
* Construct a persistence exception with the input message
* @param message the error message
*/
public PersistenceException(String message) {
super(message);
}
/**
* Construct a persistence exception with the input message and cause
* @param message the error message
* @param cause the case for the exception
*/
public PersistenceException(String message, Throwable cause) {
super(message, cause);
}
/**
* Construct a persistence exception with the input cause
* @param cause the case for the exception
*/
public PersistenceException(Throwable cause) {
super(cause);
}
}
--- NEW FILE: PersistenceHandler.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/PersistenceHandler.java,v 1.1 2003/12/31 04:06:42 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2003-12-17]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.message.handler;
import javax.activation.DataSource;
/**
* An interface represent a Persistence Storage, which can store objects and
* get objects
* @author pykoon
* @version $Revision: 1.1 $
*/
public interface PersistenceHandler {
/**
* create a new object to store on the Persistence.
* User can store their data by getting the OutputStream from the
* DataSource returned. The name got from the DataSource will be the key
* to access back the object
* @return the DataSource object which you can store the data.
* @throws PersistenceException if there are errors when creating the
* object from PersistenceHandler.
*/
DataSource createNewObject() throws PersistenceException;
/**
* get back the data stored in the persistence object using the given name
* @param name the name to access the object
* @return the DataSource which contains the object.
* @throws PersistenceException if there are errors when getting the
* object from PersistenceHandler.
*/
DataSource getObject(String name) throws PersistenceException;
/**
* remove the object from the persistence storage.
* @param name the name to access the object
* @throws PersistenceException if there are errors when removing the
* object from PersistenceHandler.
*/
void removeObject(String name) throws PersistenceException;
}
--- NEW FILE: PersistenceManager.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/PersistenceManager.java,v 1.1 2003/12/31 04:06:42 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2002-12-29]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.message.handler;
import hk.hku.cecid.phoenix.common.util.Property;
import org.apache.log4j.Logger;
/**
* This class manages the persistence of ebXML messages and the sending
* thread context of MSH to the file system. It is written based on
* the DirectoryManager, but allow the user to customize to way to store by
* writing custom PersistenceHandler
* @author pykoon
* @version $Revision: 1.1 $
*/
public class PersistenceManager {
/**
* logger for PersistenceManager class
*/
private static Logger logger = Logger.getLogger(
PersistenceManager.class);
/**
* The persistence handler for the repository
*/
private static PersistenceHandler repositoryPersistenceHandler;
/**
* The persistence handler for the object store
*/
private static PersistenceHandler objectStorePersistenceHandler;
/**
* The default repository persistenec handler class.
* The value is RepositoryPersistenceHandler
*/
private static final Class DEFAULT_REPOSITORY_PERSISTENCE_HANDLER
= RepositoryPersistenceHandler.class;
/**
* The default object store persistence handler class
* The value is ObjectStorePersistenceHandler
*/
private static final Class DEFAULT_OBJECT_STORE_PERSISTENCE_HANDLER
= ObjectStorePersistenceHandler.class;
/**
* Flag indicating if the class has been configured.
*/
private static boolean isConfigured = false;
/**
* Configure the class if and only if it has not been configured.
*
* @param prop <code>Property</code> object.
* @throws InitializationException thrown when there is error on
* configurating the PersistenceManager
*/
static synchronized void configure(Property prop)
throws InitializationException {
if (isConfigured) {
return;
}
String repositoryPersistHandlerClassName = prop.get(
Constants.PROPERTY_MESSAGE_REPOSITORY_PERSIST_HANDLER);
if (repositoryPersistHandlerClassName != null) {
logger.info("Use customize repository persistence handler : " +
repositoryPersistHandlerClassName);
} else {
logger.info("Use default repository persistence hander");
}
try {
repositoryPersistenceHandler = createPersistenceHandlerInstance(
DEFAULT_REPOSITORY_PERSISTENCE_HANDLER,
repositoryPersistHandlerClassName);
} catch (Exception e) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_INIT_ERROR, e,
"Cannot load repository persistence handler");
logger.error(err);
throw new InitializationException(err);
}
// Required message repository attribute
String objectStorePersistHandlerClassName = prop.get(
Constants.PROPERTY_MESSAGE_LISTENER_OBJECT_STORE_PERSIST_HANDLER
);
if (objectStorePersistHandlerClassName != null) {
logger.info("Use customize object store persistence handler : " +
objectStorePersistHandlerClassName);
} else {
logger.info("Use default object store persistence handler");
}
try {
objectStorePersistenceHandler = createPersistenceHandlerInstance(
DEFAULT_OBJECT_STORE_PERSISTENCE_HANDLER,
objectStorePersistHandlerClassName);
} catch (Exception e) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_INIT_ERROR, e,
"Cannot load repository persistence handler");
logger.error(err);
throw new InitializationException(err);
}
isConfigured = true;
}
/**
* create the Persistence Handler based on the inputted classMame.
* If the className is null, it will create the Persistence Handler using
* the defaultHandlerClass.
* @param defaultHandlerClass the default Handler class to load if the
* className is null
* @param className the class name of the Persistence Handler to load
* @return The Persistence Handler instance
* @throws Exception thrown when there is error occur on creating the
* instance.
*/
private static PersistenceHandler createPersistenceHandlerInstance(
Class defaultHandlerClass, String className) throws Exception {
Class handlerClass = defaultHandlerClass;
if (className != null) {
handlerClass = Class.forName(className);
}
Object result = handlerClass.newInstance();
if (result instanceof PersistenceHandler) {
return (PersistenceHandler) result;
} else {
throw new IllegalArgumentException(
"Specify class is not an instance of PersistenceHandler");
}
}
/**
* get the Repository Persistence Handler
* @return teh Repository Persistence Handler
*/
public static PersistenceHandler getRepositoryPersistenceHandler() {
return repositoryPersistenceHandler;
}
/**
* get the Object Store Persistence Handler
* @return teh Object Store Persistence Handler
*/
public static PersistenceHandler getObjectStorePersistenceHandler() {
return objectStorePersistenceHandler;
}
}
--- NEW FILE: RepositoryPersistenceHandler.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/RepositoryPersistenceHandler.java,v 1.1 2003/12/31 04:06:42 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2003-12-22]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.message.handler;
import hk.hku.cecid.phoenix.common.util.Property;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.IOException;
/**
* RepositoryPersistenceHandler is the default Persistence Handler for the
* repository object.
* It reads the property from msh.properties.xml and access the object through
* the specific directory.
* @author pykoon
* @version $Revision: 1.1 $
*/
public class RepositoryPersistenceHandler extends FilePersistenceHandler {
/**
* logger for this class
*/
private static Logger logger = Logger.getLogger(
RepositoryPersistenceHandler.class);
/**
The maximum number of files in a sub-directory
*/
private int maxNumFileInSubDir;
/**
* Current subdirectory inside the parent directory for saving ebXML
* messages
*/
private File curSubDirectory = null;
/**
* Construct the Repository Persistence Handler
* @throws InitializationException thrown when there is error on
* initialize the RepositoryPersistenceHandler.
*/
public RepositoryPersistenceHandler() throws InitializationException {
super(null);
Property prop = null;
try {
prop = Property.load(Constants.MSH_SERVER_PROPERTY_FILE);
} catch (IOException e) {
throw new InitializationException("Cannot load property");
}
String messageRepository = prop.get(
Constants.PROPERTY_MESSAGE_REPOSITORY);
if (messageRepository == null) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_INIT_ERROR,
Constants.PROPERTY_MESSAGE_REPOSITORY
+ " has not been set in property file");
logger.error(err);
throw new InitializationException(err);
}
// Optional maximum number of files in a repository subdirectory
String maxNumFile = prop.get(
Constants.PROPERTY_MAX_FILE_IN_SUBDIRECTORY);
if (maxNumFile == null) {
maxNumFileInSubDir = Constants.DEF_MAX_NUM_IN_SUBDIR;
} else {
try {
maxNumFileInSubDir = Integer.parseInt(maxNumFile);
} catch (NumberFormatException e) {
maxNumFileInSubDir = Constants.DEF_MAX_NUM_IN_SUBDIR;
}
}
// check the existence the directory
File repositoryDir = new File(messageRepository);
if (!repositoryDir.exists() && !repositoryDir.mkdirs()) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_INIT_ERROR,
"Message repository \"" + messageRepository + "\" does not "
+ "exist and cannot be created");
logger.error(err);
throw new InitializationException(err);
}
if (!repositoryDir.isDirectory() || !repositoryDir.canWrite()) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_INIT_ERROR,
"Message repository \"" + messageRepository + "\" is not "
+ "a directory or it is not writable");
logger.error(err);
throw new InitializationException(err);
}
setCurrentDirectory(repositoryDir);
}
/**
* create the DataSource which represent a new file.
* @return a new DataSource object, which user can get the OutputStream
* to store the object.
* @throws PersistenceException thrown when there is error on creating
* a new persist object
*/
public synchronized String createNewObject(File directory)
throws PersistenceException {
File repositoryDir = directory;
String directoryName = null;
if (curSubDirectory == null) {
File[] subDirs = repositoryDir.listFiles();
int maxSubDirNum = -1;
File maxSubDir = null;
for (int i = 0 ; i < subDirs.length ; i++) {
String name = subDirs[i].getName();
if (name.length() == 5 && name.startsWith("R")) {
try {
int subDirNum = Integer.parseInt(name.substring(1));
if (subDirNum > maxSubDirNum) {
maxSubDirNum = subDirNum;
maxSubDir = subDirs[i];
directoryName = name;
}
} catch (NumberFormatException e) {
continue;
}
}
}
if (maxSubDirNum != -1) {
curSubDirectory = maxSubDir;
} else {
curSubDirectory = new File(repositoryDir, "R0000");
if (!curSubDirectory.exists()) {
curSubDirectory.mkdir();
}
}
}
if (!curSubDirectory.isDirectory() || !curSubDirectory.canWrite()) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_FILE_IO_ERROR,
curSubDirectory.toString()
+ " is not a directory, or it is not writable");
logger.error(err);
throw new PersistenceException(err);
}
int numFiles = curSubDirectory.listFiles().length;
if (numFiles >= maxNumFileInSubDir) {
int subDirNum = Integer.parseInt(
curSubDirectory.getName().substring(1));
subDirNum++;
if (subDirNum > 99999) {
String err = ErrorMessages.getMessage(
ErrorMessages.ERR_HERMES_FILE_IO_ERROR,
"number of subdirectories in message repository "
+ "overflow");
throw new PersistenceException(err);
}
directoryName = "R"
+ (subDirNum > 1000 ? "" : "0")
+ (subDirNum > 100 ? "" : "0")
+ (subDirNum > 10 ? "" : "0")
+ subDirNum;
curSubDirectory = new File(repositoryDir, directoryName);
curSubDirectory.mkdir();
}
try {
File resultFile = createUniqueFile(curSubDirectory, "message");
return directoryName + File.separatorChar + resultFile.getName();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
/**
* remove the object from the persistence storage.
* @param name the name to access the object
* @throws PersistenceException if there are errors when removing the
* object from PersistenceHandler.
*/
public synchronized void removeObject(String name)
throws PersistenceException {
File file = getFileFromName(name);
super.removeObject(name);
file = file.getParentFile();
if (file.listFiles().length == 0) {
file.delete();
}
}
}
Index: Constants.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/Constants.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** Constants.java 9 Dec 2003 08:59:04 -0000 1.34
--- Constants.java 31 Dec 2003 04:06:42 -0000 1.35
***************
*** 400,403 ****
--- 400,409 ----
public static final String PROPERTY_MESSAGE_REPOSITORY =
"MSH/Persistent/MessageRepository";
+
+ /**
+ * The PersistenceHandler to store the message in message repository
+ */
+ public static final String PROPERTY_MESSAGE_REPOSITORY_PERSIST_HANDLER
+ = "MSH/Persistent/MessageRepositoryPersistHandler";
/** Maximum number of files allowed in a directory for saving ebXML
***************
*** 503,506 ****
--- 509,518 ----
public static final String PROPERTY_MESSAGE_LISTENER_OBJECT_STORE =
"MSH/MessageListener/ObjectStore";
+ /**
+ * The Persistence Handler class to handler the persistence of objectStore
+ */
+ public static final String
+ PROPERTY_MESSAGE_LISTENER_OBJECT_STORE_PERSIST_HANDLER
+ = "MSH/MessageListener/ObjectStore/PersistHandler";
/**
Index: DirectoryManager.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/DirectoryManager.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** DirectoryManager.java 11 Dec 2003 06:41:29 -0000 1.22
--- DirectoryManager.java 31 Dec 2003 04:06:42 -0000 1.23
***************
*** 347,350 ****
--- 347,351 ----
*
* @param ebxmlMessage the message to be stored
+ * @return the file name which store the message
*/
static String store(EbxmlMessage ebxmlMessage)
Index: MessageServiceHandler.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/handler/MessageServiceHandler.java,v
retrieving revision 1.180
retrieving revision 1.181
diff -C2 -d -r1.180 -r1.181
*** MessageServiceHandler.java 11 Dec 2003 06:41:29 -0000 1.180
--- MessageServiceHandler.java 31 Dec 2003 04:06:42 -0000 1.181
***************
*** 71,75 ****
import hk.hku.cecid.phoenix.common.util.AuthenticationManager;
import hk.hku.cecid.phoenix.common.util.Property;
- import hk.hku.cecid.phoenix.message.handler.InitializationException;
import hk.hku.cecid.phoenix.message.packaging.AckRequested;
import hk.hku.cecid.phoenix.message.packaging.Acknowledgment;
--- 71,74 ----
|
|
From: <bob...@us...> - 2003-12-31 04:06:46
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/message/handler
In directory sc8-pr-cvs1:/tmp/cvs-serv2011/src_junit/hk/hku/cecid/phoenix/test/message/handler
Added Files:
Tag: b0931
FilePersistenceHandlerTest.java
Log Message:
Add PersistenceHandler interface as the customize Persistence interface
Add RepositoryPersistenceHandler and ObjectStorePersistenceHandler,
which is the default persistence Handler for Repository and Object Store
Add PersistenceManager which will probably replace the DirectoryManager,
so that the persistence will not bound to File only.
Note that we haven't changed the logic on Hermes to use the PersistenceHandler
Interface yet...
Add a src_junit to add junit test case to this directory.
add test cases on testing the default persistence handler base class
Change build.xml to run the test cases.
--- NEW FILE: FilePersistenceHandlerTest.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_junit/hk/hku/cecid/phoenix/test/message/handler/Attic/FilePersistenceHandlerTest.java,v 1.1.2.1 2003/12/31 04:06:43 bobpykoon Exp $
*
* Code authored by:
*
* pykoon [2003-12-30]
*
* Code reviewed by:
*
* username [YYYY-MM-DD]
*
* Remarks:
*
* =====
*/
package hk.hku.cecid.phoenix.test.message.handler;
import hk.hku.cecid.phoenix.message.handler.FilePersistenceHandler;
import javax.activation.DataSource;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;
/**
* The testing on File Persistence Handler
* @author pykoon
* @version $Revision: 1.1.2.1 $
*/
public class FilePersistenceHandlerTest extends TestCase {
/**
The path used on testing the FilePersistenceHandler
*/
private static final String TEST_PATH = "test/testFile";
/**
A sample content used to test on the FilePersistenceHandler
*/
private static final int[] FILE_CONTENT = new int[]{0, 1, 2, 3};
/**
the dataSource used during testing
*/
private DataSource dataSource;
/**
The file persistence handler used on testing
*/
private FilePersistenceHandler handler;
/**
construct the FilePersistenceHandlerTest
@param name the name, see TestCase on JUnit
*/
public FilePersistenceHandlerTest(String name) {
super(name);
}
/**
get the test suite
@return Test the test suite
*/
public static Test suite() {
return new TestSuite(FilePersistenceHandlerTest.class);
}
/**
set up the test case.
@throws Exception thrown when error occur on start up
*/
protected void setUp() throws Exception {
File testPathFile = new File(TEST_PATH);
if (!testPathFile.exists()) {
testPathFile.mkdir();
}
handler = new FilePersistenceHandler(new File(TEST_PATH));
}
/**
method called when the test case is tear down
@throws Exception thrown when error occur on tear down
*/
protected void tearDown() throws Exception {
File testPathFile = new File(TEST_PATH);
if (dataSource != null) {
handler.removeObject(dataSource.getName());
}
if (testPathFile.exists() && !testPathFile.delete()) {
testPathFile.deleteOnExit();
}
}
/**
create teh Test Data Source.
@return the DataSource created
@throws Exception thrown when error occur on creating data source
*/
private DataSource createTestDataSource() throws Exception {
DataSource dataSource = handler.createNewObject();
writeContent(dataSource);
return dataSource;
}
/**
write the content on DataSource
@param dataSource the data source to write the content
@throws Exception thrown when error occur on writing data source
*/
private void writeContent(DataSource dataSource) throws Exception {
OutputStream ostream = dataSource.getOutputStream();
for (int i = 0; i < FILE_CONTENT.length; i++) {
ostream.write(FILE_CONTENT[i]);
}
ostream.close();
}
/**
test to create a datasource and then remove from handler
*/
public void testCreateAndRemove() {
String name = null;
try {
dataSource = createTestDataSource();
name = dataSource.getName();
assertTrue(handler.getObject(name) != null);
handler.removeObject(name);
assertTrue(handler.getObject(name) == null);
} catch (Exception e) {
fail(e.toString());
}
}
/**
test to create a data source, write data and then see if it
is read back the same data.
*/
public void testWriteAndRead() {
String name = null;
InputStream istream = null;
try {
dataSource = createTestDataSource();
name = dataSource.getName();
DataSource gotDataSource = handler.getObject(name);
assertTrue(gotDataSource != null);
istream = gotDataSource.getInputStream();
for (int i = 0; i < FILE_CONTENT.length; i++) {
int read = istream.read();
assertTrue(read == FILE_CONTENT[i]);
}
assertTrue(-1 == istream.read());
} catch (Exception e) {
fail(e.toString());
} finally {
if (istream != null) {
try {
istream.close();
} catch (IOException e) {
fail("Fail on closing : " + e.toString());
}
}
}
try {
handler.removeObject(name);
} catch (Exception e) {
fail(e.toString());
}
}
}
|
|
From: <bob...@us...> - 2003-12-31 04:06:46
|
Update of /cvsroot/ebxmlms/ebxmlms
In directory sc8-pr-cvs1:/tmp/cvs-serv2011
Modified Files:
build.xml
Log Message:
Add PersistenceHandler interface as the customize Persistence interface
Add RepositoryPersistenceHandler and ObjectStorePersistenceHandler,
which is the default persistence Handler for Repository and Object Store
Add PersistenceManager which will probably replace the DirectoryManager,
so that the persistence will not bound to File only.
Note that we haven't changed the logic on Hermes to use the PersistenceHandler
Interface yet...
Add a src_junit to add junit test case to this directory.
add test cases on testing the default persistence handler base class
Change build.xml to run the test cases.
Index: build.xml
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/build.xml,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** build.xml 7 May 2003 04:36:38 -0000 1.28
--- build.xml 31 Dec 2003 04:06:42 -0000 1.29
***************
*** 1,3 ****
! <project name="MSH - CECID, Dept of CSIS, HKU" default="compile"
basedir=".">
--- 1,3 ----
! <project name="MSH - CECID, Dept of CSIS, HKU" default="build"
basedir=".">
***************
*** 23,27 ****
:${lib}/xercesImpl.jar
:${lib}/xmlParserAPIs.jar
! :${lib}/xmlsec.jar"/>
<property name="runtime_classpath" value="
${lib}/saaj-ri.jar
--- 23,28 ----
:${lib}/xercesImpl.jar
:${lib}/xmlParserAPIs.jar
! :${lib}/xmlsec.jar
! :${lib}/commons-codec-1.2.jar"/>
<property name="runtime_classpath" value="
${lib}/saaj-ri.jar
***************
*** 44,47 ****
--- 45,49 ----
<property name="build.compiler" value="modern"/>
<property name="version" value="1.0.0.0"/>
+ <property name="src_junit" value="src_junit"/>
<!-- you should be comfortable without modifying the following lines -->
***************
*** 114,251 ****
</target>
! <target name="compiletest" depends="compile, gentestkey">
! <copy file="${test}/Config.src" tofile="${test}/Config.java"/>
! <replace file="${test}/Config.java" token="##catalina.home##"
! value="${catalina.home}"/>
! <replace file="${test}/Config.java" token="##catalina.port##"
! value="${catalina.port}"/>
! <replace file="${test}/Config.java" token="##webapps.path.1##"
! value="${webapps.path.1}"/>
! <replace file="${test}/Config.java" token="##webapps.path.2##"
! value="${webapps.path.2}"/>
! <replace file="${test}/Config.java" token="##db.driver.1##"
! value="${db.driver.1}"/>
! <replace file="${test}/Config.java" token="##db.user.1##"
! value="${db.user.1}"/>
! <replace file="${test}/Config.java" token="##db.password.1##"
! value="${db.password.1}"/>
! <replace file="${test}/Config.java" token="##db.url.1##"
! value="${db.url.1}"/>
! <replace file="${test}/Config.java" token="##db.driver.2##"
! value="${db.driver.2}"/>
! <replace file="${test}/Config.java" token="##db.user.2##"
! value="${db.user.2}"/>
! <replace file="${test}/Config.java" token="##db.password.2##"
! value="${db.password.2}"/>
! <replace file="${test}/Config.java" token="##db.url.2##"
! value="${db.url.2}"/>
! <javac srcdir="." destdir="." includes="${test}/**"
! classpath="${bin}:${classpath}" deprecation="on"/>
! <copy todir="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes">
! <fileset dir="${bin}">
! <include name="**"/>
! </fileset>
! <fileset dir="${test}">
! <include name="msh*.properties.xml"/>
! </fileset>
! </copy>
! <copy todir="${catalina.home}/webapps/${webapps.path.1}/WEB-INF">
! <fileset dir="${test}">
! <include name="web.xml"/>
! </fileset>
! </copy>
! <replace
! file="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes/msh.properties.xml"
! token="##catalina.home##" value="${catalina.home}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes/msh.properties.xml"
! token="##catalina.port##" value="${catalina.port}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes/msh.properties.xml"
! token="##db.user##" value="${db.user.1}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes/msh.properties.xml"
! token="##db.password##" value="${db.password.1}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes/msh.properties.xml"
! token="##db.url##" value="${db.url.1}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes/msh.properties.xml"
! token="##webapps.path##" value="${webapps.path.1}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes/msh_client.properties.xml"
! token="##catalina.home##" value="${catalina.home}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes/msh_client.properties.xml"
! token="##catalina.port##" value="${catalina.port}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes/msh_client.properties.xml"
! token="##webapps.path##" value="${webapps.path.1}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/web.xml"
! token="##webapps.path##" value="${webapps.path.1}"/>
! <copy todir="${catalina.home}/webapps/${webapps.path.1}/WEB-INF/lib"
! preservelastmodified="true">
! <fileset dir="${lib}" excludes="junit.jar,xalan.jar"/>
! </copy>
!
! <copy todir="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/classes">
! <fileset dir="${bin}">
! <include name="**"/>
! </fileset>
! <fileset dir="${test}">
! <include name="msh*.properties.xml"/>
! </fileset>
! </copy>
! <copy todir="${catalina.home}/webapps/${webapps.path.2}/WEB-INF">
! <fileset dir="${test}">
! <include name="web.xml"/>
! </fileset>
! </copy>
! <replace
! file="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/classes/msh.properties.xml"
! token="##catalina.home##" value="${catalina.home}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/classes/msh.properties.xml"
! token="##catalina.port##" value="${catalina.port}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/classes/msh.properties.xml"
! token="##webapps.path##" value="${webapps.path.2}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/classes/msh.properties.xml"
! token="##db.user##" value="${db.user.2}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/classes/msh.properties.xml"
! token="##db.password##" value="${db.password.2}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/classes/msh.properties.xml"
! token="##db.url##" value="${db.url.2}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/classes/msh_client.properties.xml"
! token="##catalina.home##" value="${catalina.home}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/classes/msh_client.properties.xml"
! token="##catalina.port##" value="${catalina.port}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/classes/msh_client.properties.xml"
! token="##webapps.path##" value="${webapps.path.2}"/>
! <replace
! file="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/web.xml"
! token="##webapps.path##" value="${webapps.path.2}"/>
! <copy todir="${catalina.home}/webapps/${webapps.path.2}/WEB-INF/lib"
! preservelastmodified="true">
! <fileset dir="${lib}" excludes="junit.jar,xalan.jar"/>
! </copy>
</target>
<target name="runtest" depends="compiletest">
! <input message="Enter starting test case:" addproperty="startTest"/>
! <input message="Enter ending test case:" addproperty="endTest"/>
! <java classname="test.Center" classpath="${bin}:${classpath}:${runtime_classpath}:." fork="true">
! <arg value="${startTest}-${endTest}"/>
! <jvmarg value="-Dprop.home=${catalina.home}/webapps/${webapps.path.1}/WEB-INF/classes"/>
</java>
</target>
<target name="runalltest" depends="compiletest">
<java classname="test.Center" classpath="${bin}:${classpath}:${runtime_classpath}:." fork="true">
--- 116,138 ----
</target>
! <target name="compiletest" depends="compile">
! <mkdir dir="${bin}"/>
! <!-- Compile the java code from ${src} into ${bin} -->
! <javac srcdir="${src_junit}" destdir="${bin}"
! deprecation="on">
! <classpath>
! <pathelement path="${classpath}"/>
! <pathelement path="${bin}"/>
! </classpath>
! </javac>
</target>
<target name="runtest" depends="compiletest">
! <java classname="hk.hku.cecid.phoenix.test.AllTests"
! classpath="${bin}:${classpath}:${runtime_classpath}:." fork="true">
</java>
</target>
+ <!--
<target name="runalltest" depends="compiletest">
<java classname="test.Center" classpath="${bin}:${classpath}:${runtime_classpath}:." fork="true">
***************
*** 268,271 ****
--- 155,159 ----
</junit>
</target>
+ -->
<target name="clean" depends="cleandoc, cleanbuild, cleandist">
***************
*** 292,298 ****
</target>
! <target name="build" depends="compile">
<mkdir dir="${build}"/>
! <jar jarfile="${build}/${jarname}" basedir="${bin}"/>
</target>
--- 180,186 ----
</target>
! <target name="build" depends="compile, runtest">
<mkdir dir="${build}"/>
! <jar jarfile="${build}/${jarname}" basedir="${bin}" excludes="hk/hku/cecid/phoenix/test/**"/>
</target>
|
|
From: <bob...@us...> - 2003-12-31 04:06:46
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/pki
In directory sc8-pr-cvs1:/tmp/cvs-serv2011/src/hk/hku/cecid/phoenix/pki
Modified Files:
ApacheXMLDSigner.java
Log Message:
Add PersistenceHandler interface as the customize Persistence interface
Add RepositoryPersistenceHandler and ObjectStorePersistenceHandler,
which is the default persistence Handler for Repository and Object Store
Add PersistenceManager which will probably replace the DirectoryManager,
so that the persistence will not bound to File only.
Note that we haven't changed the logic on Hermes to use the PersistenceHandler
Interface yet...
Add a src_junit to add junit test case to this directory.
add test cases on testing the default persistence handler base class
Change build.xml to run the test cases.
Index: ApacheXMLDSigner.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/pki/ApacheXMLDSigner.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** ApacheXMLDSigner.java 11 Dec 2003 06:41:30 -0000 1.12
--- ApacheXMLDSigner.java 31 Dec 2003 04:06:42 -0000 1.13
***************
*** 501,504 ****
--- 501,513 ----
if (certResolver != null) {
certs = certResolver.resolve(obj);
+ if (certs == null || certs.length <= 0) {
+ String err = "Certificates returned by certResolver is null";
+ logger.warn(err);
+ throws new VerifyException(err);
+ }
+ } else if (trusted == null || javaVersion < 1.4) {
+ String err = "Cannot verify cert path, but certResolver is null";
+ logger.warn(err);
+ throws new VerifyException;
}
KeyInfo keyInfo = null;
***************
*** 571,576 ****
ret = CertPathVerifier.verify(certs, trusted);
logger.debug("verified, result: " + ret);
! }
! else {
logger.debug("verification of cert path skipped");
}
--- 580,584 ----
ret = CertPathVerifier.verify(certs, trusted);
logger.debug("verified, result: " + ret);
! } else {
logger.debug("verification of cert path skipped");
}
|
|
From: <bob...@us...> - 2003-12-31 03:47:00
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/message/handler In directory sc8-pr-cvs1:/tmp/cvs-serv31920/handler Log Message: Directory /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/message/handler added to the repository --> Using per-directory sticky tag `b0931' |
|
From: <bob...@us...> - 2003-12-31 03:46:31
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/message In directory sc8-pr-cvs1:/tmp/cvs-serv31881/message Log Message: Directory /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test/message added to the repository --> Using per-directory sticky tag `b0931' |
|
From: <bob...@us...> - 2003-12-31 03:46:05
|
Update of /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test In directory sc8-pr-cvs1:/tmp/cvs-serv31802/test Log Message: Directory /cvsroot/ebxmlms/ebxmlms/src_junit/hk/hku/cecid/phoenix/test added to the repository --> Using per-directory sticky tag `b0931' |