From e41cb9ff7470f1dc26a70a6e9606513b95c527b3 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Wed, 5 Sep 2012 13:38:32 -0700 Subject: [PATCH] More changes --- .../org/apache/cloudstack/platform/Rules.java | 83 +++++++++++++++++++ .../cloud/entity/api/BackupEntity.java | 29 +++++++ .../service/api/OperationsServices.java | 35 ++++++++ utils/src/com/cloud/utils/fsm/State.java | 26 ++++++ 4 files changed, 173 insertions(+) create mode 100755 platform/api/src/org/apache/cloudstack/platform/Rules.java create mode 100755 platform/api/src/org/apache/cloudstack/platform/cloud/entity/api/BackupEntity.java create mode 100755 platform/api/src/org/apache/cloudstack/platform/service/api/OperationsServices.java create mode 100755 utils/src/com/cloud/utils/fsm/State.java diff --git a/platform/api/src/org/apache/cloudstack/platform/Rules.java b/platform/api/src/org/apache/cloudstack/platform/Rules.java new file mode 100755 index 00000000000..8cb0ff1afcd --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/Rules.java @@ -0,0 +1,83 @@ +/* + * 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.platform; + +import java.util.ArrayList; +import java.util.List; + +import com.cloud.utils.StringUtils; + +/** + * Rules specifies all rules about developing and using CloudStack Orchestration + * Platforms APIs. This class is not actually used in CloudStack Orchestration + * Platform but must be read by all who wants to use and develop against + * CloudStack Orchestration Platform. + * + * Make sure to make changes here when there are changes to how the APIs should + * be used and developed. + * + * Changes to this class must be approved by the maintainer of this project. + * + */ +public class Rules { + public static List whenUsing() { + List rules = new ArrayList(); + return rules; + } + + public static List whenWritingNewApis() { + List rules = new ArrayList(); + rules.add("You may think you're the greatest developer in the " + + "world but every change to the API must be reviewed and approved. "); + rules.add(""); + + + return rules; + } + + private static void printRule(String rule) { + System.out.print("API Rule: "); + String skip = ""; + int brk = 0; + while (true) { + int stop = StringUtils.formatForOutput(rule, brk, 75 - skip.length(), ' '); + if (stop < 0) { + break; + } + System.out.print(skip); + skip = " "; + System.out.println(rule.substring(brk, stop).trim()); + brk = stop; + } + } + + public static void main(String[] args) { + System.out.println("When developing against the CloudStack Orchestration Platform, you must following the following rules:"); + for (String rule : whenUsing()) { + printRule(rule); + } + System.out.println(""); + System.out.println("When writing APIs, you must follow these rules:"); + for (String rule : whenWritingNewApis()) { + printRule(rule); + } + } + +} + diff --git a/platform/api/src/org/apache/cloudstack/platform/cloud/entity/api/BackupEntity.java b/platform/api/src/org/apache/cloudstack/platform/cloud/entity/api/BackupEntity.java new file mode 100755 index 00000000000..8a5edba5341 --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/cloud/entity/api/BackupEntity.java @@ -0,0 +1,29 @@ +/* + * 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.platform.cloud.entity.api; + +import org.apache.cloudstack.platform.entity.api.CloudEntity; + +/** + * @author ahuang + * + */ +public interface BackupEntity extends CloudEntity { + +} diff --git a/platform/api/src/org/apache/cloudstack/platform/service/api/OperationsServices.java b/platform/api/src/org/apache/cloudstack/platform/service/api/OperationsServices.java new file mode 100755 index 00000000000..74dfe1bc000 --- /dev/null +++ b/platform/api/src/org/apache/cloudstack/platform/service/api/OperationsServices.java @@ -0,0 +1,35 @@ +/* + * 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.platform.service.api; + +import java.util.List; + +import com.cloud.async.AsyncJob; + +public interface OperationsServices { + List listJobs(); + + List listJobsInProgress(); + + List listJobsCompleted(Long from); + + List listJobsInWaiting(); + + void cancelJob(String job); +} diff --git a/utils/src/com/cloud/utils/fsm/State.java b/utils/src/com/cloud/utils/fsm/State.java new file mode 100755 index 00000000000..eb618e2b3cd --- /dev/null +++ b/utils/src/com/cloud/utils/fsm/State.java @@ -0,0 +1,26 @@ +/* + * 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.utils.fsm; + +/** + * State represents one state for that object + */ +public interface State { + +}