Skip to content

Commit

Permalink
TEIIDDES-2678: Fix for correct handling of vdb udf files
Browse files Browse the repository at this point in the history
* VdbEntry
* VdbFileEntry
 * The path of the entry on windows will contain backslashes and these are
   not handled by jar files as file separators. Thus, the jar entry is not
   located in sub-directories but simply labelled with the full path.
 * Replace all backslashes with forward slashes to correctly handle file
   separators for jar entries

* XmiVdb
 * Ensures streams are not left open when jar archive reading and writing
 * Important on windows since it locks open files and the archive cannot
   be replaced with the temporary one at the conclusion of the save method

* MockFileBuilder
 * Avoids creating a FileInputStream unless absolutely required.

* VdbTest
 * Additional checks for ensuring udf jar is read and written correctly
  • Loading branch information
Paul Richardson committed Oct 8, 2015
1 parent 7a08cfd commit 579c5f8
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 131 deletions.
Expand Up @@ -243,9 +243,15 @@ public boolean equals(Object obj) {
*/
public void save( final ZipOutputStream out) throws Exception {
String zipName = getPath().toString();
//
// Path on Windows will be using backslashes but zip entries only
// deal with forward slashes so need to replace with them.
//
zipName = zipName.replace(DOUBLE_BACK_SLASH, FORWARD_SLASH);

// Need to strip off the leading delimeter if it exists, else a "jar" extract command will result in models
// being located at the file system "root" folder.
if( zipName.startsWith("/") ) { //$NON-NLS-1$
if (zipName.startsWith(FORWARD_SLASH)) {
zipName = zipName.substring(1, zipName.length());
}
final ZipEntry zipEntry = new ZipEntry(zipName);
Expand Down
Expand Up @@ -179,6 +179,13 @@ public IFile findFileInWorkspace() {
public void save( final ZipOutputStream out) throws Exception {
// Name of VDB entry
String zipName = getPath().toOSString();

//
// Path on Windows will be using backslashes but zip entries only
// deal with forward slashes so need to replace with them.
//
zipName = zipName.replace(DOUBLE_BACK_SLASH, FORWARD_SLASH);

// Need to strip off the leading delimeter if it exists, else a "jar" extract command will result in models
// being located at the file system "root" folder.
if(zipName.startsWith(StringConstants.FORWARD_SLASH)) {
Expand Down

0 comments on commit 579c5f8

Please sign in to comment.