[exo-jcr-commits] exo-jcr SVN: r4222 - in jcr/trunk: exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Apr 11 05:51:55 EDT 2011
Author: areshetnyak
Date: 2011-04-11 05:51:54 -0400 (Mon, 11 Apr 2011)
New Revision: 4222
Modified:
jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
Log:
JCR-1563 : Changes was reverted.
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java 2011-04-11 09:31:32 UTC (rev 4221)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java 2011-04-11 09:51:54 UTC (rev 4222)
@@ -52,7 +52,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
import javax.ws.rs.core.Response;
@@ -470,13 +469,6 @@
BackupAgentResponse response = null;
String sURL = null;
- String backupSetPathEncoded = null;
-
- if (backupSetPath != null)
- {
- backupSetPathEncoded = URLEncoder.encode(backupSetPath, "UTF-8");
- }
-
if (workspaceName != null)
{
if (config != null)
@@ -492,8 +484,7 @@
sURL =
path + HTTPBackupAgent.Constants.BASE_URL
+ HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/"
- + repositoryName
- + "/" + removeExists + "?backup-set-path=" + backupSetPathEncoded;
+ + repositoryName + "/" + backupSetPath + "/" + removeExists;
}
WorkspaceEntry wEntry = null;
@@ -538,7 +529,8 @@
sURL =
path + HTTPBackupAgent.Constants.BASE_URL
+ HTTPBackupAgent.Constants.OperationType.RESTORE_REPOSITORY_BACKUP_SET + "/"
- + removeExists + "?backup-set-path=" + backupSetPathEncoded;
+ + backupSetPath + "/"
+ + removeExists;
}
RepositoryEntry wEntry = null;
@@ -621,8 +613,8 @@
{
sURL =
path + HTTPBackupAgent.Constants.BASE_URL
- + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + removeExists
- + "?backup-set-path=" + backupSetPathEncoded;
+ + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + backupSetPath + "/"
+ + removeExists;
}
response = transport.executeGET(sURL);
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2011-04-11 09:31:32 UTC (rev 4221)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2011-04-11 09:51:54 UTC (rev 4222)
@@ -56,8 +56,6 @@
import java.io.File;
import java.io.FilenameFilter;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
@@ -72,7 +70,6 @@
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
import javax.ws.rs.core.CacheControl;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -840,33 +837,16 @@
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("administrators")
- @Path("/restore/backup-set/{repo}/{remove-Existing}")
+ @Path("/restore/backup-set/{repo}/{backup-set-path:.*}/{remove-Existing}")
public Response restoreBackupSet(WorkspaceEntry wEntry, @PathParam("repo") String repository,
- @QueryParam("backup-set-path") String backupSetPathEncoded, @PathParam("remove-Existing") Boolean removeExisting)
+ @PathParam("backup-set-path") String backupSetPath, @PathParam("remove-Existing") Boolean removeExisting)
{
String failMessage;
Response.Status status;
Throwable exception;
- String backupSetPath = null;
-
try
{
- backupSetPath = URLDecoder.decode(backupSetPathEncoded, "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- log.error("Can not start restore the workspace '" + "/" + repository + "/" + wEntry.getName()
- + "' from backup set '" + backupSetPath + "'", e);
-
- return Response.status(Response.Status.BAD_REQUEST).entity(
- "Can not start restore the workspace '" + "/" + repository + "/" + wEntry.getName()
- + "' from backup set '" + backupSetPath + "' : " + e.getMessage())
- .type(MediaType.TEXT_PLAIN).cacheControl(noCache).build();
- }
-
- try
- {
validateOneRestoreInstants(repository, wEntry.getName());
File backupSetDir = (new File(backupSetPath));
@@ -1155,29 +1135,14 @@
@GET
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("administrators")
- @Path("/restore/backup-set/{remove-Existing}")
- public Response restoreFromBackupSet(@QueryParam("backup-set-path") String backupSetPathEncoded,
+ @Path("/restore/backup-set/{backup-set-path:.*}/{remove-Existing}")
+ public Response restoreFromBackupSet(@PathParam("backup-set-path") String backupSetPath,
@PathParam("remove-Existing") Boolean removeExisting)
{
String failMessage = null;
Response.Status status = null;
Throwable exception = null;
-
- String backupSetPath = null;
- try
- {
- backupSetPath = URLDecoder.decode(backupSetPathEncoded, "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- log.error("Can not start restore from backup set '" + backupSetPathEncoded + "'", e);
-
- return Response.status(Response.Status.BAD_REQUEST).entity(
- "Can not start restore from backup set '" + backupSetPathEncoded + "' : " + e.getMessage()).type(
- MediaType.TEXT_PLAIN).cacheControl(noCache).build();
- }
-
File backupSetDir = (new File(backupSetPath));
File backuplog = null;
@@ -1646,34 +1611,17 @@
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("administrators")
- @Path("/restore-repository/backup-set/{remove-Existing}")
+ @Path("/restore-repository/backup-set/{backup-set-path:.*}/{remove-Existing}")
public Response restoreRepositoryBackupSet(RepositoryEntry rEntry,
- @QueryParam("backup-set-path") String backupSetPathEncoded,
+ @PathParam("backup-set-path") String backupSetPath,
@PathParam("remove-Existing") Boolean removeExisting)
{
String failMessage;
Response.Status status;
Throwable exception;
- String backupSetPath = null;
-
try
{
- backupSetPath = URLDecoder.decode(backupSetPathEncoded, "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- log.error("Can not start restore the repository '" + "/" + rEntry.getName() + "' from backup set '"
- + backupSetPath + "'", e);
-
- return Response.status(Response.Status.BAD_REQUEST).entity(
- "Can not start restore the repository '" + "/" + rEntry.getName() + "' from backup set '"
- + backupSetPath + "' : " + e.getMessage()).type(MediaType.TEXT_PLAIN).cacheControl(noCache)
- .build();
- }
-
- try
- {
validateOneRepositoryRestoreInstants(rEntry.getName());
File backupSetDir = (new File(backupSetPath));
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java 2011-04-11 09:31:32 UTC (rev 4221)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java 2011-04-11 09:51:54 UTC (rev 4222)
@@ -68,7 +68,6 @@
import java.io.File;
import java.io.InputStream;
import java.net.URI;
-import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -1426,7 +1425,7 @@
{
if (bcl.getBackupId().equals(id))
{
- backupSetPath = URLEncoder.encode(bcl.getBackupConfig().getBackupDir().getCanonicalPath(), "UTF-8");
+ backupSetPath = bcl.getBackupConfig().getBackupDir().getCanonicalPath();
break;
}
}
@@ -1473,9 +1472,8 @@
headers.putSingle("Content-Type", "application/json; charset=UTF-8");
ContainerRequestUserRole creq =
new ContainerRequestUserRole("POST", new URI(HTTP_BACKUP_AGENT_PATH
- + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + "db6" + "/" + "true"
- + "?backup-set-path=" + backupSetPath), new URI(""), new ByteArrayInputStream(json
- .toString().getBytes("UTF-8")),
+ + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + "db6" + "/" + backupSetPath + "/"
+ + "true"), new URI(""), new ByteArrayInputStream(json.toString().getBytes("UTF-8")),
new InputHeadersMap(headers));
ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
@@ -1554,7 +1552,7 @@
{
if (bcl.getBackupId().equals(id))
{
- backupSetPath = URLEncoder.encode(bcl.getBackupConfig().getBackupDir().getCanonicalPath(), "UTF-8");
+ backupSetPath = bcl.getBackupConfig().getBackupDir().getCanonicalPath();
break;
}
}
@@ -1577,8 +1575,8 @@
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
ContainerRequestUserRole creq =
new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
- + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + "true"
- + "?backup-set-path=" + backupSetPath), new URI(""), null, new InputHeadersMap(headers));
+ + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + backupSetPath + "/"
+ + "true"), new URI(""), null, new InputHeadersMap(headers));
ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
ContainerResponse cres = new ContainerResponse(responseWriter);
@@ -1656,7 +1654,7 @@
{
if (bcl.getBackupId().equals(id))
{
- backupSetPath = URLEncoder.encode(bcl.getBackupConfig().getBackupDir().getCanonicalPath(), "UTF-8");
+ backupSetPath = bcl.getBackupConfig().getBackupDir().getCanonicalPath();
break;
}
}
@@ -1680,8 +1678,8 @@
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
ContainerRequestUserRole creq =
new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
- + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + "false"
- + "?backup-set-path=" + backupSetPath), new URI(""), null, new InputHeadersMap(headers));
+ + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + backupSetPath + "/"
+ + "false"), new URI(""), null, new InputHeadersMap(headers));
ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
ContainerResponse cres = new ContainerResponse(responseWriter);
@@ -1759,7 +1757,7 @@
{
if (bcl.getBackupId().equals(id))
{
- backupSetPath = URLEncoder.encode(bcl.getBackupConfig().getBackupDir().getCanonicalPath(), "UTF-8");
+ backupSetPath = bcl.getBackupConfig().getBackupDir().getCanonicalPath();
break;
}
}
@@ -1809,7 +1807,7 @@
ContainerRequestUserRole creq =
new ContainerRequestUserRole("POST", new URI(HTTP_BACKUP_AGENT_PATH
+ HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + "db6" + "/"
- + "false" + "?backup-set-path=" + backupSetPath), new URI(""), new ByteArrayInputStream(json.toString()
+ + backupSetPath + "/" + "false"), new URI(""), new ByteArrayInputStream(json.toString()
.getBytes("UTF-8")), new InputHeadersMap(headers));
ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
@@ -2513,7 +2511,7 @@
{
if (bcl.getBackupId().equals(id))
{
- backupSetPath = URLEncoder.encode(bcl.getBackupConfig().getBackupDir().getCanonicalPath(), "UTF-8");
+ backupSetPath = bcl.getBackupConfig().getBackupDir().getCanonicalPath();
break;
}
}
@@ -2581,7 +2579,8 @@
ContainerRequestUserRole creq =
new ContainerRequestUserRole("POST", new URI(HTTP_BACKUP_AGENT_PATH
+ HTTPBackupAgent.Constants.OperationType.RESTORE_REPOSITORY_BACKUP_SET + "/"
- + "true" + "?backup-set-path=" + backupSetPath),
+ + backupSetPath + "/"
+ + "true"),
new URI(""), new ByteArrayInputStream(json.toString().getBytes("UTF-8")),
new InputHeadersMap(headers));
@@ -2660,7 +2659,7 @@
{
if (bcl.getBackupId().equals(id))
{
- backupSetPath = URLEncoder.encode(bcl.getBackupConfig().getBackupDir().getCanonicalPath(), "UTF-8");
+ backupSetPath = bcl.getBackupConfig().getBackupDir().getCanonicalPath();
break;
}
}
@@ -2729,7 +2728,7 @@
ContainerRequestUserRole creq =
new ContainerRequestUserRole("POST", new URI(HTTP_BACKUP_AGENT_PATH
+ HTTPBackupAgent.Constants.OperationType.RESTORE_REPOSITORY_BACKUP_SET + "/"
- + "false" + "?backup-set-path=" + backupSetPath), new URI(""), new ByteArrayInputStream(json.toString()
+ + backupSetPath + "/" + "false"), new URI(""), new ByteArrayInputStream(json.toString()
.getBytes("UTF-8")), new InputHeadersMap(headers));
ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
@@ -2807,7 +2806,7 @@
{
if (bcl.getBackupId().equals(id))
{
- backupSetPath = URLEncoder.encode(bcl.getBackupConfig().getBackupDir().getCanonicalPath(), "UTF-8");
+ backupSetPath = bcl.getBackupConfig().getBackupDir().getCanonicalPath();
break;
}
}
@@ -2830,8 +2829,8 @@
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
ContainerRequestUserRole creq =
new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
- + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + "true"
- + "?backup-set-path=" + backupSetPath), new URI(""), null, new InputHeadersMap(headers));
+ + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + backupSetPath + "/"
+ + "true"), new URI(""), null, new InputHeadersMap(headers));
ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
ContainerResponse cres = new ContainerResponse(responseWriter);
@@ -2908,7 +2907,7 @@
{
if (bcl.getBackupId().equals(id))
{
- backupSetPath = URLEncoder.encode(bcl.getBackupConfig().getBackupDir().getCanonicalPath(), "UTF-8");
+ backupSetPath = bcl.getBackupConfig().getBackupDir().getCanonicalPath();
break;
}
}
@@ -2932,8 +2931,8 @@
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
ContainerRequestUserRole creq =
new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
- + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + "false"
- + "?backup-set-path=" + backupSetPath), new URI(""), null, new InputHeadersMap(headers));
+ + HTTPBackupAgent.Constants.OperationType.RESTORE_BACKUP_SET + "/" + backupSetPath + "/"
+ + "false"), new URI(""), null, new InputHeadersMap(headers));
ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
ContainerResponse cres = new ContainerResponse(responseWriter);
More information about the exo-jcr-commits
mailing list