You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/08 02:05:21 UTC
[1/3] git commit: api: Refactoring ListEventsCmd and EventResponse,
and create Event db view.
Updated Branches:
refs/heads/api_refactoring 41268d123 -> 30941c2d3
api: Refactoring ListEventsCmd and EventResponse, and create Event db view.
Signed-off-by: Rohit Yadav <bh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/30941c2d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/30941c2d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/30941c2d
Branch: refs/heads/api_refactoring
Commit: 30941c2d31a530a633796a5d7613f07365bb0fe7
Parents: 41268d1
Author: Min Chen <mi...@citrix.com>
Authored: Fri Dec 7 16:22:28 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Fri Dec 7 16:54:45 2012 -0800
----------------------------------------------------------------------
api/src/com/cloud/api/response/EventResponse.java | 26 +-
api/src/com/cloud/api/view/vo/EventJoinVO.java | 331 +++++++
.../com/cloud/api/view/vo/ResourceTagJoinVO.java | 18 +-
.../com/cloud/api/view/vo/SecurityGroupJoinVO.java | 19 +-
api/src/com/cloud/server/ManagementService.java | 3 +-
.../apache/cloudstack/api/ResponseGenerator.java | 3 +
.../api/user/event/command/ListEventsCmd.java | 14 +-
server/src/com/cloud/api/ApiDBUtils.java | 34 +-
server/src/com/cloud/api/ApiResponseHelper.java | 111 ++--
server/src/com/cloud/api/ApiServer.java | 48 +-
.../configuration/DefaultComponentLibrary.java | 4 +-
server/src/com/cloud/event/dao/EventJoinDao.java | 40 +
.../src/com/cloud/event/dao/EventJoinDaoImpl.java | 155 +++
.../src/com/cloud/server/ManagementServerImpl.java | 720 ++++++++-------
.../com/cloud/tags/TaggedResourceManagerImpl.java | 88 +-
.../com/cloud/tags/dao/ResourceTagJoinDaoImpl.java | 8 +-
setup/db/create-schema.sql | 33 +
17 files changed, 1147 insertions(+), 508 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/api/src/com/cloud/api/response/EventResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/EventResponse.java b/api/src/com/cloud/api/response/EventResponse.java
index b8b5dfd..990f196 100644
--- a/api/src/com/cloud/api/response/EventResponse.java
+++ b/api/src/com/cloud/api/response/EventResponse.java
@@ -25,9 +25,9 @@ import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
-public class EventResponse extends BaseResponse implements ControlledEntityResponse{
+public class EventResponse extends BaseResponse implements ControlledViewEntityResponse{
@SerializedName(ApiConstants.ID) @Param(description="the ID of the event")
- private IdentityProxy id = new IdentityProxy("event");
+ private String id;
@SerializedName(ApiConstants.USERNAME) @Param(description="the name of the user who performed the action (can be different from the account if an admin is performing an action for a user, e.g. starting/stopping a user's virtual machine)")
private String username;
@@ -45,13 +45,13 @@ public class EventResponse extends BaseResponse implements ControlledEntityRespo
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the ipaddress")
- private IdentityProxy projectId = new IdentityProxy("projects");
+ private String projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the address")
private String projectName;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the id of the account's domain")
- private IdentityProxy domainId = new IdentityProxy("domain");
+ private String domainId;
@SerializedName(ApiConstants.DOMAIN) @Param(description="the name of the account's domain")
private String domainName;
@@ -63,10 +63,10 @@ public class EventResponse extends BaseResponse implements ControlledEntityRespo
private Event.State state;
@SerializedName("parentid") @Param(description="whether the event is parented")
- private IdentityProxy parentId = new IdentityProxy("event");
+ private String parentId;
- public void setId(Long id) {
- this.id.setValue(id);
+ public void setId(String id) {
+ this.id = id;
}
public void setUsername(String username) {
@@ -91,8 +91,8 @@ public class EventResponse extends BaseResponse implements ControlledEntityRespo
}
@Override
- public void setDomainId(Long domainId) {
- this.domainId.setValue(domainId);
+ public void setDomainId(String domainId) {
+ this.domainId = domainId;
}
@Override
@@ -108,13 +108,13 @@ public class EventResponse extends BaseResponse implements ControlledEntityRespo
this.state = state;
}
- public void setParentId(Long parentId) {
- this.parentId.setValue(parentId);
+ public void setParentId(String parentId) {
+ this.parentId = parentId;
}
@Override
- public void setProjectId(Long projectId) {
- this.projectId.setValue(projectId);
+ public void setProjectId(String projectId) {
+ this.projectId = projectId;
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/api/src/com/cloud/api/view/vo/EventJoinVO.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/view/vo/EventJoinVO.java b/api/src/com/cloud/api/view/vo/EventJoinVO.java
new file mode 100644
index 0000000..00e4d20
--- /dev/null
+++ b/api/src/com/cloud/api/view/vo/EventJoinVO.java
@@ -0,0 +1,331 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.view.vo;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Table;
+
+import com.cloud.utils.db.GenericDao;
+import com.cloud.event.Event.State;
+
+@Entity
+@Table(name="event_view")
+public class EventJoinVO implements ControlledViewEntity {
+
+ @Column(name="id", updatable=false, nullable = false)
+ private long id;
+
+ @Column(name="uuid")
+ private String uuid;
+
+ @Column(name="type")
+ private String type;
+
+ @Enumerated(value=EnumType.STRING)
+ @Column(name="state")
+ private State state;
+
+ @Column(name="description")
+ private String description;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ private Date createDate;
+
+ @Column(name="user_id")
+ private long userId;
+
+ @Column(name="user_name")
+ private String userName;
+
+ @Column(name="level")
+ private String level;
+
+ @Column(name="start_id")
+ private long startId;
+
+ @Column(name="start_uuid")
+ private String startUuid;
+
+ @Column(name="parameters", length=1024)
+ private String parameters;
+
+
+ @Column(name="account_id")
+ private long accountId;
+
+ @Column(name="account_uuid")
+ private String accountUuid;
+
+ @Column(name="account_name")
+ private String accountName = null;
+
+ @Column(name="account_type")
+ private short accountType;
+
+ @Column(name="domain_id")
+ private long domainId;
+
+ @Column(name="domain_uuid")
+ private String domainUuid;
+
+ @Column(name="domain_name")
+ private String domainName = null;
+
+ @Column(name="domain_path")
+ private String domainPath = null;
+
+ @Column(name="project_id")
+ private long projectId;
+
+ @Column(name="project_uuid")
+ private String projectUuid;
+
+ @Column(name="project_name")
+ private String projectName;
+
+
+
+ public EventJoinVO() {
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+
+ @Override
+ public long getAccountId() {
+ return accountId;
+ }
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+ @Override
+ public String getAccountUuid() {
+ return accountUuid;
+ }
+
+ public void setAccountUuid(String accountUuid) {
+ this.accountUuid = accountUuid;
+ }
+
+ @Override
+ public String getAccountName() {
+ return accountName;
+ }
+
+ public void setAccountName(String accountName) {
+ this.accountName = accountName;
+ }
+
+ @Override
+ public short getAccountType() {
+ return accountType;
+ }
+
+ public void setAccountType(short accountType) {
+ this.accountType = accountType;
+ }
+
+ @Override
+ public long getDomainId() {
+ return domainId;
+ }
+
+ public void setDomainId(long domainId) {
+ this.domainId = domainId;
+ }
+
+ @Override
+ public String getDomainUuid() {
+ return domainUuid;
+ }
+
+ public void setDomainUuid(String domainUuid) {
+ this.domainUuid = domainUuid;
+ }
+
+ @Override
+ public String getDomainName() {
+ return domainName;
+ }
+
+ public void setDomainName(String domainName) {
+ this.domainName = domainName;
+ }
+
+ @Override
+ public String getDomainPath() {
+ return domainPath;
+ }
+
+ public void setDomainPath(String domainPath) {
+ this.domainPath = domainPath;
+ }
+
+ public long getProjectId() {
+ return projectId;
+ }
+
+ public void setProjectId(long projectId) {
+ this.projectId = projectId;
+ }
+
+ @Override
+ public String getProjectUuid() {
+ return projectUuid;
+ }
+
+ public void setProjectUuid(String projectUuid) {
+ this.projectUuid = projectUuid;
+ }
+
+ @Override
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+
+
+
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ public void setState(State state) {
+ this.state = state;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Date getCreateDate() {
+ return createDate;
+ }
+
+ public void setCreateDate(Date createDate) {
+ this.createDate = createDate;
+ }
+
+ public long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(long userId) {
+ this.userId = userId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getLevel() {
+ return level;
+ }
+
+ public void setLevel(String level) {
+ this.level = level;
+ }
+
+ public long getStartId() {
+ return startId;
+ }
+
+ public void setStartId(long startId) {
+ this.startId = startId;
+ }
+
+
+ public String getStartUuid() {
+ return startUuid;
+ }
+
+ public void setStartUuid(String startUuid) {
+ this.startUuid = startUuid;
+ }
+
+ public String getParameters() {
+ return parameters;
+ }
+
+ public void setParameters(String parameters) {
+ this.parameters = parameters;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (id ^ (id >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ EventJoinVO other = (EventJoinVO) obj;
+ if (id != other.id)
+ return false;
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/api/src/com/cloud/api/view/vo/ResourceTagJoinVO.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/view/vo/ResourceTagJoinVO.java b/api/src/com/cloud/api/view/vo/ResourceTagJoinVO.java
index 070720b..2237119 100644
--- a/api/src/com/cloud/api/view/vo/ResourceTagJoinVO.java
+++ b/api/src/com/cloud/api/view/vo/ResourceTagJoinVO.java
@@ -16,22 +16,13 @@
// under the License.
package com.cloud.api.view.vo;
-import java.net.URI;
-import java.util.Date;
-
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
-import com.cloud.network.Network.GuestType;
-import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.router.VirtualRouter.RedundantState;
-import com.cloud.network.security.SecurityRule.SecurityRuleType;
import com.cloud.server.ResourceTag.TaggedResourceType;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.vm.VirtualMachine.State;
@Entity
@Table(name="resource_tag_view")
@@ -121,6 +112,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity {
}
+ @Override
public long getAccountId() {
return accountId;
}
@@ -129,6 +121,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity {
this.accountId = accountId;
}
+ @Override
public String getAccountUuid() {
return accountUuid;
}
@@ -137,6 +130,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity {
this.accountUuid = accountUuid;
}
+ @Override
public String getAccountName() {
return accountName;
}
@@ -145,6 +139,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity {
this.accountName = accountName;
}
+ @Override
public short getAccountType() {
return accountType;
}
@@ -153,6 +148,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity {
this.accountType = accountType;
}
+ @Override
public long getDomainId() {
return domainId;
}
@@ -170,6 +166,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity {
this.domainUuid = domainUuid;
}
+ @Override
public String getDomainName() {
return domainName;
}
@@ -178,6 +175,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity {
this.domainName = domainName;
}
+ @Override
public String getDomainPath() {
return domainPath;
}
@@ -194,6 +192,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity {
this.projectId = projectId;
}
+ @Override
public String getProjectUuid() {
return projectUuid;
}
@@ -202,6 +201,7 @@ public class ResourceTagJoinVO implements ControlledViewEntity {
this.projectUuid = projectUuid;
}
+ @Override
public String getProjectName() {
return projectName;
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/api/src/com/cloud/api/view/vo/SecurityGroupJoinVO.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/view/vo/SecurityGroupJoinVO.java b/api/src/com/cloud/api/view/vo/SecurityGroupJoinVO.java
index c679d3d..cd4c738 100644
--- a/api/src/com/cloud/api/view/vo/SecurityGroupJoinVO.java
+++ b/api/src/com/cloud/api/view/vo/SecurityGroupJoinVO.java
@@ -5,7 +5,7 @@
// 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,
@@ -16,22 +16,14 @@
// under the License.
package com.cloud.api.view.vo;
-import java.net.URI;
-import java.util.Date;
-
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
-import com.cloud.network.Network.GuestType;
-import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.router.VirtualRouter.RedundantState;
import com.cloud.network.security.SecurityRule.SecurityRuleType;
import com.cloud.server.ResourceTag.TaggedResourceType;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.vm.VirtualMachine.State;
@Entity
@Table(name="security_group_view")
@@ -173,6 +165,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity {
this.name = name;
}
+ @Override
public long getAccountId() {
return accountId;
}
@@ -181,6 +174,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity {
this.accountId = accountId;
}
+ @Override
public String getAccountUuid() {
return accountUuid;
}
@@ -189,6 +183,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity {
this.accountUuid = accountUuid;
}
+ @Override
public String getAccountName() {
return accountName;
}
@@ -197,6 +192,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity {
this.accountName = accountName;
}
+ @Override
public short getAccountType() {
return accountType;
}
@@ -205,6 +201,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity {
this.accountType = accountType;
}
+ @Override
public long getDomainId() {
return domainId;
}
@@ -222,6 +219,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity {
this.domainUuid = domainUuid;
}
+ @Override
public String getDomainName() {
return domainName;
}
@@ -230,6 +228,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity {
this.domainName = domainName;
}
+ @Override
public String getDomainPath() {
return domainPath;
}
@@ -246,6 +245,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity {
this.projectId = projectId;
}
+ @Override
public String getProjectUuid() {
return projectUuid;
}
@@ -254,6 +254,7 @@ public class SecurityGroupJoinVO implements ControlledViewEntity {
this.projectUuid = projectUuid;
}
+ @Override
public String getProjectName() {
return projectName;
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/api/src/com/cloud/server/ManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index 5ee9054..75064bf 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -63,6 +63,7 @@ import org.apache.cloudstack.api.user.vmgroup.command.UpdateVMGroupCmd;
import org.apache.cloudstack.api.admin.systemvm.command.UpgradeSystemVMCmd;
import org.apache.cloudstack.api.admin.resource.command.UploadCustomCertificateCmd;
import com.cloud.api.view.vo.DomainRouterJoinVO;
+import com.cloud.api.view.vo.EventJoinVO;
import com.cloud.async.AsyncJob;
import com.cloud.capacity.Capacity;
import com.cloud.configuration.Configuration;
@@ -174,7 +175,7 @@ public interface ManagementService {
* @param c
* @return List of Events.
*/
- List<? extends Event> searchForEvents(ListEventsCmd c);
+ Pair<List<EventJoinVO>, Integer> searchForEvents(ListEventsCmd c);
/**
* Obtains a list of routers by the specified search criteria. Can search by: "userId", "name", "state",
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/api/src/org/apache/cloudstack/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
index 4f0c804..c247e34 100755
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -153,6 +153,7 @@ import com.cloud.user.UserAccount;
import com.cloud.uservm.UserVm;
import com.cloud.vm.InstanceGroup;
import com.cloud.api.view.vo.DomainRouterJoinVO;
+import com.cloud.api.view.vo.EventJoinVO;
import com.cloud.api.view.vo.ResourceTagJoinVO;
import com.cloud.api.view.vo.SecurityGroupJoinVO;
import com.cloud.api.view.vo.UserVmJoinVO;
@@ -262,6 +263,8 @@ public interface ResponseGenerator {
EventResponse createEventResponse(Event event);
+ List<EventResponse> createEventResponse(EventJoinVO... events);
+
TemplateResponse createIsoResponse(VirtualMachineTemplate result);
List<CapacityResponse> createCapacityResponse(List<? extends Capacity> result, DecimalFormat format);
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/api/src/org/apache/cloudstack/api/user/event/command/ListEventsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/event/command/ListEventsCmd.java b/api/src/org/apache/cloudstack/api/user/event/command/ListEventsCmd.java
index 56f1626..a16252d 100755
--- a/api/src/org/apache/cloudstack/api/user/event/command/ListEventsCmd.java
+++ b/api/src/org/apache/cloudstack/api/user/event/command/ListEventsCmd.java
@@ -29,7 +29,11 @@ import org.apache.cloudstack.api.Implementation;
import org.apache.cloudstack.api.Parameter;
import com.cloud.api.response.EventResponse;
import com.cloud.api.response.ListResponse;
+import com.cloud.api.response.ResourceTagResponse;
+import com.cloud.api.view.vo.EventJoinVO;
+import com.cloud.api.view.vo.ResourceTagJoinVO;
import com.cloud.event.Event;
+import com.cloud.utils.Pair;
@Implementation(description="A command to list events.", responseObject=EventResponse.class)
public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -106,14 +110,10 @@ public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd {
@Override
public void execute(){
- List<? extends Event> result = _mgr.searchForEvents(this);
+ Pair<List<EventJoinVO>, Integer> result = _mgr.searchForEvents(this);
ListResponse<EventResponse> response = new ListResponse<EventResponse>();
- List<EventResponse> eventResponses = new ArrayList<EventResponse>();
- for (Event event : result) {
- eventResponses.add(_responseGenerator.createEventResponse(event));
- }
-
- response.setResponses(eventResponses);
+ List<EventResponse> eventResponses = _responseGenerator.createEventResponse(result.first().toArray(new EventJoinVO[result.first().size()]));
+ response.setResponses(eventResponses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index b537bcb..3d232c6 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -5,7 +5,7 @@
// 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,
@@ -24,10 +24,12 @@ import java.util.Set;
import org.apache.cloudstack.api.ApiConstants.VMDetails;
import com.cloud.api.response.DomainRouterResponse;
+import com.cloud.api.response.EventResponse;
import com.cloud.api.response.ResourceTagResponse;
import com.cloud.api.response.SecurityGroupResponse;
import com.cloud.api.response.UserVmResponse;
import com.cloud.api.view.vo.DomainRouterJoinVO;
+import com.cloud.api.view.vo.EventJoinVO;
import com.cloud.api.view.vo.ResourceTagJoinVO;
import com.cloud.api.view.vo.SecurityGroupJoinVO;
import com.cloud.api.view.vo.UserVmJoinVO;
@@ -53,6 +55,8 @@ import com.cloud.dc.dao.HostPodDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.domain.DomainVO;
import com.cloud.domain.dao.DomainDao;
+import com.cloud.event.Event;
+import com.cloud.event.dao.EventJoinDao;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.ha.HighAvailabilityManager;
import com.cloud.host.Host;
@@ -247,6 +251,7 @@ public class ApiDBUtils {
private static AutoScalePolicyDao _asPolicyDao;
private static CounterDao _counterDao;
private static ResourceTagJoinDao _tagJoinDao;
+ private static EventJoinDao _eventJoinDao;
static {
_ms = (ManagementServer) ComponentLocator.getComponent(ManagementServer.Name);
@@ -317,6 +322,7 @@ public class ApiDBUtils {
_asVmGroupPolicyMapDao = locator.getDao(AutoScaleVmGroupPolicyMapDao.class);
_counterDao = locator.getDao(CounterDao.class);
_tagJoinDao = locator.getDao(ResourceTagJoinDao.class);
+ _eventJoinDao = locator.getDao(EventJoinDao.class);
// Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
_statsCollector = StatsCollector.getInstance();
@@ -621,11 +627,11 @@ public class ApiDBUtils {
public static Site2SiteVpnGatewayVO findVpnGatewayById(Long vpnGatewayId) {
return _site2SiteVpnGatewayDao.findById(vpnGatewayId);
}
-
- public static Site2SiteCustomerGatewayVO findCustomerGatewayById(Long customerGatewayId) {
+
+ public static Site2SiteCustomerGatewayVO findCustomerGatewayById(Long customerGatewayId) {
return _site2SiteCustomerGatewayDao.findById(customerGatewayId);
}
-
+
public static List<UserVO> listUsersByAccount(long accountId) {
return _userDao.listByAccount(accountId);
}
@@ -775,11 +781,11 @@ public class ApiDBUtils {
public static Project findProjectByProjectAccountId(long projectAccountId) {
return _projectMgr.findByProjectAccountId(projectAccountId);
}
-
+
public static Project findProjectByProjectAccountIdIncludingRemoved(long projectAccountId) {
return _projectMgr.findByProjectAccountIdIncludingRemoved(projectAccountId);
}
-
+
public static Project findProjectById(long projectId) {
return _projectMgr.getProject(projectId);
}
@@ -833,15 +839,15 @@ public class ApiDBUtils {
public static String getHaTag() {
return _haMgr.getHaTag();
}
-
+
public static Map<Service, Set<Provider>> listVpcOffServices(long vpcOffId) {
return _vpcMgr.getVpcOffSvcProvidersMap(vpcOffId);
}
-
+
public static List<? extends Network> listVpcNetworks(long vpcId) {
return _networkMgr.listNetworksByVpc(vpcId);
}
-
+
public static boolean canUseForDeploy(Network network) {
return _networkMgr.canUseForDeploy(network);
}
@@ -849,7 +855,7 @@ public class ApiDBUtils {
public static String getUuid(String resourceId, TaggedResourceType resourceType) {
return _taggedResourceService.getUuid(resourceId, resourceType);
}
-
+
public static boolean isOfferingForVpc(NetworkOffering offering) {
boolean vpcProvider = _configMgr.isOfferingForVpc(offering);
return vpcProvider;
@@ -970,4 +976,12 @@ public class ApiDBUtils {
return null;
}
}
+
+ public static EventResponse newEventResponse(EventJoinVO ve) {
+ return _eventJoinDao.newEventResponse(ve);
+ }
+
+ public static EventJoinVO newEventView(Event e){
+ return _eventJoinDao.newEventView(e);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 7bb2f5e..95d10f4 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -5,7 +5,7 @@
// 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,
@@ -118,6 +118,7 @@ import com.cloud.api.response.VpnUsersResponse;
import com.cloud.api.response.ZoneResponse;
import com.cloud.api.view.vo.DomainRouterJoinVO;
import com.cloud.api.view.vo.ControlledViewEntity;
+import com.cloud.api.view.vo.EventJoinVO;
import com.cloud.api.view.vo.ResourceTagJoinVO;
import com.cloud.api.view.vo.SecurityGroupJoinVO;
import com.cloud.api.view.vo.UserVmJoinVO;
@@ -401,7 +402,7 @@ public class ApiResponseHelper implements ResponseGenerator {
accountResponse.setNetworkLimit(networkLimitDisplay);
accountResponse.setNetworkTotal(networkTotal);
accountResponse.setNetworkAvailable(networkAvail);
-
+
//get resource limits for vpcs
Long vpcLimit = ApiDBUtils.findCorrectResourceLimit(ResourceType.vpc, account.getId());
String vpcLimitDisplay = (accountIsAdmin || vpcLimit == -1) ? "Unlimited" : String.valueOf(vpcLimit);
@@ -423,8 +424,8 @@ public class ApiResponseHelper implements ResponseGenerator {
accountResponse.setDetails(ApiDBUtils.getAccountDetails(account.getId()));
return accountResponse;
}
-
-
+
+
@Override
public UserResponse createUserResponse(UserAccount user) {
UserResponse userResponse = new UserResponse();
@@ -1080,7 +1081,7 @@ public class ApiResponseHelper implements ResponseGenerator {
volResponse.setVolumeType(volume.getVolumeType().toString());
volResponse.setDeviceId(volume.getDeviceId());
-
+
Long instanceId = volume.getInstanceId();
if (instanceId != null && volume.getState() != Volume.State.Destroy) {
VMInstanceVO vm = ApiDBUtils.findVMInstanceById(instanceId);
@@ -1169,8 +1170,8 @@ public class ApiResponseHelper implements ResponseGenerator {
// return hypervisor for ROOT and Resource domain only
Account caller = UserContext.current().getCaller();
- if ((caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) && volume.getState() != Volume.State.UploadOp) {
- volResponse.setHypervisor(ApiDBUtils.getVolumeHyperType(volume.getId()).toString());
+ if ((caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) && volume.getState() != Volume.State.UploadOp) {
+ volResponse.setHypervisor(ApiDBUtils.getVolumeHyperType(volume.getId()).toString());
}
volResponse.setAttached(volume.getAttached());
@@ -1182,7 +1183,7 @@ public class ApiResponseHelper implements ResponseGenerator {
isExtractable = template.isExtractable() && template.getTemplateType() != Storage.TemplateType.SYSTEM;
}
}
-
+
//set tag information
List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.Volume, volume.getId());
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
@@ -2140,26 +2141,20 @@ public class ApiResponseHelper implements ResponseGenerator {
return createTemplateResponses(templateId, host.getDataCenterId(), true);
}
- @Override
- public EventResponse createEventResponse(Event event) {
- EventResponse responseEvent = new EventResponse();
- responseEvent.setCreated(event.getCreateDate());
- responseEvent.setDescription(event.getDescription());
- responseEvent.setEventType(event.getType());
- responseEvent.setId(event.getId());
- responseEvent.setLevel(event.getLevel());
- responseEvent.setParentId(event.getStartId());
- responseEvent.setState(event.getState());
-
- populateOwner(responseEvent, event);
- User user = ApiDBUtils.findUserById(event.getUserId());
- if (user != null) {
- responseEvent.setUsername(user.getUsername());
+ @Override
+ public List<EventResponse> createEventResponse(EventJoinVO... events) {
+ List<EventResponse> respList = new ArrayList<EventResponse>();
+ for (EventJoinVO vt : events){
+ respList.add(ApiDBUtils.newEventResponse(vt));
}
+ return respList;
+ }
- responseEvent.setObjectName("event");
- return responseEvent;
+ @Override
+ public EventResponse createEventResponse(Event event) {
+ EventJoinVO vEvent = ApiDBUtils.newEventView(event);
+ return ApiDBUtils.newEventResponse(vEvent);
}
private List<CapacityVO> sumCapacities(List<? extends Capacity> hostCapacities) {
@@ -2554,7 +2549,7 @@ public class ApiResponseHelper implements ResponseGenerator {
serviceResponses.add(svcRsp);
}
response.setForVpc(ApiDBUtils.isOfferingForVpc(offering));
-
+
response.setServices(serviceResponses);
response.setObjectName("networkoffering");
return response;
@@ -2598,7 +2593,7 @@ public class ApiResponseHelper implements ResponseGenerator {
}
//return vlan information only to Root admin
response.setVlan(vlan);
-
+
}
DataCenter zone = ApiDBUtils.findZoneById(network.getDataCenterId());
@@ -2715,7 +2710,7 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setDomain(domain.getName());
response.setOwner(ApiDBUtils.getProjectOwner(project.getId()).getAccountName());
-
+
//set tag information
List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.Project, project.getId());
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
@@ -2772,7 +2767,7 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setObjectName("firewallrule");
return response;
}
-
+
@Override
public NetworkACLResponse createNetworkACLResponse(FirewallRule networkACL) {
NetworkACLResponse response = new NetworkACLResponse();
@@ -2802,7 +2797,7 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setIcmpType(networkACL.getIcmpType());
response.setState(stateToSet);
-
+
//set tag information
List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.NetworkACL, networkACL.getId());
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
@@ -2811,7 +2806,7 @@ public class ApiResponseHelper implements ResponseGenerator {
tagResponses.add(tagResponse);
}
response.setTags(tagResponses);
-
+
response.setObjectName("networkacl");
return response;
}
@@ -3164,7 +3159,7 @@ public class ApiResponseHelper implements ResponseGenerator {
return ApiDBUtils.newResourceTagResponse(rto, keyValueOnly);
}
-
+
@Override
public List<ResourceTagResponse> createResourceTagResponse(boolean keyValueOnly, ResourceTagJoinVO... tags) {
List<ResourceTagResponse> respList = new ArrayList<ResourceTagResponse>();
@@ -3208,8 +3203,8 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setObjectName("vpcoffering");
return response;
}
-
-
+
+
@Override
public VpcResponse createVpcResponse(Vpc vpc) {
VpcResponse response = new VpcResponse();
@@ -3243,22 +3238,22 @@ public class ApiResponseHelper implements ResponseGenerator {
serviceResponses.add(svcRsp);
}
-
+
List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
List<? extends Network> networks = ApiDBUtils.listVpcNetworks(vpc.getId());
for (Network network : networks) {
NetworkResponse ntwkRsp = createNetworkResponse(network);
networkResponses.add(ntwkRsp);
}
-
+
DataCenter zone = ApiDBUtils.findZoneById(vpc.getZoneId());
response.setZoneId(vpc.getZoneId());
response.setZoneName(zone.getName());
-
+
response.setNetworks(networkResponses);
response.setServices(serviceResponses);
populateOwner(response, vpc);
-
+
//set tag information
List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.Vpc, vpc.getId());
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
@@ -3284,13 +3279,13 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setZoneName(zone.getName());
response.setAddress(result.getIp4Address());
response.setPhysicalNetworkId(result.getPhysicalNetworkId());
-
+
populateAccount(response, result.getAccountId());
populateDomain(response, result.getDomainId());
response.setState(result.getState().toString());
-
+
response.setObjectName("privategateway");
-
+
return response;
}
@@ -3390,14 +3385,14 @@ public class ApiResponseHelper implements ResponseGenerator {
return response;
}
-
+
@Override
public StaticRouteResponse createStaticRouteResponse(StaticRoute result) {
StaticRouteResponse response = new StaticRouteResponse();
response.setId(result.getId());
response.setVpcId(result.getVpcId());
response.setCidr(result.getCidr());
-
+
StaticRoute.State state = result.getState();
String stateToSet = state.toString();
if (state.equals(FirewallRule.State.Revoke)) {
@@ -3406,7 +3401,7 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setState(stateToSet);
populateAccount(response, result.getAccountId());
populateDomain(response, result.getDomainId());
-
+
//set tag information
List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(TaggedResourceType.StaticRoute, result.getId());
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
@@ -3416,10 +3411,10 @@ public class ApiResponseHelper implements ResponseGenerator {
}
response.setTags(tagResponses);
response.setObjectName("staticroute");
-
+
return response;
}
-
+
@Override
public Site2SiteVpnGatewayResponse createSite2SiteVpnGatewayResponse(Site2SiteVpnGateway result) {
Site2SiteVpnGatewayResponse response = new Site2SiteVpnGatewayResponse();
@@ -3428,7 +3423,7 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setVpcId(result.getVpcId());
response.setRemoved(result.getRemoved());
response.setObjectName("vpngateway");
-
+
populateAccount(response, result.getAccountId());
populateDomain(response, result.getDomainId());
return response;
@@ -3450,10 +3445,10 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setRemoved(result.getRemoved());
response.setObjectName("vpncustomergateway");
-
+
populateAccount(response, result.getAccountId());
populateDomain(response, result.getDomainId());
-
+
return response;
}
@@ -3461,18 +3456,18 @@ public class ApiResponseHelper implements ResponseGenerator {
public Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result) {
Site2SiteVpnConnectionResponse response = new Site2SiteVpnConnectionResponse();
response.setId(result.getId());
-
- response.setVpnGatewayId(result.getVpnGatewayId());
+
+ response.setVpnGatewayId(result.getVpnGatewayId());
Long vpnGatewayId = result.getVpnGatewayId();
if(vpnGatewayId != null) {
Site2SiteVpnGatewayVO vpnGateway = ApiDBUtils.findVpnGatewayById(vpnGatewayId);
-
+
long ipId = vpnGateway.getAddrId();
IPAddressVO ipObj = ApiDBUtils.findIpAddressById(ipId);
- response.setIp(ipObj.getAddress().addr());
+ response.setIp(ipObj.getAddress().addr());
}
-
- response.setCustomerGatewayId(result.getCustomerGatewayId());
+
+ response.setCustomerGatewayId(result.getCustomerGatewayId());
Long customerGatewayId = result.getCustomerGatewayId();
if(customerGatewayId != null) {
Site2SiteCustomerGatewayVO customerGateway = ApiDBUtils.findCustomerGatewayById(customerGatewayId);
@@ -3484,11 +3479,11 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setIkeLifetime(customerGateway.getIkeLifetime());
response.setEspLifetime(customerGateway.getEspLifetime());
response.setDpd(customerGateway.getDpd());
- }
-
+ }
+
populateAccount(response, result.getAccountId());
populateDomain(response, result.getDomainId());
-
+
response.setState(result.getState().toString());
response.setCreated(result.getCreated());
response.setRemoved(result.getRemoved());
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index bacec72..ae12715 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -5,7 +5,7 @@
// 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,
@@ -79,7 +79,9 @@ import org.apache.http.protocol.ResponseServer;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.admin.router.command.ListRoutersCmd;
+import org.apache.cloudstack.api.user.event.command.ListEventsCmd;
import org.apache.cloudstack.api.user.securitygroup.command.ListSecurityGroupsCmd;
+import org.apache.cloudstack.api.user.tag.command.ListTagsCmd;
import org.apache.cloudstack.api.user.vm.command.ListVMsCmd;
import com.cloud.acl.ControlledEntity;
import com.cloud.api.response.ApiResponseSerializer;
@@ -137,7 +139,7 @@ public class ApiServer implements HttpRequestHandler {
private static final DateFormat _dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
@Inject(adapter = APIAccessChecker.class)
protected Adapters<APIAccessChecker> _apiAccessCheckers;
-
+
private static ExecutorService _executor = new ThreadPoolExecutor(10, 150, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("ApiServer"));
@@ -191,7 +193,7 @@ public class ApiServer implements HttpRequestHandler {
if (apiPort != null) {
ListenerThread listenerThread = new ListenerThread(this, apiPort);
listenerThread.start();
- }
+ }
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -246,7 +248,7 @@ public class ApiServer implements HttpRequestHandler {
writeResponse(response, responseText, HttpStatus.SC_OK, responseType, null);
} catch (ServerApiException se) {
- String responseText = getSerializedApiError(se.getErrorCode(), se.getDescription(), parameterMap, responseType, se);
+ String responseText = getSerializedApiError(se.getErrorCode(), se.getDescription(), parameterMap, responseType, se);
writeResponse(response, responseText, se.getErrorCode(), responseType, se.getDescription());
sb.append(" " + se.getErrorCode() + " " + se.getDescription());
} catch (RuntimeException e) {
@@ -325,7 +327,7 @@ public class ApiServer implements HttpRequestHandler {
} catch (Exception ex) {
if (ex instanceof InvalidParameterValueException) {
InvalidParameterValueException ref = (InvalidParameterValueException)ex;
- ServerApiException e = new ServerApiException(BaseCmd.PARAM_ERROR, ex.getMessage());
+ ServerApiException e = new ServerApiException(BaseCmd.PARAM_ERROR, ex.getMessage());
// copy over the IdentityProxy information as well and throw the serverapiexception.
ArrayList<IdentityProxy> idList = ref.getIdProxyList();
if (idList != null) {
@@ -380,11 +382,11 @@ public class ApiServer implements HttpRequestHandler {
} else {
List<ControlledEntity> entitiesToAccess = new ArrayList<ControlledEntity>();
ApiDispatcher.setupParameters(cmdObj, params, entitiesToAccess);
-
+
if(!entitiesToAccess.isEmpty()){
Account owner = s_instance._accountMgr.getActiveAccountById(cmdObj.getEntityOwnerId());
s_instance._accountMgr.checkAccess(caller, null, true, owner);
-
+
s_instance._accountMgr.checkAccess(caller, null, true, (ControlledEntity[])entitiesToAccess.toArray());
}
}
@@ -402,7 +404,7 @@ public class ApiServer implements HttpRequestHandler {
asyncCmd.setStartEventId(startEventId);
// save the scheduled event
- Long eventId = EventUtils.saveScheduledEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId,
+ Long eventId = EventUtils.saveScheduledEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId,
asyncCmd.getEntityOwnerId(), asyncCmd.getEventType(), asyncCmd.getEventDescription(),
startEventId);
if (startEventId == 0) {
@@ -414,8 +416,8 @@ public class ApiServer implements HttpRequestHandler {
ctx.setAccountId(asyncCmd.getEntityOwnerId());
- Long instanceId = (objectId == null) ? asyncCmd.getInstanceId() : objectId;
- AsyncJobVO job = new AsyncJobVO(callerUserId, caller.getId(), cmdObj.getClass().getName(),
+ Long instanceId = (objectId == null) ? asyncCmd.getInstanceId() : objectId;
+ AsyncJobVO job = new AsyncJobVO(callerUserId, caller.getId(), cmdObj.getClass().getName(),
ApiGsonHelper.getBuilder().create().toJson(params), instanceId, asyncCmd.getInstanceType());
long jobId = _asyncMgr.submitAsyncJob(job);
@@ -439,7 +441,9 @@ public class ApiServer implements HttpRequestHandler {
// if the command is of the listXXXCommand, we will need to also return the
// the job id and status if possible
if (cmdObj instanceof BaseListCmd && !(cmdObj instanceof ListVMsCmd) && !(cmdObj instanceof ListRoutersCmd)
- && !(cmdObj instanceof ListSecurityGroupsCmd)) {
+ && !(cmdObj instanceof ListSecurityGroupsCmd)
+ && !(cmdObj instanceof ListTagsCmd)
+ && !(cmdObj instanceof ListEventsCmd)) {
buildAsyncListResponse((BaseListCmd) cmdObj, caller);
}
@@ -653,7 +657,7 @@ public class ApiServer implements HttpRequestHandler {
}
return false;
}
-
+
public Long fetchDomainId(String domainUUID){
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
IdentityDao identityDao = locator.getDao(IdentityDao.class);
@@ -704,19 +708,19 @@ public class ApiServer implements HttpRequestHandler {
if(user.getUuid() != null){
session.setAttribute("user_UUID", user.getUuid());
}
-
+
session.setAttribute("username", userAcct.getUsername());
session.setAttribute("firstname", userAcct.getFirstname());
session.setAttribute("lastname", userAcct.getLastname());
session.setAttribute("accountobj", account);
session.setAttribute("account", account.getAccountName());
-
+
session.setAttribute("domainid", account.getDomainId());
DomainVO domain = (DomainVO) _domainMgr.getDomain(account.getDomainId());
if(domain.getUuid() != null){
session.setAttribute("domain_UUID", domain.getUuid());
}
-
+
session.setAttribute("type", Short.valueOf(account.getType()).toString());
session.setAttribute("registrationtoken", userAcct.getRegistrationToken());
session.setAttribute("registered", new Boolean(userAcct.isRegistered()).toString());
@@ -760,14 +764,14 @@ public class ApiServer implements HttpRequestHandler {
private boolean isCommandAvailable(User user, String commandName) {
boolean isCommandAvailable = false;
-
+
for(APIAccessChecker apichecker : _apiAccessCheckers){
isCommandAvailable = apichecker.canAccessAPI(user, commandName);
}
-
+
return isCommandAvailable;
}
-
+
// FIXME: rather than isError, we might was to pass in the status code to give more flexibility
private void writeResponse(HttpResponse resp, final String responseText, final int statusCode, String responseType, String reasonPhrase) {
try {
@@ -942,7 +946,7 @@ public class ApiServer implements HttpRequestHandler {
for (int i=0; i < idList.size(); i++) {
IdentityProxy id = idList.get(i);
apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName());
- }
+ }
}
// Also copy over the cserror code and the function/layer in which it was thrown.
apiResponse.setCSErrorCode(ref.getCSErrorCode());
@@ -953,7 +957,7 @@ public class ApiServer implements HttpRequestHandler {
for (int i=0; i < idList.size(); i++) {
IdentityProxy id = idList.get(i);
apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName());
- }
+ }
}
// Also copy over the cserror code and the function/layer in which it was thrown.
apiResponse.setCSErrorCode(ref.getCSErrorCode());
@@ -964,7 +968,7 @@ public class ApiServer implements HttpRequestHandler {
for (int i=0; i < idList.size(); i++) {
IdentityProxy id = idList.get(i);
apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName());
- }
+ }
}
// Also copy over the cserror code and the function/layer in which it was thrown.
apiResponse.setCSErrorCode(ref.getCSErrorCode());
@@ -975,7 +979,7 @@ public class ApiServer implements HttpRequestHandler {
responseText = ApiResponseSerializer.toSerializedString(apiResponse, responseType);
} catch (Exception e) {
- s_logger.error("Exception responding to http request", e);
+ s_logger.error("Exception responding to http request", e);
}
return responseText;
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/server/src/com/cloud/configuration/DefaultComponentLibrary.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
index 89313e9..b3ef40a 100755
--- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java
+++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
@@ -5,7 +5,7 @@
// 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,
@@ -209,6 +209,7 @@ import com.cloud.vm.dao.UserVmDaoImpl;
import com.cloud.vm.dao.UserVmJoinDaoImpl;
import com.cloud.vm.dao.UserVmDetailsDaoImpl;
import com.cloud.vm.dao.VMInstanceDaoImpl;
+import com.cloud.event.dao.EventJoinDaoImpl;
public class DefaultComponentLibrary extends ComponentLibraryBase implements ComponentLibrary {
@@ -224,6 +225,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
addDao("DomainRouterJoinDao", DomainRouterJoinDaoImpl.class);
addDao("SecurityGroupJoinDao", SecurityGroupJoinDaoImpl.class);
addDao("ResourceTagJoinDao", ResourceTagJoinDaoImpl.class);
+ addDao("EventJoinDao", EventJoinDaoImpl.class);
ComponentInfo<? extends GenericDao<?, ? extends Serializable>> info = addDao("ServiceOfferingDao", ServiceOfferingDaoImpl.class);
info.addParameter("cache.size", "50");
info.addParameter("cache.time.to.live", "600");
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/server/src/com/cloud/event/dao/EventJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/dao/EventJoinDao.java b/server/src/com/cloud/event/dao/EventJoinDao.java
new file mode 100644
index 0000000..bfdcd09
--- /dev/null
+++ b/server/src/com/cloud/event/dao/EventJoinDao.java
@@ -0,0 +1,40 @@
+// 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.event.dao;
+
+import java.util.List;
+
+import com.cloud.api.response.EventResponse;
+import com.cloud.api.view.vo.EventJoinVO;
+import com.cloud.event.Event;
+import com.cloud.event.EventVO;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.SearchCriteria;
+
+public interface EventJoinDao extends GenericDao<EventJoinVO, Long> {
+
+ EventResponse newEventResponse(EventJoinVO uvo);
+
+ EventJoinVO newEventView(Event vr);
+
+ List<EventJoinVO> searchByIds(Long... ids);
+
+ List<EventJoinVO> searchAllEvents(SearchCriteria<EventJoinVO> sc, Filter filter);
+
+ EventJoinVO findCompletedEvent(long startId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/30941c2d/server/src/com/cloud/event/dao/EventJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/dao/EventJoinDaoImpl.java b/server/src/com/cloud/event/dao/EventJoinDaoImpl.java
new file mode 100644
index 0000000..a00d1b3
--- /dev/null
+++ b/server/src/com/cloud/event/dao/EventJoinDaoImpl.java
@@ -0,0 +1,155 @@
+// 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.event.dao;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.ApiDBUtils;
+import com.cloud.api.ApiResponseHelper;
+import com.cloud.api.response.DomainRouterResponse;
+import com.cloud.api.response.EventResponse;
+import com.cloud.api.response.NicResponse;
+import com.cloud.api.response.ResourceTagResponse;
+import com.cloud.api.response.SecurityGroupResponse;
+import com.cloud.api.response.UserVmResponse;
+import com.cloud.api.view.vo.DomainRouterJoinVO;
+import com.cloud.api.view.vo.EventJoinVO;
+import com.cloud.api.view.vo.ResourceTagJoinVO;
+import com.cloud.dc.DataCenter;
+import com.cloud.event.Event;
+import com.cloud.event.EventVO;
+import com.cloud.event.Event.State;
+import com.cloud.network.Network;
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.projects.Project;
+import com.cloud.server.ResourceTag;
+import com.cloud.user.Account;
+import com.cloud.user.User;
+import com.cloud.uservm.UserVm;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.Attribute;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.JoinBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.vm.NicProfile;
+
+
+@Local(value={EventJoinDao.class})
+public class EventJoinDaoImpl extends GenericDaoBase<EventJoinVO, Long> implements EventJoinDao {
+ public static final Logger s_logger = Logger.getLogger(EventJoinDaoImpl.class);
+
+ private SearchBuilder<EventJoinVO> vrSearch;
+
+ private SearchBuilder<EventJoinVO> vrIdSearch;
+
+ private SearchBuilder<EventJoinVO> CompletedEventSearch;
+
+ protected EventJoinDaoImpl() {
+
+ vrSearch = createSearchBuilder();
+ vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
+ vrSearch.done();
+
+ vrIdSearch = createSearchBuilder();
+ vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+ vrIdSearch.done();
+
+ CompletedEventSearch = createSearchBuilder();
+ CompletedEventSearch.and("state",CompletedEventSearch.entity().getState(),SearchCriteria.Op.EQ);
+ CompletedEventSearch.and("startId", CompletedEventSearch.entity().getStartId(), SearchCriteria.Op.EQ);
+ CompletedEventSearch.done();
+
+
+ this._count = "select count(distinct id) from event_view WHERE ";
+ }
+
+
+
+ @Override
+ public List<EventJoinVO> searchAllEvents(SearchCriteria<EventJoinVO> sc, Filter filter) {
+ return listIncludingRemovedBy(sc, filter);
+ }
+
+
+
+ @Override
+ public EventJoinVO findCompletedEvent(long startId) {
+ SearchCriteria<EventJoinVO> sc = CompletedEventSearch.create();
+ sc.setParameters("state", State.Completed);
+ sc.setParameters("startId", startId);
+ return findOneIncludingRemovedBy(sc);
+ }
+
+
+
+ @Override
+ public EventResponse newEventResponse(EventJoinVO event) {
+ EventResponse responseEvent = new EventResponse();
+ responseEvent.setCreated(event.getCreateDate());
+ responseEvent.setDescription(event.getDescription());
+ responseEvent.setEventType(event.getType());
+ responseEvent.setId(event.getUuid());
+ responseEvent.setLevel(event.getLevel());
+ responseEvent.setParentId(event.getStartUuid());
+ responseEvent.setState(event.getState());
+ responseEvent.setUsername(event.getUserName());
+
+ ApiResponseHelper.populateOwner(responseEvent, event);
+ responseEvent.setObjectName("event");
+ return responseEvent;
+ }
+
+
+
+ @Override
+ public List<EventJoinVO> searchByIds(Long... ids) {
+ SearchCriteria<EventJoinVO> sc = vrSearch.create();
+ sc.setParameters("idIN", ids);
+ return searchIncludingRemoved(sc, null, null, false);
+ }
+
+
+ @Override
+ public EventJoinVO newEventView(Event vr) {
+
+ List<EventJoinVO> uvList = new ArrayList<EventJoinVO>();
+ SearchCriteria<EventJoinVO> sc = vrIdSearch.create();
+ sc.setParameters("id", vr.getId());
+ List<EventJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+ assert vms != null && vms.size() == 1 : "No event found for event id " + vr.getId();
+ return vms.get(0);
+
+ }
+
+}