You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2014/11/15 01:05:18 UTC
[09/21] incubator-brooklyn git commit: specify a filename when people
download service state
specify a filename when people download service state
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/ed805673
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/ed805673
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/ed805673
Branch: refs/heads/master
Commit: ed805673797a032d002aa941a3e2eab32aef9881
Parents: f6cd031
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Nov 13 17:34:24 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Nov 13 23:38:54 2014 +0000
----------------------------------------------------------------------
.../main/java/brooklyn/rest/resources/ServerResource.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ed805673/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java b/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
index 50f99e1..ceb688c 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
@@ -58,7 +58,6 @@ import brooklyn.rest.domain.VersionSummary;
import brooklyn.rest.transform.HighAvailabilityTransformer;
import brooklyn.rest.util.WebResourceUtils;
import brooklyn.util.ResourceUtils;
-import brooklyn.util.collections.MutableMap;
import brooklyn.util.exceptions.Exceptions;
import brooklyn.util.file.ArchiveBuilder;
import brooklyn.util.flags.TypeCoercions;
@@ -302,13 +301,17 @@ public class ServerResource extends AbstractBrooklynRestResource implements Serv
throw WebResourceUtils.unauthorized("User '%s' is not authorized for this operation", Entitlements.getEntitlementContext().user());
try {
+ String label = mgmt().getManagementNodeId()+"-"+Time.makeDateSimpleStampString();
PersistenceObjectStore targetStore = BrooklynPersistenceUtils.newPersistenceObjectStore(mgmt(), null,
- "web-persistence-"+mgmt().getManagementNodeId()+"-"+Time.makeDateStampString()+"-"+Identifiers.makeRandomId(4));
+ "web-persistence-"+label+"-"+Identifiers.makeRandomId(4));
BrooklynPersistenceUtils.writeMemento(mgmt(), targetStore, preferredOrigin);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ArchiveBuilder.zip().addDirContentsAt( ((FileBasedObjectStore)targetStore).getBaseDir(), "/" ).stream(baos);
- return Response.ok(baos.toByteArray(), MediaType.APPLICATION_OCTET_STREAM_TYPE).build();
+ String filename = "brooklyn-state-"+label+".zip";
+ return Response.ok(baos.toByteArray(), MediaType.APPLICATION_OCTET_STREAM_TYPE)
+ .header("Content-Disposition","attachment; filename = "+filename)
+ .build();
} catch (Exception e) {
log.warn("Unable to serve persistence data (rethrowing): "+e, e);
throw Exceptions.propagate(e);