You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/06 20:14:31 UTC

[4/14] git commit: api_refactor: move userkeys api to admin pkg

api_refactor: move userkeys api to admin pkg

Signed-off-by: Rohit Yadav <bh...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/e763fd7d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/e763fd7d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/e763fd7d

Branch: refs/heads/api_refactoring
Commit: e763fd7d369221695690bd392d8172c8899aab52
Parents: 1f1ac79
Author: Rohit Yadav <bh...@apache.org>
Authored: Thu Dec 6 10:59:26 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Thu Dec 6 10:59:26 2012 -0800

----------------------------------------------------------------------
 api/src/com/cloud/api/commands/RegisterCmd.java    |   80 ---------------
 api/src/com/cloud/user/AccountService.java         |    2 +-
 .../api/admin/user/command/RegisterCmd.java        |   80 +++++++++++++++
 client/tomcatconf/commands.properties.in           |    2 +-
 server/src/com/cloud/user/AccountManagerImpl.java  |    2 +-
 .../com/cloud/user/MockAccountManagerImpl.java     |    2 +-
 6 files changed, 84 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e763fd7d/api/src/com/cloud/api/commands/RegisterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/RegisterCmd.java b/api/src/com/cloud/api/commands/RegisterCmd.java
deleted file mode 100644
index 7e9b01e..0000000
--- a/api/src/com/cloud/api/commands/RegisterCmd.java
+++ /dev/null
@@ -1,80 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.RegisterResponse;
-import com.cloud.user.Account;
-import com.cloud.user.User;
-
-@Implementation(responseObject=RegisterResponse.class, description="This command allows a user to register for the developer API, returning a secret key and an API key. This request is made through the integration API port, so it is a privileged command and must be made on behalf of a user. It is up to the implementer just how the username and password are entered, and then how that translates to an integration API request. Both secret key and API key should be returned to the user")
-public class RegisterCmd extends BaseCmd {
-    public static final Logger s_logger = Logger.getLogger(RegisterCmd.class.getName());
-
-    private static final String s_name = "registeruserkeysresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="user")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="User id")
-    private Long id;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        User user = _entityMgr.findById(User.class, getId());
-        if (user != null) {
-            return user.getAccountId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
-    }
-
-    @Override
-    public void execute(){
-        String[] keys = _accountService.createApiKeyAndSecretKey(this);
-        RegisterResponse response = new RegisterResponse();
-        response.setApiKey(keys[0]);
-        response.setSecretKey(keys[1]);
-        response.setObjectName("userkeys");
-        response.setResponseName(getCommandName());
-        this.setResponseObject(response);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e763fd7d/api/src/com/cloud/user/AccountService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java
index fe68c3e..e73b04e 100755
--- a/api/src/com/cloud/user/AccountService.java
+++ b/api/src/com/cloud/user/AccountService.java
@@ -22,10 +22,10 @@ import java.util.Map;
 import com.cloud.acl.ControlledEntity;
 import com.cloud.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.api.admin.user.command.DeleteUserCmd;
+import org.apache.cloudstack.api.admin.user.command.RegisterCmd;
 import org.apache.cloudstack.api.admin.user.command.UpdateUserCmd;
 import org.apache.cloudstack.api.user.account.command.ListAccountsCmd;
 import org.apache.cloudstack.api.admin.user.command.ListUsersCmd;
-import com.cloud.api.commands.RegisterCmd;
 import org.apache.cloudstack.api.admin.account.command.UpdateAccountCmd;
 import com.cloud.domain.Domain;
 import com.cloud.exception.ConcurrentOperationException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e763fd7d/api/src/org/apache/cloudstack/api/admin/user/command/RegisterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/user/command/RegisterCmd.java b/api/src/org/apache/cloudstack/api/admin/user/command/RegisterCmd.java
new file mode 100644
index 0000000..8aa4d04
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/user/command/RegisterCmd.java
@@ -0,0 +1,80 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.admin.user.command;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.RegisterResponse;
+import com.cloud.user.Account;
+import com.cloud.user.User;
+
+@Implementation(responseObject=RegisterResponse.class, description="This command allows a user to register for the developer API, returning a secret key and an API key. This request is made through the integration API port, so it is a privileged command and must be made on behalf of a user. It is up to the implementer just how the username and password are entered, and then how that translates to an integration API request. Both secret key and API key should be returned to the user")
+public class RegisterCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(RegisterCmd.class.getName());
+
+    private static final String s_name = "registeruserkeysresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="user")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="User id")
+    private Long id;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        User user = _entityMgr.findById(User.class, getId());
+        if (user != null) {
+            return user.getAccountId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute(){
+        String[] keys = _accountService.createApiKeyAndSecretKey(this);
+        RegisterResponse response = new RegisterResponse();
+        response.setApiKey(keys[0]);
+        response.setSecretKey(keys[1]);
+        response.setObjectName("userkeys");
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e763fd7d/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index e954581..2f4f1b1 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -257,7 +257,7 @@ migrateVolume=org.apache.cloudstack.api.user.volume.command.MigrateVolumeCmd;15
 ####                                 use that key...the key is stored in the db associated w/
 ####                                 the userId...every request to the developer API should be
 ####                                 checked against the key
-registerUserKeys=com.cloud.api.commands.RegisterCmd;1
+registerUserKeys=org.apache.cloudstack.api.admin.user.command.RegisterCmd;1
 
 ### async-query command
 queryAsyncJobResult=org.apache.cloudstack.api.user.job.command.QueryAsyncJobResultCmd;15

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e763fd7d/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index ae5be66..980ee3a 100755
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -37,6 +37,7 @@ import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.api.admin.user.command.ListUsersCmd;
+import org.apache.cloudstack.api.admin.user.command.RegisterCmd;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
 
@@ -47,7 +48,6 @@ import com.cloud.acl.SecurityChecker.AccessType;
 import com.cloud.api.ApiDBUtils;
 import org.apache.cloudstack.api.admin.user.command.DeleteUserCmd;
 import org.apache.cloudstack.api.user.account.command.ListAccountsCmd;
-import com.cloud.api.commands.RegisterCmd;
 import org.apache.cloudstack.api.admin.account.command.UpdateAccountCmd;
 import org.apache.cloudstack.api.admin.user.command.UpdateUserCmd;
 import com.cloud.configuration.Config;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e763fd7d/server/test/com/cloud/user/MockAccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/user/MockAccountManagerImpl.java b/server/test/com/cloud/user/MockAccountManagerImpl.java
index 484a2cc..03e2c1a 100644
--- a/server/test/com/cloud/user/MockAccountManagerImpl.java
+++ b/server/test/com/cloud/user/MockAccountManagerImpl.java
@@ -26,8 +26,8 @@ import com.cloud.acl.ControlledEntity;
 import com.cloud.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.api.admin.user.command.DeleteUserCmd;
 import org.apache.cloudstack.api.admin.user.command.ListUsersCmd;
+import org.apache.cloudstack.api.admin.user.command.RegisterCmd;
 import org.apache.cloudstack.api.user.account.command.ListAccountsCmd;
-import com.cloud.api.commands.RegisterCmd;
 import org.apache.cloudstack.api.admin.account.command.UpdateAccountCmd;
 import org.apache.cloudstack.api.admin.user.command.UpdateUserCmd;
 import com.cloud.api.view.vo.ControlledViewEntity;