syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbernha...@apache.org
Subject svn commit: r1439469 - in /syncope/trunk: common/src/main/java/org/apache/syncope/common/report/ console/src/main/java/org/apache/syncope/console/rest/ core/src/main/java/org/apache/syncope/core/services/ core/src/test/java/org/apache/syncope/core/rest...
Date Mon, 28 Jan 2013 16:08:28 GMT
Author: jbernhardt
Date: Mon Jan 28 16:08:27 2013
New Revision: 1439469

URL: http://svn.apache.org/viewvc?rev=1439469&view=rev
Log:
[SYNCOPE-231]
* Adding (fixing) JAX-B Annotations

Modified:
    syncope/trunk/common/src/main/java/org/apache/syncope/common/report/StaticReportletConf.java
    syncope/trunk/common/src/main/java/org/apache/syncope/common/report/UserReportletConf.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/EntitlementTestITCaseJAXRS.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/PolicyTestITCaseJAXRS.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/ReportTestITCaseJAXRS.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/SchemaTestITCaseJAXRS.java

Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/report/StaticReportletConf.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/report/StaticReportletConf.java?rev=1439469&r1=1439468&r2=1439469&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/report/StaticReportletConf.java
(original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/report/StaticReportletConf.java
Mon Jan 28 16:08:27 2013
@@ -22,11 +22,15 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 
 import org.apache.syncope.common.types.TraceLevel;
 
 @XmlRootElement
+@XmlType
 public class StaticReportletConf extends AbstractReportletConf {
 
     private static final long serialVersionUID = -4814950086361753689L;
@@ -72,6 +76,8 @@ public class StaticReportletConf extends
         this.doubleField = doubleField;
     }
 
+    @XmlElementWrapper(name = "listField")
+    @XmlElement(name = "field")
     public List<String> getListField() {
         return listField;
     }

Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/report/UserReportletConf.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/report/UserReportletConf.java?rev=1439469&r1=1439468&r2=1439469&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/report/UserReportletConf.java
(original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/report/UserReportletConf.java
Mon Jan 28 16:08:27 2013
@@ -21,15 +21,22 @@ package org.apache.syncope.common.report
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlEnum;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 
 import org.apache.syncope.common.annotation.FormAttributeField;
 import org.apache.syncope.common.search.NodeCond;
 import org.apache.syncope.common.types.IntMappingType;
 
-@XmlRootElement
+@XmlRootElement(name = "UserReportletConfiguration")
+@XmlType
 public class UserReportletConf extends AbstractReportletConf {
 
+    @XmlEnum
+    @XmlType(name = "UserReportletConfigurationFeature")
     public enum Feature {
 
         id,
@@ -74,6 +81,8 @@ public class UserReportletConf extends A
         features = new ArrayList<Feature>();
     }
 
+    @XmlElementWrapper(name = "normalAttributes")
+    @XmlElement(name = "attribute")
     public List<String> getAttrs() {
         return attrs;
     }
@@ -82,6 +91,8 @@ public class UserReportletConf extends A
         this.attrs = attrs;
     }
 
+    @XmlElementWrapper(name = "derivedAttributes")
+    @XmlElement(name = "attribute")
     public List<String> getDerAttrs() {
         return derAttrs;
     }
@@ -90,6 +101,8 @@ public class UserReportletConf extends A
         this.derAttrs = derAttrs;
     }
 
+    @XmlElementWrapper(name = "features")
+    @XmlElement(name = "feature")
     public List<Feature> getFeatures() {
         return features;
     }
@@ -106,6 +119,8 @@ public class UserReportletConf extends A
         this.matchingCond = matchingCond;
     }
 
+    @XmlElementWrapper(name = "virtualAttributes")
+    @XmlElement(name = "attribute")
     public List<String> getVirAttrs() {
         return virAttrs;
     }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java?rev=1439469&r1=1439468&r2=1439469&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
(original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
Mon Jan 28 16:08:27 2013
@@ -37,31 +37,12 @@ public class PolicyRestClient extends Ba
 
     private static final long serialVersionUID = -1392090291817187902L;
 
-    @SuppressWarnings("unchecked")
     public <T extends PolicyTO> T getGlobalPolicy(final PolicyType type) {
-
         T policy = null;
-
         try {
             policy = getService(PolicyService.class).readGlobal(type);
         } catch (Exception e) {
             LOG.warn("No global " + type + " policy found", e);
-            switch (type) {
-            case ACCOUNT:
-            case GLOBAL_ACCOUNT:
-                policy = (T) new AccountPolicyTO();
-                break;
-            case PASSWORD:
-            case GLOBAL_PASSWORD:
-                policy = (T) new PasswordPolicyTO();
-                break;
-            case SYNC:
-            case GLOBAL_SYNC:
-                policy = (T) new SyncPolicyTO();
-                break;
-            default:
-                LOG.warn("Invalid policy type");
-            }
         }
         return policy;
     }
@@ -81,7 +62,9 @@ public class PolicyRestClient extends Ba
         if (includeGlobal) {
             try {
                 PolicyTO globalPolicy = getGlobalPolicy(type);
-                res.add(0, (T) globalPolicy);
+                if (globalPolicy != null) {
+                    res.add(0, (T) globalPolicy);
+                }
             } catch (Exception ignore) {
                 LOG.warn("No global policy found", ignore);
             }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java?rev=1439469&r1=1439468&r2=1439469&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java
(original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java
Mon Jan 28 16:08:27 2013
@@ -24,13 +24,11 @@ import java.net.URI;
 import java.util.List;
 import java.util.Set;
 
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.StreamingOutput;
 import javax.ws.rs.core.UriInfo;
 
+import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.ReportService;
 import org.apache.syncope.common.to.ReportExecTO;
 import org.apache.syncope.common.to.ReportTO;
@@ -44,23 +42,24 @@ import org.springframework.stereotype.Se
 
 @Service
 public class ReportServiceImpl implements ReportService, ContextAware {
+
     @Autowired
-    ReportController reportController;
-    
+    private ReportController reportController;
+
     @Autowired
     private ReportDAO reportDAO;
-    
+
     private UriInfo uriInfo;
 
     @Override
-    public Response create(ReportTO reportTO) {
+    public Response create(final ReportTO reportTO) {
         ReportTO createdReportTO = reportController.createInternal(reportTO);
         URI location = uriInfo.getAbsolutePathBuilder().path("" + createdReportTO.getId()).build();
-        return Response.created(location).build();
+        return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, createdReportTO.getId()).build();
     }
 
     @Override
-    public void update(@PathParam("reportId") Long reportId, ReportTO reportTO) {
+    public void update(final Long reportId, final ReportTO reportTO) {
         try {
             reportController.update(reportTO);
         } catch (NotFoundException e) {
@@ -79,8 +78,7 @@ public class ReportServiceImpl implement
     }
 
     @Override
-    public List<ReportTO> list(@QueryParam("page") int page,
-            @QueryParam("size") @DefaultValue("25") int size) {
+    public List<ReportTO> list(final int page, final int size) {
         return reportController.list(page, size);
     }
 
@@ -95,16 +93,16 @@ public class ReportServiceImpl implement
     }
 
     @Override
-    public ReportTO read(@PathParam("reportId") Long reportId) {
+    public ReportTO read(final Long reportId) {
         try {
             return reportController.read(reportId);
         } catch (NotFoundException e) {
-            throw new javax.ws.rs.NotFoundException();
+            throw new javax.ws.rs.NotFoundException(e);
         }
     }
 
     @Override
-    public ReportExecTO readExecution(@PathParam("executionId") Long executionId) {
+    public ReportExecTO readExecution(final Long executionId) {
         try {
             return reportController.readExecution(executionId);
         } catch (NotFoundException e) {
@@ -113,12 +111,14 @@ public class ReportServiceImpl implement
     }
 
     @Override
-    public Response exportExecutionResult(final @PathParam("executionId") Long executionId,
-            final @QueryParam("format") ReportExecExportFormat fmt) {
-        final ReportExecExportFormat format = (fmt == null) ? ReportExecExportFormat.XML
: fmt;
+    public Response exportExecutionResult(final Long executionId, final ReportExecExportFormat
fmt) {
+        final ReportExecExportFormat format = (fmt == null)
+                ? ReportExecExportFormat.XML
+                : fmt;
         try {
             final ReportExec reportExec = reportController.getAndCheckReportExecInternal(executionId);
             return Response.ok(new StreamingOutput() {
+                @Override
                 public void write(final OutputStream os) throws IOException {
                     reportController.exportExecutionResultInternal(os, reportExec, format);
                 }
@@ -129,7 +129,7 @@ public class ReportServiceImpl implement
     }
 
     @Override
-    public ReportExecTO execute(@PathParam("reportId") Long reportId) {
+    public ReportExecTO execute(final Long reportId) {
         try {
             return reportController.execute(reportId);
         } catch (NotFoundException e) {
@@ -138,7 +138,7 @@ public class ReportServiceImpl implement
     }
 
     @Override
-    public void delete(@PathParam("reportId") Long reportId) {
+    public void delete(final Long reportId) {
         try {
             reportController.delete(reportId);
         } catch (NotFoundException e) {
@@ -147,7 +147,7 @@ public class ReportServiceImpl implement
     }
 
     @Override
-    public void deleteExecution(@PathParam("executionId") Long executionId) {
+    public void deleteExecution(final Long executionId) {
         try {
             reportController.deleteExecution(executionId);
         } catch (NotFoundException e) {
@@ -156,7 +156,7 @@ public class ReportServiceImpl implement
     }
 
     @Override
-    public void setUriInfo(UriInfo uriInfo) {
+    public void setUriInfo(final UriInfo uriInfo) {
         this.uriInfo = uriInfo;
     }
 

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1439469&r1=1439468&r2=1439469&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Mon Jan
28 16:08:27 2013
@@ -93,7 +93,7 @@ public abstract class AbstractTest {
     protected static final String ADMIN_PWD = "password";
 
     public static final String CONTENT_TYPE_JSON = "application/json";
-    public static final String CONTENT_TYPE_XML = "text/xml";
+    public static final String CONTENT_TYPE_XML = "application/xml";
     public static final String DEFAULT_CONTENT_TYPE = CONTENT_TYPE_JSON;
 
     private static final String ENV_KEY_CONTENT_TYPE = "jaxrsContentType";

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java?rev=1439469&r1=1439468&r2=1439469&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java Mon
Jan 28 16:08:27 2013
@@ -46,11 +46,10 @@ import org.springframework.web.client.Ht
 
 @FixMethodOrder(MethodSorters.JVM)
 public class ReportTestITCase extends AbstractTest {
-    
-    ReportTO createReport(ReportTO report) {
+
+    ReportTO createReport(final ReportTO report) {
         Response response = reportService.create(report);
-        Long reportId = (Long) response.getEntity();
-        return reportService.read(reportId);
+        return getObject(response, ReportTO.class, reportService);
     }
 
     @Test

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/EntitlementTestITCaseJAXRS.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/EntitlementTestITCaseJAXRS.java?rev=1439469&r1=1439468&r2=1439469&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/EntitlementTestITCaseJAXRS.java
(original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/EntitlementTestITCaseJAXRS.java
Mon Jan 28 16:08:27 2013
@@ -28,6 +28,6 @@ public class EntitlementTestITCaseJAXRS 
     public EntitlementTestITCaseJAXRS() {
        setEnabledCXF(true);
        //JSON is currently not working (fix after CXF migration is complete)
-       setContentType(super.CONTENT_TYPE_XML);
+       setContentType(CONTENT_TYPE_XML);
     }
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/PolicyTestITCaseJAXRS.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/PolicyTestITCaseJAXRS.java?rev=1439469&r1=1439468&r2=1439469&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/PolicyTestITCaseJAXRS.java
(original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/PolicyTestITCaseJAXRS.java
Mon Jan 28 16:08:27 2013
@@ -28,6 +28,6 @@ public class PolicyTestITCaseJAXRS exten
     public PolicyTestITCaseJAXRS() {
         setEnabledCXF(true);
         // JSON is currently not working (fix after CXF migration is complete)
-        setContentType(super.CONTENT_TYPE_XML);
+        setContentType(CONTENT_TYPE_XML);
     }
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/ReportTestITCaseJAXRS.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/ReportTestITCaseJAXRS.java?rev=1439469&r1=1439468&r2=1439469&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/ReportTestITCaseJAXRS.java
(original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/ReportTestITCaseJAXRS.java
Mon Jan 28 16:08:27 2013
@@ -24,8 +24,10 @@ import org.junit.runners.MethodSorters;
 
 @FixMethodOrder(MethodSorters.JVM)
 public class ReportTestITCaseJAXRS extends ReportTestITCase {
-    
+
     public ReportTestITCaseJAXRS() {
-       setEnabledCXF(true);
+        setEnabledCXF(true);
+        // JSON is currently not working (fix after CXF migration is complete)
+        setContentType(CONTENT_TYPE_XML);
     }
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/SchemaTestITCaseJAXRS.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/SchemaTestITCaseJAXRS.java?rev=1439469&r1=1439468&r2=1439469&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/SchemaTestITCaseJAXRS.java
(original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/jaxrs/SchemaTestITCaseJAXRS.java
Mon Jan 28 16:08:27 2013
@@ -28,6 +28,6 @@ public class SchemaTestITCaseJAXRS exten
     public SchemaTestITCaseJAXRS() {
         setEnabledCXF(true);
         // JSON is currently not working (fix after CXF migration is complete)
-        setContentType(super.CONTENT_TYPE_XML);
+        setContentType(CONTENT_TYPE_XML);
     }
 }



Mime
View raw message