Updated Branches: refs/heads/master ee1d29c3f -> 850f099aa
adding mock REST app code and related build files Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/0b55e2fb Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/0b55e2fb Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/0b55e2fb Branch: refs/heads/master Commit: 0b55e2fb5d5f10d13ba1a24c9c730a14f4fe38e0 Parents: 8cf82f2 Author: Pradeep Fernando <[email protected]> Authored: Tue Jan 7 14:24:17 2014 +0530 Committer: Pradeep Fernando <[email protected]> Committed: Tue Jan 7 14:24:17 2014 +0530 ---------------------------------------------------------------------- .../org.apache.stratos.rest.endpoint/pom.xml | 30 ++- .../rest/endpoint/mock/StratosTestAdmin.java | 181 +++++++++++++++++++ .../META-INF/webapp-classloading.xml | 35 ++++ .../webapp/stratos-test/WEB-INF/cxf-servlet.xml | 36 ++++ .../main/webapp/stratos-test/WEB-INF/web.xml | 40 ++++ .../stratos/META-INF/webapp-classloading.xml | 35 ++++ .../main/webapp/stratos/WEB-INF/cxf-servlet.xml | 59 ++++++ .../src/main/webapp/stratos/WEB-INF/web.xml | 40 ++++ 8 files changed, 453 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0b55e2fb/components/org.apache.stratos.rest.endpoint/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/pom.xml b/components/org.apache.stratos.rest.endpoint/pom.xml index 0effd27..209007d 100644 --- a/components/org.apache.stratos.rest.endpoint/pom.xml +++ b/components/org.apache.stratos.rest.endpoint/pom.xml @@ -30,8 +30,32 @@ <packaging>war</packaging> <name>Apache Stratos - RESTful admin service module</name> - <build> + <profiles> + <profile> + <id>test</id> + <activation> + <property> + <name>env</name> + <value>test</value> + </property> + </activation> + <properties> + <appName>stratos-test</appName> + </properties> + </profile> + <profile> + <id>prod</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <properties> + <appName>stratos</appName> + </properties> + </profile> + </profiles> + + <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> @@ -48,10 +72,10 @@ <webResources> <resource> <!-- this is relative to the pom.xml directory --> - <directory>src/main/webapp</directory> + <directory>src/main/webapp/${appName}</directory> </resource> </webResources> - <warName>stratos</warName> + <warName>${appName}</warName> </configuration> </plugin> </plugins> http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0b55e2fb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosTestAdmin.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosTestAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosTestAdmin.java new file mode 100644 index 0000000..b76ca5a --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosTestAdmin.java @@ -0,0 +1,181 @@ +/* + * 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.stratos.rest.endpoint.mock; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction; +import org.apache.stratos.rest.endpoint.annotation.SuperTenantService; +import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean; +import org.apache.stratos.rest.endpoint.exception.RestAPIException; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +@Path("/admin/") +public class StratosTestAdmin { + private static Log log = LogFactory.getLog(StratosTestAdmin.class); + + + + @POST + @Path("/cartridge/definition/") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public void deployCartridgeDefinition (CartridgeDefinitionBean cartridgeDefinitionBean) + throws RestAPIException { + log.info("Cartridge definition : " + cartridgeDefinitionBean.toString()); + + } + + + /*@GET + @Path("/cartridge/tenanted/list") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Cartridge[] getAvailableMultiTenantCartridges() throws ADCException { + + } + + @GET + @Path("/cartridge/list") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Cartridge[] getAvailableSingleTenantCartridges() throws ADCException { + List<Cartridge> cartridges = ServiceUtils.getAvailableCartridges(null, false, getConfigContext()); + return cartridges.isEmpty() ? new Cartridge[0] : cartridges.toArray(new Cartridge[cartridges.size()]); + } + + @GET + @Path("/cartridge/list/subscribed") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Cartridge[] getSubscribedCartridges() throws ADCException { + + } + + @POST + @Path("/cartridge/subscribe") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public SubscriptionInfo subscribe(CartridgeInfoBean cartridgeInfoBean) { + + } + + + + + + @POST + @Path("/cartridge/unsubscribe") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public void unsubscribe(String alias){ + + } + + @POST + @Path("/tenant") + @Consumes("application/json") + @Produces("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public String addTenant(TenantInfoBean tenantInfoBean) throws Exception { + + } + + + @PUT + @Path("/tenant") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public void updateTenant(TenantInfoBean tenantInfoBean) throws Exception { + + } + + @GET + @Path("/tenant/{tenantDomain}") + @Consumes("application/json") + @Produces("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public TenantInfoBean getTenant(@PathParam("tenantDomain") String tenantDomain) throws Exception { + + } + + @DELETE + @Path("/tenant/{tenantDomain}") + @Consumes("application/json") + @Produces("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public void deleteTenant(@PathParam("tenantDomain") String tenantDomain) throws Exception { + + } + + + @GET + @Path("/tenant/list") + @Produces("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public TenantInfoBean[] retrieveTenants() throws Exception { + + } + + @GET + @Path("tenant/search/{domain}") + @Consumes("application/json") + @Produces("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public TenantInfoBean[] retrievePartialSearchTenants(@PathParam("domain")String domain) throws Exception { + + } + + + @POST + @Path("tenant/activate/{tenantDomain}") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public void activateTenant(@PathParam("tenantDomain") String tenantDomain) throws Exception { + + + } + + @POST + @Path("tenant/deactivate/{tenantDomain}") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public void deactivateTenant(@PathParam("tenantDomain") String tenantDomain) throws Exception { + + }*/ + +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0b55e2fb/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/META-INF/webapp-classloading.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/META-INF/webapp-classloading.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/META-INF/webapp-classloading.xml new file mode 100644 index 0000000..c62912d --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/META-INF/webapp-classloading.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + # 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. + --> + +<!-- + This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory. +--> +<Classloading xmlns="http://wso2.org/projects/as/classloading"> + + <!-- Parent-first or child-first. Default behaviour is child-first.--> + <ParentFirst>false</ParentFirst> + + <!-- + Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments + Tomcat environment is the default and every webapps gets it even if they didn't specify it. + e.g. If a webapps requires CXF, they will get both Tomcat and CXF. + --> + <Environments>CXF,Carbon</Environments> +</Classloading> http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0b55e2fb/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/cxf-servlet.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/cxf-servlet.xml new file mode 100644 index 0000000..3c80869 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/cxf-servlet.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + # 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. + --> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jaxrs="http://cxf.apache.org/jaxrs" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd + http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> + + <jaxrs:server id="stratosAdmin" address="/"> + <jaxrs:serviceBeans> + <ref bean="stratosRestEndpointTestBean"/> + </jaxrs:serviceBeans> + </jaxrs:server> + + <bean id="stratosRestEndpointTestBean" class="org.apache.stratos.rest.endpoint.services.StratosAdmin"/> + +</beans> http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0b55e2fb/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/web.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/web.xml new file mode 100644 index 0000000..7cef351 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/web.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + # 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. + --> + +<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee + http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> + + <display-name>S2 Admin Endpoint</display-name> + + <servlet> + <servlet-name>StratosAdminEndpoint</servlet-name> + <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>StratosAdminEndpoint</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + +</web-app> + http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0b55e2fb/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/META-INF/webapp-classloading.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/META-INF/webapp-classloading.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/META-INF/webapp-classloading.xml new file mode 100644 index 0000000..c62912d --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/META-INF/webapp-classloading.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + # 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. + --> + +<!-- + This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory. +--> +<Classloading xmlns="http://wso2.org/projects/as/classloading"> + + <!-- Parent-first or child-first. Default behaviour is child-first.--> + <ParentFirst>false</ParentFirst> + + <!-- + Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments + Tomcat environment is the default and every webapps gets it even if they didn't specify it. + e.g. If a webapps requires CXF, they will get both Tomcat and CXF. + --> + <Environments>CXF,Carbon</Environments> +</Classloading> http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0b55e2fb/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml new file mode 100644 index 0000000..dfb7263 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + # 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. + --> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jaxrs="http://cxf.apache.org/jaxrs" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd + http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> + + <jaxrs:server id="stratosAdmin" address="/"> + <jaxrs:serviceBeans> + <ref bean="stratosRestEndpointBean"/> + </jaxrs:serviceBeans> + + <jaxrs:providers> + <ref bean="exceptionHandler"/> + <ref bean="authenticationFilter"/> + <ref bean="authorizationFilter"/> + </jaxrs:providers> + + <!--The below config enables OAuth based authentication/authorization for REST API--> + <!--jaxrs:providers> + <ref bean="OAuthFilter"/> + </jaxrs:providers--> + </jaxrs:server> + + <bean id="stratosRestEndpointBean" class="org.apache.stratos.rest.endpoint.services.StratosAdmin"/> + <bean id="authenticationFilter" class="org.apache.stratos.rest.endpoint.handlers.StratosAuthenticationHandler"/> + <bean id="authorizationFilter" class="org.apache.stratos.rest.endpoint.handlers.StratosAuthorizingHandler"> + <property name="securedObject" ref="stratosRestEndpointBean"/> + </bean> + <bean id="exceptionHandler" class="org.apache.stratos.rest.endpoint.handlers.CustomExceptionMapper"/> + + <!--The below config enables OAuth based authentication/authorization for REST API--> + <!--bean id="OAuthFilter" class="org.apache.stratos.rest.endpoint.handlers.OAuthHandler"> + <property name="password" value="admin"/> + <property name="username" value="admin"/> + <property name="oauthValidationEndpoint" value="https://localhost:9443/services/"/> + </bean--> + +</beans> http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/0b55e2fb/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/web.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/web.xml new file mode 100644 index 0000000..7cef351 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/web.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + # 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. + --> + +<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee + http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> + + <display-name>S2 Admin Endpoint</display-name> + + <servlet> + <servlet-name>StratosAdminEndpoint</servlet-name> + <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>StratosAdminEndpoint</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + +</web-app> +
