Author: areshetnyak
Date: 2011-01-10 07:31:23 -0500 (Mon, 10 Jan 2011)
New Revision: 3785
Removed:
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryChainLogPathHelper.java
jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRepositoryChainLogPathHelper.java
Modified:
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java
Log:
JCR-1564 : Wrong commit was reverted.
Modified:
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java 2011-01-10
12:14:19 UTC (rev 3784)
+++
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java 2011-01-10
12:31:23 UTC (rev 3785)
@@ -114,7 +114,8 @@
for (String path : wsLogFilePathList)
{
writer.writeStartElement("url");
- writer.writeCharacters(RepositoryChainLogPathHelper.getRelativePath(path,
config.getBackupDir().getCanonicalPath()));
+ writer.writeCharacters(path.replace(config.getBackupDir().getCanonicalPath()
+ + File.separator, ""));
writer.writeEndElement();
}
@@ -360,8 +361,9 @@
{
if (version != null && version.equals(VERSION_LOG_1_1))
{
- String path = readContent();
- wsBackupInfo.add(RepositoryChainLogPathHelper.getPath(path,
config.getBackupDir().getCanonicalPath()));
+ String path = config.getBackupDir().getCanonicalPath() +
File.separator
+ + readContent();
+ wsBackupInfo.add(path);
}
else
{
Deleted:
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryChainLogPathHelper.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryChainLogPathHelper.java 2011-01-10
12:14:19 UTC (rev 3784)
+++
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryChainLogPathHelper.java 2011-01-10
12:31:23 UTC (rev 3785)
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2003-2011 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not,
see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.ext.backup;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 2011
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
- * @version $Id: RepositoryChainLogPathHelper.java 111 2011-11-11 11:11:11Z rainf0x $
- */
-public class RepositoryChainLogPathHelper
-{
-
- private RepositoryChainLogPathHelper()
- {
- }
-
- /**
- * Will be returned relative path <name>/<name>.xml for all OS.
- *
- * @param path
- * String, path to
- * @param backupDirCanonicalPath
- * String, path to backup dir
- * @return String
- * Will be returned relative path <name>/<name>.xml for all OS
- * @throws MalformedURLException
- *
- */
- public static String getRelativePath(String path, String backupDirCanonicalPath)
throws MalformedURLException
- {
- URL urlPath = new URL(resolveFileURL("file:" + path));
- URL urlBackupDir = new URL(resolveFileURL("file:" +
backupDirCanonicalPath));
-
- return urlPath.toString().replace(urlBackupDir.toString() + "/",
"");
- }
-
- /**
- * Will be returned absolute path.
- *
- * @param relativePath
- * String, relative path.
- * @param backupDirCanonicalPath
- * String, path to backup dir
- * @return String
- * Will be returned absolute path.
- * @throws MalformedURLException
- */
- public static String getPath(String relativePath, String backupDirCanonicalPath)
throws MalformedURLException
- {
- String path = "file:" + backupDirCanonicalPath + "/" +
relativePath;
-
- URL urlPath = new URL(resolveFileURL(path));
-
- return urlPath.getFile();
- }
-
- private static String resolveFileURL(String url)
- {
- // we ensure that we don't have windows path separator in the url
- url = url.replace('\\', '/');
- if (!url.startsWith("file:///"))
- {
- // The url is invalid, so we will fix it
- // it happens when we use a path of type file://${path}, under
- // linux or mac os the path will start with a '/' so the url
- // will be correct but under windows we will have something
- // like C:\ so the first '/' is missing
- if (url.startsWith("file://"))
- {
- // The url is of type file://, so one '/' is missing
- url = "file:///" + url.substring(7);
- }
- else if (url.startsWith("file:/"))
- {
- // The url is of type file:/, so two '/' are missing
- url = "file:///" + url.substring(6);
- }
- else
- {
- // The url is of type file:, so three '/' are missing
- url = "file:///" + url.substring(5);
- }
- }
- return url;
- }
-
-}
Deleted:
jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRepositoryChainLogPathHelper.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRepositoryChainLogPathHelper.java 2011-01-10
12:14:19 UTC (rev 3784)
+++
jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRepositoryChainLogPathHelper.java 2011-01-10
12:31:23 UTC (rev 3785)
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2003-2011 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not,
see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.ext.backup;
-
-import junit.framework.TestCase;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 2011
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
- * @version $Id: TestRepositoryChainLogPathHelper.java 111 2011-11-11 11:11:11Z rainf0x
$
- */
-public class TestRepositoryChainLogPathHelper
- extends TestCase
-{
-
- public void testGetRelativePathOSLinux() throws Exception
- {
- String path =
"/path/to/repository-backup-dir/workspace-backup-dir/workspace-backup-log.xml";
- String backupDirCanonicalPath = "/path/to/repository-backup-dir";
-
- String relativePath = RepositoryChainLogPathHelper.getRelativePath(path,
backupDirCanonicalPath);
-
- assertEquals("workspace-backup-dir/workspace-backup-log.xml",
relativePath);
- }
-
- public void testGetRelativePathOSWindows() throws Exception
- {
- String path =
"c:\\\\path\\to\\repository-backup-dir\\workspace-backup-dir\\workspace-backup-log.xml";
- String backupDirCanonicalPath = "c:\\\\path\\to\\repository-backup-dir";
-
- String relativePath = RepositoryChainLogPathHelper.getRelativePath(path,
backupDirCanonicalPath);
-
- assertEquals("workspace-backup-dir/workspace-backup-log.xml",
relativePath);
- }
-
- public void testGetPathOSLinux() throws Exception
- {
- String relativePath = "workspace-backup-dir/workspace-backup-log.xml";
- String backupDirCanonicalPath = "/path/to/repository-backup-dir";
-
- String path = RepositoryChainLogPathHelper.getPath(relativePath,
backupDirCanonicalPath);
-
-
assertEquals("/path/to/repository-backup-dir/workspace-backup-dir/workspace-backup-log.xml",
path);
- }
-
- public void testGetPathOSWindiws() throws Exception
- {
- String relativePath = "workspace-backup-dir/workspace-backup-log.xml";
- String backupDirCanonicalPath = "c:\\\\path\\to\\repository-backup-dir";
-
- String path = RepositoryChainLogPathHelper.getPath(relativePath,
backupDirCanonicalPath);
-
-
assertEquals("/c://path/to/repository-backup-dir/workspace-backup-dir/workspace-backup-log.xml",
path);
- }
-
-}