You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/08/02 06:21:33 UTC

syncope git commit: Applying lambdas to all StreamingOutput instances

Repository: syncope
Updated Branches:
  refs/heads/master 2f182750b -> 43c66bfe3


Applying lambdas to all StreamingOutput instances


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/43c66bfe
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/43c66bfe
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/43c66bfe

Branch: refs/heads/master
Commit: 43c66bfe30c15f6c8ba42901098ac5f207624002
Parents: 2f18275
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Aug 2 08:21:27 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Aug 2 08:21:27 2017 +0200

----------------------------------------------------------------------
 .../cxf/service/ConfigurationServiceImpl.java   | 12 ++----------
 .../cxf/service/MailTemplateServiceImpl.java    | 10 ++--------
 .../rest/cxf/service/ReportServiceImpl.java     | 13 +++----------
 .../cxf/service/ReportTemplateServiceImpl.java  | 10 ++--------
 .../core/rest/cxf/service/RoleServiceImpl.java  | 10 ++--------
 .../rest/cxf/service/WorkflowServiceImpl.java   | 20 +++-----------------
 6 files changed, 14 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/43c66bfe/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ConfigurationServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ConfigurationServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ConfigurationServiceImpl.java
index 8c8473d..4a40a75 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ConfigurationServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ConfigurationServiceImpl.java
@@ -18,8 +18,6 @@
  */
 package org.apache.syncope.core.rest.cxf.service;
 
-import java.io.IOException;
-import java.io.OutputStream;
 import java.util.List;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
@@ -42,17 +40,11 @@ public class ConfigurationServiceImpl extends AbstractServiceImpl implements Con
 
     @Override
     public Response export() {
-        StreamingOutput sout = new StreamingOutput() {
+        StreamingOutput sout = (os) -> logic.export(os);
 
-            @Override
-            public void write(final OutputStream os) throws IOException {
-                logic.export(os);
-            }
-        };
         return Response.ok(sout).
                 type(MediaType.TEXT_XML).
-                header(
-                        HttpHeaders.CONTENT_DISPOSITION,
+                header(HttpHeaders.CONTENT_DISPOSITION,
                         "attachment; filename=" + AuthContextUtils.getDomain() + CONTENT_XML).
                 build();
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/43c66bfe/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java
index 6ea590a..7596171 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java
@@ -20,7 +20,6 @@ package org.apache.syncope.core.rest.cxf.service;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.net.URI;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
@@ -68,14 +67,9 @@ public class MailTemplateServiceImpl extends AbstractServiceImpl implements Mail
 
     @Override
     public Response getFormat(final String key, final MailTemplateFormat format) {
-        final String template = logic.getFormat(key, format);
-        StreamingOutput sout = new StreamingOutput() {
+        String template = logic.getFormat(key, format);
+        StreamingOutput sout = (os) -> os.write(template.getBytes());
 
-            @Override
-            public void write(final OutputStream os) throws IOException {
-                os.write(template.getBytes());
-            }
-        };
         return Response.ok(sout).
                 type(format.getMediaType()).
                 build();

http://git-wip-us.apache.org/repos/asf/syncope/blob/43c66bfe/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportServiceImpl.java
index 0826b99..ea5a707 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportServiceImpl.java
@@ -18,8 +18,6 @@
  */
 package org.apache.syncope.core.rest.cxf.service;
 
-import java.io.IOException;
-import java.io.OutputStream;
 import java.net.URI;
 import java.util.List;
 import javax.ws.rs.core.HttpHeaders;
@@ -72,15 +70,10 @@ public class ReportServiceImpl extends AbstractExecutableService implements Repo
 
     @Override
     public Response exportExecutionResult(final String executionKey, final ReportExecExportFormat fmt) {
-        final ReportExecExportFormat format = (fmt == null) ? ReportExecExportFormat.XML : fmt;
-        final ReportExec reportExec = logic.getReportExec(executionKey);
-        StreamingOutput sout = new StreamingOutput() {
+        ReportExecExportFormat format = (fmt == null) ? ReportExecExportFormat.XML : fmt;
+        ReportExec reportExec = logic.getReportExec(executionKey);
+        StreamingOutput sout = (os) -> logic.exportExecutionResult(os, reportExec, format);
 
-            @Override
-            public void write(final OutputStream os) throws IOException {
-                logic.exportExecutionResult(os, reportExec, format);
-            }
-        };
         return Response.ok(sout).
                 header(HttpHeaders.CONTENT_DISPOSITION,
                         "attachment; filename=" + reportExec.getReport().getName() + "." + format.name().toLowerCase()).

http://git-wip-us.apache.org/repos/asf/syncope/blob/43c66bfe/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportTemplateServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportTemplateServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportTemplateServiceImpl.java
index d63f5f6..3191eb1 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportTemplateServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportTemplateServiceImpl.java
@@ -20,7 +20,6 @@ package org.apache.syncope.core.rest.cxf.service;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.net.URI;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
@@ -69,14 +68,9 @@ public class ReportTemplateServiceImpl extends AbstractServiceImpl implements Re
 
     @Override
     public Response getFormat(final String key, final ReportTemplateFormat format) {
-        final String template = logic.getFormat(key, format);
-        StreamingOutput sout = new StreamingOutput() {
+        String template = logic.getFormat(key, format);
+        StreamingOutput sout = (os) -> os.write(template.getBytes());
 
-            @Override
-            public void write(final OutputStream os) throws IOException {
-                os.write(template.getBytes());
-            }
-        };
         return Response.ok(sout).
                 type(MediaType.APPLICATION_XML).
                 build();

http://git-wip-us.apache.org/repos/asf/syncope/blob/43c66bfe/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java
index a6a3f2e..6a0a75a 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java
@@ -20,7 +20,6 @@ package org.apache.syncope.core.rest.cxf.service;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.net.URI;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
@@ -73,14 +72,9 @@ public class RoleServiceImpl extends AbstractServiceImpl implements RoleService
 
     @Override
     public Response getConsoleLayoutInfo(final String key) {
-        final String template = logic.getConsoleLayoutInfo(key);
-        StreamingOutput sout = new StreamingOutput() {
+        String template = logic.getConsoleLayoutInfo(key);
+        StreamingOutput sout = (os) -> os.write(template.getBytes());
 
-            @Override
-            public void write(final OutputStream os) throws IOException {
-                os.write(template.getBytes());
-            }
-        };
         return Response.ok(sout).
                 type(MediaType.APPLICATION_JSON_TYPE).
                 build();

http://git-wip-us.apache.org/repos/asf/syncope/blob/43c66bfe/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/WorkflowServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/WorkflowServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/WorkflowServiceImpl.java
index 2642853..2321e0a 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/WorkflowServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/WorkflowServiceImpl.java
@@ -18,8 +18,6 @@
  */
 package org.apache.syncope.core.rest.cxf.service;
 
-import java.io.IOException;
-import java.io.OutputStream;
 import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -45,18 +43,12 @@ public class WorkflowServiceImpl extends AbstractServiceImpl implements Workflow
 
     @Override
     public Response get(final String anyType, final String key) {
-        final WorkflowDefinitionFormat format =
+        WorkflowDefinitionFormat format =
                 messageContext.getHttpHeaders().getAcceptableMediaTypes().contains(MediaType.APPLICATION_JSON_TYPE)
                 ? WorkflowDefinitionFormat.JSON
                 : WorkflowDefinitionFormat.XML;
 
-        StreamingOutput sout = new StreamingOutput() {
-
-            @Override
-            public void write(final OutputStream os) throws IOException {
-                logic.exportDefinition(anyType, key, format, os);
-            }
-        };
+        StreamingOutput sout = (os) -> logic.exportDefinition(anyType, key, format, os);
 
         return Response.ok(sout).
                 type(format == WorkflowDefinitionFormat.JSON
@@ -66,13 +58,7 @@ public class WorkflowServiceImpl extends AbstractServiceImpl implements Workflow
 
     @Override
     public Response exportDiagram(final String anyType, final String key) {
-        StreamingOutput sout = new StreamingOutput() {
-
-            @Override
-            public void write(final OutputStream os) throws IOException {
-                logic.exportDiagram(anyType, key, os);
-            }
-        };
+        StreamingOutput sout = (os) -> logic.exportDiagram(anyType, key, os);
 
         return Response.ok(sout).
                 type(RESTHeaders.MEDIATYPE_IMAGE_PNG).