-
-
Notifications
You must be signed in to change notification settings - Fork 956
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-50724 rubric Implement archive/merge
- Loading branch information
1 parent
2251b74
commit f7b28d3
Showing
27 changed files
with
883 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
kernel/api/src/main/java/org/sakaiproject/serialization/MapperFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Copyright (c) 2003-2017 The Apereo Foundation | ||
* | ||
* Licensed under the Educational Community 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://opensource.org/licenses/ecl2 | ||
* | ||
* 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.sakaiproject.serialization; | ||
|
||
import javax.xml.stream.XMLInputFactory; | ||
import javax.xml.stream.XMLOutputFactory; | ||
|
||
import com.ctc.wstx.api.WstxInputProperties; | ||
import com.ctc.wstx.api.WstxOutputProperties; | ||
import com.ctc.wstx.stax.WstxInputFactory; | ||
import com.ctc.wstx.stax.WstxOutputFactory; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import com.fasterxml.jackson.dataformat.xml.XmlFactory; | ||
import com.fasterxml.jackson.dataformat.xml.XmlMapper; | ||
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MapperFactory { | ||
|
||
private ObjectMapper jsonMapper; | ||
private XmlMapper wrappedXmlMapper; | ||
private XmlMapper xmlMapper; | ||
|
||
public void init() { | ||
|
||
jsonMapper = new ObjectMapper(); | ||
jsonMapper.registerModules(new JavaTimeModule()); | ||
|
||
XMLInputFactory inputFactory = new WstxInputFactory(); | ||
inputFactory.setProperty(WstxInputProperties.P_MAX_ATTRIBUTE_SIZE, 32000); | ||
inputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false); | ||
|
||
XMLOutputFactory wrappedCdataOutputFactory = new WstxOutputFactory(); | ||
wrappedCdataOutputFactory.setProperty(WstxOutputProperties.P_OUTPUT_CDATA_AS_TEXT, true); | ||
wrappedCdataOutputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); | ||
|
||
wrappedXmlMapper = createXmlMapper(new XmlFactory(inputFactory, wrappedCdataOutputFactory)); | ||
|
||
XMLOutputFactory outputFactory = new WstxOutputFactory(); | ||
outputFactory.setProperty(WstxOutputProperties.P_OUTPUT_CDATA_AS_TEXT, false); | ||
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); | ||
|
||
xmlMapper = createXmlMapper(new XmlFactory(inputFactory, outputFactory)); | ||
} | ||
|
||
private XmlMapper createXmlMapper(XmlFactory factory) { | ||
|
||
XmlMapper mapper = new XmlMapper(factory); | ||
mapper.registerModules(new JavaTimeModule()); | ||
mapper.enable(SerializationFeature.INDENT_OUTPUT); | ||
mapper.configure(ToXmlGenerator.Feature.WRITE_XML_1_1, true); | ||
return mapper; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.