incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [15/25] git commit: removed componentlocator and inject
Date Thu, 10 Jan 2013 22:47:20 GMT
removed componentlocator and inject


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

Branch: refs/heads/javelin
Commit: f40e7b7511274742ac3531781b90124afbf02fc6
Parents: ad2cd77
Author: Alex Huang <alex.huang@citrix.com>
Authored: Thu Jan 10 11:05:20 2013 -0800
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Thu Jan 10 11:05:20 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/user/UserContext.java            |    6 +-
 api/src/org/apache/cloudstack/api/BaseCmd.java     |   84 +-
 .../command/admin/network/AddNetworkDeviceCmd.java |   18 +-
 .../admin/network/DeleteNetworkDeviceCmd.java      |   17 +-
 .../admin/network/ListNetworkDeviceCmd.java        |   18 +-
 .../bridge/auth/ec2/AuthenticationHandler.java     |  247 +-
 .../bridge/auth/s3/AuthenticationHandler.java      |  346 +-
 .../bridge/persist/dao/BucketPolicyDaoImpl.java    |   57 +-
 .../dao/CloudStackConfigurationDaoImpl.java        |   54 +-
 .../cloud/bridge/persist/dao/MultipartLoadDao.java |  420 +-
 .../cloud/bridge/persist/dao/SObjectDaoImpl.java   |   87 +-
 .../com/cloud/bridge/service/EC2MainServlet.java   |  119 +-
 .../com/cloud/bridge/service/EC2RestServlet.java   | 2300 ++++----
 .../com/cloud/bridge/service/S3RestServlet.java    | 1250 +++---
 .../service/controller/s3/S3BucketAction.java      | 2054 ++++----
 .../service/controller/s3/S3ObjectAction.java      | 2257 ++++----
 .../service/controller/s3/ServiceProvider.java     |  626 ++--
 .../cloud/bridge/service/core/ec2/EC2Engine.java   | 4109 +++++++--------
 .../com/cloud/bridge/service/core/s3/S3Engine.java | 3085 ++++++------
 .../resource/CifsSecondaryStorageResource.java     |  575 +-
 .../resource/LocalSecondaryStorageResource.java    |   56 +-
 .../resource/NfsSecondaryStorageResource.java      |  807 ++--
 .../storage/template/DownloadManagerImpl.java      |  239 +-
 .../entity/api/db/dao/ClusterDaoImpl.java          |  180 +-
 .../entity/api/db/dao/DataCenterDaoImpl.java       |  151 +-
 .../datacenter/entity/api/db/dao/HostDaoImpl.java  |  336 +-
 .../provider/DefaultImageDataStoreProvider.java    |    8 +-
 .../storage/datastore/DefaultPrimaryDataStore.java |   38 +-
 .../configurator/kvm/KvmNfsConfigurator.java       |    4 +-
 .../configurator/vmware/VmwareNfsConfigurator.java |    5 +-
 .../configurator/xen/XenNfsConfigurator.java       |   20 +-
 .../datastore/db/PrimaryDataStoreDaoImpl.java      |    9 +-
 .../storage/volume/VolumeManagerImpl.java          |   62 +-
 .../cloudstack/storage/volume/VolumeObject.java    |   18 +-
 .../acl/StaticRoleBasedAPIAccessChecker.java       |    6 +-
 pom.xml                                            |    2 +-
 server/pom.xml                                     |   10 +
 .../com/cloud/agent/manager/AgentManagerImpl.java  |  317 +-
 .../agent/manager/ClusteredAgentManagerImpl.java   |  166 +-
 .../manager/allocator/impl/TestingAllocator.java   |   20 +-
 server/src/com/cloud/alert/AlertManagerImpl.java   |  493 +-
 .../com/cloud/alert/ConsoleProxyAlertAdapter.java  |  345 +-
 server/src/com/cloud/api/ApiDBUtils.java           |  354 +-
 server/src/com/cloud/api/ApiDispatcher.java        |  318 +-
 .../src/com/cloud/api/query/QueryManagerImpl.java  |   36 +-
 .../cloud/baremetal/BareMetalVmManagerImpl.java    |    4 +-
 .../com/cloud/baremetal/PxeServerManagerImpl.java  |    4 +-
 .../configuration/ConfigurationManagerImpl.java    |  182 +-
 .../src/com/cloud/network/NetworkManagerImpl.java  |   38 +-
 .../src/com/cloud/servlet/CloudStartupServlet.java |    4 +-
 .../com/cloud/template/TemplateManagerImpl.java    |    6 +-
 .../test/com/cloud/async/TestAsyncJobManager.java  |  319 +-
 .../test/com/cloud/async/TestSyncQueueManager.java |  341 +-
 .../com/cloud/cluster/CheckPointManagerTest.java   |  390 --
 .../src/com/cloud/utils/component/AdapterBase.java |    9 +
 utils/src/com/cloud/utils/component/Adapters.java  |   93 -
 .../cloud/utils/component/ComponentContext.java    |    4 +-
 .../com/cloud/utils/component/ComponentInject.java |   27 -
 .../cloud/utils/component/ComponentLibrary.java    |   56 -
 .../utils/component/ComponentLibraryBase.java      |   99 -
 .../cloud/utils/component/ComponentLocator.java    |   58 -
 .../utils/component/ComponentLocatorMBean.java     |   43 -
 utils/src/com/cloud/utils/component/Inject.java    |   30 -
 .../utils/component/LegacyComponentLocator.java    | 1282 -----
 utils/src/com/cloud/utils/component/Plugin.java    |   64 -
 .../utils/component/MockComponentLocator.java      |  121 -
 .../com/cloud/utils/testcase/ComponentSetup.java   |   28 -
 .../cloud/utils/testcase/ComponentTestCase.java    |   44 -
 68 files changed, 11231 insertions(+), 13744 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/api/src/com/cloud/user/UserContext.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/UserContext.java b/api/src/com/cloud/user/UserContext.java
index 786590e..39da4ea 100644
--- a/api/src/com/cloud/user/UserContext.java
+++ b/api/src/com/cloud/user/UserContext.java
@@ -16,13 +16,11 @@
 // under the License.
 package com.cloud.user;
 
-import com.cloud.server.ManagementService;
-import com.cloud.utils.component.ComponentLocator;
 
 public class UserContext {
 
     private static ThreadLocal<UserContext> s_currentContext = new ThreadLocal<UserContext>();
-    
+
     private long userId;
     private String sessionId;
     private Account account;
@@ -82,7 +80,7 @@ public class UserContext {
             // however, there are many places that run background jobs assume the system context.
             //
             // If there is a security concern, all entry points from user (including the front end that takes HTTP
-        	// request in and
+            // request in and
             // the core async-job manager that runs commands from user) have explicitly setup the UserContext.
             //
             return UserContextInitializer.getInstance().getAdminContext();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index fbbee50..c0ef8a0 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -19,7 +19,6 @@ package org.apache.cloudstack.api;
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -64,10 +63,8 @@ import com.cloud.user.Account;
 import com.cloud.user.AccountService;
 import com.cloud.user.DomainService;
 import com.cloud.user.ResourceLimitService;
-import com.cloud.utils.IdentityProxy;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.ComponentContext;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.vm.BareMetalVmService;
 import com.cloud.vm.UserVmService;
 
@@ -112,7 +109,6 @@ public abstract class BaseCmd {
     @Parameter(name = "response", type = CommandType.STRING)
     private String responseType;
 
-    public static ComponentLocator s_locator;
     public static ConfigurationService _configService;
     public static AccountService _accountService;
     public static UserVmService _userVmService;
@@ -145,38 +141,48 @@ public abstract class BaseCmd {
 
     public static QueryService _queryService;
 
-    public static void setComponents(ResponseGenerator generator) {
-        ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
-        _mgr = (ManagementService) ComponentLocator.getComponent(ManagementService.Name);
-        _accountService = locator.getManager(AccountService.class);
-        _configService = locator.getManager(ConfigurationService.class);
-        _userVmService = locator.getManager(UserVmService.class);
-        _storageService = locator.getManager(StorageService.class);
-        _resourceService = locator.getManager(ResourceService.class);
-        _networkService = locator.getManager(NetworkService.class);
-        _templateService = locator.getManager(TemplateService.class);
-        _securityGroupService = locator.getManager(SecurityGroupService.class);
-        _snapshotService = locator.getManager(SnapshotService.class);
-        _consoleProxyService = locator.getManager(ConsoleProxyService.class);
-        _routerService = locator.getManager(VpcVirtualNetworkApplianceService.class);
-        _entityMgr = locator.getManager(EntityManager.class);
-        _rulesService = locator.getManager(RulesService.class);
-        _lbService = locator.getManager(LoadBalancingRulesService.class);
-        _autoScaleService = locator.getManager(AutoScaleService.class);
-        _ravService = locator.getManager(RemoteAccessVpnService.class);
+    static void setComponents(ResponseGenerator generator) {
+        _mgr = ComponentContext.getComponent(ManagementService.class);
+        _accountService = ComponentContext.getComponent(AccountService.class);
+        _configService = ComponentContext.getComponent(ConfigurationService.class);
+
+        _userVmService = ComponentContext.getComponent(UserVmService.class);
+
+        // TODO, ugly and will change soon
+        //
+        Map<String, UserVmService> svmServices = ComponentContext.getComponentsOfType(UserVmService.class);
+        _userVmService = svmServices.get("BareMetalVmManagerImpl");
+
+        _storageService = ComponentContext.getComponent(StorageService.class);
+        _resourceService = ComponentContext.getComponent(ResourceService.class);
+
+        _networkService = ComponentContext.getComponent(NetworkService.class);
+        _templateService = ComponentContext.getComponent(TemplateService.class);
+
+        // TODO, will change to looking for primary component
+        // ugly binding to a specific implementation
+        Map<String, SecurityGroupService> _sgServices = ComponentContext.getComponentsOfType(SecurityGroupService.class);
+        _securityGroupService = _sgServices.get("SecurityGroupManagerImpl2");
+
+        _snapshotService = ComponentContext.getComponent(SnapshotService.class);
+        _consoleProxyService = ComponentContext.getComponent(ConsoleProxyService.class);
+        _routerService = ComponentContext.getComponent(VpcVirtualNetworkApplianceService.class);
+        _entityMgr = ComponentContext.getComponent(EntityManager.class);
+        _rulesService = ComponentContext.getComponent(RulesService.class);
+        _lbService = ComponentContext.getComponent(LoadBalancingRulesService.class);
+        _ravService = ComponentContext.getComponent(RemoteAccessVpnService.class);
         _responseGenerator = generator;
-        _bareMetalVmService = locator.getManager(BareMetalVmService.class);
-        _projectService = locator.getManager(ProjectService.class);
-        _firewallService = locator.getManager(FirewallService.class);
-        _domainService = locator.getManager(DomainService.class);
-        _resourceLimitService = locator.getManager(ResourceLimitService.class);
-        _identityService = locator.getManager(IdentityService.class);
-        _storageNetworkService = locator.getManager(StorageNetworkService.class);
-        _taggedResourceService = locator.getManager(TaggedResourceService.class);
-        _vpcService = locator.getManager(VpcService.class);
-        _networkACLService = locator.getManager(NetworkACLService.class);
-        _s2sVpnService = locator.getManager(Site2SiteVpnService.class);
-        _queryService = locator.getManager(QueryService.class);
+        _bareMetalVmService = ComponentContext.getComponent(BareMetalVmService.class);
+        _projectService = ComponentContext.getComponent(ProjectService.class);
+        _firewallService = ComponentContext.getComponent(FirewallService.class);
+        _domainService = ComponentContext.getComponent(DomainService.class);
+        _resourceLimitService = ComponentContext.getComponent(ResourceLimitService.class);
+        _identityService = ComponentContext.getComponent(IdentityService.class);
+        _storageNetworkService = ComponentContext.getComponent(StorageNetworkService.class);
+        _taggedResourceService = ComponentContext.getComponent(TaggedResourceService.class);
+        _vpcService = ComponentContext.getComponent(VpcService.class);
+        _networkACLService = ComponentContext.getComponent(NetworkACLService.class);
+        _s2sVpnService = ComponentContext.getComponent(Site2SiteVpnService.class);
     }
 
     public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
@@ -211,9 +217,9 @@ public abstract class BaseCmd {
     }
 
     public ManagementService getMgmtServiceRef() {
-    	return _mgr;
+        return _mgr;
     }
-    
+
     public static String getDateString(Date date) {
         if (date == null) {
             return "";
@@ -526,8 +532,8 @@ public abstract class BaseCmd {
                 if (!enabledOnly || project.getState() == Project.State.Active) {
                     return project.getProjectAccountId();
                 } else {
-                	PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() + " as it's no longer active");
-                	ex.addProxyObject(project, projectId, "projectId");                    
+                    PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() + " as it's no longer active");
+                    ex.addProxyObject(project, projectId, "projectId");                    
                     throw ex;
                 }
             } else {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkDeviceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkDeviceCmd.java
index 3e1d74d..793c982 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkDeviceCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkDeviceCmd.java
@@ -18,23 +18,23 @@ package org.apache.cloudstack.api.command.admin.network;
 
 import java.util.Map;
 
-import org.apache.log4j.Logger;
+import javax.inject.Inject;
 
+import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.NetworkDeviceResponse;
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
+import org.apache.log4j.Logger;
+
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.host.Host;
-import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
-import com.cloud.server.ManagementService;
-import org.apache.cloudstack.api.response.NetworkDeviceResponse;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.exception.CloudRuntimeException;
 
 @APICommand(name = "addNetworkDevice", description="Adds a network device of one of the following types: ExternalDhcp, ExternalFirewall, ExternalLoadBalancer, PxeServer", responseObject = NetworkDeviceResponse.class)
@@ -46,6 +46,7 @@ public class AddNetworkDeviceCmd extends BaseCmd {
     // ////////////// API parameters /////////////////////
     // ///////////////////////////////////////////////////
 
+    @Inject ExternalNetworkDeviceManager nwDeviceMgr;
     @Parameter(name = ApiConstants.NETWORK_DEVICE_TYPE, type = CommandType.STRING, description = "Network device type, now supports ExternalDhcp, PxeServer, NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer, F5BigIpLoadBalancer, JuniperSRXFirewall")
     private String type;
 
@@ -63,11 +64,8 @@ public class AddNetworkDeviceCmd extends BaseCmd {
 
     @Override
     public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
-            ResourceAllocationException {
+    ResourceAllocationException {
         try {
-            ExternalNetworkDeviceManager nwDeviceMgr;
-            ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
-            nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
             Host device = nwDeviceMgr.addNetworkDevice(this);
             NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(device);
             response.setObjectName("networkdevice");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkDeviceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkDeviceCmd.java
index 0945124..38971c1 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkDeviceCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkDeviceCmd.java
@@ -16,23 +16,23 @@
 // under the License.
 package org.apache.cloudstack.api.command.admin.network;
 
-import org.apache.log4j.Logger;
+import javax.inject.Inject;
 
+import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
 import org.apache.cloudstack.api.response.HostResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
+import org.apache.log4j.Logger;
+
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.server.ManagementService;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.exception.CloudRuntimeException;
 
 @APICommand(name = "deleteNetworkDevice", description="Deletes network device.", responseObject=SuccessResponse.class)
@@ -40,6 +40,8 @@ public class DeleteNetworkDeviceCmd extends BaseCmd {
     public static final Logger s_logger = Logger.getLogger(DeleteNetworkDeviceCmd.class);
     private static final String s_name = "deletenetworkdeviceresponse";
 
+    @Inject ExternalNetworkDeviceManager nwDeviceMgr;
+
     /////////////////////////////////////////////////////
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
@@ -54,11 +56,8 @@ public class DeleteNetworkDeviceCmd extends BaseCmd {
 
     @Override
     public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
-            ResourceAllocationException {
+    ResourceAllocationException {
         try {
-            ExternalNetworkDeviceManager nwDeviceMgr;
-            ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
-            nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
             boolean result = nwDeviceMgr.deleteNetworkDevice(this);
             if (result) {
                 SuccessResponse response = new SuccessResponse(getCommandName());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/api/src/org/apache/cloudstack/api/command/admin/network/ListNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ListNetworkDeviceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ListNetworkDeviceCmd.java
index 742ff1f..04a26af 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/ListNetworkDeviceCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/ListNetworkDeviceCmd.java
@@ -20,25 +20,25 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
+import javax.inject.Inject;
 
+import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
-import org.apache.cloudstack.api.response.NetworkDeviceResponse;
 import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.NetworkDeviceResponse;
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
+import org.apache.log4j.Logger;
+
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.host.Host;
-import com.cloud.server.ManagementService;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.exception.CloudRuntimeException;
 
 @APICommand(name = "listNetworkDevice", description="List network devices", responseObject = NetworkDeviceResponse.class)
@@ -46,6 +46,7 @@ public class ListNetworkDeviceCmd extends BaseListCmd {
     public static final Logger s_logger = Logger.getLogger(ListNetworkDeviceCmd.class);
     private static final String s_name = "listnetworkdevice";
 
+    @Inject ExternalNetworkDeviceManager nwDeviceMgr;
     /////////////////////////////////////////////////////
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
@@ -66,11 +67,8 @@ public class ListNetworkDeviceCmd extends BaseListCmd {
 
     @Override
     public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
-            ResourceAllocationException {
+    ResourceAllocationException {
         try {
-            ExternalNetworkDeviceManager nwDeviceMgr;
-            ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
-            nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
             List<Host> devices = nwDeviceMgr.listNetworkDevice(this);
             List<NetworkDeviceResponse> nwdeviceResponses = new ArrayList<NetworkDeviceResponse>();
             ListResponse<NetworkDeviceResponse> listResponse = new ListResponse<NetworkDeviceResponse>();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/awsapi/src/com/cloud/bridge/auth/ec2/AuthenticationHandler.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/auth/ec2/AuthenticationHandler.java b/awsapi/src/com/cloud/bridge/auth/ec2/AuthenticationHandler.java
index f79feaa..0406084 100644
--- a/awsapi/src/com/cloud/bridge/auth/ec2/AuthenticationHandler.java
+++ b/awsapi/src/com/cloud/bridge/auth/ec2/AuthenticationHandler.java
@@ -16,142 +16,147 @@
 // under the License.
 package com.cloud.bridge.auth.ec2;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+
+import javax.inject.Inject;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
 import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.log4j.Logger;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.engine.Handler;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.HandlerDescription; 
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.HandlerDescription;
 import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.Handler;
 import org.apache.commons.codec.binary.Base64;
-
+import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import java.security.cert.Certificate;
-import java.security.cert.CertificateFactory;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
 import com.cloud.bridge.model.UserCredentialsVO;
-import com.cloud.bridge.persist.dao.UserCredentialsDaoImpl;
+import com.cloud.bridge.persist.dao.UserCredentialsDao;
 import com.cloud.bridge.service.UserContext;
 import com.cloud.bridge.util.AuthenticationUtils;
-import com.cloud.utils.component.ComponentLocator;
 
 
 public class AuthenticationHandler implements Handler {
-     protected final static Logger logger = Logger.getLogger(AuthenticationHandler.class);
-     protected final UserCredentialsDaoImpl ucDao = ComponentLocator.inject(UserCredentialsDaoImpl.class);
-     private DocumentBuilderFactory dbf = null;
-
-	 protected HandlerDescription handlerDesc = new HandlerDescription( "EC2AuthenticationHandler" );
-     private String name = "EC2AuthenticationHandler";
-    
-     public void init( HandlerDescription handlerdesc ) 
-     {
- 		 dbf = DocumentBuilderFactory.newInstance();
-		 dbf.setNamespaceAware( true );
-
-   	  	 this.handlerDesc = handlerdesc;
-     }
-    	  	
-     public String getName() 
-     {
-          return name;
-     }
-
-     public String toString() 
-     {
-    	 return (name != null) ? name.toString() : null;
-     }
-     
-     public HandlerDescription getHandlerDesc() 
-     {
-       	 return handlerDesc;
-     }
-    	
-     public Parameter getParameter( String name ) 
-     {
-    	 return handlerDesc.getParameter( name );
-     } 
-     
-     
-     /**
-      * For EC2 SOAP calls this function's goal is to extract the X509 certificate that is
-      * part of the WS-Security wrapped SOAP request.   We need the cert in order to 
-      * map it to the user's Cloud API key and Cloud Secret Key.
-      */
-     public InvocationResponse invoke(MessageContext msgContext) throws AxisFault 
-     {
-    	 // -> the certificate we want is embedded into the soap header
-    	 try
-    	 {  SOAPEnvelope soapEnvelope = msgContext.getEnvelope();
-            String       xmlHeader    = soapEnvelope.toString();
-            //System.out.println( "entire request: " + xmlHeader );
-    
-    		InputStream is = new ByteArrayInputStream( xmlHeader.getBytes("UTF-8"));
-    		DocumentBuilder db = dbf.newDocumentBuilder();
-    		Document request = db.parse( is );   		
-    		NodeList certs   = request.getElementsByTagNameNS( "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "BinarySecurityToken" ); 
-	        if (0 < certs.getLength()) {
-	    	    Node item = certs.item(0);
-	    	    String result = new String( item.getFirstChild().getNodeValue());
-	    	    byte[] certBytes = Base64.decodeBase64( result.getBytes()); 
-
-	    	    Certificate userCert  = null;
-	    	    CertificateFactory cf = CertificateFactory.getInstance( "X.509" );
-	    	    ByteArrayInputStream bs = new ByteArrayInputStream( certBytes );
-	    	    while (bs.available() > 0) userCert = cf.generateCertificate(bs);
-                //System.out.println( "cert: " + userCert.toString());              
-                String uniqueId = AuthenticationUtils.X509CertUniqueId( userCert );
-                logger.debug( "X509 cert's uniqueId: " + uniqueId );
-                
-                // -> find the Cloud API key and the secret key from the cert's uniqueId 
-/*	     	    UserCredentialsDao credentialDao = new UserCredentialsDao();
+    protected final static Logger logger = Logger.getLogger(AuthenticationHandler.class);
+    @Inject protected UserCredentialsDao ucDao;
+    private DocumentBuilderFactory dbf = null;
+
+    protected HandlerDescription handlerDesc = new HandlerDescription( "EC2AuthenticationHandler" );
+    private String name = "EC2AuthenticationHandler";
+
+    @Override
+    public void init( HandlerDescription handlerdesc ) 
+    {
+        dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware( true );
+
+        this.handlerDesc = handlerdesc;
+    }
+
+    @Override
+    public String getName() 
+    {
+        return name;
+    }
+
+    @Override
+    public String toString() 
+    {
+        return (name != null) ? name.toString() : null;
+    }
+
+    @Override
+    public HandlerDescription getHandlerDesc() 
+    {
+        return handlerDesc;
+    }
+
+    @Override
+    public Parameter getParameter( String name ) 
+    {
+        return handlerDesc.getParameter( name );
+    } 
+
+
+    /**
+     * For EC2 SOAP calls this function's goal is to extract the X509 certificate that is
+     * part of the WS-Security wrapped SOAP request.   We need the cert in order to 
+     * map it to the user's Cloud API key and Cloud Secret Key.
+     */
+    @Override
+    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault 
+    {
+        // -> the certificate we want is embedded into the soap header
+        try
+        {  SOAPEnvelope soapEnvelope = msgContext.getEnvelope();
+        String       xmlHeader    = soapEnvelope.toString();
+        //System.out.println( "entire request: " + xmlHeader );
+
+        InputStream is = new ByteArrayInputStream( xmlHeader.getBytes("UTF-8"));
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        Document request = db.parse( is );   		
+        NodeList certs   = request.getElementsByTagNameNS( "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "BinarySecurityToken" ); 
+        if (0 < certs.getLength()) {
+            Node item = certs.item(0);
+            String result = new String( item.getFirstChild().getNodeValue());
+            byte[] certBytes = Base64.decodeBase64( result.getBytes()); 
+
+            Certificate userCert  = null;
+            CertificateFactory cf = CertificateFactory.getInstance( "X.509" );
+            ByteArrayInputStream bs = new ByteArrayInputStream( certBytes );
+            while (bs.available() > 0) userCert = cf.generateCertificate(bs);
+            //System.out.println( "cert: " + userCert.toString());              
+            String uniqueId = AuthenticationUtils.X509CertUniqueId( userCert );
+            logger.debug( "X509 cert's uniqueId: " + uniqueId );
+
+            // -> find the Cloud API key and the secret key from the cert's uniqueId 
+            /*	     	    UserCredentialsDao credentialDao = new UserCredentialsDao();
 	     	    UserCredentials cloudKeys = credentialDao.getByCertUniqueId( uniqueId );
-*/	     	    
-                UserCredentialsVO cloudKeys = ucDao.getByCertUniqueId(uniqueId);
-                if ( null == cloudKeys ) {
-                    logger.error( "Cert does not map to Cloud API keys: " + uniqueId );
-                    throw new AxisFault( "User not properly registered: Certificate does not map to Cloud API Keys", "Client.Blocked" );
-                }
-	     	else UserContext.current().initContext( cloudKeys.getAccessKey(), cloudKeys.getSecretKey(), cloudKeys.getAccessKey(), "SOAP Request", null );
-                //System.out.println( "end of cert match: " + UserContext.current().getSecretKey());
-	        }
-    	} 
-    	catch (AxisFault e) {
-    		throw e;
-    	} 
-    	catch( Exception e ) {
+             */	     	    
+            UserCredentialsVO cloudKeys = ucDao.getByCertUniqueId(uniqueId);
+            if ( null == cloudKeys ) {
+                logger.error( "Cert does not map to Cloud API keys: " + uniqueId );
+                throw new AxisFault( "User not properly registered: Certificate does not map to Cloud API Keys", "Client.Blocked" );
+            }
+            else UserContext.current().initContext( cloudKeys.getAccessKey(), cloudKeys.getSecretKey(), cloudKeys.getAccessKey(), "SOAP Request", null );
+            //System.out.println( "end of cert match: " + UserContext.current().getSecretKey());
+        }
+        } 
+        catch (AxisFault e) {
+            throw e;
+        } 
+        catch( Exception e ) {
             logger.error("EC2 Authentication Handler: ", e);
-    		throw new AxisFault( "An unknown error occurred.", "Server.InternalError" );
-    	}    	
+            throw new AxisFault( "An unknown error occurred.", "Server.InternalError" );
+        }    	
         return InvocationResponse.CONTINUE;
-     }
-
-     
-     public void revoke(MessageContext msgContext) 
-     {
-         logger.info(msgContext.getEnvelope().toString());
-     }
-
-     public void setName(String name) 
-     {
-         this.name = name;
-     }
-     
- 	 @Override
-	 public void cleanup() 
-	 {
-	 }
-
-	 @Override
-	 public void flowComplete( MessageContext arg0 ) 
-	 {
-	 }
+    }
+
+
+    public void revoke(MessageContext msgContext) 
+    {
+        logger.info(msgContext.getEnvelope().toString());
+    }
+
+    public void setName(String name) 
+    {
+        this.name = name;
+    }
+
+    @Override
+    public void cleanup() 
+    {
+    }
+
+    @Override
+    public void flowComplete( MessageContext arg0 ) 
+    {
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/awsapi/src/com/cloud/bridge/auth/s3/AuthenticationHandler.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/auth/s3/AuthenticationHandler.java b/awsapi/src/com/cloud/bridge/auth/s3/AuthenticationHandler.java
index b951916..5b20b02 100644
--- a/awsapi/src/com/cloud/bridge/auth/s3/AuthenticationHandler.java
+++ b/awsapi/src/com/cloud/bridge/auth/s3/AuthenticationHandler.java
@@ -18,197 +18,203 @@ package com.cloud.bridge.auth.s3;
 
 import java.sql.SQLException;
 
+import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPBody;
-import org.apache.log4j.Logger;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.engine.Handler;
+import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.HandlerDescription; 
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.HandlerDescription;
 import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.Handler;
+import org.apache.log4j.Logger;
 
 import com.cloud.bridge.model.UserCredentialsVO;
 import com.cloud.bridge.persist.dao.UserCredentialsDaoImpl;
 import com.cloud.bridge.service.UserContext;
 import com.cloud.bridge.util.S3SoapAuth;
-import com.cloud.utils.component.ComponentLocator;
 
 /*
  *  For SOAP compatibility.
  */
 
 public class AuthenticationHandler implements Handler {
-     protected final static Logger logger = Logger.getLogger(AuthenticationHandler.class);
-     protected final UserCredentialsDaoImpl ucDao = ComponentLocator.inject(UserCredentialsDaoImpl.class);
-	 protected HandlerDescription handlerDesc = new HandlerDescription( "default handler" );
-     private String name = "S3AuthenticationHandler";
-    
-     public void init( HandlerDescription handlerdesc ) 
-     {
-   	  	 this.handlerDesc = handlerdesc;
-     }
-    	  	
-     public String getName() 
-     {
-    	 //logger.debug( "getName entry S3AuthenticationHandler" + name );
-         return name;
-     }
-
-     public String toString() 
-     {
-    	 return (name != null) ? name.toString() : null;
-     }
-     
-     public HandlerDescription getHandlerDesc() 
-     {
-       	 return handlerDesc;
-     }
-    	
-     public Parameter getParameter( String name ) 
-     {
-    	 return handlerDesc.getParameter( name );
-     } 
-     
-     
-     /**
-      * Verify the request's authentication signature by extracting all the 
-      * necessary parts of the request, obtaining the requestor's secret key, and
-      * recalculating the signature.
-      * 
-      * On Signature mismatch raise an AxisFault (i.e., a SoapFault) with what Amazon S3 
-      * defines as a "Client.SignatureMismatch" error.
-      * 
-      * Special case: need to deal with anonymous requests where no AWSAccessKeyId is
-      * given.   In this case just pass the request on.
-      */
-     public InvocationResponse invoke(MessageContext msgContext) throws AxisFault  
-     {
-    	 String accessKey  = null;
-    	 String operation  = null;
-    	 String msgSig     = null;
-    	 String timestamp  = null;
-    	 String secretKey  = null;
-    	 String temp       = null;
-    	 
-    	 // [A] Obtain the HttpServletRequest object 
-    	 HttpServletRequest httpObj =(HttpServletRequest)msgContext.getProperty("transport.http.servletRequest");
-    	 if (null != httpObj) System.out.println("S3 SOAP auth test header access - acceptable Encoding type: "+ httpObj.getHeader("Accept-Encoding"));
-    	 
-    	 // [A] Try to recalculate the signature for non-anonymous requests
-    	 try
-    	 {  SOAPEnvelope soapEnvelope = msgContext.getEnvelope();
-            SOAPBody     soapBody     = soapEnvelope.getBody();
-            String       xmlBody      = soapBody.toString();
-            //logger.debug( "xmlrequest: " + xmlBody );
-         
-            // -> did we get here yet its an EC2 request?
-            int offset = xmlBody.indexOf( "http://ec2.amazonaws.com" );
-            if (-1 != offset) return InvocationResponse.CONTINUE;
-            
-            
-            // -> if it is anonymous request, then no access key should exist
-            int start = xmlBody.indexOf( "AWSAccessKeyId>" );
-            if (-1 == start) {
-                UserContext.current().initContext();
-                return InvocationResponse.CONTINUE;
-            }           
-            temp = xmlBody.substring( start+15 );
-            int end   = temp.indexOf( "</" );
-            accessKey = temp.substring( 0, end );
-            //logger.debug( "accesskey " + accessKey );
-            
-            
-            // -> what if we cannot find the user's key?
-            if (null != (secretKey = lookupSecretKey( accessKey )))
+    protected final static Logger logger = Logger.getLogger(AuthenticationHandler.class);
+    @Inject UserCredentialsDaoImpl ucDao;
+    protected HandlerDescription handlerDesc = new HandlerDescription( "default handler" );
+    private String name = "S3AuthenticationHandler";
+
+    @Override
+    public void init( HandlerDescription handlerdesc ) 
+    {
+        this.handlerDesc = handlerdesc;
+    }
+
+    @Override
+    public String getName() 
+    {
+        //logger.debug( "getName entry S3AuthenticationHandler" + name );
+        return name;
+    }
+
+    @Override
+    public String toString() 
+    {
+        return (name != null) ? name.toString() : null;
+    }
+
+    @Override
+    public HandlerDescription getHandlerDesc() 
+    {
+        return handlerDesc;
+    }
+
+    @Override
+    public Parameter getParameter( String name ) 
+    {
+        return handlerDesc.getParameter( name );
+    } 
+
+
+    /**
+     * Verify the request's authentication signature by extracting all the 
+     * necessary parts of the request, obtaining the requestor's secret key, and
+     * recalculating the signature.
+     * 
+     * On Signature mismatch raise an AxisFault (i.e., a SoapFault) with what Amazon S3 
+     * defines as a "Client.SignatureMismatch" error.
+     * 
+     * Special case: need to deal with anonymous requests where no AWSAccessKeyId is
+     * given.   In this case just pass the request on.
+     */
+    @Override
+    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault  
+    {
+        String accessKey  = null;
+        String operation  = null;
+        String msgSig     = null;
+        String timestamp  = null;
+        String secretKey  = null;
+        String temp       = null;
+
+        // [A] Obtain the HttpServletRequest object 
+        HttpServletRequest httpObj =(HttpServletRequest)msgContext.getProperty("transport.http.servletRequest");
+        if (null != httpObj) System.out.println("S3 SOAP auth test header access - acceptable Encoding type: "+ httpObj.getHeader("Accept-Encoding"));
+
+        // [A] Try to recalculate the signature for non-anonymous requests
+        try
+        {  SOAPEnvelope soapEnvelope = msgContext.getEnvelope();
+        SOAPBody     soapBody     = soapEnvelope.getBody();
+        String       xmlBody      = soapBody.toString();
+        //logger.debug( "xmlrequest: " + xmlBody );
+
+        // -> did we get here yet its an EC2 request?
+        int offset = xmlBody.indexOf( "http://ec2.amazonaws.com" );
+        if (-1 != offset) return InvocationResponse.CONTINUE;
+
+
+        // -> if it is anonymous request, then no access key should exist
+        int start = xmlBody.indexOf( "AWSAccessKeyId>" );
+        if (-1 == start) {
+            UserContext.current().initContext();
+            return InvocationResponse.CONTINUE;
+        }           
+        temp = xmlBody.substring( start+15 );
+        int end   = temp.indexOf( "</" );
+        accessKey = temp.substring( 0, end );
+        //logger.debug( "accesskey " + accessKey );
+
+
+        // -> what if we cannot find the user's key?
+        if (null != (secretKey = lookupSecretKey( accessKey )))
+        {
+            // -> if any other field is missing, then the signature will not match
+            if ( null != (operation = soapBody.getFirstElementLocalName()))
+                operation = operation.trim();
+            else operation = "";
+            //logger.debug( "operation " + operation );
+
+            start = xmlBody.indexOf( "Timestamp>" );
+            if ( -1 < start )
             {
-                // -> if any other field is missing, then the signature will not match
-                if ( null != (operation = soapBody.getFirstElementLocalName()))
-                     operation = operation.trim();
-                else operation = "";
-                //logger.debug( "operation " + operation );
- 
-                start = xmlBody.indexOf( "Timestamp>" );
-                if ( -1 < start )
-                {
-                    temp = xmlBody.substring( start+10 );
-                    end  = temp.indexOf( "</" );
-                    timestamp = temp.substring( 0, end );
-                    //logger.debug( "timestamp " + timestamp );
-                }
-                else timestamp = "";
-        
-                start  = xmlBody.indexOf( "Signature>" );
-                if ( -1 < start )
-                {
-                    temp = xmlBody.substring( start+10 );
-                    end  = temp.indexOf( "</" );
-                    msgSig = temp.substring( 0, end );
-                    //logger.debug( "signature " + msgSig );
-                }
-                else msgSig = "";
+                temp = xmlBody.substring( start+10 );
+                end  = temp.indexOf( "</" );
+                timestamp = temp.substring( 0, end );
+                //logger.debug( "timestamp " + timestamp );
             }
-    	}
-    	catch( Exception e )
-    	{
+            else timestamp = "";
+
+            start  = xmlBody.indexOf( "Signature>" );
+            if ( -1 < start )
+            {
+                temp = xmlBody.substring( start+10 );
+                end  = temp.indexOf( "</" );
+                msgSig = temp.substring( 0, end );
+                //logger.debug( "signature " + msgSig );
+            }
+            else msgSig = "";
+        }
+        }
+        catch( Exception e )
+        {
             logger.error("Signature calculation failed due to: ", e);
-    		throw new AxisFault( e.toString(), "Server.InternalError" );
-    	}
-    	
-    	
-    	// [B] Verify that the given signature matches what we calculated here
-    	if (null == secretKey)
-    	{
-    	     logger.error( "Unknown AWSAccessKeyId: [" + accessKey + "]" );
-    		 throw new AxisFault( "Unknown AWSAccessKeyId: [" + accessKey + "]", "Client.InvalidAccessKeyId" );
-    	}
-    	
+            throw new AxisFault( e.toString(), "Server.InternalError" );
+        }
+
+
+        // [B] Verify that the given signature matches what we calculated here
+        if (null == secretKey)
+        {
+            logger.error( "Unknown AWSAccessKeyId: [" + accessKey + "]" );
+            throw new AxisFault( "Unknown AWSAccessKeyId: [" + accessKey + "]", "Client.InvalidAccessKeyId" );
+        }
+
         // -> for SOAP requests the Cloud API keys are sent here and only here
-    	S3SoapAuth.verifySignature( msgSig, operation, timestamp, accessKey, secretKey );   	
+        S3SoapAuth.verifySignature( msgSig, operation, timestamp, accessKey, secretKey );   	
         UserContext.current().initContext( accessKey, secretKey, accessKey, "S3 SOAP request", httpObj );
         return InvocationResponse.CONTINUE;
-     }
-
-     
-     public void revoke(MessageContext msgContext) 
-     {
-         logger.info(msgContext.getEnvelope().toString());
-     }
-
-     public void setName(String name) 
-     {
-    	 //logger.debug( "setName entry S3AuthenticationHandler " + name );
-         this.name = name;
-     }
-     
-     /**
-      * Given the user's access key, then obtain his secret key in the user database.
-      * 
-      * @param accessKey - a unique string allocated for each registered user
-      * @return the secret key or null of no matching user found
-      */
-     private String lookupSecretKey( String accessKey )
-	    throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-     {
-	    UserCredentialsVO cloudKeys = ucDao.getByAccessKey( accessKey );
-	    if ( null == cloudKeys ) {
-	    	 logger.debug( accessKey + " is not defined in the S3 service - call SetUserKeys" );
-	         return null; 
-	    }
-		else return cloudKeys.getSecretKey(); 
-     }
-
-	 @Override
-	 public void cleanup() 
-	 {
-      	//logger.debug( "cleanup entry S3AuthenticationHandler " );
-	 }
-
-	 @Override
-	 public void flowComplete( MessageContext arg0 ) 
-	 {
-     	//logger.debug( "flowComplete entry S3AuthenticationHandler " );
-	 }
+    }
+
+
+    public void revoke(MessageContext msgContext) 
+    {
+        logger.info(msgContext.getEnvelope().toString());
+    }
+
+    public void setName(String name) 
+    {
+        //logger.debug( "setName entry S3AuthenticationHandler " + name );
+        this.name = name;
+    }
+
+    /**
+     * Given the user's access key, then obtain his secret key in the user database.
+     * 
+     * @param accessKey - a unique string allocated for each registered user
+     * @return the secret key or null of no matching user found
+     */
+    private String lookupSecretKey( String accessKey )
+            throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+            {
+        UserCredentialsVO cloudKeys = ucDao.getByAccessKey( accessKey );
+        if ( null == cloudKeys ) {
+            logger.debug( accessKey + " is not defined in the S3 service - call SetUserKeys" );
+            return null; 
+        }
+        else return cloudKeys.getSecretKey(); 
+            }
+
+    @Override
+    public void cleanup() 
+    {
+        //logger.debug( "cleanup entry S3AuthenticationHandler " );
+    }
+
+    @Override
+    public void flowComplete( MessageContext arg0 ) 
+    {
+        //logger.debug( "flowComplete entry S3AuthenticationHandler " );
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/awsapi/src/com/cloud/bridge/persist/dao/BucketPolicyDaoImpl.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/persist/dao/BucketPolicyDaoImpl.java b/awsapi/src/com/cloud/bridge/persist/dao/BucketPolicyDaoImpl.java
index ce230c3..dd354a3 100644
--- a/awsapi/src/com/cloud/bridge/persist/dao/BucketPolicyDaoImpl.java
+++ b/awsapi/src/com/cloud/bridge/persist/dao/BucketPolicyDaoImpl.java
@@ -23,7 +23,6 @@ import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import com.cloud.bridge.model.BucketPolicyVO;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -33,43 +32,43 @@ import com.cloud.utils.db.Transaction;
 @Local(value={BucketPolicyDao.class})
 public class BucketPolicyDaoImpl extends GenericDaoBase<BucketPolicyVO, Long> implements BucketPolicyDao{
     public static final Logger logger = Logger.getLogger(BucketPolicyDaoImpl.class);
-	public BucketPolicyDaoImpl(){ }
+    public BucketPolicyDaoImpl(){ }
 
-	/**
-	 * Since a bucket policy can exist before its bucket we also need to keep the policy's owner
-	 * so we can restrict who modifies it (because of the "s3:CreateBucket" action).
-	 */
-	@Override
-	public BucketPolicyVO getByName( String bucketName ) {
-	    SearchBuilder <BucketPolicyVO> searchByBucket = createSearchBuilder();
-	    searchByBucket.and("BucketName", searchByBucket.entity().getBucketName(), SearchCriteria.Op.EQ);
-	    Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
+    /**
+     * Since a bucket policy can exist before its bucket we also need to keep the policy's owner
+     * so we can restrict who modifies it (because of the "s3:CreateBucket" action).
+     */
+    @Override
+    public BucketPolicyVO getByName( String bucketName ) {
+        SearchBuilder <BucketPolicyVO> searchByBucket = createSearchBuilder();
+        searchByBucket.and("BucketName", searchByBucket.entity().getBucketName(), SearchCriteria.Op.EQ);
+        Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
         try {
             txn.start();
             SearchCriteria<BucketPolicyVO> sc = searchByBucket.create();
             sc.setParameters("BucketName", bucketName);
             return findOneBy(sc);
 
-	    }finally {
-		txn.close();
-	    }
-	    
-	}
-	
-	@Override
-	public void deletePolicy( String bucketName ) {
-	    SearchBuilder <BucketPolicyVO> deleteByBucket = createSearchBuilder();
-	    deleteByBucket.and("BucketName", deleteByBucket.entity().getBucketName(), SearchCriteria.Op.EQ);
-	    Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
-	    try {
+        }finally {
+            txn.close();
+        }
+
+    }
+
+    @Override
+    public void deletePolicy( String bucketName ) {
+        SearchBuilder <BucketPolicyVO> deleteByBucket = createSearchBuilder();
+        deleteByBucket.and("BucketName", deleteByBucket.entity().getBucketName(), SearchCriteria.Op.EQ);
+        Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
+        try {
             txn.start();
             SearchCriteria<BucketPolicyVO> sc = deleteByBucket.create();
             sc.setParameters("BucketName", bucketName);
             remove(sc);
-		
-	    }finally {
-		txn.close();
-	    }
-	    
-	}
+
+        }finally {
+            txn.close();
+        }
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/awsapi/src/com/cloud/bridge/persist/dao/CloudStackConfigurationDaoImpl.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/persist/dao/CloudStackConfigurationDaoImpl.java b/awsapi/src/com/cloud/bridge/persist/dao/CloudStackConfigurationDaoImpl.java
index 511cfa7..e770611 100644
--- a/awsapi/src/com/cloud/bridge/persist/dao/CloudStackConfigurationDaoImpl.java
+++ b/awsapi/src/com/cloud/bridge/persist/dao/CloudStackConfigurationDaoImpl.java
@@ -16,18 +16,12 @@
 // under the License.
 package com.cloud.bridge.persist.dao;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
 import javax.ejb.Local;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import com.cloud.bridge.model.CloudStackConfigurationVO;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
@@ -37,31 +31,31 @@ import com.cloud.utils.db.Transaction;
 @Component
 @Local(value={CloudStackConfigurationDao.class})
 public class CloudStackConfigurationDaoImpl extends GenericDaoBase<CloudStackConfigurationVO, String> implements CloudStackConfigurationDao {
-	private static final Logger s_logger = Logger.getLogger(CloudStackConfigurationDaoImpl.class);
-	
-	final SearchBuilder<CloudStackConfigurationVO> NameSearch= createSearchBuilder();
-	
-	public CloudStackConfigurationDaoImpl() { }
-	
-	
-	@Override
-	@DB
-	public String getConfigValue(String name) {
+    private static final Logger s_logger = Logger.getLogger(CloudStackConfigurationDaoImpl.class);
+
+    final SearchBuilder<CloudStackConfigurationVO> NameSearch= createSearchBuilder();
+
+    public CloudStackConfigurationDaoImpl() { }
+
+
+    @Override
+    @DB
+    public String getConfigValue(String name) {
         NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
         Transaction txn = Transaction.currentTxn();
-		try {
-			txn.start();
-			SearchCriteria<CloudStackConfigurationVO> sc = NameSearch.create();
-			sc.setParameters("name", name);
-			CloudStackConfigurationVO configItem = findOneBy(sc);
-			if (configItem == null) {
-				s_logger.warn("No configuration item found with name " + name);
-				return null;
-			}
-			return configItem.getValue();
+        try {
+            txn.start();
+            SearchCriteria<CloudStackConfigurationVO> sc = NameSearch.create();
+            sc.setParameters("name", name);
+            CloudStackConfigurationVO configItem = findOneBy(sc);
+            if (configItem == null) {
+                s_logger.warn("No configuration item found with name " + name);
+                return null;
+            }
+            return configItem.getValue();
         }finally {
-		
-		}
-	}
-	
+
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/awsapi/src/com/cloud/bridge/persist/dao/MultipartLoadDao.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/persist/dao/MultipartLoadDao.java b/awsapi/src/com/cloud/bridge/persist/dao/MultipartLoadDao.java
index c9b5ec7..c1a69dc 100644
--- a/awsapi/src/com/cloud/bridge/persist/dao/MultipartLoadDao.java
+++ b/awsapi/src/com/cloud/bridge/persist/dao/MultipartLoadDao.java
@@ -16,21 +16,13 @@
 // under the License.
 package com.cloud.bridge.persist.dao;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
-import java.util.Properties;
+
+import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 
@@ -40,71 +32,69 @@ import com.cloud.bridge.model.MultipartMetaVO;
 import com.cloud.bridge.service.core.s3.S3MetaDataEntry;
 import com.cloud.bridge.service.core.s3.S3MultipartPart;
 import com.cloud.bridge.service.core.s3.S3MultipartUpload;
-import com.cloud.bridge.util.ConfigurationHelper;
 import com.cloud.bridge.util.OrderedPair;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.db.Transaction;
 
 public class MultipartLoadDao {
-	public static final Logger logger = Logger.getLogger(MultipartLoadDao.class);
-	
-	protected final MultipartMetaDao mpartMetaDao = ComponentLocator.inject(MultipartMetaDaoImpl.class);
-	protected final MultiPartPartsDao mpartPartsDao = ComponentLocator.inject(MultiPartPartsDaoImpl.class);
-	protected final MultiPartUploadsDao mpartUploadDao = ComponentLocator.inject(MultiPartUploadsDaoImpl.class);
-	
-	public MultipartLoadDao() {}
-	
-	/**
-	 * If a multipart upload exists with the uploadId value then return the non-null creators
-	 * accessKey.
-	 * 
-	 * @param uploadId
-	 * @return creator of the multipart upload, and NameKey of upload
-	 */
-	
-	
-	public OrderedPair<String,String> multipartExits( int uploadId ) 
-	    throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-	{
-	    return mpartUploadDao.multipartExits(uploadId);
-	}
-	
-	/**
-	 * The multipart upload was either successfully completed or was aborted.   In either case, we need
-	 * to remove all of its state from the tables.   Note that we have cascade deletes so all tables with
-	 * uploadId as a foreign key are automatically cleaned.
-	 * 
-	 * @param uploadId
-	 * 
-	 */
-	public void deleteUpload( int uploadId ) {
-	    mpartUploadDao.deleteUpload(uploadId);
-	}
-	
-	/**
-	 * The caller needs to know who initiated the multipart upload.
-	 * 
-	 * @param uploadId
-	 * @return the access key value defining the initiator
-	 */
-	public String getInitiator( int uploadId ) {
-	    return mpartUploadDao.getAtrributeValue("AccessKey", uploadId);
-	}
-	
-	/**
-	 * Create a new "in-process" multipart upload entry to keep track of its state.
-	 * 
-	 * @param accessKey
-	 * @param bucketName
-	 * @param key
-	 * @param cannedAccess
-	 * 
-	 * @return if positive its the uploadId to be returned to the client
-	 *
-	 */
-	public int initiateUpload( String accessKey, String bucketName, String key, String cannedAccess, S3MetaDataEntry[] meta ) {
-		int uploadId = -1;
-		Transaction txn = null;
+    public static final Logger logger = Logger.getLogger(MultipartLoadDao.class);
+
+    @Inject MultipartMetaDao mpartMetaDao;
+    @Inject MultiPartPartsDao mpartPartsDao;
+    @Inject MultiPartUploadsDao mpartUploadDao;
+
+    public MultipartLoadDao() {}
+
+    /**
+     * If a multipart upload exists with the uploadId value then return the non-null creators
+     * accessKey.
+     * 
+     * @param uploadId
+     * @return creator of the multipart upload, and NameKey of upload
+     */
+
+
+    public OrderedPair<String,String> multipartExits( int uploadId ) 
+            throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+            {
+        return mpartUploadDao.multipartExits(uploadId);
+            }
+
+    /**
+     * The multipart upload was either successfully completed or was aborted.   In either case, we need
+     * to remove all of its state from the tables.   Note that we have cascade deletes so all tables with
+     * uploadId as a foreign key are automatically cleaned.
+     * 
+     * @param uploadId
+     * 
+     */
+    public void deleteUpload( int uploadId ) {
+        mpartUploadDao.deleteUpload(uploadId);
+    }
+
+    /**
+     * The caller needs to know who initiated the multipart upload.
+     * 
+     * @param uploadId
+     * @return the access key value defining the initiator
+     */
+    public String getInitiator( int uploadId ) {
+        return mpartUploadDao.getAtrributeValue("AccessKey", uploadId);
+    }
+
+    /**
+     * Create a new "in-process" multipart upload entry to keep track of its state.
+     * 
+     * @param accessKey
+     * @param bucketName
+     * @param key
+     * @param cannedAccess
+     * 
+     * @return if positive its the uploadId to be returned to the client
+     *
+     */
+    public int initiateUpload( String accessKey, String bucketName, String key, String cannedAccess, S3MetaDataEntry[] meta ) {
+        int uploadId = -1;
+        Transaction txn = null;
         try {
             txn = Transaction.open(Transaction.AWSAPI_DB);
             Date tod = new Date();
@@ -126,26 +116,26 @@ public class MultipartLoadDao {
                     txn.commit();
                 }
             }
-            
+
             return uploadId;
         } finally {
             txn.close();
         }
     }
-	
-	/**
-	 * Remember all the individual parts that make up the entire multipart upload so that once
-	 * the upload is complete all the parts can be glued together into a single object.  Note, 
-	 * the caller can over write an existing part.
-	 * 
-	 * @param uploadId
-	 * @param partNumber
-	 * @param md5
-	 * @param storedPath
-	 * @param size
-	 * @throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-	 */
-	public void savePart( int uploadId, int partNumber, String md5, String storedPath, int size ) {
+
+    /**
+     * Remember all the individual parts that make up the entire multipart upload so that once
+     * the upload is complete all the parts can be glued together into a single object.  Note, 
+     * the caller can over write an existing part.
+     * 
+     * @param uploadId
+     * @param partNumber
+     * @param md5
+     * @param storedPath
+     * @param size
+     * @throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+     */
+    public void savePart( int uploadId, int partNumber, String md5, String storedPath, int size ) {
 
         try {
             MultiPartPartsVO partVO = null;
@@ -169,32 +159,32 @@ public class MultipartLoadDao {
         } finally {
         }
     }
-	
-	/**
-	 * It is possible for there to be a null canned access policy defined.
-	 * @param uploadId
-	 * @return the value defined in the x-amz-acl header or null
-	 */
-	public String getCannedAccess( int uploadId ) {
-	    return mpartUploadDao.getAtrributeValue("x_amz_acl", uploadId);
-	}
-	
-	/**
-	 * When the multipart are being composed into one object we need any meta data to be saved with
-	 * the new re-constituted object.
-	 * 
-	 * @param uploadId
-	 * @return an array of S3MetaDataEntry (will be null if no meta values exist)
-	 * @throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-	 */
-	public S3MetaDataEntry[] getMeta( int uploadId )
-        throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-	{
-		List<S3MetaDataEntry> metaList = new ArrayList<S3MetaDataEntry>();
-	    int count = 0;
-	    List<MultipartMetaVO> metaVO; 
+
+    /**
+     * It is possible for there to be a null canned access policy defined.
+     * @param uploadId
+     * @return the value defined in the x-amz-acl header or null
+     */
+    public String getCannedAccess( int uploadId ) {
+        return mpartUploadDao.getAtrributeValue("x_amz_acl", uploadId);
+    }
+
+    /**
+     * When the multipart are being composed into one object we need any meta data to be saved with
+     * the new re-constituted object.
+     * 
+     * @param uploadId
+     * @return an array of S3MetaDataEntry (will be null if no meta values exist)
+     * @throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+     */
+    public S3MetaDataEntry[] getMeta( int uploadId )
+            throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+            {
+        List<S3MetaDataEntry> metaList = new ArrayList<S3MetaDataEntry>();
+        int count = 0;
+        List<MultipartMetaVO> metaVO; 
         try {
-            
+
             metaVO = mpartMetaDao.getByUploadID(uploadId);
             for (MultipartMetaVO multipartMetaVO : metaVO) {
                 S3MetaDataEntry oneMeta = new S3MetaDataEntry();
@@ -203,42 +193,42 @@ public class MultipartLoadDao {
                 metaList.add( oneMeta );
                 count++;
             }
-            
+
             if ( 0 == count )
                 return null;
             else return metaList.toArray(new S3MetaDataEntry[0]);
-        
+
         } finally {
 
         }
-	}
-	
-	/** 
-	 * The result has to be ordered by key and if there is more than one identical key then all the 
-	 * identical keys are ordered by create time.
-	 * 
-	 * @param bucketName
-	 * @param maxParts
-	 * @param prefix - can be null
-	 * @param keyMarker - can be null
-	 * @param uploadIdMarker - can be null, should only be defined if keyMarker is not-null
-	 * @return OrderedPair<S3MultipartUpload[], isTruncated>
-	 * @throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-	 */
-	public OrderedPair<S3MultipartUpload[],Boolean> getInitiatedUploads( String bucketName, int maxParts, String prefix, String keyMarker, String uploadIdMarker )
-        throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-	{
-		S3MultipartUpload[] inProgress = new S3MultipartUpload[maxParts];
-	    boolean isTruncated = false;
-	    int i = 0;
-	    int pos = 1;
-	    List<MultiPartUploadsVO> uploadList;
-	    // -> SQL like condition requires the '%' as a wildcard marker
-	    if (null != prefix) prefix = prefix + "%";
-	    
+            }
+
+    /** 
+     * The result has to be ordered by key and if there is more than one identical key then all the 
+     * identical keys are ordered by create time.
+     * 
+     * @param bucketName
+     * @param maxParts
+     * @param prefix - can be null
+     * @param keyMarker - can be null
+     * @param uploadIdMarker - can be null, should only be defined if keyMarker is not-null
+     * @return OrderedPair<S3MultipartUpload[], isTruncated>
+     * @throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+     */
+    public OrderedPair<S3MultipartUpload[],Boolean> getInitiatedUploads( String bucketName, int maxParts, String prefix, String keyMarker, String uploadIdMarker )
+            throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+            {
+        S3MultipartUpload[] inProgress = new S3MultipartUpload[maxParts];
+        boolean isTruncated = false;
+        int i = 0;
+        int pos = 1;
+        List<MultiPartUploadsVO> uploadList;
+        // -> SQL like condition requires the '%' as a wildcard marker
+        if (null != prefix) prefix = prefix + "%";
+
 
         try {
-		    uploadList = mpartUploadDao.getInitiatedUploads(bucketName, maxParts, prefix, keyMarker, uploadIdMarker);
+            uploadList = mpartUploadDao.getInitiatedUploads(bucketName, maxParts, prefix, keyMarker, uploadIdMarker);
             for (MultiPartUploadsVO uploadsVO : uploadList) {
                 Calendar tod = Calendar.getInstance();
                 tod.setTime(uploadsVO.getCreateTime());
@@ -258,33 +248,33 @@ public class MultipartLoadDao {
         }finally {
         }
 
-	}
-	
-	/**
-	 * Return info on a range of upload parts that have already been stored in disk.
-	 * Note that parts can be uploaded in any order yet we must returned an ordered list
-	 * of parts thus we use the "ORDERED BY" clause to sort the list.
-	 * 
-	 * @param uploadId
-	 * @param maxParts
-	 * @param startAt
-	 * @return an array of S3MultipartPart objects
-	 * @throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-	 */
-	public S3MultipartPart[] getParts( int uploadId, int maxParts, int startAt ) 
-	    throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-	{
-		S3MultipartPart[] parts = new S3MultipartPart[maxParts];
-	    int i = 0;
-	    List<MultiPartPartsVO> partsVO;
-	    try {
-	        
-	        partsVO = mpartPartsDao.getParts(uploadId, startAt + maxParts + 1, startAt);
-	        
-	        for (MultiPartPartsVO partVO : partsVO) {
+            }
+
+    /**
+     * Return info on a range of upload parts that have already been stored in disk.
+     * Note that parts can be uploaded in any order yet we must returned an ordered list
+     * of parts thus we use the "ORDERED BY" clause to sort the list.
+     * 
+     * @param uploadId
+     * @param maxParts
+     * @param startAt
+     * @return an array of S3MultipartPart objects
+     * @throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+     */
+    public S3MultipartPart[] getParts( int uploadId, int maxParts, int startAt ) 
+            throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+            {
+        S3MultipartPart[] parts = new S3MultipartPart[maxParts];
+        int i = 0;
+        List<MultiPartPartsVO> partsVO;
+        try {
+
+            partsVO = mpartPartsDao.getParts(uploadId, startAt + maxParts + 1, startAt);
+
+            for (MultiPartPartsVO partVO : partsVO) {
                 Calendar tod = Calendar.getInstance();
                 tod.setTime(partVO.getCreateTime());
-                
+
                 parts[i] = new S3MultipartPart();
                 parts[i].setPartNumber(partVO.getPartNumber());
                 parts[i].setEtag(partVO.getMd5());
@@ -293,74 +283,74 @@ public class MultipartLoadDao {
                 parts[i].setPath(partVO.getStoredPath());
                 i++;
             }
-	        
+
             if (i < maxParts) parts = (S3MultipartPart[])resizeArray(parts,i);
             return parts;
-        
+
         } finally {
 
         }
-	}
-  
-	/**
-	 * How many parts exist after the endMarker part number?
-	 * 
-	 * @param uploadId
-	 * @param endMarker - can be used to see if getUploadedParts was truncated
-	 * @return number of parts with partNumber greater than endMarker
-	 * @throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-	 */
-	public int numParts( int uploadId, int endMarker ) {
-	    return mpartPartsDao.getnumParts(uploadId, endMarker);
+            }
+
+    /**
+     * How many parts exist after the endMarker part number?
+     * 
+     * @param uploadId
+     * @param endMarker - can be used to see if getUploadedParts was truncated
+     * @return number of parts with partNumber greater than endMarker
+     * @throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+     */
+    public int numParts( int uploadId, int endMarker ) {
+        return mpartPartsDao.getnumParts(uploadId, endMarker);
     }
 
-	/**
-	 * A multipart upload request can have zero to many meta data entries to be applied to the
-	 * final object.   We need to remember all of the objects meta data until the multipart is complete.
-	 * 
-	 * @param uploadId - defines an in-process multipart upload
-	 * @param meta - an array of meta data to be assocated with the uploadId value
-	 * 
-	 */
-	private void saveMultipartMeta( int uploadId, S3MetaDataEntry[] meta ) {
-		if (null == meta) return;
-		
-		Transaction txn = null;
+    /**
+     * A multipart upload request can have zero to many meta data entries to be applied to the
+     * final object.   We need to remember all of the objects meta data until the multipart is complete.
+     * 
+     * @param uploadId - defines an in-process multipart upload
+     * @param meta - an array of meta data to be assocated with the uploadId value
+     * 
+     */
+    private void saveMultipartMeta( int uploadId, S3MetaDataEntry[] meta ) {
+        if (null == meta) return;
+
+        Transaction txn = null;
         try {
             txn = Transaction.open(Transaction.AWSAPI_DB);
             for( int i=0; i < meta.length; i++ ) 
             {
-               S3MetaDataEntry entry = meta[i];
-               MultipartMetaVO metaVO = new MultipartMetaVO();
-               metaVO.setUploadID(uploadId);
-               metaVO.setName(entry.getName());
-               metaVO.setValue(entry.getValue());
-               metaVO=mpartMetaDao.persist(metaVO);
+                S3MetaDataEntry entry = meta[i];
+                MultipartMetaVO metaVO = new MultipartMetaVO();
+                metaVO.setUploadID(uploadId);
+                metaVO.setName(entry.getName());
+                metaVO.setValue(entry.getValue());
+                metaVO=mpartMetaDao.persist(metaVO);
             }
             txn.commit();
         } finally {
             txn.close();
         }
-	}
-	
-
-	/**
-    * Reallocates an array with a new size, and copies the contents
-    * of the old array to the new array.
-    * 
-    * @param oldArray  the old array, to be reallocated.
-    * @param newSize   the new array size.
-    * @return          A new array with the same contents.
-    */
+    }
+
+
+    /**
+     * Reallocates an array with a new size, and copies the contents
+     * of the old array to the new array.
+     * 
+     * @param oldArray  the old array, to be reallocated.
+     * @param newSize   the new array size.
+     * @return          A new array with the same contents.
+     */
     private static Object resizeArray(Object oldArray, int newSize) 
     {
-       int oldSize = java.lang.reflect.Array.getLength(oldArray);
-       Class elementType = oldArray.getClass().getComponentType();
-       Object newArray = java.lang.reflect.Array.newInstance(
-             elementType,newSize);
-       int preserveLength = Math.min(oldSize,newSize);
-       if (preserveLength > 0)
-          System.arraycopy (oldArray,0,newArray,0,preserveLength);
-       return newArray; 
+        int oldSize = java.lang.reflect.Array.getLength(oldArray);
+        Class elementType = oldArray.getClass().getComponentType();
+        Object newArray = java.lang.reflect.Array.newInstance(
+                elementType,newSize);
+        int preserveLength = Math.min(oldSize,newSize);
+        if (preserveLength > 0)
+            System.arraycopy (oldArray,0,newArray,0,preserveLength);
+        return newArray; 
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/awsapi/src/com/cloud/bridge/persist/dao/SObjectDaoImpl.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/persist/dao/SObjectDaoImpl.java b/awsapi/src/com/cloud/bridge/persist/dao/SObjectDaoImpl.java
index 3e68152..6d23757 100644
--- a/awsapi/src/com/cloud/bridge/persist/dao/SObjectDaoImpl.java
+++ b/awsapi/src/com/cloud/bridge/persist/dao/SObjectDaoImpl.java
@@ -22,16 +22,13 @@ import java.util.List;
 import java.util.Set;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
-import com.cloud.bridge.model.SBucket;
 import com.cloud.bridge.model.SBucketVO;
 import com.cloud.bridge.model.SObjectItemVO;
 import com.cloud.bridge.model.SObjectVO;
-import com.cloud.bridge.util.EntityParam;
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -40,18 +37,18 @@ import com.cloud.utils.db.Transaction;
 @Component
 @Local(value={SObjectDao.class})
 public class SObjectDaoImpl extends GenericDaoBase<SObjectVO, Long> implements SObjectDao {
-    protected final SObjectItemDao itemDao = ComponentLocator.inject(SObjectItemDaoImpl.class);
-    
-	public SObjectDaoImpl() {}
+    @Inject SObjectItemDao itemDao;
 
-	@Override
-	public SObjectVO getByNameKey(SBucketVO bucket, String nameKey) {
-		SObjectVO object = null; 
-	    SearchBuilder<SObjectVO> SearchByName = createSearchBuilder();
-	    SearchByName.and("SBucketID", SearchByName.entity().getBucketID() , SearchCriteria.Op.EQ);
-	    SearchByName.and("NameKey", SearchByName.entity().getNameKey() , SearchCriteria.Op.EQ);
-	    Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
-	    try {
+    public SObjectDaoImpl() {}
+
+    @Override
+    public SObjectVO getByNameKey(SBucketVO bucket, String nameKey) {
+        SObjectVO object = null; 
+        SearchBuilder<SObjectVO> SearchByName = createSearchBuilder();
+        SearchByName.and("SBucketID", SearchByName.entity().getBucketID() , SearchCriteria.Op.EQ);
+        SearchByName.and("NameKey", SearchByName.entity().getNameKey() , SearchCriteria.Op.EQ);
+        Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
+        try {
             txn.start();
             SearchCriteria<SObjectVO> sc = SearchByName.create();
             sc.setParameters("SBucketID", bucket.getId());
@@ -62,23 +59,23 @@ public class SObjectDaoImpl extends GenericDaoBase<SObjectVO, Long> implements S
                         itemDao.getItems(object.getId()));
                 object.setItems(items);
             }
-		return object;
-		
-	    }finally {
+            return object;
+
+        }finally {
             txn.close();
-	    }
-	    
-	}
-	
-	@Override
-	public List<SObjectVO> listBucketObjects(SBucketVO bucket, String prefix, String marker, int maxKeys) {
-		StringBuffer sb = new StringBuffer();
-		List<Object> params = new ArrayList<Object>();
-		SearchBuilder<SObjectVO> SearchByBucket = createSearchBuilder();
-		List<SObjectVO> objects = new ArrayList<SObjectVO>();
-		
-		SearchByBucket.and("SBucketID", SearchByBucket.entity().getBucketID(), SearchCriteria.Op.EQ);
-		SearchByBucket.and("DeletionMark", SearchByBucket.entity().getDeletionMark(), SearchCriteria.Op.NULL);		
+        }
+
+    }
+
+    @Override
+    public List<SObjectVO> listBucketObjects(SBucketVO bucket, String prefix, String marker, int maxKeys) {
+        StringBuffer sb = new StringBuffer();
+        List<Object> params = new ArrayList<Object>();
+        SearchBuilder<SObjectVO> SearchByBucket = createSearchBuilder();
+        List<SObjectVO> objects = new ArrayList<SObjectVO>();
+
+        SearchByBucket.and("SBucketID", SearchByBucket.entity().getBucketID(), SearchCriteria.Op.EQ);
+        SearchByBucket.and("DeletionMark", SearchByBucket.entity().getDeletionMark(), SearchCriteria.Op.NULL);		
         Transaction txn = Transaction.currentTxn();  // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
         try {
             txn.start();
@@ -91,19 +88,19 @@ public class SObjectDaoImpl extends GenericDaoBase<SObjectVO, Long> implements S
             }
             return objects;
         }finally {
-        txn.close();
+            txn.close();
         }
-	}
-	
-	@Override
-	public List<SObjectVO> listAllBucketObjects(SBucketVO bucket, String prefix, String marker, int maxKeys) {
-		StringBuffer sb = new StringBuffer();
-		List<Object> params = new ArrayList<Object>();
-		SearchBuilder<SObjectVO> getAllBuckets = createSearchBuilder();
-		List<SObjectVO> objects = new ArrayList<SObjectVO>();
-		getAllBuckets.and("SBucketID", getAllBuckets.entity().getBucketID(), SearchCriteria.Op.EQ);
+    }
+
+    @Override
+    public List<SObjectVO> listAllBucketObjects(SBucketVO bucket, String prefix, String marker, int maxKeys) {
+        StringBuffer sb = new StringBuffer();
+        List<Object> params = new ArrayList<Object>();
+        SearchBuilder<SObjectVO> getAllBuckets = createSearchBuilder();
+        List<SObjectVO> objects = new ArrayList<SObjectVO>();
+        getAllBuckets.and("SBucketID", getAllBuckets.entity().getBucketID(), SearchCriteria.Op.EQ);
 
-		Transaction txn = Transaction.currentTxn();  // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
+        Transaction txn = Transaction.currentTxn();  // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
         try {
             txn.start();
             SearchCriteria<SObjectVO> sc = getAllBuckets.create();
@@ -115,8 +112,8 @@ public class SObjectDaoImpl extends GenericDaoBase<SObjectVO, Long> implements S
             }
             return objects;
         }finally {
-        txn.close();
+            txn.close();
         }
-		
-	}
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java b/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
index e8ccb0c..f5a2d21 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.util.UUID;
 
+import javax.inject.Inject;
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
@@ -30,50 +31,48 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.log4j.Logger;
 
 import com.cloud.bridge.persist.dao.CloudStackConfigurationDao;
-import com.cloud.bridge.persist.dao.CloudStackConfigurationDaoImpl;
 import com.cloud.bridge.util.ConfigurationHelper;
-import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Transaction;
-
-import net.sf.ehcache.Cache;
 @DB
 public class EC2MainServlet extends HttpServlet{
 
-	private static final long serialVersionUID = 2201599478145974479L;
-	
-	public static final String EC2_REST_SERVLET_PATH="/rest/AmazonEC2/";
-	public static final String EC2_SOAP_SERVLET_PATH="/services/AmazonEC2/";
-	public static final String ENABLE_EC2_API="enable.ec2.api";
-	private static boolean isEC2APIEnabled = false;
-	public static final Logger logger = Logger.getLogger(EC2MainServlet.class);
-	CloudStackConfigurationDao csDao = ComponentLocator.inject(CloudStackConfigurationDaoImpl.class);
-	
-	/**
-	 * We build the path to where the keystore holding the WS-Security X509 certificates
-	 * are stored.
-	 */
-	@DB
-	public void init( ServletConfig config ) throws ServletException {
-		try{
-		    ConfigurationHelper.preConfigureConfigPathFromServletContext(config.getServletContext());
-    		// check if API is enabled
-    		String value = csDao.getConfigValue(ENABLE_EC2_API);
-    		if(value != null){
-    		    isEC2APIEnabled = Boolean.valueOf(value);
-    		}
-    		logger.info("Value of EC2 API Flag ::" + value);
-		}catch(Exception e){
-		    throw new ServletException("Error initializing awsapi: " + e.getMessage(), e);
-		}
-	}
-	
-	protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
-	    doGetOrPost(req, resp);
+    private static final long serialVersionUID = 2201599478145974479L;
+
+    public static final String EC2_REST_SERVLET_PATH="/rest/AmazonEC2/";
+    public static final String EC2_SOAP_SERVLET_PATH="/services/AmazonEC2/";
+    public static final String ENABLE_EC2_API="enable.ec2.api";
+    private static boolean isEC2APIEnabled = false;
+    public static final Logger logger = Logger.getLogger(EC2MainServlet.class);
+    @Inject CloudStackConfigurationDao csDao;
+
+    /**
+     * We build the path to where the keystore holding the WS-Security X509 certificates
+     * are stored.
+     */
+    @Override
+    @DB
+    public void init( ServletConfig config ) throws ServletException {
+        try{
+            ConfigurationHelper.preConfigureConfigPathFromServletContext(config.getServletContext());
+            // check if API is enabled
+            String value = csDao.getConfigValue(ENABLE_EC2_API);
+            if(value != null){
+                isEC2APIEnabled = Boolean.valueOf(value);
+            }
+            logger.info("Value of EC2 API Flag ::" + value);
+        }catch(Exception e){
+            throw new ServletException("Error initializing awsapi: " + e.getMessage(), e);
+        }
+    }
+
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
+        doGetOrPost(req, resp);
     }
-	
+
+    @Override
     protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
-	    doGetOrPost(req, resp);
+        doGetOrPost(req, resp);
     }
 
     protected void doGetOrPost(HttpServletRequest request, HttpServletResponse response) {
@@ -84,30 +83,30 @@ public class EC2MainServlet extends HttpServlet{
             faultResponse(response, "404" , "EC2 API is disabled.");
             return;
         }
-        
-    	if(action != null){
-    		//We presume it's a Query/Rest call
-    		try {
-				RequestDispatcher dispatcher = request.getRequestDispatcher(EC2_REST_SERVLET_PATH);
-				dispatcher.forward(request, response);
-			} catch (ServletException e) {
-				throw new RuntimeException(e);
-			} catch (IOException e) {
-				throw new RuntimeException(e);
-			}
-    	}
-    	else {
-    		try {
-				request.getRequestDispatcher(EC2_SOAP_SERVLET_PATH).forward(request, response);
-			} catch (ServletException e) {
-				throw new RuntimeException(e);
-			} catch (IOException e) {
-				throw new RuntimeException(e);
-			}
-    	}
-    	
+
+        if(action != null){
+            //We presume it's a Query/Rest call
+            try {
+                RequestDispatcher dispatcher = request.getRequestDispatcher(EC2_REST_SERVLET_PATH);
+                dispatcher.forward(request, response);
+            } catch (ServletException e) {
+                throw new RuntimeException(e);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        else {
+            try {
+                request.getRequestDispatcher(EC2_SOAP_SERVLET_PATH).forward(request, response);
+            } catch (ServletException e) {
+                throw new RuntimeException(e);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
     }
-    
+
     private void faultResponse(HttpServletResponse response, String errorCode, String errorMessage) {
         try {
             OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream());


Mime
View raw message