api: Rename Validator to Validate, cosmetic fixes Signed-off-by: Rohit Yadav <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/6a112bd6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/6a112bd6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/6a112bd6 Branch: refs/heads/master Commit: 6a112bd64c33ede4fa24c01bde59fe0e9bb3a925 Parents: b00ed17 Author: Rohit Yadav <[email protected]> Authored: Sat Jan 5 16:52:53 2013 -0800 Committer: Rohit Yadav <[email protected]> Committed: Sat Jan 5 16:52:53 2013 -0800 ---------------------------------------------------------------------- api/src/com/cloud/acl/APIAccessChecker.java | 2 +- api/src/org/apache/cloudstack/api/Validate.java | 30 +++++++++++++++++ api/src/org/apache/cloudstack/api/Validator.java | 30 ----------------- server/src/com/cloud/api/ApiDispatcher.java | 11 +++--- 4 files changed, 36 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6a112bd6/api/src/com/cloud/acl/APIAccessChecker.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/acl/APIAccessChecker.java b/api/src/com/cloud/acl/APIAccessChecker.java index caa94f5..9066e74 100644 --- a/api/src/com/cloud/acl/APIAccessChecker.java +++ b/api/src/com/cloud/acl/APIAccessChecker.java @@ -27,6 +27,6 @@ import com.cloud.utils.component.Adapter; * APIAccessChecker checks the ownership and access control to API requests */ public interface APIAccessChecker extends Adapter { - // Interface for checking access to an API for a user + // Interface for checking access to an API for an user boolean canAccessAPI(User user, String apiCommandName) throws PermissionDeniedException; } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6a112bd6/api/src/org/apache/cloudstack/api/Validate.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/Validate.java b/api/src/org/apache/cloudstack/api/Validate.java new file mode 100644 index 0000000..deedda6 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/Validate.java @@ -0,0 +1,30 @@ +// 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; + +import static java.lang.annotation.ElementType.FIELD; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ FIELD }) +public @interface Validate { + Class<?>[] validators() default Object.class; + String description() default ""; +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6a112bd6/api/src/org/apache/cloudstack/api/Validator.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/Validator.java b/api/src/org/apache/cloudstack/api/Validator.java deleted file mode 100644 index 541e01f..0000000 --- a/api/src/org/apache/cloudstack/api/Validator.java +++ /dev/null @@ -1,30 +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 org.apache.cloudstack.api; - -import static java.lang.annotation.ElementType.FIELD; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ FIELD }) -public @interface Validator { - Class<?>[] validators() default Object.class; - String description() default ""; -} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6a112bd6/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 251aab9..ed60ba7 100755 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -396,20 +396,19 @@ public class ApiDispatcher { } for (Field field : fields) { - //plug Services + PlugService plugServiceAnnotation = field.getAnnotation(PlugService.class); if(plugServiceAnnotation != null){ plugService(field, cmd); } - //APITODO: change the checking here + Parameter parameterAnnotation = field.getAnnotation(Parameter.class); if ((parameterAnnotation == null) || !parameterAnnotation.expose()) { continue; } - //ACL checkAccess = field.getAnnotation(ACL.class); - - Validator validators = field.getAnnotation(Validator.class); + //TODO: Annotate @Validate on API Cmd classes, FIXME how to process Validate + Validate validateAnnotation = field.getAnnotation(Validate.class); Object paramObj = unpackedParams.get(parameterAnnotation.name()); if (paramObj == null) { if (parameterAnnotation.required()) { @@ -530,7 +529,7 @@ public class ApiDispatcher { } - //check access on the entities. + //check access on the enstities. } private static Long translateUuidToInternalId(String uuid, Parameter annotation)
