You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by md...@apache.org on 2013/10/31 16:49:22 UTC
svn commit: r1537537 - in /syncope/branches/1_1_X:
common/src/main/java/org/apache/syncope/common/types/
core/src/main/java/org/apache/syncope/core/report/
core/src/main/java/org/apache/syncope/core/report/cocoon/
core/src/main/java/org/apache/syncope/...
Author: mdisabatino
Date: Thu Oct 31 15:49:22 2013
New Revision: 1537537
URL: http://svn.apache.org/r1537537
Log:
SYNCOPE-427 add CSV report format
Added:
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/cocoon/
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/cocoon/TextSerializer.java
syncope/branches/1_1_X/core/src/main/resources/report/report2csv.xsl
- copied, changed from r1536283, syncope/branches/1_1_X/core/src/main/resources/report/report2fo.xsl
syncope/branches/1_1_X/core/src/main/resources/report/roleReportlet2csv.xsl
syncope/branches/1_1_X/core/src/main/resources/report/staticReportlet2csv.xsl
syncope/branches/1_1_X/core/src/main/resources/report/userReportlet2csv.xsl
Modified:
syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/types/ReportExecExportFormat.java
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/StaticReportlet.java
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java
syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
Modified: syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/types/ReportExecExportFormat.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/types/ReportExecExportFormat.java?rev=1537537&r1=1537536&r2=1537537&view=diff
==============================================================================
--- syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/types/ReportExecExportFormat.java (original)
+++ syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/types/ReportExecExportFormat.java Thu Oct 31 15:49:22 2013
@@ -26,6 +26,7 @@ public enum ReportExecExportFormat {
XML,
HTML,
PDF,
- RTF
+ RTF,
+ CSV
}
Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java?rev=1537537&r1=1537536&r2=1537537&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java Thu Oct 31 15:49:22 2013
@@ -21,7 +21,6 @@ package org.apache.syncope.core.report;
import static org.apache.syncope.core.report.ReportXMLConst.ATTR_NAME;
import static org.apache.syncope.core.report.ReportXMLConst.XSD_LONG;
import static org.apache.syncope.core.report.ReportXMLConst.XSD_STRING;
-
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -37,6 +36,7 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.dao.AttributableSearchDAO;
import org.apache.syncope.core.persistence.dao.EntitlementDAO;
import org.apache.syncope.core.persistence.dao.RoleDAO;
+import static org.apache.syncope.core.report.AbstractReportlet.LOG;
import org.apache.syncope.core.rest.data.RoleDataBinder;
import org.apache.syncope.core.util.AttributableUtil;
import org.apache.syncope.core.util.EntitlementUtil;
@@ -278,8 +278,51 @@ public class RoleReportlet extends Abstr
}
}
+ private void doExtractConf(final ContentHandler handler) throws SAXException {
+
+ if (conf == null) {
+ LOG.debug("Report configuration is not present");
+ }
+
+ AttributesImpl atts = new AttributesImpl();
+ handler.startElement("", "", "configurations", null);
+ handler.startElement("", "", "roleAttributes", atts);
+
+ for (Feature feature : conf.getFeatures()) {
+ atts.clear();
+ handler.startElement("", "", "feature", atts);
+ handler.characters(feature.name().toCharArray(), 0, feature.name().length());
+ handler.endElement("", "", "feature");
+ }
+
+ for (String attr : conf.getAttrs()) {
+ atts.clear();
+ handler.startElement("", "", "attribute", atts);
+ handler.characters(attr.toCharArray(), 0, attr.length());
+ handler.endElement("", "", "attribute");
+ }
+
+ for (String derAttr : conf.getDerAttrs()) {
+ atts.clear();
+ handler.startElement("", "", "derAttribute", atts);
+ handler.characters(derAttr.toCharArray(), 0, derAttr.length());
+ handler.endElement("", "", "derAttribute");
+ }
+
+ for (String virAttr : conf.getVirAttrs()) {
+ atts.clear();
+ handler.startElement("", "", "virAttribute", atts);
+ handler.characters(virAttr.toCharArray(), 0, virAttr.length());
+ handler.endElement("", "", "virAttribute");
+ }
+
+ handler.endElement("", "", "roleAttributes");
+ handler.endElement("", "", "configurations");
+ }
+
@Override
protected void doExtract(final ContentHandler handler) throws SAXException, ReportException {
+ doExtractConf(handler);
for (int i = 1; i <= (count() / PAGE_SIZE) + 1; i++) {
doExtract(handler, getPagedRoles(i));
}
Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/StaticReportlet.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/StaticReportlet.java?rev=1537537&r1=1537536&r2=1537537&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/StaticReportlet.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/StaticReportlet.java Thu Oct 31 15:49:22 2013
@@ -23,13 +23,54 @@ import org.apache.syncope.core.util.Data
import org.springframework.util.StringUtils;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
@ReportletConfClass(StaticReportletConf.class)
public class StaticReportlet extends AbstractReportlet<StaticReportletConf> {
+ private void doExtractConf(final ContentHandler handler) throws SAXException {
+
+ AttributesImpl atts = new AttributesImpl();
+ handler.startElement("", "", "configurations", null);
+ handler.startElement("", "", "staticAttributes", atts);
+
+ handler.startElement("", "", "string", atts);
+ handler.characters("string".toCharArray(), 0, "string".length());
+ handler.endElement("", "", "string");
+
+ handler.startElement("", "", "long", atts);
+ handler.characters("long".toCharArray(), 0, "long".length());
+ handler.endElement("", "", "long");
+
+ handler.startElement("", "", "double", atts);
+ handler.characters("double".toCharArray(), 0, "double".length());
+ handler.endElement("", "", "double");
+
+ handler.startElement("", "", "date", atts);
+ handler.characters("date".toCharArray(), 0, "date".length());
+ handler.endElement("", "", "date");
+
+ handler.startElement("", "", "double", atts);
+ handler.characters("double".toCharArray(), 0, "double".length());
+ handler.endElement("", "", "double");
+
+ handler.startElement("", "", "enum", atts);
+ handler.characters("enum".toCharArray(), 0, "enum".length());
+ handler.endElement("", "", "enum");
+
+ handler.startElement("", "", "list", atts);
+ handler.characters("list".toCharArray(), 0, "list".length());
+ handler.endElement("", "", "list");
+
+ handler.endElement("", "", "staticAttributes");
+ handler.endElement("", "", "configurations");
+ }
+
@Override
public void doExtract(final ContentHandler handler) throws SAXException, ReportException {
+ doExtractConf(handler);
+
if (StringUtils.hasText(conf.getStringField())) {
handler.startElement("", "", "string", null);
handler.characters(conf.getStringField().toCharArray(), 0, conf.getStringField().length());
@@ -39,28 +80,28 @@ public class StaticReportlet extends Abs
if (conf.getLongField() != null) {
handler.startElement("", "", "long", null);
String printed = String.valueOf(conf.getLongField());
- handler.characters(printed.toCharArray(), 0, printed.length() - 1);
+ handler.characters(printed.toCharArray(), 0, printed.length());
handler.endElement("", "", "long");
}
if (conf.getDoubleField() != null) {
handler.startElement("", "", "double", null);
String printed = String.valueOf(conf.getDoubleField());
- handler.characters(printed.toCharArray(), 0, printed.length() - 1);
+ handler.characters(printed.toCharArray(), 0, printed.length());
handler.endElement("", "", "double");
}
if (conf.getDateField() != null) {
handler.startElement("", "", "date", null);
String printed = DataFormat.format(conf.getDateField());
- handler.characters(printed.toCharArray(), 0, printed.length() - 1);
+ handler.characters(printed.toCharArray(), 0, printed.length());
handler.endElement("", "", "date");
}
if (conf.getTraceLevel() != null) {
handler.startElement("", "", "enum", null);
String printed = conf.getTraceLevel().name();
- handler.characters(printed.toCharArray(), 0, printed.length() - 1);
+ handler.characters(printed.toCharArray(), 0, printed.length());
handler.endElement("", "", "enum");
}
@@ -69,7 +110,7 @@ public class StaticReportlet extends Abs
for (String item : conf.getListField()) {
if (StringUtils.hasText(item)) {
handler.startElement("", "", "string", null);
- handler.characters(item.toCharArray(), 0, item.length() - 1);
+ handler.characters(item.toCharArray(), 0, item.length());
handler.endElement("", "", "string");
}
}
Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java?rev=1537537&r1=1537536&r2=1537537&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java Thu Oct 31 15:49:22 2013
@@ -41,6 +41,7 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.dao.AttributableSearchDAO;
import org.apache.syncope.core.persistence.dao.EntitlementDAO;
import org.apache.syncope.core.persistence.dao.UserDAO;
+import static org.apache.syncope.core.report.AbstractReportlet.LOG;
import org.apache.syncope.core.rest.data.RoleDataBinder;
import org.apache.syncope.core.rest.data.UserDataBinder;
import org.apache.syncope.core.util.AttributableUtil;
@@ -316,8 +317,47 @@ public class UserReportlet extends Abstr
}
}
+ private void doExtractConf(final ContentHandler handler) throws SAXException {
+
+ AttributesImpl atts = new AttributesImpl();
+ handler.startElement("", "", "configurations", null);
+ handler.startElement("", "", "userAttributes", atts);
+
+ for (Feature feature : conf.getFeatures()) {
+ atts.clear();
+ handler.startElement("", "", "feature", atts);
+ handler.characters(feature.name().toCharArray(), 0, feature.name().length());
+ handler.endElement("", "", "feature");
+ }
+
+ for (String attr : conf.getAttrs()) {
+ atts.clear();
+ handler.startElement("", "", "attribute", atts);
+ handler.characters(attr.toCharArray(), 0, attr.length());
+ handler.endElement("", "", "attribute");
+ }
+
+ for (String derAttr : conf.getDerAttrs()) {
+ atts.clear();
+ handler.startElement("", "", "derAttribute", atts);
+ handler.characters(derAttr.toCharArray(), 0, derAttr.length());
+ handler.endElement("", "", "derAttribute");
+ }
+
+ for (String virAttr : conf.getVirAttrs()) {
+ atts.clear();
+ handler.startElement("", "", "virAttribute", atts);
+ handler.characters(virAttr.toCharArray(), 0, virAttr.length());
+ handler.endElement("", "", "virAttribute");
+ }
+
+ handler.endElement("", "", "userAttributes");
+ handler.endElement("", "", "configurations");
+ }
+
@Override
protected void doExtract(final ContentHandler handler) throws SAXException, ReportException {
+ doExtractConf(handler);
for (int i = 1; i <= (count() / PAGE_SIZE) + 1; i++) {
doExtract(handler, getPagedUsers(i));
}
Added: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/cocoon/TextSerializer.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/cocoon/TextSerializer.java?rev=1537537&view=auto
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/cocoon/TextSerializer.java (added)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/cocoon/TextSerializer.java Thu Oct 31 15:49:22 2013
@@ -0,0 +1,101 @@
+/*
+ * 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.report.cocoon;
+
+import org.apache.cocoon.sax.component.XMLSerializer;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * Converts XML into plain text. It omits all XML tags and writes only character events to the output. Input document
+ * must have at least one element - root element - which should wrap all the text inside it.
+ *
+ */
+public class TextSerializer extends XMLSerializer {
+
+ private static final String UTF_8 = "UTF-8";
+
+ private static final String TXT = "text";
+
+ public TextSerializer() {
+ super();
+ super.setOmitXmlDeclaration(true);
+ }
+
+ @Override
+ public void setDocumentLocator(final Locator locator) {
+ // nothing
+ }
+
+ @Override
+ public void processingInstruction(final String target, final String data)
+ throws SAXException {
+ // nothing
+ }
+
+ @Override
+ public void startDTD(final String name, final String publicId, final String systemId)
+ throws SAXException {
+ // nothing
+ }
+
+ @Override
+ public void endDTD() throws SAXException {
+ // nothing
+ }
+
+ @Override
+ public void startElement(final String uri, final String loc, final String raw, final Attributes atts)
+ throws SAXException {
+ // nothing
+ }
+
+ @Override
+ public void endElement(final String uri, final String name, final String raw)
+ throws SAXException {
+ // nothing
+ }
+
+ @Override
+ public void endDocument() throws SAXException {
+ super.endDocument();
+ }
+
+ /**
+ * @throws SAXException if text is encountered before root element.
+ */
+ @Override
+ public void characters(final char buffer[], final int start, final int len) throws SAXException {
+ super.characters(buffer, start, len);
+ }
+
+ @Override
+ public void recycle() {
+ super.recycle();
+ }
+
+ public static TextSerializer createPlainSerializer() {
+ final TextSerializer serializer = new TextSerializer();
+ serializer.setContentType("text/plain; charset=" + UTF_8);
+ serializer.setEncoding(UTF_8);
+ serializer.setMethod(TXT);
+ return serializer;
+ }
+}
\ No newline at end of file
Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java?rev=1537537&r1=1537536&r2=1537537&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java Thu Oct 31 15:49:22 2013
@@ -47,6 +47,7 @@ import org.apache.syncope.common.types.A
import org.apache.syncope.common.types.AuditElements.ReportSubCategory;
import org.apache.syncope.common.types.AuditElements.Result;
import org.apache.syncope.common.types.ReportExecExportFormat;
+import static org.apache.syncope.common.types.ReportExecExportFormat.RTF;
import org.apache.syncope.common.types.ReportExecStatus;
import org.apache.syncope.common.types.SyncopeClientExceptionType;
import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
@@ -59,6 +60,7 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.dao.ReportDAO;
import org.apache.syncope.core.persistence.dao.ReportExecDAO;
import org.apache.syncope.core.report.Reportlet;
+import org.apache.syncope.core.report.cocoon.TextSerializer;
import org.apache.syncope.core.rest.data.ReportDataBinder;
import org.apache.xmlgraphics.util.MimeConstants;
import org.quartz.JobKey;
@@ -290,7 +292,7 @@ public class ReportController extends Ab
Pipeline<SAXPipelineComponent> pipeline = new NonCachingPipeline<SAXPipelineComponent>();
pipeline.addComponent(new XMLGenerator(zis));
-
+
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("status", reportExec.getStatus());
parameters.put("message", reportExec.getMessage());
@@ -319,6 +321,13 @@ public class ReportController extends Ab
pipeline.addComponent(new FopSerializer(MimeConstants.MIME_RTF));
break;
+ case CSV:
+ XSLTTransformer xsl2csv = new XSLTTransformer(getClass().getResource("/report/report2csv.xsl"));
+ xsl2csv.setParameters(parameters);
+ pipeline.addComponent(xsl2csv);
+ pipeline.addComponent(new TextSerializer());
+ break;
+
case XML:
default:
pipeline.addComponent(XMLSerializer.createXMLSerializer());
Copied: syncope/branches/1_1_X/core/src/main/resources/report/report2csv.xsl (from r1536283, syncope/branches/1_1_X/core/src/main/resources/report/report2fo.xsl)
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/report/report2csv.xsl?p2=syncope/branches/1_1_X/core/src/main/resources/report/report2csv.xsl&p1=syncope/branches/1_1_X/core/src/main/resources/report/report2fo.xsl&r1=1536283&r2=1537537&rev=1537537&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/report/report2fo.xsl (original)
+++ syncope/branches/1_1_X/core/src/main/resources/report/report2csv.xsl Thu Oct 31 15:49:22 2013
@@ -18,80 +18,19 @@ specific language governing permissions
under the License.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
- <xsl:import href="userReportlet2fo.xsl"/>
- <xsl:import href="roleReportlet2fo.xsl"/>
- <xsl:import href="staticReportlet2fo.xsl"/>
+ <xsl:import href="userReportlet2csv.xsl"/>
+ <xsl:import href="roleReportlet2csv.xsl"/>
+ <xsl:import href="staticReportlet2csv.xsl"/>
<xsl:param name="status"/>
<xsl:param name="message"/>
<xsl:param name="startDate"/>
<xsl:param name="endDate"/>
-
+
<xsl:template match="/">
- <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Helvetica" font-size="10pt">
-
- <!-- defines the layout master -->
- <fo:layout-master-set>
- <fo:simple-page-master master-name="first" page-height="29.7cm" page-width="21cm"
- margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
- <fo:region-body margin-top="1cm"/>
- <fo:region-before extent="1cm"/>
- <fo:region-after extent="1.5cm"/>
- </fo:simple-page-master>
- </fo:layout-master-set>
-
- <!-- starts actual layout -->
- <fo:page-sequence master-reference="first">
-
- <fo:flow flow-name="xsl-region-body">
- <fo:block font-size="24pt" font-weight="bold" text-align="center" space-after="1cm">
- Apache Syncope Report - <xsl:value-of select="report/@name"/>
- </fo:block>
-
- <fo:table table-layout="fixed" border-width="0.5mm" border-style="solid" width="100%" space-after="1cm">
- <fo:table-column column-width="proportional-column-width(1)"/>
- <fo:table-column column-width="proportional-column-width(1)"/>
- <fo:table-body>
- <fo:table-row>
- <fo:table-cell>
- <fo:block font-size="18pt" font-weight="bold">Report Name:</fo:block>
- </fo:table-cell>
- <fo:table-cell>
- <fo:block font-size="18pt" font-weight="bold">
- <xsl:value-of select="report/@name"/>
- </fo:block>
- </fo:table-cell>
- </fo:table-row>
- <fo:table-row>
- <fo:table-cell>
- <fo:block font-size="18pt" font-weight="bold">Start Date:</fo:block>
- </fo:table-cell>
- <fo:table-cell>
- <fo:block font-size="18pt" font-weight="bold">
- <xsl:value-of select="$startDate"/>
- </fo:block>
- </fo:table-cell>
- </fo:table-row>
- <fo:table-row>
- <fo:table-cell>
- <fo:block font-size="18pt" font-weight="bold">End Date:</fo:block>
- </fo:table-cell>
- <fo:table-cell>
- <fo:block font-size="18pt" font-weight="bold">
- <xsl:value-of select="$endDate"/>
- </fo:block>
- </fo:table-cell>
- </fo:table-row>
- </fo:table-body>
- </fo:table>
-
- <xsl:apply-templates/>
- </fo:flow>
- </fo:page-sequence>
- </fo:root>
+ <xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
Added: syncope/branches/1_1_X/core/src/main/resources/report/roleReportlet2csv.xsl
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/report/roleReportlet2csv.xsl?rev=1537537&view=auto
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/report/roleReportlet2csv.xsl (added)
+++ syncope/branches/1_1_X/core/src/main/resources/report/roleReportlet2csv.xsl Thu Oct 31 15:49:22 2013
@@ -0,0 +1,118 @@
+<?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.
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+ <xsl:variable name="delimiter" select="';'"/>
+
+ <xsl:template match="reportlet[@class='org.apache.syncope.core.report.RoleReportlet']">
+
+ <xsl:call-template name="header">
+ <xsl:with-param name="node" select="configurations/roleAttributes"/>
+ </xsl:call-template>
+ <xsl:for-each select="role">
+ <xsl:call-template name="roleAttributes">
+ <xsl:with-param name="header" select="../configurations/roleAttributes"/>
+ <xsl:with-param name="attrs" select="."/>
+ </xsl:call-template>
+ <xsl:text> </xsl:text>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template name="header">
+ <xsl:param name="node"/>
+ <xsl:for-each select="$node/*">
+ <xsl:value-of select="text()"/>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text> </xsl:text>
+ </xsl:template>
+
+ <xsl:template name="roleAttributes">
+ <xsl:param name="header"/>
+ <xsl:param name="attrs"/>
+
+ <xsl:for-each select="$header/*">
+ <xsl:variable name="nameAttr" select="text()"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($attrs/@*[name()=$nameAttr]) > 0">
+ <xsl:variable name="roleAttr" select="$attrs/@*[name()=$nameAttr]"/>
+ <xsl:text>"</xsl:text>
+ <xsl:value-of select="$roleAttr/."/>
+ <xsl:text>"</xsl:text>
+ </xsl:when>
+ <xsl:when test="name($attrs/*[name(.)=$nameAttr]/*[name(.)='entitlement'])
+ and count($attrs/*[name(.)=$nameAttr]/node()) > 0">
+ <xsl:text>"</xsl:text>
+ <xsl:for-each select="$attrs/*/entitlement">
+ <xsl:variable name="value" select="@id"/>
+ <xsl:value-of select="$value"/>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>"</xsl:text>
+ </xsl:when>
+ <xsl:when test="name($attrs/*[name(.)=$nameAttr]/*[name(.)='resource'])
+ and count($attrs/*[name(.)=$nameAttr]/node()) > 0">
+ <xsl:text>"</xsl:text>
+ <xsl:for-each select="$attrs/*/resource">
+ <xsl:variable name="value" select="@name"/>
+ <xsl:value-of select="$value"/>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>"</xsl:text>
+ </xsl:when>
+ <xsl:when test="name($attrs/*[name(.)=$nameAttr]/*[name(.)='user'])
+ and count($attrs/*[name(.)=$nameAttr]/node()) > 0">
+ <xsl:text>"</xsl:text>
+ <xsl:for-each select="$attrs/*/user">
+ <xsl:variable name="value" select="@userUsername"/>
+ <xsl:value-of select="$value"/>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>"</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>"</xsl:text>
+ <xsl:if test="string-length($attrs/*/*[@name=$nameAttr]/value/text()) > 0">
+ <xsl:variable name="value" select="$attrs/*/*[@name=$nameAttr]/value/text()"/>
+ <xsl:value-of select="$value"/>
+ </xsl:if>
+ <xsl:text>"</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+
+ </xsl:for-each>
+ </xsl:template>
+
+</xsl:stylesheet>
+
Added: syncope/branches/1_1_X/core/src/main/resources/report/staticReportlet2csv.xsl
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/report/staticReportlet2csv.xsl?rev=1537537&view=auto
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/report/staticReportlet2csv.xsl (added)
+++ syncope/branches/1_1_X/core/src/main/resources/report/staticReportlet2csv.xsl Thu Oct 31 15:49:22 2013
@@ -0,0 +1,81 @@
+<?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.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:variable name="delimiter" select="';'"/>
+
+ <xsl:template match="reportlet[@class='org.apache.syncope.core.report.StaticReportlet']">
+ <xsl:call-template name="header">
+ <xsl:with-param name="node" select="configurations/staticAttributes"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="staticAttributes">
+ <xsl:with-param name="header" select="configurations/staticAttributes"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template name="header">
+ <xsl:param name="node"/>
+ <xsl:for-each select="$node/*">
+ <xsl:text>"</xsl:text>
+ <xsl:value-of select="text()"/>
+ <xsl:text>"</xsl:text>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text> </xsl:text>
+ </xsl:template>
+
+ <xsl:template name="staticAttributes">
+ <xsl:param name="header"/>
+
+ <xsl:variable name="attrs" select="."/>
+ <xsl:for-each select="$header/*">
+ <xsl:variable name="nameAttr" select="text()"/>
+ <xsl:if test="string-length($attrs/*[name(.)=$nameAttr]/text()) > 0
+ and count($attrs/*[name(.)=$nameAttr]/*/node()) = 0">
+ <xsl:variable name="value" select="$attrs/*[name(.)=$nameAttr]/text()"/>
+ <xsl:text>"</xsl:text>
+ <xsl:value-of select="$value"/>
+ <xsl:text>"</xsl:text>
+ </xsl:if>
+
+ <xsl:if test="string-length($attrs/*[name(.)=$nameAttr]/*/text()) > 0
+ and count($attrs/*[name(.)=$nameAttr]/*/node()) > 0">
+ <xsl:text>"</xsl:text>
+ <xsl:for-each select="$attrs/*[name(.)=$nameAttr]/*">
+ <xsl:variable name="value" select="text()"/>
+ <xsl:text></xsl:text>
+ <xsl:value-of select="$value"/>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>"</xsl:text>
+ </xsl:if>
+
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+
+ </xsl:for-each>
+ </xsl:template>
+</xsl:stylesheet>
Added: syncope/branches/1_1_X/core/src/main/resources/report/userReportlet2csv.xsl
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/report/userReportlet2csv.xsl?rev=1537537&view=auto
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/report/userReportlet2csv.xsl (added)
+++ syncope/branches/1_1_X/core/src/main/resources/report/userReportlet2csv.xsl Thu Oct 31 15:49:22 2013
@@ -0,0 +1,119 @@
+<?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.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+ <xsl:variable name="delimiter" select="';'"/>
+
+ <xsl:template match="reportlet[@class='org.apache.syncope.core.report.UserReportlet']">
+
+ <xsl:call-template name="header">
+ <xsl:with-param name="node" select="configurations/userAttributes"/>
+ </xsl:call-template>
+ <xsl:for-each select="user">
+ <xsl:call-template name="userAttributes">
+ <xsl:with-param name="header" select="../configurations/userAttributes"/>
+ </xsl:call-template>
+ <xsl:text> </xsl:text>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template name="header">
+ <xsl:param name="node"/>
+ <xsl:for-each select="$node/*">
+ <xsl:text>"</xsl:text>
+ <xsl:value-of select="text()"/>
+ <xsl:text>"</xsl:text>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text> </xsl:text>
+ </xsl:template>
+
+ <xsl:template name="userAttributes">
+ <xsl:param name="header"/>
+
+ <xsl:variable name="attrs" select="."/>
+ <xsl:for-each select="$header/*">
+ <xsl:variable name="nameAttr" select="text()"/>
+ <xsl:choose>
+ <xsl:when test="count($attrs/@*[name()=$nameAttr]) > 0">
+ <xsl:variable name="userAttr" select="$attrs/@*[name()=$nameAttr]"/>
+ <xsl:text>"</xsl:text>
+ <xsl:value-of select="$userAttr/."/>
+ <xsl:text>"</xsl:text>
+ </xsl:when>
+ <xsl:when test="string-length($attrs/*/*[@name=$nameAttr]/value/text()) > 0
+ and count($attrs/*/*[@name=$nameAttr]/node()) = 0">
+ <xsl:variable name="value" select="$attrs/*/*[@name=$nameAttr]/value/text()"/>
+ <xsl:text>"</xsl:text>
+ <xsl:value-of select="$value"/>
+ <xsl:text>"</xsl:text>
+ </xsl:when>
+ <xsl:when test="string-length($attrs/*/*[@name=$nameAttr]/value/text()) > 0
+ and count($attrs/*/*[@name=$nameAttr]/node()) > 0">
+ <xsl:text>"</xsl:text>
+ <xsl:for-each select="$attrs/*/*[@name=$nameAttr]/*">
+ <xsl:variable name="value" select="$attrs/*/*[@name=$nameAttr]/value/text()"/>
+ <xsl:value-of select="$value"/>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>"</xsl:text>
+ </xsl:when>
+ <xsl:when test="name($attrs/*[name(.)=$nameAttr]/*[name(.)='membership'])
+ and count($attrs/*[name(.)=$nameAttr]/node()) > 0">
+ <xsl:text>"</xsl:text>
+ <xsl:variable name="value" select="@roleName"/>
+ <xsl:for-each select="$attrs/*/membership">
+ <xsl:variable name="value" select="@roleName"/>
+ <xsl:value-of select="$value"/>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>"</xsl:text>
+ </xsl:when>
+ <xsl:when test="name($attrs/*[name(.)=$nameAttr]/*[name(.)='resource'])
+ and count($attrs/*[name(.)=$nameAttr]/node()) > 0">
+ <xsl:text>"</xsl:text>
+ <xsl:variable name="value" select="@name"/>
+ <xsl:for-each select="$attrs/*/resource">
+ <xsl:variable name="value" select="@name"/>
+ <xsl:value-of select="$value"/>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>"</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>""</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="position() != last()">
+ <xsl:value-of select="$delimiter"/>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
Modified: syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java?rev=1537537&r1=1537536&r2=1537537&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java (original)
+++ syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java Thu Oct 31 15:49:22 2013
@@ -195,6 +195,7 @@ public class ReportTestITCase extends Ab
checkExport(execId, ReportExecExportFormat.HTML);
checkExport(execId, ReportExecExportFormat.PDF);
checkExport(execId, ReportExecExportFormat.RTF);
+ checkExport(execId, ReportExecExportFormat.CSV);
}
@Test