Skip to content

Commit 39aa7d8

Browse files
rajesh-battalaPrachi Damle
authored andcommitted
Moved Awsapi (EC2/S3) from Hibernate framework to CloudStack Generic Dao Framework
Created/Modified new VO's and Dao Impl classes to use Generic Dao Framework
1 parent 9064236 commit 39aa7d8

98 files changed

Lines changed: 4120 additions & 3905 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

awsapi-setup/setup/cloudstack-aws-api-register

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/cygdrive/c/python26/python
1+
#!/usr/bin/python
22
#
33
# Licensed to the Apache Software Foundation (ASF) under one
44
# or more contributor license agreements. See the NOTICE file

awsapi/.classpath

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
3-
Licensed to the Apache Software Foundation (ASF) under one
4-
or more contributor license agreements. See the NOTICE file
5-
distributed with this work for additional information
6-
regarding copyright ownership. The ASF licenses this file
7-
to you under the Apache License, Version 2.0 (the
8-
"License"); you may not use this file except in compliance
9-
with the License. You may obtain a copy of the License at
10-
11-
http://www.apache.org/licenses/LICENSE-2.0
12-
13-
Unless required by applicable law or agreed to in writing,
14-
software distributed under the License is distributed on an
15-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16-
KIND, either express or implied. See the License for the
17-
specific language governing permissions and limitations
18-
under the License.
19-
-->
202
<classpath>
213
<classpathentry kind="src" path="src"/>
22-
<classpathentry kind="src" path="test"/>
234
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
245
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
256
<classpathentry kind="lib" path="/deps/awsapi-lib/antlr-2.7.6.jar"/>
@@ -44,7 +25,6 @@ under the License.
4425
<classpathentry kind="lib" path="/deps/awsapi-lib/commons-io-1.4.jar"/>
4526
<classpathentry kind="lib" path="/deps/awsapi-lib/commons-logging-1.1.1.jar"/>
4627
<classpathentry kind="lib" path="/deps/awsapi-lib/dom4j-1.6.1.jar"/>
47-
<classpathentry kind="lib" path="/deps/awsapi-lib/hibernate3.jar"/>
4828
<classpathentry kind="lib" path="/deps/awsapi-lib/httpcore-4.0.jar"/>
4929
<classpathentry kind="lib" path="/deps/awsapi-lib/javassist-3.9.0.GA.jar"/>
5030
<classpathentry kind="lib" path="/deps/awsapi-lib/jaxb-api-2.1.jar"/>
@@ -81,5 +61,8 @@ under the License.
8161
<classpathentry kind="lib" path="/deps/awsapi-lib/rampart-lib/xmlsec-1.4.2.jar"/>
8262
<classpathentry kind="lib" path="/deps/awsapi-lib/rampart-lib/xmltooling-1.2.0.jar"/>
8363
<classpathentry kind="lib" path="/deps/cloud-servlet-api.jar"/>
64+
<classpathentry kind="lib" path="/deps/cloud-javax.persistence-2.0.0.jar"/>
65+
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
66+
<classpathentry kind="lib" path="/deps/cloud-ehcache.jar"/>
8467
<classpathentry kind="output" path="bin"/>
8568
</classpath>

awsapi/conf/hibernate.cfg.xml

Lines changed: 0 additions & 51 deletions
This file was deleted.

awsapi/src/com/cloud/bridge/auth/ec2/AuthenticationHandler.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@
3737
import javax.xml.parsers.DocumentBuilder;
3838
import javax.xml.parsers.DocumentBuilderFactory;
3939

40-
import com.cloud.bridge.model.UserCredentials;
41-
import com.cloud.bridge.persist.dao.UserCredentialsDao;
40+
import com.cloud.bridge.model.UserCredentialsVO;
41+
import com.cloud.bridge.persist.dao.UserCredentialsDaoImpl;
4242
import com.cloud.bridge.service.UserContext;
4343
import com.cloud.bridge.util.AuthenticationUtils;
44+
import com.cloud.utils.component.ComponentLocator;
4445

4546

4647
public class AuthenticationHandler implements Handler {
4748
protected final static Logger logger = Logger.getLogger(AuthenticationHandler.class);
48-
49+
protected final UserCredentialsDaoImpl ucDao = ComponentLocator.inject(UserCredentialsDaoImpl.class);
4950
private DocumentBuilderFactory dbf = null;
5051

5152
protected HandlerDescription handlerDesc = new HandlerDescription( "EC2AuthenticationHandler" );
@@ -111,13 +112,15 @@ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault
111112
logger.debug( "X509 cert's uniqueId: " + uniqueId );
112113

113114
// -> find the Cloud API key and the secret key from the cert's uniqueId
114-
UserCredentialsDao credentialDao = new UserCredentialsDao();
115+
/* UserCredentialsDao credentialDao = new UserCredentialsDao();
115116
UserCredentials cloudKeys = credentialDao.getByCertUniqueId( uniqueId );
116-
if ( null == cloudKeys ) {
117-
logger.error( "Cert does not map to Cloud API keys: " + uniqueId );
118-
throw new AxisFault( "User not properly registered: Certificate does not map to Cloud API Keys", "Client.Blocked" );
119-
}
120-
else UserContext.current().initContext( cloudKeys.getAccessKey(), cloudKeys.getSecretKey(), cloudKeys.getAccessKey(), "SOAP Request", null );
117+
*/
118+
UserCredentialsVO cloudKeys = ucDao.getByCertUniqueId(uniqueId);
119+
if ( null == cloudKeys ) {
120+
logger.error( "Cert does not map to Cloud API keys: " + uniqueId );
121+
throw new AxisFault( "User not properly registered: Certificate does not map to Cloud API Keys", "Client.Blocked" );
122+
}
123+
else UserContext.current().initContext( cloudKeys.getAccessKey(), cloudKeys.getSecretKey(), cloudKeys.getAccessKey(), "SOAP Request", null );
121124
//System.out.println( "end of cert match: " + UserContext.current().getSecretKey());
122125
}
123126
}

awsapi/src/com/cloud/bridge/auth/s3/AuthenticationHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@
2929
import org.apache.axis2.description.HandlerDescription;
3030
import org.apache.axis2.description.Parameter;
3131

32-
import com.cloud.bridge.model.UserCredentials;
33-
import com.cloud.bridge.persist.dao.UserCredentialsDao;
32+
import com.cloud.bridge.model.UserCredentialsVO;
33+
import com.cloud.bridge.persist.dao.UserCredentialsDaoImpl;
3434
import com.cloud.bridge.service.UserContext;
3535
import com.cloud.bridge.util.S3SoapAuth;
36+
import com.cloud.utils.component.ComponentLocator;
3637

3738
/*
3839
* For SOAP compatibility.
3940
*/
4041

4142
public class AuthenticationHandler implements Handler {
4243
protected final static Logger logger = Logger.getLogger(AuthenticationHandler.class);
43-
44+
protected final UserCredentialsDaoImpl ucDao = ComponentLocator.inject(UserCredentialsDaoImpl.class);
4445
protected HandlerDescription handlerDesc = new HandlerDescription( "default handler" );
4546
private String name = "S3AuthenticationHandler";
4647

@@ -190,8 +191,7 @@ public void setName(String name)
190191
private String lookupSecretKey( String accessKey )
191192
throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
192193
{
193-
UserCredentialsDao credentialDao = new UserCredentialsDao();
194-
UserCredentials cloudKeys = credentialDao.getByAccessKey( accessKey );
194+
UserCredentialsVO cloudKeys = ucDao.getByAccessKey( accessKey );
195195
if ( null == cloudKeys ) {
196196
logger.debug( accessKey + " is not defined in the S3 service - call SetUserKeys" );
197197
return null;

awsapi/src/com/cloud/bridge/lifecycle/ServiceEngineLifecycle.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import org.apache.axis2.engine.ServiceLifeCycle;
2222
import org.apache.log4j.Logger;
2323

24-
import com.cloud.bridge.persist.dao.UserCredentialsDao;
2524
import com.cloud.bridge.service.controller.s3.ServiceProvider;
25+
import com.cloud.utils.db.Transaction;
2626

2727

2828
/**
@@ -38,7 +38,7 @@ public class ServiceEngineLifecycle implements ServiceLifeCycle {
3838
public void startUp(ConfigurationContext config, AxisService service) {
3939
// initialize service provider during Axis engine startup
4040
try{
41-
UserCredentialsDao.preCheckTableExistence();
41+
//UserCredentialsDao.preCheckTableExistence();
4242
ServiceProvider.getInstance();
4343
ServiceEngineLifecycle.initialized = true;
4444
}catch(Exception e){
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.cloud.bridge.model;
2+
3+
import javax.persistence.Column;
4+
import javax.persistence.Entity;
5+
import javax.persistence.GeneratedValue;
6+
import javax.persistence.GenerationType;
7+
import javax.persistence.Id;
8+
import javax.persistence.Table;
9+
10+
@Entity
11+
@Table(name="bucket_policies")
12+
public class BucketPolicyVO {
13+
14+
@Id
15+
@GeneratedValue(strategy=GenerationType.IDENTITY)
16+
@Column(name="ID")
17+
private long id;
18+
19+
@Column(name="BucketName")
20+
private String bucketName;
21+
22+
@Column(name="OwnerCanonicalID")
23+
private String ownerCanonicalID;
24+
25+
@Column(name="Policy")
26+
private String policy;
27+
28+
public BucketPolicyVO() { }
29+
public BucketPolicyVO(String bucketName, String client, String policy) {
30+
this.bucketName = bucketName;
31+
this.ownerCanonicalID = client;
32+
this.policy = policy;
33+
}
34+
35+
public long getId() {
36+
return id;
37+
}
38+
public void setId(long id) {
39+
this.id = id;
40+
}
41+
public String getBucketName() {
42+
return bucketName;
43+
}
44+
public void setBucketName(String bucketName) {
45+
this.bucketName = bucketName;
46+
}
47+
public String getOwnerCanonicalID() {
48+
return ownerCanonicalID;
49+
}
50+
public void setOwnerCanonicalID(String ownerCanonicalID) {
51+
this.ownerCanonicalID = ownerCanonicalID;
52+
}
53+
public String getPolicy() {
54+
return policy;
55+
}
56+
public void setPolicy(String policy) {
57+
this.policy = policy;
58+
}
59+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.cloud.bridge.model;
2+
3+
import javax.persistence.Column;
4+
import javax.persistence.Entity;
5+
import javax.persistence.Table;
6+
7+
@Entity
8+
@Table(name="account")
9+
public class CloudStackAccountVO {
10+
11+
@Column(name="uuid")
12+
private String uuid;
13+
14+
@Column(name="default_zone_id")
15+
private Long defaultZoneId = null;
16+
17+
public String getUuid() {
18+
return uuid;
19+
}
20+
21+
public void setUuid(String uuid) {
22+
this.uuid = uuid;
23+
}
24+
25+
public Long getDefaultZoneId() {
26+
return defaultZoneId;
27+
}
28+
29+
public void setDefaultZoneId(Long defaultZoneId) {
30+
this.defaultZoneId = defaultZoneId;
31+
}
32+
33+
34+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.cloud.bridge.model;
2+
3+
import javax.persistence.Column;
4+
import javax.persistence.Entity;
5+
import javax.persistence.Id;
6+
import javax.persistence.Table;
7+
8+
import com.cloud.utils.db.DB;
9+
10+
@Entity
11+
@Table(name="configuration")
12+
public class CloudStackConfigurationVO {
13+
@Id
14+
@Column(name="name")
15+
private String name;
16+
17+
@Column(name="value", length=4095)
18+
private String value;
19+
20+
@DB
21+
public String getValue() {
22+
return value;
23+
}
24+
25+
public String getName() {
26+
return name;
27+
}
28+
29+
30+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.cloud.bridge.model;
2+
3+
import javax.persistence.Column;
4+
import javax.persistence.Entity;
5+
import javax.persistence.GeneratedValue;
6+
import javax.persistence.GenerationType;
7+
import javax.persistence.Id;
8+
import javax.persistence.Table;
9+
10+
@Entity
11+
@Table(name="disk_offering")
12+
public class CloudStackServiceOfferingVO {
13+
14+
@Id
15+
@Column(name="id")
16+
private String id;
17+
18+
@Column(name="name")
19+
private String name;
20+
21+
@Column(name="domain_id")
22+
private String domainId;
23+
24+
25+
public String getId() {
26+
return id;
27+
}
28+
29+
30+
public String getName() {
31+
return name;
32+
}
33+
34+
35+
public void setName(String name) {
36+
this.name = name;
37+
}
38+
39+
40+
public String getDomainId() {
41+
return domainId;
42+
}
43+
44+
45+
public void setDomainId(String domainId) {
46+
this.domainId = domainId;
47+
}
48+
49+
50+
51+
}

0 commit comments

Comments
 (0)