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/04 11:02:55 UTC
[9/55] [abbrv] git commit: api_refactor: refactor event apis
api_refactor: refactor event apis
- Fix refactored apis, mappings in commands*.in
- Fix comments etc.
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/7ac48798
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7ac48798
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7ac48798
Branch: refs/heads/api_refactoring
Commit: 7ac48798b4420a80ff0d2415e070e550a2297b77
Parents: add1b9b
Author: Rohit Yadav <bh...@apache.org>
Authored: Tue Dec 4 00:05:54 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Tue Dec 4 00:05:54 2012 -0800
----------------------------------------------------------------------
.../com/cloud/api/commands/ListEventTypesCmd.java | 60 -------
api/src/com/cloud/api/commands/ListEventsCmd.java | 120 ---------------
api/src/com/cloud/server/ManagementService.java | 2 +-
.../api/user/event/command/ListEventTypesCmd.java | 60 +++++++
.../api/user/event/command/ListEventsCmd.java | 120 +++++++++++++++
client/tomcatconf/commands.properties.in | 4 +-
server/src/com/cloud/api/ApiDispatcher.java | 2 +-
.../src/com/cloud/server/ManagementServerImpl.java | 2 +-
8 files changed, 185 insertions(+), 185 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ac48798/api/src/com/cloud/api/commands/ListEventTypesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListEventTypesCmd.java b/api/src/com/cloud/api/commands/ListEventTypesCmd.java
deleted file mode 100644
index 8d6f21f..0000000
--- a/api/src/com/cloud/api/commands/ListEventTypesCmd.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.Implementation;
-import com.cloud.api.response.EventTypeResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.user.Account;
-
-@Implementation(description = "List Event Types", responseObject = EventTypeResponse.class)
-public class ListEventTypesCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(ListEventTypesCmd.class.getName());
- private static final String s_name = "listeventtypesresponse";
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute() {
- String[] result = _mgr.listEventTypes();
- ListResponse<EventTypeResponse> response = new ListResponse<EventTypeResponse>();
- ArrayList<EventTypeResponse> responses = new ArrayList<EventTypeResponse>();
- if (result != null) {
- for (String eventType : result) {
- EventTypeResponse eventTypeResponse = new EventTypeResponse();
- eventTypeResponse.setName(eventType);
- eventTypeResponse.setObjectName("eventtype");
- responses.add(eventTypeResponse);
- }
- }
- response.setResponses(responses);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ac48798/api/src/com/cloud/api/commands/ListEventsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListEventsCmd.java b/api/src/com/cloud/api/commands/ListEventsCmd.java
deleted file mode 100755
index d0e09e1..0000000
--- a/api/src/com/cloud/api/commands/ListEventsCmd.java
+++ /dev/null
@@ -1,120 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-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.event.Event;
-
-@Implementation(description="A command to list events.", responseObject=EventResponse.class)
-public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd {
- public static final Logger s_logger = Logger.getLogger(ListEventsCmd.class.getName());
-
- private static final String s_name = "listeventsresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="event")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the event")
- private Long id;
-
- @Parameter(name=ApiConstants.DURATION, type=CommandType.INTEGER, description="the duration of the event")
- private Integer duration;
-
- @Parameter(name=ApiConstants.END_DATE, type=CommandType.DATE, description="the end date range of the list you want to retrieve (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")")
- private Date endDate;
-
- @Parameter(name=ApiConstants.ENTRY_TIME, type=CommandType.INTEGER, description="the time the event was entered")
- private Integer entryTime;
-
- @Parameter(name=ApiConstants.LEVEL, type=CommandType.STRING, description="the event level (INFO, WARN, ERROR)")
- private String level;
-
- @Parameter(name=ApiConstants.START_DATE, type=CommandType.DATE, description="the start date range of the list you want to retrieve (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")")
- private Date startDate;
-
- @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="the event type (see event types)")
- private String type;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- public Integer getDuration() {
- return duration;
- }
-
- public Date getEndDate() {
- return endDate;
- }
-
- public Integer getEntryTime() {
- return entryTime;
- }
-
- public String getLevel() {
- return level;
- }
-
- public Date getStartDate() {
- return startDate;
- }
-
- public String getType() {
- return type;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public void execute(){
- List<? extends Event> 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);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ac48798/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 ccb1efa..e2ab658 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -38,7 +38,7 @@ import com.cloud.api.commands.ListCapacityCmd;
import com.cloud.api.commands.ListCfgsByCmd;
import com.cloud.api.commands.ListClustersCmd;
import com.cloud.api.commands.ListDiskOfferingsCmd;
-import com.cloud.api.commands.ListEventsCmd;
+import org.apache.cloudstack.api.user.event.command.ListEventsCmd;
import com.cloud.api.commands.ListGuestOsCategoriesCmd;
import com.cloud.api.commands.ListGuestOsCmd;
import com.cloud.api.commands.ListHostsCmd;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ac48798/api/src/org/apache/cloudstack/api/user/event/command/ListEventTypesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/event/command/ListEventTypesCmd.java b/api/src/org/apache/cloudstack/api/user/event/command/ListEventTypesCmd.java
new file mode 100644
index 0000000..6cb385a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/event/command/ListEventTypesCmd.java
@@ -0,0 +1,60 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.user.event.command;
+
+import java.util.ArrayList;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Implementation;
+import com.cloud.api.response.EventTypeResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.user.Account;
+
+@Implementation(description = "List Event Types", responseObject = EventTypeResponse.class)
+public class ListEventTypesCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(ListEventTypesCmd.class.getName());
+ private static final String s_name = "listeventtypesresponse";
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute() {
+ String[] result = _mgr.listEventTypes();
+ ListResponse<EventTypeResponse> response = new ListResponse<EventTypeResponse>();
+ ArrayList<EventTypeResponse> responses = new ArrayList<EventTypeResponse>();
+ if (result != null) {
+ for (String eventType : result) {
+ EventTypeResponse eventTypeResponse = new EventTypeResponse();
+ eventTypeResponse.setName(eventType);
+ eventTypeResponse.setObjectName("eventtype");
+ responses.add(eventTypeResponse);
+ }
+ }
+ response.setResponses(responses);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ac48798/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
new file mode 100755
index 0000000..56f1626
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/event/command/ListEventsCmd.java
@@ -0,0 +1,120 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.user.event.command;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+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.event.Event;
+
+@Implementation(description="A command to list events.", responseObject=EventResponse.class)
+public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd {
+ public static final Logger s_logger = Logger.getLogger(ListEventsCmd.class.getName());
+
+ private static final String s_name = "listeventsresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @IdentityMapper(entityTableName="event")
+ @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the event")
+ private Long id;
+
+ @Parameter(name=ApiConstants.DURATION, type=CommandType.INTEGER, description="the duration of the event")
+ private Integer duration;
+
+ @Parameter(name=ApiConstants.END_DATE, type=CommandType.DATE, description="the end date range of the list you want to retrieve (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")")
+ private Date endDate;
+
+ @Parameter(name=ApiConstants.ENTRY_TIME, type=CommandType.INTEGER, description="the time the event was entered")
+ private Integer entryTime;
+
+ @Parameter(name=ApiConstants.LEVEL, type=CommandType.STRING, description="the event level (INFO, WARN, ERROR)")
+ private String level;
+
+ @Parameter(name=ApiConstants.START_DATE, type=CommandType.DATE, description="the start date range of the list you want to retrieve (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")")
+ private Date startDate;
+
+ @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="the event type (see event types)")
+ private String type;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public Integer getDuration() {
+ return duration;
+ }
+
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public Integer getEntryTime() {
+ return entryTime;
+ }
+
+ public String getLevel() {
+ return level;
+ }
+
+ public Date getStartDate() {
+ return startDate;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public void execute(){
+ List<? extends Event> 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);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ac48798/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 05f949e..3a549f5 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -214,8 +214,8 @@ deleteZone=com.cloud.api.commands.DeleteZoneCmd;1
listZones=com.cloud.api.commands.ListZonesByCmd;15
#### events commands
-listEvents=com.cloud.api.commands.ListEventsCmd;15
-listEventTypes=com.cloud.api.commands.ListEventTypesCmd;15
+listEvents=org.apache.cloudstack.api.user.event.command.ListEventsCmd;15
+listEventTypes=org.apache.cloudstack.api.user.event.command.ListEventTypesCmd;15
#### alerts commands
listAlerts=com.cloud.api.commands.ListAlertsCmd;3
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ac48798/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java
index 184a071..40847ea 100755
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@ -34,7 +34,7 @@ import org.apache.log4j.Logger;
import com.cloud.acl.ControlledEntity;
import com.cloud.acl.Role;
import org.apache.cloudstack.api.BaseCmd.CommandType;
-import com.cloud.api.commands.ListEventsCmd;
+import org.apache.cloudstack.api.user.event.command.ListEventsCmd;
import com.cloud.async.AsyncCommandQueued;
import com.cloud.async.AsyncJobManager;
import com.cloud.configuration.Config;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7ac48798/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 92a4fbc..e4c357c 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -75,7 +75,7 @@ import com.cloud.api.commands.ListCapacityCmd;
import com.cloud.api.commands.ListCfgsByCmd;
import com.cloud.api.commands.ListClustersCmd;
import com.cloud.api.commands.ListDiskOfferingsCmd;
-import com.cloud.api.commands.ListEventsCmd;
+import org.apache.cloudstack.api.user.event.command.ListEventsCmd;
import com.cloud.api.commands.ListGuestOsCategoriesCmd;
import com.cloud.api.commands.ListGuestOsCmd;
import com.cloud.api.commands.ListHostsCmd;