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 17:06:08 UTC
svn commit: r1537541 - in /syncope/trunk: ./
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/core/r...
Author: mdisabatino
Date: Thu Oct 31 16:06:08 2013
New Revision: 1537541
URL: http://svn.apache.org/r1537541
Log:
Merge from 1.1.X
Added:
syncope/trunk/core/src/main/java/org/apache/syncope/core/report/cocoon/
- copied from r1537538, syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/report/cocoon/
syncope/trunk/core/src/main/resources/report/report2csv.xsl
- copied unchanged from r1537538, syncope/branches/1_1_X/core/src/main/resources/report/report2csv.xsl
syncope/trunk/core/src/main/resources/report/roleReportlet2csv.xsl
- copied unchanged from r1537538, syncope/branches/1_1_X/core/src/main/resources/report/roleReportlet2csv.xsl
syncope/trunk/core/src/main/resources/report/staticReportlet2csv.xsl
- copied unchanged from r1537538, syncope/branches/1_1_X/core/src/main/resources/report/staticReportlet2csv.xsl
syncope/trunk/core/src/main/resources/report/userReportlet2csv.xsl
- copied unchanged from r1537538, syncope/branches/1_1_X/core/src/main/resources/report/userReportlet2csv.xsl
Modified:
syncope/trunk/ (props changed)
syncope/trunk/common/src/main/java/org/apache/syncope/common/types/ReportExecExportFormat.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/report/StaticReportlet.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
Propchange: syncope/trunk/
------------------------------------------------------------------------------
Merged /syncope/branches/1_1_X:r1537136-1537538
Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/types/ReportExecExportFormat.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/types/ReportExecExportFormat.java?rev=1537541&r1=1537540&r2=1537541&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/types/ReportExecExportFormat.java (original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/types/ReportExecExportFormat.java Thu Oct 31 16:06:08 2013
@@ -26,6 +26,7 @@ public enum ReportExecExportFormat {
XML,
HTML,
PDF,
- RTF
+ RTF,
+ CSV
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java?rev=1537541&r1=1537540&r2=1537541&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java Thu Oct 31 16:06:08 2013
@@ -275,8 +275,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/trunk/core/src/main/java/org/apache/syncope/core/report/StaticReportlet.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/report/StaticReportlet.java?rev=1537541&r1=1537540&r2=1537541&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/report/StaticReportlet.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/report/StaticReportlet.java Thu Oct 31 16:06:08 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/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java?rev=1537541&r1=1537540&r2=1537541&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java Thu Oct 31 16:06:08 2013
@@ -310,8 +310,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));
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java?rev=1537541&r1=1537540&r2=1537541&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java Thu Oct 31 16:06:08 2013
@@ -44,6 +44,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.ClientExceptionType;
import org.apache.syncope.common.validation.SyncopeClientCompositeException;
@@ -56,6 +57,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;
@@ -232,7 +234,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());
@@ -261,6 +263,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());
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=1537541&r1=1537540&r2=1537541&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 Thu Oct 31 16:06:08 2013
@@ -197,6 +197,7 @@ public class ReportTestITCase extends Ab
checkExport(execId, ReportExecExportFormat.HTML);
checkExport(execId, ReportExecExportFormat.PDF);
checkExport(execId, ReportExecExportFormat.RTF);
+ checkExport(execId, ReportExecExportFormat.CSV);
}
@Test