syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbernha...@apache.org
Subject svn commit: r1435174 - in /syncope/trunk/core/src/main: java/org/apache/syncope/core/services/ java/org/apache/syncope/core/services/impl/ resources/
Date Fri, 18 Jan 2013 15:03:50 GMT
Author: jbernhardt
Date: Fri Jan 18 15:03:50 2013
New Revision: 1435174

URL: http://svn.apache.org/viewvc?rev=1435174&view=rev
Log:
[SYNCOPE-231]
Moved implementation classes to impl sub-package.

Added:
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConfigurationServiceImpl.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ContextAware.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/DummyHTTPServletResponse.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/EntitlementServiceImpl.java
Removed:
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/DummyHTTPServletResponse.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java
Modified:
    syncope/trunk/core/src/main/resources/restContext.xml

Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConfigurationServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConfigurationServiceImpl.java?rev=1435174&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConfigurationServiceImpl.java
(added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConfigurationServiceImpl.java
Fri Jan 18 15:03:50 2013
@@ -0,0 +1,106 @@
+/*
+ * 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.syncope.core.services.impl;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.syncope.client.to.ConfigurationTO;
+import org.apache.syncope.client.to.MailTemplateTO;
+import org.apache.syncope.client.to.ValidatorTO;
+import org.apache.syncope.client.util.CollectionWrapper;
+import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
+import org.apache.syncope.core.rest.controller.ConfigurationController;
+import org.apache.syncope.services.ConfigurationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ConfigurationServiceImpl implements ConfigurationService, ContextAware {
+
+    @Autowired
+    private ConfigurationController configurationController;
+    private UriInfo uriInfo;
+
+    @Override
+    public Response create(final ConfigurationTO configurationTO) {
+        ConfigurationTO created = configurationController.create(new DummyHTTPServletResponse(),
configurationTO);
+        URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
+        return Response.created(location).entity(created).build();
+    }
+
+    @Override
+    public Response dbExport() {
+        configurationController.dbExport(new DummyHTTPServletResponse());
+        // TODO catch output-stream and forward it to response
+        return null;
+    }
+
+    @Override
+    public void delete(final String key) {
+        try {
+            configurationController.delete(key);
+        } catch (MissingConfKeyException e) {
+            throw new NotFoundException(e);
+        }
+    }
+
+    @Override
+    public Set<MailTemplateTO> getMailTemplates() {
+        return CollectionWrapper.wrapMailTemplates(configurationController.getMailTemplates());
+    }
+
+    @Override
+    public Set<ValidatorTO> getValidators() {
+        return CollectionWrapper.wrapValidator(configurationController.getValidators());
+    }
+
+    @Override
+    public List<ConfigurationTO> list() {
+        return configurationController.list(null);
+    }
+
+    @Override
+    public ConfigurationTO read(String key) {
+        try {
+            return configurationController.read(null, key);
+        } catch (MissingConfKeyException e) {
+            throw new NotFoundException(e);
+        }
+    }
+
+    @Override
+    public ConfigurationTO update(String key, ConfigurationTO configurationTO) {
+        try {
+            return configurationController.update(null, configurationTO);
+        } catch (MissingConfKeyException e) {
+            throw new NotFoundException(e);
+        }
+    }
+
+    @Override
+    public void setUriInfo(UriInfo ui) {
+        this.uriInfo = ui;
+    }
+}

Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ContextAware.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ContextAware.java?rev=1435174&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ContextAware.java
(added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ContextAware.java
Fri Jan 18 15:03:50 2013
@@ -0,0 +1,28 @@
+/*
+ * 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.syncope.core.services.impl;
+
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+
+public interface ContextAware {
+
+    @Context
+    void setUriInfo(UriInfo ui);
+}

Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/DummyHTTPServletResponse.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/DummyHTTPServletResponse.java?rev=1435174&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/DummyHTTPServletResponse.java
(added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/DummyHTTPServletResponse.java
Fri Jan 18 15:03:50 2013
@@ -0,0 +1,171 @@
+/*
+ * 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.syncope.core.services.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+public class DummyHTTPServletResponse implements HttpServletResponse {
+
+    @Override
+    public void flushBuffer() throws IOException {
+    }
+
+    @Override
+    public int getBufferSize() {
+        return 0;
+    }
+
+    @Override
+    public String getCharacterEncoding() {
+        return null;
+    }
+
+    @Override
+    public String getContentType() {
+        return null;
+    }
+
+    @Override
+    public Locale getLocale() {
+        return null;
+    }
+
+    @Override
+    public ServletOutputStream getOutputStream() throws IOException {
+        return null;
+    }
+
+    @Override
+    public PrintWriter getWriter() throws IOException {
+        return null;
+    }
+
+    @Override
+    public boolean isCommitted() {
+        return false;
+    }
+
+    @Override
+    public void reset() {
+    }
+
+    @Override
+    public void resetBuffer() {
+    }
+
+    @Override
+    public void setBufferSize(int arg0) {
+    }
+
+    @Override
+    public void setCharacterEncoding(String arg0) {
+    }
+
+    @Override
+    public void setContentLength(int arg0) {
+    }
+
+    @Override
+    public void setContentType(String arg0) {
+    }
+
+    @Override
+    public void setLocale(Locale arg0) {
+    }
+
+    @Override
+    public void addCookie(Cookie arg0) {
+    }
+
+    @Override
+    public void addDateHeader(String arg0, long arg1) {
+    }
+
+    @Override
+    public void addHeader(String arg0, String arg1) {
+    }
+
+    @Override
+    public void addIntHeader(String arg0, int arg1) {
+    }
+
+    @Override
+    public boolean containsHeader(String arg0) {
+        return false;
+    }
+
+    @Override
+    public String encodeRedirectURL(String arg0) {
+        return null;
+    }
+
+    @Override
+    public String encodeRedirectUrl(String arg0) {
+        return null;
+    }
+
+    @Override
+    public String encodeURL(String arg0) {
+        return null;
+    }
+
+    @Override
+    public String encodeUrl(String arg0) {
+        return null;
+    }
+
+    @Override
+    public void sendError(int arg0) throws IOException {
+    }
+
+    @Override
+    public void sendError(int arg0, String arg1) throws IOException {
+    }
+
+    @Override
+    public void sendRedirect(String arg0) throws IOException {
+    }
+
+    @Override
+    public void setDateHeader(String arg0, long arg1) {
+    }
+
+    @Override
+    public void setHeader(String arg0, String arg1) {
+    }
+
+    @Override
+    public void setIntHeader(String arg0, int arg1) {
+    }
+
+    @Override
+    public void setStatus(int arg0) {
+    }
+
+    @Override
+    public void setStatus(int arg0, String arg1) {
+    }
+
+}

Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/EntitlementServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/EntitlementServiceImpl.java?rev=1435174&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/EntitlementServiceImpl.java
(added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/EntitlementServiceImpl.java
Fri Jan 18 15:03:50 2013
@@ -0,0 +1,48 @@
+/*
+ * 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.syncope.core.services.impl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.syncope.client.to.EntitlementTO;
+import org.apache.syncope.client.util.CollectionWrapper;
+import org.apache.syncope.core.rest.controller.AuthenticationController;
+import org.apache.syncope.services.EntitlementService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class EntitlementServiceImpl implements EntitlementService {
+
+    @Autowired
+    private AuthenticationController authenticationController;
+
+    @Override
+    public Set<EntitlementTO> getAllEntitlements() {
+        Set<String> entitlements = new HashSet<String>(authenticationController.listEntitlements());
+        return CollectionWrapper.wrap(entitlements);
+    }
+
+    @Override
+    public Set<EntitlementTO> getMyEntitlements() {
+        Set<String> entitlements = authenticationController.getEntitlements();
+        return CollectionWrapper.wrap(entitlements);
+    }
+}

Modified: syncope/trunk/core/src/main/resources/restContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/restContext.xml?rev=1435174&r1=1435173&r2=1435174&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/restContext.xml (original)
+++ syncope/trunk/core/src/main/resources/restContext.xml Fri Jan 18 15:03:50 2013
@@ -41,7 +41,7 @@ under the License.
    </bean>
   
   <!-- CXF Configuration - BEGINN -->
-   <context:component-scan base-package="org.apache.syncope.core.services" />
+   <context:component-scan base-package="org.apache.syncope.core.services.impl" />
 
    <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
       <property name="depthProperties">



Mime
View raw message