Skip to content

Commit

Permalink
#21060 Using XStreamFactory everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyDOTCMS committed May 10, 2022
1 parent a289c96 commit eeaed79
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import com.dotcms.util.ConversionUtils;
import com.dotcms.util.DotPreconditions;
import com.dotcms.util.ThreadContextUtil;
import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.Host;
import com.dotmarketing.beans.Identifier;
import com.dotmarketing.beans.MultiTree;
Expand Down Expand Up @@ -2478,7 +2479,7 @@ private void backupDestroyedContentlets(final List<Contentlet> contentlets, fina

if (contentlets.size() > 0) {

final XStream xstream = new XStream(new DomDriver());
final XStream xstream = XStreamFactory.INSTANCE.getInstance();
final File backupFolder = new File(backupPath);
if (!backupFolder.exists()) {

Expand Down Expand Up @@ -2791,7 +2792,7 @@ public void deleteAllVersionsandBackup(List<Contentlet> contentlets, User user,
}

if (contentlets.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotcms.contenttype.business.sql;


import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.beans.Identifier;
import com.dotmarketing.beans.Inode;
Expand Down Expand Up @@ -188,7 +189,7 @@ public List <Map <String,Object>> executeFix() throws DotDataException, DotRunti
public List <Map<String, String>> getModifiedData() {

if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();;
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dotcms.publisher.business;

import com.dotcms.util.XStreamFactory;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.UtilMethods;
import com.thoughtworks.xstream.XStream;
Expand Down Expand Up @@ -113,7 +114,7 @@ public void addOrUpdateEndpoint(String groupId, String endpointId, EndpointDetai
}
}

static XStream xstream=new XStream(new DomDriver());
static XStream xstream = XStreamFactory.INSTANCE.getInstance();
public String getSerialized() {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.dotcms.publisher.pusher.wrapper.CategoryWrapper;
import com.dotcms.publishing.DotPublishingException;
import com.dotcms.util.XStreamFactory;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import java.io.File;
Expand All @@ -28,7 +29,7 @@ public class PushCategoryUtil {
private int categoriesCount;

public PushCategoryUtil(Collection<File> categories, String categoryExtension) throws DotPublishingException {
xstream=new XStream(new DomDriver());
xstream = XStreamFactory.INSTANCE.getInstance();

categoriesByInode = new HashMap<>();
categoriesTopLevel = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotcms.publishing;


import com.dotcms.util.XStreamFactory;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.XStreamException;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
Expand Down Expand Up @@ -28,7 +29,7 @@ public static XMLSerializerUtil getInstance() {
}

private XMLSerializerUtil(){
xmlSerializer = new XStream(new DomDriver(StandardCharsets.UTF_8.name()));
xmlSerializer = XStreamFactory.INSTANCE.getInstance(StandardCharsets.UTF_8);
}

public XStream getXmlSerializer() {
Expand Down
7 changes: 4 additions & 3 deletions dotCMS/src/main/java/com/dotcms/rest/ContentResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.dotcms.rest.api.v1.authentication.ResponseUtil;
import com.dotcms.rest.exception.ForbiddenException;
import com.dotcms.rest.exception.mapper.ExceptionMapperUtil;
import com.dotcms.util.XStreamFactory;
import com.dotcms.uuid.shorty.ShortyId;
import com.dotcms.uuid.shorty.ShortyIdAPI;
import com.dotcms.workflow.form.FireActionForm;
Expand Down Expand Up @@ -776,7 +777,7 @@ private String getXML(final List<Contentlet> cons, final HttpServletRequest requ
final boolean allCategoriesInfo){

final StringBuilder sb = new StringBuilder();
final XStream xstream = new XStream(new DomDriver());
final XStream xstream = XStreamFactory.INSTANCE.getInstance();
xstream.alias("content", Map.class);
xstream.registerConverter(new MapEntryConverter());
sb.append("<?xml version=\"1.0\" encoding='UTF-8'?>");
Expand Down Expand Up @@ -1019,7 +1020,7 @@ private List addRelatedContentToXMLMap(final HttpServletRequest request, final H


private String getXMLContentIds(Contentlet con) {
XStream xstream = new XStream(new DomDriver());
XStream xstream = XStreamFactory.INSTANCE.getInstance();
xstream.alias("content", Map.class);
xstream.registerConverter(new MapEntryConverter());
StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -2130,7 +2131,7 @@ protected void processXML(Contentlet contentlet, InputStream inputStream)
.startsWith("<?XML")) {
throw new DotSecurityException("Invalid XML");
}
XStream xstream = new XStream(new DomDriver());
XStream xstream = XStreamFactory.INSTANCE.getInstance();
xstream.alias("content", Map.class);
xstream.registerConverter(new MapEntryConverter());
Map<String, Object> root = (Map<String, Object>) xstream.fromXML(input);
Expand Down
5 changes: 3 additions & 2 deletions dotCMS/src/main/java/com/dotcms/rest/TestResource.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotcms.rest;

import com.dotcms.repackage.org.apache.commons.httpclient.HttpStatus;
import com.dotcms.util.XStreamFactory;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.UtilMethods;
import com.dotmarketing.util.json.JSONException;
Expand Down Expand Up @@ -79,7 +80,7 @@ public Response getDocumentCount (@Context HttpServletRequest request, @Context
mapResponse.put( "param1", param1 );
mapResponse.put( "param2", param2 );

XStream xstream = new XStream( new DomDriver() );
XStream xstream = XStreamFactory.INSTANCE.getInstance();
xstream.alias( "response", Map.class );

StringBuilder xmlBuilder = new StringBuilder();
Expand Down Expand Up @@ -170,7 +171,7 @@ public Response saveTest ( @Context HttpServletRequest request,
mapResponse.put( "param1", param1 );
mapResponse.put( "param2", param2 );

XStream xstream = new XStream( new DomDriver() );
XStream xstream = XStreamFactory.INSTANCE.getInstance();
xstream.alias( "response", Map.class );

StringBuilder xmlBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.fixtask.tasks;


import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.beans.Identifier;
import com.dotmarketing.beans.Inode;
Expand Down Expand Up @@ -188,7 +189,7 @@ public List <Map <String,Object>> executeFix() throws DotDataException, DotRunti
public List <Map<String, String>> getModifiedData() {

if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.fixtask.tasks;


import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.beans.Inode;
import com.dotmarketing.common.db.DotConnect;
Expand Down Expand Up @@ -152,7 +153,7 @@ public List <Map <String,Object>> executeFix() throws DotDataException, DotRunt
public List <Map<String, String>> getModifiedData() {

if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.fixtask.tasks;


import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.db.DbConnectionFactory;
Expand Down Expand Up @@ -155,7 +156,7 @@ public List <Map <String,Object>> executeFix() throws DotDataException, DotRunti
public List <Map<String, String>> getModifiedData() {

if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.fixtask.tasks;


import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.db.DbConnectionFactory;
Expand Down Expand Up @@ -154,7 +155,7 @@ public List <Map <String,Object>> executeFix() throws DotDataException, DotRunti
public List <Map<String, String>> getModifiedData() {

if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.fixtask.tasks;


import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.db.DbConnectionFactory;
Expand Down Expand Up @@ -144,7 +145,7 @@ public List <Map <String,Object>> executeFix() throws DotDataException,
public List <Map<String, String>> getModifiedData() {

if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.fixtask.tasks;


import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.db.HibernateUtil;
Expand Down Expand Up @@ -121,7 +122,7 @@ public class FixTask00009CheckContentletsInexistentInodes implements FixTask {
public List <Map<String, String>> getModifiedData() {

if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dotmarketing.fixtask.tasks;

import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.db.HibernateUtil;
Expand Down Expand Up @@ -85,7 +86,7 @@ public List<Map<String, Object>> executeFix() throws DotDataException, DotRuntim

public List <Map<String, String>> getModifiedData() {
if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dotmarketing.fixtask.tasks;

import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.beans.Host;
import com.dotmarketing.beans.Inode;
Expand Down Expand Up @@ -195,7 +196,7 @@ public List<Map<String, Object>> executeFix() throws DotDataException, DotRuntim

public List<Map<String, String>> getModifiedData() {
if (0 < modifiedData.size()) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.fixtask.tasks;

import com.dotcms.util.CloseUtils;
import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.beans.Inode;
import com.dotmarketing.common.db.DotConnect;
Expand Down Expand Up @@ -140,7 +141,7 @@ public List<Map<String, Object>> executeFix() throws DotDataException,

public List<Map<String, String>> getModifiedData() {
if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.dotmarketing.fixtask.tasks;

import com.dotcms.util.CloseUtils;
import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.db.HibernateUtil;
Expand Down Expand Up @@ -165,7 +166,7 @@ public List<Map<String, Object>> executeFix() throws DotDataException, DotRuntim

public List<Map<String, String>> getModifiedData() {
if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.fixtask.tasks;

import com.dotcms.util.CloseUtils;
import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.db.HibernateUtil;
Expand Down Expand Up @@ -141,7 +142,7 @@ public List<Map<String, Object>> executeFix() throws DotDataException,

public List<Map<String, String>> getModifiedData() {
if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.fixtask.tasks;

import com.dotcms.util.CloseUtils;
import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.Inode;
import com.dotmarketing.business.CacheLocator;
import com.dotmarketing.common.db.DotConnect;
Expand Down Expand Up @@ -142,7 +143,7 @@ public List<Map<String, Object>> executeFix() throws DotDataException, DotRuntim
@Override
public List<Map<String, String>> getModifiedData() {
if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.fixtask.tasks;

import com.dotcms.util.CloseUtils;
import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.db.HibernateUtil;
Expand Down Expand Up @@ -118,7 +119,7 @@ public List<Map<String, Object>> executeFix() throws DotDataException,
@Override
public List<Map<String, String>> getModifiedData() {
if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.dotcms.repackage.com.google.common.base.Preconditions;
import com.dotcms.repackage.com.google.common.base.Strings;
import com.dotcms.util.CloseUtils;
import com.dotcms.util.XStreamFactory;
import com.dotmarketing.beans.FixAudit;
import com.dotmarketing.beans.Identifier;
import com.dotmarketing.business.APILocator;
Expand Down Expand Up @@ -205,7 +206,7 @@ private void createFixAudit(List<Map<String, Object>> returnValue, int total) th
@Override
public List<Map<String, String>> getModifiedData() {
if (modifiedData.size() > 0) {
XStream _xstream = new XStream(new DomDriver());
XStream _xstream = XStreamFactory.INSTANCE.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");
String lastmoddate = sdf.format(date);
Expand Down
Loading

0 comments on commit eeaed79

Please sign in to comment.