diff --git a/awsapi-setup/setup/cloudstack-aws-api-register b/awsapi-setup/setup/cloudstack-aws-api-register
index 19b53fd26c5..ea57d0b9dcf 100644
--- a/awsapi-setup/setup/cloudstack-aws-api-register
+++ b/awsapi-setup/setup/cloudstack-aws-api-register
@@ -1,4 +1,4 @@
-#!/cygdrive/c/python26/python
+#!/usr/bin/python
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
diff --git a/awsapi/.classpath b/awsapi/.classpath
index 4dc46c4b1ec..c5e598f9f43 100644
--- a/awsapi/.classpath
+++ b/awsapi/.classpath
@@ -1,25 +1,6 @@
-
-
@@ -44,7 +25,6 @@ under the License.
-
@@ -81,5 +61,8 @@ under the License.
+
+
+
diff --git a/awsapi/conf/hibernate.cfg.xml b/awsapi/conf/hibernate.cfg.xml
deleted file mode 100644
index d484849fd07..00000000000
--- a/awsapi/conf/hibernate.cfg.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
- com.mysql.jdbc.Driver
- 20
- false
-
-
- 2
-
- true
- org.hibernate.dialect.MySQLDialect
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/awsapi/src/com/cloud/bridge/auth/ec2/AuthenticationHandler.java b/awsapi/src/com/cloud/bridge/auth/ec2/AuthenticationHandler.java
index 3b28c001b7d..f79feaad5bc 100644
--- a/awsapi/src/com/cloud/bridge/auth/ec2/AuthenticationHandler.java
+++ b/awsapi/src/com/cloud/bridge/auth/ec2/AuthenticationHandler.java
@@ -37,15 +37,16 @@ import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import com.cloud.bridge.model.UserCredentials;
-import com.cloud.bridge.persist.dao.UserCredentialsDao;
+import com.cloud.bridge.model.UserCredentialsVO;
+import com.cloud.bridge.persist.dao.UserCredentialsDaoImpl;
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" );
@@ -111,13 +112,15 @@ public class AuthenticationHandler implements Handler {
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();
+/* UserCredentialsDao credentialDao = new UserCredentialsDao();
UserCredentials cloudKeys = credentialDao.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 );
+*/
+ 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());
}
}
diff --git a/awsapi/src/com/cloud/bridge/auth/s3/AuthenticationHandler.java b/awsapi/src/com/cloud/bridge/auth/s3/AuthenticationHandler.java
index f7a1a7e8c6e..b9519169632 100644
--- a/awsapi/src/com/cloud/bridge/auth/s3/AuthenticationHandler.java
+++ b/awsapi/src/com/cloud/bridge/auth/s3/AuthenticationHandler.java
@@ -29,10 +29,11 @@ import org.apache.axis2.AxisFault;
import org.apache.axis2.description.HandlerDescription;
import org.apache.axis2.description.Parameter;
-import com.cloud.bridge.model.UserCredentials;
-import com.cloud.bridge.persist.dao.UserCredentialsDao;
+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.
@@ -40,7 +41,7 @@ import com.cloud.bridge.util.S3SoapAuth;
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";
@@ -190,8 +191,7 @@ public class AuthenticationHandler implements Handler {
private String lookupSecretKey( String accessKey )
throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
{
- UserCredentialsDao credentialDao = new UserCredentialsDao();
- UserCredentials cloudKeys = credentialDao.getByAccessKey( accessKey );
+ UserCredentialsVO cloudKeys = ucDao.getByAccessKey( accessKey );
if ( null == cloudKeys ) {
logger.debug( accessKey + " is not defined in the S3 service - call SetUserKeys" );
return null;
diff --git a/awsapi/src/com/cloud/bridge/lifecycle/ServiceEngineLifecycle.java b/awsapi/src/com/cloud/bridge/lifecycle/ServiceEngineLifecycle.java
index 88c8729d902..73cb801cec4 100644
--- a/awsapi/src/com/cloud/bridge/lifecycle/ServiceEngineLifecycle.java
+++ b/awsapi/src/com/cloud/bridge/lifecycle/ServiceEngineLifecycle.java
@@ -21,8 +21,8 @@ import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.ServiceLifeCycle;
import org.apache.log4j.Logger;
-import com.cloud.bridge.persist.dao.UserCredentialsDao;
import com.cloud.bridge.service.controller.s3.ServiceProvider;
+import com.cloud.utils.db.Transaction;
/**
@@ -38,7 +38,7 @@ public class ServiceEngineLifecycle implements ServiceLifeCycle {
public void startUp(ConfigurationContext config, AxisService service) {
// initialize service provider during Axis engine startup
try{
- UserCredentialsDao.preCheckTableExistence();
+ //UserCredentialsDao.preCheckTableExistence();
ServiceProvider.getInstance();
ServiceEngineLifecycle.initialized = true;
}catch(Exception e){
diff --git a/awsapi/src/com/cloud/bridge/model/BucketPolicyVO.java b/awsapi/src/com/cloud/bridge/model/BucketPolicyVO.java
new file mode 100644
index 00000000000..c4be142d5c7
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/BucketPolicyVO.java
@@ -0,0 +1,59 @@
+package com.cloud.bridge.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="bucket_policies")
+public class BucketPolicyVO {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
+ private long id;
+
+ @Column(name="BucketName")
+ private String bucketName;
+
+ @Column(name="OwnerCanonicalID")
+ private String ownerCanonicalID;
+
+ @Column(name="Policy")
+ private String policy;
+
+ public BucketPolicyVO() { }
+ public BucketPolicyVO(String bucketName, String client, String policy) {
+ this.bucketName = bucketName;
+ this.ownerCanonicalID = client;
+ this.policy = policy;
+ }
+
+ public long getId() {
+ return id;
+ }
+ public void setId(long id) {
+ this.id = id;
+ }
+ public String getBucketName() {
+ return bucketName;
+ }
+ public void setBucketName(String bucketName) {
+ this.bucketName = bucketName;
+ }
+ public String getOwnerCanonicalID() {
+ return ownerCanonicalID;
+ }
+ public void setOwnerCanonicalID(String ownerCanonicalID) {
+ this.ownerCanonicalID = ownerCanonicalID;
+ }
+ public String getPolicy() {
+ return policy;
+ }
+ public void setPolicy(String policy) {
+ this.policy = policy;
+ }
+}
diff --git a/awsapi/src/com/cloud/bridge/model/CloudStackAccountVO.java b/awsapi/src/com/cloud/bridge/model/CloudStackAccountVO.java
new file mode 100644
index 00000000000..5737abb9e79
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/CloudStackAccountVO.java
@@ -0,0 +1,34 @@
+package com.cloud.bridge.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="account")
+public class CloudStackAccountVO {
+
+ @Column(name="uuid")
+ private String uuid;
+
+ @Column(name="default_zone_id")
+ private Long defaultZoneId = null;
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public Long getDefaultZoneId() {
+ return defaultZoneId;
+ }
+
+ public void setDefaultZoneId(Long defaultZoneId) {
+ this.defaultZoneId = defaultZoneId;
+ }
+
+
+}
diff --git a/awsapi/src/com/cloud/bridge/model/CloudStackConfigurationVO.java b/awsapi/src/com/cloud/bridge/model/CloudStackConfigurationVO.java
new file mode 100644
index 00000000000..982969f73dd
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/CloudStackConfigurationVO.java
@@ -0,0 +1,30 @@
+package com.cloud.bridge.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.utils.db.DB;
+
+@Entity
+@Table(name="configuration")
+public class CloudStackConfigurationVO {
+ @Id
+ @Column(name="name")
+ private String name;
+
+ @Column(name="value", length=4095)
+ private String value;
+
+ @DB
+ public String getValue() {
+ return value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+
+}
diff --git a/awsapi/src/com/cloud/bridge/model/CloudStackServiceOfferingVO.java b/awsapi/src/com/cloud/bridge/model/CloudStackServiceOfferingVO.java
new file mode 100644
index 00000000000..23e0cc850d2
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/CloudStackServiceOfferingVO.java
@@ -0,0 +1,51 @@
+package com.cloud.bridge.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="disk_offering")
+public class CloudStackServiceOfferingVO {
+
+ @Id
+ @Column(name="id")
+ private String id;
+
+ @Column(name="name")
+ private String name;
+
+ @Column(name="domain_id")
+ private String domainId;
+
+
+ public String getId() {
+ return id;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ public String getDomainId() {
+ return domainId;
+ }
+
+
+ public void setDomainId(String domainId) {
+ this.domainId = domainId;
+ }
+
+
+
+}
diff --git a/awsapi/src/com/cloud/bridge/model/MHost.hbm.xml b/awsapi/src/com/cloud/bridge/model/MHost.hbm.xml
deleted file mode 100644
index e151171ee9a..00000000000
--- a/awsapi/src/com/cloud/bridge/model/MHost.hbm.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/awsapi/src/com/cloud/bridge/model/MHostMount.hbm.xml b/awsapi/src/com/cloud/bridge/model/MHostMount.hbm.xml
deleted file mode 100644
index c186de56cc4..00000000000
--- a/awsapi/src/com/cloud/bridge/model/MHostMount.hbm.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/awsapi/src/com/cloud/bridge/model/MHostMount.java b/awsapi/src/com/cloud/bridge/model/MHostMountVO.java
similarity index 56%
rename from awsapi/src/com/cloud/bridge/model/MHostMount.java
rename to awsapi/src/com/cloud/bridge/model/MHostMountVO.java
index 771ed8b6aab..a008658a1be 100644
--- a/awsapi/src/com/cloud/bridge/model/MHostMount.java
+++ b/awsapi/src/com/cloud/bridge/model/MHostMountVO.java
@@ -19,18 +19,46 @@ package com.cloud.bridge.model;
import java.io.Serializable;
import java.util.Date;
-public class MHostMount implements Serializable {
- private static final long serialVersionUID = -1119494563131099642L;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+@Entity
+@Table(name="mhost_mount")
+public class MHostMountVO implements Serializable {
+ private static final long serialVersionUID = -1119494563131099642L;
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
private Long id;
- private MHost mhost;
- private SHost shost;
+ @Column(name="MHostID")
+ private long mHostID;
+ @Column(name="SHostID")
+ private long sHostID;
+
+ @Transient
+ private MHostVO mhost;
+
+ @Transient
+ private SHostVO shost;
+
+ @Column(name="MountPath")
private String mountPath;
+
+ @Column(name="LastMountTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
private Date lastMountTime;
- public MHostMount() {
+ public MHostMountVO() {
}
public Long getId() {
@@ -41,19 +69,35 @@ public class MHostMount implements Serializable {
this.id = id;
}
- public MHost getMhost() {
+ public long getmHostID() {
+ return mHostID;
+ }
+
+ public void setmHostID(long mHostID) {
+ this.mHostID = mHostID;
+ }
+
+ public long getsHostID() {
+ return sHostID;
+ }
+
+ public void setsHostID(long sHostID) {
+ this.sHostID = sHostID;
+ }
+
+ public MHostVO getMhost() {
return mhost;
}
- public void setMhost(MHost mhost) {
+ public void setMhost(MHostVO mhost) {
this.mhost = mhost;
}
- public SHost getShost() {
+ public SHostVO getShost() {
return shost;
}
- public void setShost(SHost shost) {
+ public void setShost(SHostVO shost) {
this.shost = shost;
}
@@ -78,11 +122,11 @@ public class MHostMount implements Serializable {
if(this == other)
return true;
- if(!(other instanceof MHostMount))
+ if(!(other instanceof MHostMountVO))
return false;
- return getMhost().equals(((MHostMount)other).getMhost()) &&
- getShost().equals(((MHostMount)other).getShost());
+ return getMhost().equals(((MHostMountVO)other).getMhost()) &&
+ getShost().equals(((MHostMountVO)other).getShost());
}
@Override
diff --git a/awsapi/src/com/cloud/bridge/model/MHost.java b/awsapi/src/com/cloud/bridge/model/MHostVO.java
similarity index 65%
rename from awsapi/src/com/cloud/bridge/model/MHost.java
rename to awsapi/src/com/cloud/bridge/model/MHostVO.java
index 2187c7ee546..0be74b7fe90 100644
--- a/awsapi/src/com/cloud/bridge/model/MHost.java
+++ b/awsapi/src/com/cloud/bridge/model/MHostVO.java
@@ -21,20 +21,46 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Set;
-public class MHost implements Serializable {
- private static final long serialVersionUID = 4848254624679753930L;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+@Entity
+@Table(name="mhost")
+public class MHostVO implements Serializable {
+ private static final long serialVersionUID = 4848254624679753930L;
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
private Long id;
+ @Column(name="MHostKey", nullable=false)
private String hostKey;
+
+ @Column(name="Host")
private String host;
+
+ @Column(name="Version")
private String version;
+
+ @Column(name="LastHeartbeatTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
private Date lastHeartbeatTime;
+
+ @Transient
+ private Set localSHosts = new HashSet();
+
+ @Transient
+ private Set mounts = new HashSet();
- private Set localSHosts = new HashSet();
- private Set mounts = new HashSet();
-
- public MHost() {
+ public MHostVO() {
}
public Long getId() {
@@ -77,19 +103,19 @@ public class MHost implements Serializable {
this.lastHeartbeatTime = lastHeartbeatTime;
}
- public Set getLocalSHosts() {
+ public Set getLocalSHosts() {
return localSHosts;
}
- public void setLocalSHosts(Set localSHosts) {
+ public void setLocalSHosts(Set localSHosts) {
this.localSHosts = localSHosts;
}
- public Set getMounts() {
+ public Set getMounts() {
return mounts;
}
- public void setMounts(Set mounts) {
+ public void setMounts(Set mounts) {
this.mounts = mounts;
}
@@ -98,10 +124,10 @@ public class MHost implements Serializable {
if(this == other)
return true;
- if(!(other instanceof MHost))
+ if(!(other instanceof MHostVO))
return false;
- return hostKey == ((MHost)other).getHostKey();
+ return hostKey == ((MHostVO)other).getHostKey();
}
@Override
diff --git a/awsapi/src/com/cloud/bridge/model/MultiPartPartsVO.java b/awsapi/src/com/cloud/bridge/model/MultiPartPartsVO.java
new file mode 100644
index 00000000000..d622e47a691
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/MultiPartPartsVO.java
@@ -0,0 +1,108 @@
+package com.cloud.bridge.model;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name="multipart_parts")
+public class MultiPartPartsVO {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
+ private Long id;
+
+ @Column(name="UploadID")
+ private Long uploadid;
+
+ @Column(name="partNumber")
+ private int partNumber;
+
+ @Column(name="MD5")
+ private String md5;
+
+ @Column(name="StoredPath")
+ private String storedPath;
+
+ @Column(name="StoredSize")
+ private Long storedSize;
+
+ @Column(name="CreateTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
+ private Date createTime;
+
+ public MultiPartPartsVO() { }
+
+ public MultiPartPartsVO(int uploadId, int partNumber, String md5,
+ String storedPath, int size, Date date) {
+ this.uploadid = new Long(uploadId);
+ this.partNumber = partNumber;
+ this.md5 = md5;
+ this.storedPath = storedPath;
+ this.storedSize = new Long(size);
+ this.createTime = date;
+ }
+
+ public Long getUploadid() {
+ return uploadid;
+ }
+
+ public void setUploadid(Long uploadid) {
+ this.uploadid = uploadid;
+ }
+
+ public int getPartNumber() {
+ return partNumber;
+ }
+
+ public void setPartNumber(int partNumber) {
+ this.partNumber = partNumber;
+ }
+
+ public String getMd5() {
+ return md5;
+ }
+
+ public void setMd5(String md5) {
+ this.md5 = md5;
+ }
+
+ public String getStoredPath() {
+ return storedPath;
+ }
+
+ public void setStoredPath(String storedPath) {
+ this.storedPath = storedPath;
+ }
+
+ public Long getStoredSize() {
+ return storedSize;
+ }
+
+ public void setStoredSize(Long storedSize) {
+ this.storedSize = storedSize;
+ }
+
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+
+
+}
diff --git a/awsapi/src/com/cloud/bridge/model/MultiPartUploadsVO.java b/awsapi/src/com/cloud/bridge/model/MultiPartUploadsVO.java
new file mode 100644
index 00000000000..fd0bb42f4c2
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/MultiPartUploadsVO.java
@@ -0,0 +1,94 @@
+package com.cloud.bridge.model;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name="multipart_uploads")
+
+public class MultiPartUploadsVO {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
+ private Long id;
+
+ @Column(name="AccessKey")
+ private String accessKey;
+
+ @Column(name="BucketName")
+ private String bucketName;
+
+ @Column(name="NameKey")
+ private String nameKey;
+
+ @Column(name="x_amz_acl")
+ private String amzAcl;
+
+ @Column(name="CreateTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
+ private Date createTime;
+
+ public MultiPartUploadsVO() {}
+
+ public MultiPartUploadsVO(String accessKey, String bucketName, String key, String cannedAccess, Date tod) {
+ this.accessKey = accessKey;
+ this.bucketName = bucketName;
+ this.nameKey = key;
+ this.amzAcl = cannedAccess;
+ this.createTime = tod;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getAccessKey() {
+ return accessKey;
+ }
+
+ public void setAccessKey(String accessKey) {
+ this.accessKey = accessKey;
+ }
+
+ public String getBucketName() {
+ return bucketName;
+ }
+
+ public void setBucketName(String bucketName) {
+ this.bucketName = bucketName;
+ }
+
+ public String getNameKey() {
+ return nameKey;
+ }
+
+ public void setNameKey(String nameKey) {
+ this.nameKey = nameKey;
+ }
+
+ public String getAmzAcl() {
+ return amzAcl;
+ }
+
+ public void setAmzAcl(String amzAcl) {
+ this.amzAcl = amzAcl;
+ }
+
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+
+}
\ No newline at end of file
diff --git a/awsapi/src/com/cloud/bridge/model/MultipartMetaVO.java b/awsapi/src/com/cloud/bridge/model/MultipartMetaVO.java
new file mode 100644
index 00000000000..ca2b69ee64f
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/MultipartMetaVO.java
@@ -0,0 +1,59 @@
+package com.cloud.bridge.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="multipart_meta")
+
+public class MultipartMetaVO {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
+ private Long id;
+
+ @Column(name="UploadID")
+ private long uploadID;
+
+ @Column(name="Name")
+ private String name;
+
+ @Column(name="Value")
+ private String value;
+
+ public long getID() {
+ return id;
+ }
+
+ public long getUploadID() {
+ return uploadID;
+ }
+
+ public void setUploadID(long uploadID) {
+ this.uploadID = uploadID;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+
+
+}
diff --git a/awsapi/src/com/cloud/bridge/model/OfferingBundleVO.java b/awsapi/src/com/cloud/bridge/model/OfferingBundleVO.java
new file mode 100644
index 00000000000..4c41cff451a
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/OfferingBundleVO.java
@@ -0,0 +1,46 @@
+package com.cloud.bridge.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+
+@Entity
+@Table(name="offering_bundle")
+public class OfferingBundleVO {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
+ private long id;
+
+ @Column(name="AmazonEC2Offering")
+ private String amazonOffering;
+
+ @Column(name="CloudStackOffering")
+ private String cloudstackOffering;
+
+ public long getID() {
+ return id;
+ }
+
+ public String getAmazonOffering() {
+ return amazonOffering;
+ }
+
+ public void setAmazonOffering(String amazonOffering) {
+ this.amazonOffering = amazonOffering;
+ }
+
+ public String getCloudstackOffering() {
+ return cloudstackOffering;
+ }
+
+ public void setCloudstackOffering(String cloudstackOffering) {
+ this.cloudstackOffering = cloudstackOffering;
+ }
+
+
+}
diff --git a/awsapi/src/com/cloud/bridge/model/SAcl.hbm.xml b/awsapi/src/com/cloud/bridge/model/SAcl.hbm.xml
deleted file mode 100644
index 175e1a7808d..00000000000
--- a/awsapi/src/com/cloud/bridge/model/SAcl.hbm.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/awsapi/src/com/cloud/bridge/model/SAcl.java b/awsapi/src/com/cloud/bridge/model/SAcl.java
index 7cbcabee316..af0bb5eee91 100644
--- a/awsapi/src/com/cloud/bridge/model/SAcl.java
+++ b/awsapi/src/com/cloud/bridge/model/SAcl.java
@@ -37,8 +37,7 @@ import com.cloud.bridge.util.Triple;
* < permission1, permission2, symbol >
* when given an aclRequestString, a target (i.e. bucket or object) and the ID of the owner.
*/
-public class SAcl implements Serializable {
- private static final long serialVersionUID = 7900837117165018850L;
+public interface SAcl {
public static final int GRANTEE_USER = 0;
public static final int GRANTEE_ALLUSERS = 1;
@@ -52,95 +51,6 @@ public class SAcl implements Serializable {
public static final int PERMISSION_WRITE_ACL = 8;
public static final int PERMISSION_FULL = (PERMISSION_READ | PERMISSION_WRITE | PERMISSION_READ_ACL | PERMISSION_WRITE_ACL);
- private Long id;
-
- private String target;
- private long targetId;
-
- private int granteeType;
- private String granteeCanonicalId;
-
- private int permission;
- private int grantOrder;
-
- private Date createTime;
- private Date lastModifiedTime;
-
- public SAcl() {
- }
-
- public Long getId() {
- return id;
- }
-
- private void setId(Long id) {
- this.id = id;
- }
-
- public String getTarget() {
- return target;
- }
-
- public void setTarget(String target) {
- this.target = target;
- }
-
- public long getTargetId() {
- return targetId;
- }
-
- public void setTargetId(long targetId) {
- this.targetId = targetId;
- }
-
- public int getGranteeType() {
- return granteeType;
- }
-
- public void setGranteeType(int granteeType) {
- this.granteeType = granteeType;
- }
-
- public String getGranteeCanonicalId() {
- return granteeCanonicalId;
- }
-
- public void setGranteeCanonicalId(String granteeCanonicalId) {
- this.granteeCanonicalId = granteeCanonicalId;
- }
-
- public int getPermission() {
- return permission;
- }
-
- public void setPermission(int permission) {
- this.permission = permission;
- }
-
- public int getGrantOrder() {
- return grantOrder;
- }
-
- public void setGrantOrder(int grantOrder) {
- this.grantOrder = grantOrder;
- }
-
- public Date getCreateTime() {
- return createTime;
- }
-
- public void setCreateTime(Date createTime) {
- this.createTime = createTime;
- }
-
- public Date getLastModifiedTime() {
- return lastModifiedTime;
- }
-
- public void setLastModifiedTime(Date lastModifiedTime) {
- this.lastModifiedTime = lastModifiedTime;
- }
-
/** Return an OrderedPair
* < permission, grantee >
* comprising
@@ -153,9 +63,9 @@ public class SAcl implements Serializable {
* @param aclRequestString - The requested ACL from the set of AWS S3 canned ACLs
* @param target - Either "SBucket" or otherwise assumed to be for a single object item
*/
- public static OrderedPair getCannedAccessControls ( String aclRequestString, String target )
- throws UnsupportedException
- {
+ //public static OrderedPair getCannedAccessControls ( String aclRequestString, String target );
+
+/* {
if ( aclRequestString.equalsIgnoreCase( "public-read" ))
// All users granted READ access.
return new OrderedPair (PERMISSION_READ,GRANTEE_ALLUSERS);
@@ -184,7 +94,7 @@ public class SAcl implements Serializable {
}
else throw new UnsupportedException( "Unknown Canned Access Policy: " + aclRequestString + " is not supported" );
}
-
+*/
/** Return a Triple
* < permission1, permission2, symbol >
* comprising
@@ -200,8 +110,8 @@ public class SAcl implements Serializable {
* @param target - Either "SBucket" or otherwise assumed to be for a single object item
* @param ownerID - An ID for the owner, if used in place of symbols "A" or "*"
*/
- public static Triple getCannedAccessControls ( String aclRequestString, String target, String ownerID )
- throws UnsupportedException
+ //public static Triple getCannedAccessControls ( String aclRequestString, String target, String ownerID );
+/* throws UnsupportedException
{
if ( aclRequestString.equalsIgnoreCase( "public-read" ))
// Owner gets FULL_CONTROL and the anonymous principal (the 'A' symbol here) is granted READ access.
@@ -235,5 +145,5 @@ public class SAcl implements Serializable {
}
else throw new UnsupportedException( "Unknown Canned Access Policy: " + aclRequestString + " is not supported" );
}
-
+*/
}
diff --git a/awsapi/src/com/cloud/bridge/model/SAclVO.java b/awsapi/src/com/cloud/bridge/model/SAclVO.java
new file mode 100644
index 00000000000..96a252f42da
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/SAclVO.java
@@ -0,0 +1,254 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.bridge.model;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import com.cloud.bridge.service.exception.UnsupportedException;
+import com.cloud.bridge.util.OrderedPair;
+import com.cloud.bridge.util.Triple;
+
+/**
+ * A model of stored ACLs to remember the ACL permissions per canonicalUserID per grantee
+ * Hold the AWS S3 grantee and permission constants.
+ *
+ * This class implements two forms of getCannedAccessControls mappings, as static methods,
+ *
+ * (a) an OrderedPair which provides a maplet across
+ * < permission, grantee >
+ * when given an aclRequestString and a target (i.e. bucket or object),
+ *
+ * (b) a Triplet
+ * < permission1, permission2, symbol >
+ * when given an aclRequestString, a target (i.e. bucket or object) and the ID of the owner.
+ */
+@Entity
+@Table(name="acl")
+public class SAclVO implements SAcl {
+ private static final long serialVersionUID = 7900837117165018850L;
+
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
+ private Long id;
+ @Column(name="Target")
+ private String target;
+
+ @Column(name="TargetID")
+ private long targetId;
+
+ @Column(name="GranteeType")
+ private int granteeType;
+
+ @Column(name="GranteeCanonicalID")
+ private String granteeCanonicalId;
+
+ @Column(name="Permission")
+ private int permission;
+
+ @Column(name="GrantOrder")
+ private int grantOrder;
+
+ @Column(name="CreateTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
+ private Date createTime;
+
+ @Column(name="LastModifiedTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
+ private Date lastModifiedTime;
+
+ public SAclVO() {
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ private void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public long getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetId(long targetId) {
+ this.targetId = targetId;
+ }
+
+ public int getGranteeType() {
+ return granteeType;
+ }
+
+ public void setGranteeType(int granteeType) {
+ this.granteeType = granteeType;
+ }
+
+ public String getGranteeCanonicalId() {
+ return granteeCanonicalId;
+ }
+
+ public void setGranteeCanonicalId(String granteeCanonicalId) {
+ this.granteeCanonicalId = granteeCanonicalId;
+ }
+
+ public int getPermission() {
+ return permission;
+ }
+
+ public void setPermission(int permission) {
+ this.permission = permission;
+ }
+
+ public int getGrantOrder() {
+ return grantOrder;
+ }
+
+ public void setGrantOrder(int grantOrder) {
+ this.grantOrder = grantOrder;
+ }
+
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+
+ public Date getLastModifiedTime() {
+ return lastModifiedTime;
+ }
+
+ public void setLastModifiedTime(Date lastModifiedTime) {
+ this.lastModifiedTime = lastModifiedTime;
+ }
+
+ /** Return an OrderedPair
+ * < permission, grantee >
+ * comprising
+ * a permission - which is one of SAcl.PERMISSION_PASS, SAcl.PERMISSION_NONE, SAcl.PERMISSION_READ,
+ * SAcl.PERMISSION_WRITE, SAcl.PERMISSION_READ_ACL, SAcl.PERMISSION_WRITE_ACL, SAcl.PERMISSION_FULL
+ * a grantee - which is one of GRANTEE_ALLUSERS, GRANTEE_AUTHENTICATED, GRANTEE_USER
+ *
+ * Access controls that are specified via the "x-amz-acl:" headers in REST requests for buckets.
+ * The ACL request string is treated as a request for a known cannedAccessPolicy
+ * @param aclRequestString - The requested ACL from the set of AWS S3 canned ACLs
+ * @param target - Either "SBucket" or otherwise assumed to be for a single object item
+ */
+ public static OrderedPair getCannedAccessControls ( String aclRequestString, String target )
+ throws UnsupportedException
+ {
+ if ( aclRequestString.equalsIgnoreCase( "public-read" ))
+ // All users granted READ access.
+ return new OrderedPair (PERMISSION_READ,GRANTEE_ALLUSERS);
+ else if (aclRequestString.equalsIgnoreCase( "public-read-write" ))
+ // All users granted READ and WRITE access
+ return new OrderedPair ((PERMISSION_READ | PERMISSION_WRITE),GRANTEE_ALLUSERS);
+ else if (aclRequestString.equalsIgnoreCase( "authenticated-read" ))
+ // Authenticated users have READ access
+ return new OrderedPair (PERMISSION_READ,GRANTEE_AUTHENTICATED);
+ else if (aclRequestString.equalsIgnoreCase( "private" ))
+ // Only Owner gets FULL_CONTROL
+ return new OrderedPair (PERMISSION_FULL,GRANTEE_USER);
+ else if (aclRequestString.equalsIgnoreCase( "bucket-owner-read" ))
+ {
+ // Object Owner gets FULL_CONTROL, Bucket Owner gets READ
+ if ( target.equalsIgnoreCase( "SBucket" ))
+ return new OrderedPair (PERMISSION_READ, GRANTEE_USER);
+ else
+ return new OrderedPair (PERMISSION_FULL, GRANTEE_USER);
+ }
+ else if (aclRequestString.equalsIgnoreCase( "bucket-owner-full-control" ))
+ {
+ // Object Owner gets FULL_CONTROL, Bucket Owner gets FULL_CONTROL
+ // This is equivalent to private when used with PUT Bucket
+ return new OrderedPair (PERMISSION_FULL,GRANTEE_USER);
+ }
+ else throw new UnsupportedException( "Unknown Canned Access Policy: " + aclRequestString + " is not supported" );
+ }
+
+ /** Return a Triple
+ * < permission1, permission2, symbol >
+ * comprising
+ * two permissions - which is one of SAcl.PERMISSION_PASS, SAcl.PERMISSION_NONE, SAcl.PERMISSION_READ,
+ * SAcl.PERMISSION_WRITE, SAcl.PERMISSION_READ_ACL, SAcl.PERMISSION_WRITE_ACL, SAcl.PERMISSION_FULL
+ * permission1 applies to objects, permission2 applies to buckets.
+ * a symbol to indicate whether the principal is anonymous (i.e. string "A") or authenticated user (i.e.
+ * string "*") - otherwise null indicates a single ACL for all users.
+ *
+ * Access controls that are specified via the "x-amz-acl:" headers in REST requests for buckets.
+ * The ACL request string is treated as a request for a known cannedAccessPolicy
+ * @param aclRequestString - The requested ACL from the set of AWS S3 canned ACLs
+ * @param target - Either "SBucket" or otherwise assumed to be for a single object item
+ * @param ownerID - An ID for the owner, if used in place of symbols "A" or "*"
+ */
+ public static Triple getCannedAccessControls ( String aclRequestString, String target, String ownerID )
+ throws UnsupportedException
+ {
+ if ( aclRequestString.equalsIgnoreCase( "public-read" ))
+ // Owner gets FULL_CONTROL and the anonymous principal (the 'A' symbol here) is granted READ access.
+ return new Triple (PERMISSION_FULL, PERMISSION_READ,"A");
+ else if (aclRequestString.equalsIgnoreCase( "public-read-write" ))
+ // Owner gets FULL_CONTROL and the anonymous principal (the 'A' symbol here) is granted READ and WRITE access
+ return new Triple (PERMISSION_FULL, (PERMISSION_READ | PERMISSION_WRITE),"A");
+ else if (aclRequestString.equalsIgnoreCase( "authenticated-read" ))
+ // Owner gets FULL_CONTROL and ANY principal authenticated as a registered S3 user (the '*' symbol here) is granted READ access
+ return new Triple (PERMISSION_FULL, PERMISSION_READ,"*");
+ else if (aclRequestString.equalsIgnoreCase( "private" ))
+ // This is termed the "private" or default ACL, "Owner gets FULL_CONTROL"
+ return new Triple (PERMISSION_FULL, PERMISSION_FULL,null);
+ else if (aclRequestString.equalsIgnoreCase( "bucket-owner-read" ))
+ {
+ // Object Owner gets FULL_CONTROL, Bucket Owner gets READ
+ // This is equivalent to private when used with PUT Bucket
+ if ( target.equalsIgnoreCase( "SBucket" ))
+ return new Triple (PERMISSION_FULL,PERMISSION_FULL ,null);
+ else
+ return new Triple (PERMISSION_FULL,PERMISSION_READ,ownerID);
+ }
+ else if (aclRequestString.equalsIgnoreCase( "bucket-owner-full-control" ))
+ {
+ // Object Owner gets FULL_CONTROL, Bucket Owner gets FULL_CONTROL
+ // This is equivalent to private when used with PUT Bucket
+ if ( target.equalsIgnoreCase( "SBucket" ))
+ return new Triple (PERMISSION_FULL, PERMISSION_FULL, null);
+ else
+ return new Triple (PERMISSION_FULL,PERMISSION_FULL, ownerID);
+ }
+ else throw new UnsupportedException( "Unknown Canned Access Policy: " + aclRequestString + " is not supported" );
+ }
+
+}
diff --git a/awsapi/src/com/cloud/bridge/model/SBucket.hbm.xml b/awsapi/src/com/cloud/bridge/model/SBucket.hbm.xml
deleted file mode 100644
index 83f495d9ad9..00000000000
--- a/awsapi/src/com/cloud/bridge/model/SBucket.hbm.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/awsapi/src/com/cloud/bridge/model/SBucket.java b/awsapi/src/com/cloud/bridge/model/SBucket.java
index 720907fa529..7703ae72962 100644
--- a/awsapi/src/com/cloud/bridge/model/SBucket.java
+++ b/awsapi/src/com/cloud/bridge/model/SBucket.java
@@ -31,14 +31,13 @@ import java.util.Set;
* VersioningStatus
* For ORM see "com/cloud/bridge/model/SHost.hbm.xml"
*/
-public class SBucket implements Serializable {
- private static final long serialVersionUID = 7430267766019671273L;
-
- public static final int VERSIONING_NULL = 0;
+public interface SBucket {
+
+ public static final int VERSIONING_NULL = 0;
public static final int VERSIONING_ENABLED = 1;
public static final int VERSIONING_SUSPENDED = 2;
- private Long id;
+/* private Long id;
private String name;
private String ownerCanonicalId;
@@ -124,5 +123,5 @@ public class SBucket implements Serializable {
@Override
public int hashCode() {
return getName().hashCode();
- }
+ }*/
}
diff --git a/awsapi/src/com/cloud/bridge/model/SBucketVO.java b/awsapi/src/com/cloud/bridge/model/SBucketVO.java
new file mode 100644
index 00000000000..ca47bf7b3ca
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/SBucketVO.java
@@ -0,0 +1,169 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.bridge.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+/**
+ * Holds the relation
+ * Id,
+ * Name,
+ * OwnerCanonicalId,
+ * SHost,
+ * CreateTime,
+ * VersioningStatus
+ * For ORM see "com/cloud/bridge/model/SHost.hbm.xml"
+ */
+
+@Entity
+@Table(name="sbucket")
+public class SBucketVO implements SBucket {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
+ private Long id;
+
+ @Column(name="Name")
+ private String name;
+
+ @Column(name="OwnerCanonicalID")
+ private String ownerCanonicalId;
+
+ @Column(name="SHostID")
+ private long shostID;
+
+ @Column(name="CreateTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
+ private Date createTime;
+
+ @Column(name="VersioningStatus")
+ private int versioningStatus;
+
+ @Transient
+ private SHostVO shost;
+
+ @Transient
+ private Set objectsInBucket = new HashSet();
+
+ public SBucketVO() {
+ versioningStatus = VERSIONING_NULL;
+ this.createTime = new Date();
+ }
+
+
+ public SBucketVO(String bucketName, Date currentGMTTime,
+ String canonicalUserId, SHostVO first) {
+ this.versioningStatus = VERSIONING_NULL;
+ this.name = bucketName;
+ this.createTime = new Date();
+ this.ownerCanonicalId = canonicalUserId;
+ this.shost = first;
+ this.shostID = shost.getId();
+ }
+
+
+ public Long getId() {
+ return id;
+ }
+
+ private void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getOwnerCanonicalId() {
+ return ownerCanonicalId;
+ }
+
+ public void setOwnerCanonicalId(String ownerCanonicalId) {
+ this.ownerCanonicalId = ownerCanonicalId;
+ }
+
+ public long getShostID() {
+ return shostID;
+ }
+
+ public void setShostID(long shostID) {
+ this.shostID = shostID;
+ }
+
+ public SHostVO getShost() {
+ return shost;
+ }
+
+ public void setShost(SHostVO shost) {
+ this.shost = shost;
+ }
+
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+
+ public int getVersioningStatus() {
+ return versioningStatus;
+ }
+
+ public void setVersioningStatus( int versioningStatus ) {
+ this.versioningStatus = versioningStatus;
+ }
+
+ public Set getObjectsInBucket() {
+ return objectsInBucket;
+ }
+
+ public void setObjectsInBucket(Set objectsInBucket) {
+ this.objectsInBucket = objectsInBucket;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if(this == other)
+ return true;
+
+ if(!(other instanceof SBucketVO))
+ return false;
+
+ return getName().equals(((SBucketVO)other).getName());
+ }
+
+ @Override
+ public int hashCode() {
+ return getName().hashCode();
+ }
+}
diff --git a/awsapi/src/com/cloud/bridge/model/SHost.hbm.xml b/awsapi/src/com/cloud/bridge/model/SHost.hbm.xml
deleted file mode 100644
index 5308a0837fd..00000000000
--- a/awsapi/src/com/cloud/bridge/model/SHost.hbm.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/awsapi/src/com/cloud/bridge/model/SHost.java b/awsapi/src/com/cloud/bridge/model/SHost.java
index 758cbbf0930..4ed5b7e45c9 100644
--- a/awsapi/src/com/cloud/bridge/model/SHost.java
+++ b/awsapi/src/com/cloud/bridge/model/SHost.java
@@ -20,17 +20,19 @@ import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
-public class SHost implements Serializable {
- private static final long serialVersionUID = 213346565810468018L;
+public interface SHost {
public static final int STORAGE_HOST_TYPE_LOCAL = 0;
public static final int STORAGE_HOST_TYPE_NFS = 1;
-
- private Long id;
+ public static enum StorageHostType {
+ STORAGE_HOST_TYPE_LOCAL, //0
+ STORAGE_HOST_TYPE_NFS //1
+ }
+/* private Long id;
private String host;
private int hostType;
- private MHost mhost;
+ private MHostVO mhost;
private String exportRoot;
private String userOnHost;
private String userPassword;
@@ -89,11 +91,11 @@ public class SHost implements Serializable {
this.userPassword = userPassword;
}
- public MHost getMhost() {
+ public MHostVO getMhost() {
return mhost;
}
- public void setMhost(MHost mhost) {
+ public void setMhost(MHostVO mhost) {
this.mhost = mhost;
}
@@ -111,5 +113,5 @@ public class SHost implements Serializable {
public void setMounts(Set mounts) {
this.mounts = mounts;
- }
+ }*/
}
diff --git a/awsapi/src/com/cloud/bridge/model/SHostVO.java b/awsapi/src/com/cloud/bridge/model/SHostVO.java
new file mode 100644
index 00000000000..f3d2a5801b6
--- /dev/null
+++ b/awsapi/src/com/cloud/bridge/model/SHostVO.java
@@ -0,0 +1,152 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.bridge.model;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name="shost")
+public class SHostVO implements SHost{
+ private static final long serialVersionUID = 213346565810468018L;
+
+ public static final int STORAGE_HOST_TYPE_LOCAL = 0;
+ public static final int STORAGE_HOST_TYPE_NFS = 1;
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
+ private Long id;
+
+ @Column(name="Host")
+ private String host;
+
+ @Column(name="HostType")
+ private int hostType;
+
+ @Column(name="MHostID")
+ private long mhostid;
+
+ @Column(name="ExportRoot")
+ private String exportRoot;
+
+ @Column(name="UserOnHost")
+ private String userOnHost;
+
+ @Column(name="UserPassword")
+ private String userPassword;
+
+ @Transient
+ private MHostVO mhost;
+
+ @Transient
+ private Set buckets = new HashSet();
+
+ @Transient
+ private Set mounts = new HashSet();
+
+ public SHostVO() {
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ private void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getHostType() {
+ return hostType;
+ }
+
+ public void setHostType(int hostType) {
+ this.hostType = hostType;
+ }
+
+ public long getMhostid() {
+ return mhostid;
+ }
+
+ public void setMhostid(long mhostid) {
+ this.mhostid = mhostid;
+ }
+
+ public String getExportRoot() {
+ return exportRoot;
+ }
+
+ public void setExportRoot(String exportRoot) {
+ this.exportRoot = exportRoot;
+ }
+
+ public String getUserOnHost() {
+ return userOnHost;
+ }
+
+ public void setUserOnHost(String userOnHost) {
+ this.userOnHost = userOnHost;
+ }
+
+ public String getUserPassword() {
+ return userPassword;
+ }
+
+ public void setUserPassword(String userPassword) {
+ this.userPassword = userPassword;
+ }
+
+ public MHostVO getMhost() {
+ return mhost;
+ }
+
+ public void setMhost(MHostVO mhost) {
+ this.mhost = mhost;
+ }
+
+ public Set getBuckets() {
+ return buckets;
+ }
+
+ public void setBuckets(Set buckets) {
+ this.buckets = buckets;
+ }
+
+ public Set getMounts() {
+ return mounts;
+ }
+
+ public void setMounts(Set mounts) {
+ this.mounts = mounts;
+ }
+}
diff --git a/awsapi/src/com/cloud/bridge/model/SMeta.hbm.xml b/awsapi/src/com/cloud/bridge/model/SMeta.hbm.xml
deleted file mode 100644
index 0f3b12be7f7..00000000000
--- a/awsapi/src/com/cloud/bridge/model/SMeta.hbm.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/awsapi/src/com/cloud/bridge/model/SMeta.java b/awsapi/src/com/cloud/bridge/model/SMetaVO.java
similarity index 74%
rename from awsapi/src/com/cloud/bridge/model/SMeta.java
rename to awsapi/src/com/cloud/bridge/model/SMetaVO.java
index 2c985710ae4..537310fc8f7 100644
--- a/awsapi/src/com/cloud/bridge/model/SMeta.java
+++ b/awsapi/src/com/cloud/bridge/model/SMetaVO.java
@@ -18,18 +18,36 @@ package com.cloud.bridge.model;
import java.io.Serializable;
-public class SMeta implements Serializable {
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="meta")
+public class SMetaVO implements Serializable {
private static final long serialVersionUID = 7459503272337054283L;
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
private Long id;
+
+ @Column(name="Target")
private String target;
+
+ @Column(name="TargetID")
private long targetId;
+ @Column(name="Name")
private String name;
- private String value;
- public SMeta() {
- }
+ @Column(name="Value")
+ private String value;
+
+ public SMetaVO() {}
public Long getId() {
return id;
@@ -76,11 +94,11 @@ public class SMeta implements Serializable {
if(this == other)
return true;
- if(!(other instanceof SMeta))
+ if(!(other instanceof SMetaVO))
return false;
- return getTarget().equals(((SMeta)other).getTarget()) && getTargetId() == ((SMeta)other).getTargetId()
- && getName().equals(((SMeta)other).getName());
+ return getTarget().equals(((SMetaVO)other).getTarget()) && getTargetId() == ((SMetaVO)other).getTargetId()
+ && getName().equals(((SMetaVO)other).getName());
}
@Override
diff --git a/awsapi/src/com/cloud/bridge/model/SObject.hbm.xml b/awsapi/src/com/cloud/bridge/model/SObject.hbm.xml
deleted file mode 100644
index 3929bcddad7..00000000000
--- a/awsapi/src/com/cloud/bridge/model/SObject.hbm.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/awsapi/src/com/cloud/bridge/model/SObjectItem.hbm.xml b/awsapi/src/com/cloud/bridge/model/SObjectItem.hbm.xml
deleted file mode 100644
index 02297a2afff..00000000000
--- a/awsapi/src/com/cloud/bridge/model/SObjectItem.hbm.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/awsapi/src/com/cloud/bridge/model/SObjectItem.java b/awsapi/src/com/cloud/bridge/model/SObjectItemVO.java
similarity index 67%
rename from awsapi/src/com/cloud/bridge/model/SObjectItem.java
rename to awsapi/src/com/cloud/bridge/model/SObjectItemVO.java
index bbff2679109..8d86103d90b 100644
--- a/awsapi/src/com/cloud/bridge/model/SObjectItem.java
+++ b/awsapi/src/com/cloud/bridge/model/SObjectItemVO.java
@@ -19,22 +19,56 @@ package com.cloud.bridge.model;
import java.io.Serializable;
import java.util.Date;
-public class SObjectItem implements Serializable {
- private static final long serialVersionUID = -7351173256185687851L;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+@Entity
+@Table(name="sobject_item")
+public class SObjectItemVO {
+ private static final long serialVersionUID = -7351173256185687851L;
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
private Long id;
- private SObject theObject;
+ @Column(name="SObjectID")
+ private long sObjectID;
+
+ @Column(name="Version")
private String version;
+
+ @Column(name="MD5")
private String md5;
+
+ @Column(name="StoredPath")
private String storedPath;
+
+ @Column(name="StoredSize")
private long storedSize;
+ @Column(name="CreateTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
private Date createTime;
+
+ @Column(name="LastModifiedTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
private Date lastModifiedTime;
+
+ @Column(name="LastAccessTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
private Date lastAccessTime;
- public SObjectItem() {
+ @Transient
+ private SObjectVO theObject;
+ public SObjectItemVO() {
}
public Long getId() {
@@ -45,14 +79,22 @@ public class SObjectItem implements Serializable {
this.id = id;
}
- public SObject getTheObject() {
+ public SObjectVO getTheObject() {
return theObject;
}
- public void setTheObject(SObject theObject) {
+ public void setTheObject(SObjectVO theObject) {
this.theObject = theObject;
}
+ public long getsObjectID() {
+ return sObjectID;
+ }
+
+ public void setsObjectID(long sObjectID) {
+ this.sObjectID = sObjectID;
+ }
+
public String getVersion() {
return version;
}
@@ -114,22 +156,22 @@ public class SObjectItem implements Serializable {
if(this == other)
return true;
- if(!(other instanceof SObjectItem))
+ if(!(other instanceof SObjectItemVO))
return false;
if(version != null) {
- if(!version.equals(((SObjectItem)other).getVersion()))
+ if(!version.equals(((SObjectItemVO)other).getVersion()))
return false;
} else {
- if(((SObjectItem)other).getVersion() != null)
+ if(((SObjectItemVO)other).getVersion() != null)
return false;
}
if(theObject.getId() != null) {
- if(!theObject.getId().equals(((SObjectItem)other).getTheObject()))
+ if(!theObject.getId().equals(((SObjectItemVO)other).getTheObject()))
return false;
} else {
- if(((SObjectItem)other).getTheObject() != null)
+ if(((SObjectItemVO)other).getTheObject() != null)
return false;
}
return true;
diff --git a/awsapi/src/com/cloud/bridge/model/SObject.java b/awsapi/src/com/cloud/bridge/model/SObjectVO.java
similarity index 68%
rename from awsapi/src/com/cloud/bridge/model/SObject.java
rename to awsapi/src/com/cloud/bridge/model/SObjectVO.java
index 1692b685295..02f576a8b73 100644
--- a/awsapi/src/com/cloud/bridge/model/SObject.java
+++ b/awsapi/src/com/cloud/bridge/model/SObjectVO.java
@@ -16,30 +16,58 @@
// under the License.
package com.cloud.bridge.model;
-import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-public class SObject implements Serializable {
- private static final long serialVersionUID = 8566744941395660486L;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name="sobject")
+public class SObjectVO {
+ //private static final long serialVersionUID = 8566744941395660486L;
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
private Long id;
+ @Column(name="SBucketID")
+ private long bucketID;
+
+ @Column(name="NameKey")
private String nameKey;
+
+ @Column(name="OwnerCanonicalID")
private String ownerCanonicalId;
+ @Column(name="NextSequence")
private int nextSequence;
- private String deletionMark; // This must also a unique ID to give to the REST client
+ @Column(name="DeletionMark")
+ private String deletionMark; // This must also a unique ID to give to the REST client
+
+ @Column(name="CreateTime")
+ @Temporal(value=TemporalType.TIMESTAMP)
private Date createTime;
+ @Transient
private SBucket bucket;
- private Set items = new HashSet();
-
- public SObject() {
+ @Transient
+ private Set items = new HashSet();
+
+ public SObjectVO() {
deletionMark = null;
}
@@ -51,6 +79,14 @@ public class SObject implements Serializable {
this.id = id;
}
+ public long getBucketID() {
+ return bucketID;
+ }
+
+ public void setBucketID(long bucketID) {
+ this.bucketID = bucketID;
+ }
+
public String getNameKey() {
return nameKey;
}
@@ -99,20 +135,20 @@ public class SObject implements Serializable {
this.bucket = bucket;
}
- public Set getItems() {
+ public Set getItems() {
return items;
}
- public void setItems(Set items) {
+ public void setItems(Set items) {
this.items = items;
}
public void deleteItem( long id ) {
- Iterator it = getItems().iterator();
+ Iterator it = getItems().iterator();
while( it.hasNext())
{
- SObjectItem oneItem = it.next();
+ SObjectItemVO oneItem = it.next();
if (id == oneItem.getId()) {
boolean bRemoved = items.remove( oneItem );
System.out.println( "deleteItem from sobject: " + bRemoved );
@@ -121,15 +157,15 @@ public class SObject implements Serializable {
}
}
- public SObjectItem getLatestVersion( boolean versioningOff ) {
- Iterator it = getItems().iterator();
+ public SObjectItemVO getLatestVersion( boolean versioningOff ) {
+ Iterator it = getItems().iterator();
int maxVersion = 0;
int curVersion = 0;
- SObjectItem latestItem = null;
+ SObjectItemVO latestItem = null;
while( it.hasNext())
{
- SObjectItem item = it.next();
+ SObjectItemVO item = it.next();
// If versioning is off then return the item with the null version string (if exists)
// For example, the bucket could have allowed versioning and then it was suspended
@@ -160,12 +196,12 @@ public class SObject implements Serializable {
* @param wantVersion
* @return
*/
- public SObjectItem getVersion( String wantVersion )
+ public SObjectItemVO getVersion( String wantVersion )
{
- Iterator it = getItems().iterator();
+ Iterator it = getItems().iterator();
while( it.hasNext())
{
- SObjectItem item = it.next();
+ SObjectItemVO item = it.next();
String curVersion = item.getVersion();
if (null != curVersion && wantVersion.equalsIgnoreCase( curVersion )) return item;
}
@@ -177,17 +213,17 @@ public class SObject implements Serializable {
if(this == other)
return true;
- if(!(other instanceof SObject))
+ if(!(other instanceof SObjectVO))
return false;
- if(!getNameKey().equals(((SObject)other).getNameKey()))
+ if(!getNameKey().equals(((SObjectVO)other).getNameKey()))
return false;
if(getBucket() != null) {
- if(!getBucket().equals(((SObject)other).getBucket()))
+ if(!getBucket().equals(((SObjectVO)other).getBucket()))
return false;
} else {
- if(((SObject)other).getBucket() != null)
+ if(((SObjectVO)other).getBucket() != null)
return false;
}
diff --git a/awsapi/src/com/cloud/bridge/model/UserCredentials.hbm.xml b/awsapi/src/com/cloud/bridge/model/UserCredentials.hbm.xml
deleted file mode 100644
index d2f39190556..00000000000
--- a/awsapi/src/com/cloud/bridge/model/UserCredentials.hbm.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/awsapi/src/com/cloud/bridge/model/UserCredentials.java b/awsapi/src/com/cloud/bridge/model/UserCredentialsVO.java
similarity index 72%
rename from awsapi/src/com/cloud/bridge/model/UserCredentials.java
rename to awsapi/src/com/cloud/bridge/model/UserCredentialsVO.java
index b674f40c191..dae5fd91fbc 100644
--- a/awsapi/src/com/cloud/bridge/model/UserCredentials.java
+++ b/awsapi/src/com/cloud/bridge/model/UserCredentialsVO.java
@@ -18,17 +18,39 @@ package com.cloud.bridge.model;
import java.io.Serializable;
-public class UserCredentials implements Serializable {
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="usercredentials")
+public class UserCredentialsVO{
private static final long serialVersionUID = 7459503272337054299L;
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="ID")
private Long id;
+
+ @Column(name="AccessKey")
private String accessKey;
+
+ @Column(name="SecretKey")
private String secretKey;
+
+ @Column(name="CertUniqueId")
private String certUniqueId;
- public UserCredentials() {
- }
+ public UserCredentialsVO() { }
+ public UserCredentialsVO(String accessKey, String secretKey) {
+ this.accessKey = accessKey;
+ this.secretKey = secretKey;
+ }
+
public Long getId() {
return id;
}
@@ -65,14 +87,14 @@ public class UserCredentials implements Serializable {
public boolean equals(Object other) {
if (this == other) return true;
- if (!(other instanceof UserCredentials)) return false;
+ if (!(other instanceof UserCredentialsVO)) return false;
// The cert id can be null. The cert is unused in the REST API.
- if ( getAccessKey().equals(((UserCredentials)other).getAccessKey()) &&
- getSecretKey().equals(((UserCredentials)other).getSecretKey()))
+ if ( getAccessKey().equals(((UserCredentialsVO)other).getAccessKey()) &&
+ getSecretKey().equals(((UserCredentialsVO)other).getSecretKey()))
{
String thisCertId = getCertUniqueId();
- String otherCertId = ((UserCredentials)other).getCertUniqueId();
+ String otherCertId = ((UserCredentialsVO)other).getCertUniqueId();
if (null == thisCertId && null == otherCertId) return true;
diff --git a/awsapi/src/com/cloud/bridge/persist/EntityDao.java b/awsapi/src/com/cloud/bridge/persist/EntityDao.java
deleted file mode 100644
index cc4a8c7d818..00000000000
--- a/awsapi/src/com/cloud/bridge/persist/EntityDao.java
+++ /dev/null
@@ -1,118 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.bridge.persist;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-
-import com.cloud.bridge.util.QueryHelper;
-
-/**
- * Provide methods for getting, saving, deleting or updating state per session or, in a given session, returnin a List in
- * response to queryEntities for a particular instantation of the EntityDao generic class, as defined here.
- * Any instantation of EntityDao passes in the class for which it is instantiating. For example a new instance of SBucketDao
- * passes in com.cloud.bridge.model.SBucket as its clazz.
- * Instantiators, providing an Entity definition, are the classes
- * MHostDao,
- * MHostMountDao,
- * SAclDao,
- * SBucketDao,
- * SHostDao,
- * SMetaDao,
- * SObjectDao,
- * SObjectItemDao,
- * CloudStackSvcOfferingDao
- */
-
-public class EntityDao {
- private Class> clazz;
-
- private boolean isCloudStackSession = false;
-
- // Constructor to implement CloudStackSvcOffering: see class CloudStackSvcOfferingDao
- public EntityDao(Class> clazz){
- this(clazz, false);
- }
-
- public EntityDao(Class> clazz, boolean isCloudStackSession) {
- this.clazz = clazz;
- this.isCloudStackSession = isCloudStackSession;
- // Note : beginTransaction can be called multiple times
- // "If a new underlying transaction is required, begin the transaction. Otherwise continue the new work in the
- // context of the existing underlying transaction." from the Hibernate spec
- PersistContext.beginTransaction(isCloudStackSession);
- }
-
- @SuppressWarnings("unchecked")
- public T get(Serializable id) {
- Session session = PersistContext.getSession(isCloudStackSession);
- return (T)session.get(clazz, id);
- }
-
- public T save(T entity) {
- Session session = PersistContext.getSession(isCloudStackSession);
- session.saveOrUpdate(entity);
- return entity;
- }
-
- public T update(T entity) {
- Session session = PersistContext.getSession(isCloudStackSession);
- session.saveOrUpdate(entity);
- return entity;
- }
-
- public void delete(T entity) {
- Session session = PersistContext.getSession(isCloudStackSession);
- session.delete(entity);
- }
-
- public T queryEntity(String hql, Object[] params) {
- Session session = PersistContext.getSession(isCloudStackSession);
- Query query = session.createQuery(hql);
- query.setMaxResults(1);
- QueryHelper.bindParameters(query, params);
- return (T)query.uniqueResult();
- }
-
- public List queryEntities(String hql, Object[] params) {
- Session session = PersistContext.getSession(isCloudStackSession);
- Query query = session.createQuery(hql);
- QueryHelper.bindParameters(query, params);
-
- return (List)query.list();
- }
-
- public List queryEntities(String hql, int offset, int limit, Object[] params) {
- Session session = PersistContext.getSession(isCloudStackSession);
- Query query = session.createQuery(hql);
- QueryHelper.bindParameters(query, params);
- query.setFirstResult(offset);
- query.setMaxResults(limit);
- return (List)query.list();
- }
-
- public int executeUpdate(String hql, Object[] params) {
- Session session = PersistContext.getSession(isCloudStackSession);
- Query query = session.createQuery(hql);
- QueryHelper.bindParameters(query, params);
-
- return query.executeUpdate();
- }
-}
diff --git a/awsapi/src/com/cloud/bridge/persist/GMTDateTimeUserType.java b/awsapi/src/com/cloud/bridge/persist/GMTDateTimeUserType.java
deleted file mode 100644
index cf16233b680..00000000000
--- a/awsapi/src/com/cloud/bridge/persist/GMTDateTimeUserType.java
+++ /dev/null
@@ -1,102 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.bridge.persist;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.Date;
-
-import org.hibernate.HibernateException;
-import org.hibernate.usertype.UserType;
-
-import com.cloud.bridge.util.DateHelper;
-
-/**
- * GMTDateTimeUserType implements a Hibernate user type, it deals with GMT date/time conversion
- * between Java Date/Calendar and MySQL DATE types
- */
-public class GMTDateTimeUserType implements UserType {
-
- private static final int[] SQL_TYPES = { Types.VARBINARY };
-
- public Class> returnedClass() { return Date.class; }
-
- public boolean equals(Object x, Object y) {
- if (x == y)
- return true;
-
- if (x == null || y == null)
- return false;
-
- return x.equals(y);
- }
-
- public int hashCode(Object x) {
- if(x != null)
- return x.hashCode();
-
- return 0;
- }
-
- public Object deepCopy(Object value) {
- if(value != null)
- return ((Date)value).clone();
- return null;
- }
-
- public boolean isMutable() {
- return true;
- }
-
- public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner)
- throws HibernateException, SQLException {
-
- String dateString = resultSet.getString(names[0]);
- if(dateString != null)
- return DateHelper.parseDateString(DateHelper.GMT_TIMEZONE, dateString);
- return null;
- }
-
- public void nullSafeSet(PreparedStatement statement, Object value, int index)
- throws HibernateException, SQLException {
- if (value == null) {
- statement.setNull(index, Types.TIMESTAMP);
- } else {
- Date dt = (Date)value;
- statement.setString(index, DateHelper.getDateDisplayString(DateHelper.GMT_TIMEZONE, dt));
- }
- }
-
- public Object assemble(Serializable cached, Object owner) throws HibernateException {
- return DateHelper.parseDateString(DateHelper.GMT_TIMEZONE, (String)cached);
- }
-
- public Serializable disassemble(Object value) throws HibernateException {
- return DateHelper.getDateDisplayString(DateHelper.GMT_TIMEZONE, (Date)value);
- }
-
- public Object replace(Object original, Object target, Object owner) throws HibernateException {
- return ((Date)original).clone();
- }
-
- public int[] sqlTypes() {
- return SQL_TYPES;
- }
-}
diff --git a/awsapi/src/com/cloud/bridge/persist/PersistContext.java b/awsapi/src/com/cloud/bridge/persist/PersistContext.java
deleted file mode 100644
index 8e5e0de8884..00000000000
--- a/awsapi/src/com/cloud/bridge/persist/PersistContext.java
+++ /dev/null
@@ -1,359 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.bridge.persist;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-
-import com.cloud.bridge.util.CloudSessionFactory;
-import com.cloud.bridge.util.CloudStackSessionFactory;
-import com.cloud.bridge.util.OrderedPair;
-
-/**
- *
- * We use Per-thread based hibernate session and transaction pattern. Transaction will be
- * started implicitly by EntityDao instances and be committed implicitly in the end of
- * request-process cycle. All requests are guarded by a dynamic proxy.
- *
- * We will try to keep transaction management as implicit as we can, so that
- * most of service layer implementation contains business-logic only, all business logic are
- * built on top of domain object model, and all persistent layer handling lie within persist layer
- * in Dao classes.
- *
- * PersistContext class also provides per-thread based registry service and global named-lock service
- */
-public class PersistContext {
- protected final static Logger logger = Logger.getLogger(PersistContext.class);
-
- private static final CloudSessionFactory sessionFactory;
-
- private static final ThreadLocal threadSession = new ThreadLocal();
- private static final ThreadLocal threadTransaction = new ThreadLocal();
- private static final ThreadLocal