From 4a85ffe9e19f1880f4e00468fdee56191babc818 Mon Sep 17 00:00:00 2001 From: Selvasundaram Date: Thu, 14 Jul 2011 20:40:29 +0530 Subject: Export SSH keys feature --- .../storage/management/client/AbstractClient.java | 11 ++++- .../storage/management/client/KeysClient.java | 49 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/KeysClient.java (limited to 'src/com.gluster.storage.management.client') diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java index 8898cf92..c083d298 100644 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java +++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java @@ -32,6 +32,7 @@ import com.sun.jersey.api.client.WebResource.Builder; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.representation.Form; import com.sun.jersey.client.urlconnection.HTTPSProperties; +import com.sun.jersey.core.header.FormDataContentDisposition; import com.sun.jersey.core.util.MultivaluedMapImpl; @@ -135,6 +136,7 @@ public abstract class AbstractClient { return res.queryParams(queryParams).header(HTTP_HEADER_AUTH, authHeader).accept(MediaType.APPLICATION_XML) .get(responseClass); } catch (Exception e1) { + e1.printStackTrace(); throw createGlusterException(e1); } } @@ -160,7 +162,7 @@ public abstract class AbstractClient { return new GlusterRuntimeException("Couldn't connect to Gluster Management Gateway!"); } - return new GlusterRuntimeException("Exception in REST communication!", e); + return new GlusterRuntimeException("Exception in REST communication! [" + e.getMessage() + "]", e); } } @@ -185,6 +187,13 @@ public abstract class AbstractClient { throw new GlusterRuntimeException("Error while downloading resource [" + res.getURI().getPath() + "]", e); } } + + +/* public void uploadResource(WebResource res, FormDataMultiPart form) { + ClientResponse response = res.header(HTTP_HEADER_AUTH, authHeader).type(MediaType.MULTIPART_FORM_DATA) + .accept(MediaType.TEXT_PLAIN).header(name, value)post(form); + } +*/ /** * Fetches the default resource (the one returned by {@link AbstractClient#getResourcePath()}) by dispatching a GET diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/KeysClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/KeysClient.java new file mode 100644 index 00000000..15c70146 --- /dev/null +++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/KeysClient.java @@ -0,0 +1,49 @@ +/** + * KeysClient.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console 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. + * + * Gluster Management Console 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 Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package com.gluster.storage.management.client; + +import java.io.File; + +public class KeysClient extends AbstractClient { + // Resource path: /glustermg/1.0/keys + private static final String RESOURCE_NAME = "keys"; + + public KeysClient() { + super(); + } + + public KeysClient(String clusterName) { + super(clusterName); + } + + @Override + public String getResourcePath() { + return RESOURCE_NAME; + } + + public void exportSshKeys(String filePath) { + downloadResource(resource, filePath); + } + + public void importSshKeys(File keysFile) { + + } +} -- cgit