Skip to content

Commit

Permalink
Eliminate XmlWriterFactory class
Browse files Browse the repository at this point in the history
because it does not add any value.
  • Loading branch information
bertfrees committed Jan 20, 2023
1 parent 6690bed commit ceafbe1
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 93 deletions.
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<dependency>
<groupId>org.daisy.pipeline</groupId>
<artifactId>webservice</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.daisy.pipeline</groupId>
Expand Down
2 changes: 1 addition & 1 deletion webservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>

<artifactId>webservice</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>

<name>DAISY Pipeline 2 :: Web Service</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.daisy.pipeline.webservice.impl;

import org.daisy.pipeline.webservice.xml.AliveXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand All @@ -26,7 +25,7 @@ public Representation getResource() {

maybeEnableCORS();
setStatus(Status.SUCCESS_OK);
AliveXmlWriter writer = XmlWriterFactory.createXmlWriter();
AliveXmlWriter writer = new AliveXmlWriter();
DomRepresentation dom = new DomRepresentation(MediaType.APPLICATION_XML,
writer.getXmlDocument());
logResponse(dom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.daisy.pipeline.clients.Client;
import org.daisy.pipeline.webservice.xml.ClientXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlValidator;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand Down Expand Up @@ -68,7 +67,7 @@ public Representation getResource() {
}

setStatus(Status.SUCCESS_OK);
ClientXmlWriter writer = XmlWriterFactory.createXmlWriterForClient(client.get());
ClientXmlWriter writer = new ClientXmlWriter(client.get());
DomRepresentation dom = new DomRepresentation(MediaType.APPLICATION_XML,
writer.getXmlDocument());
logResponse(dom);
Expand Down Expand Up @@ -168,7 +167,7 @@ public Representation putResource(Representation representation) {
}

setStatus(Status.SUCCESS_OK);
ClientXmlWriter writer = XmlWriterFactory.createXmlWriterForClient(updated.get());
ClientXmlWriter writer = new ClientXmlWriter(updated.get());
DomRepresentation dom = new DomRepresentation(MediaType.APPLICATION_XML,
writer.getXmlDocument());
logResponse(dom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.daisy.pipeline.webservice.xml.ClientXmlWriter;
import org.daisy.pipeline.webservice.xml.ClientsXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlValidator;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand Down Expand Up @@ -56,7 +55,7 @@ public Representation getResource() {
}

setStatus(Status.SUCCESS_OK);
ClientsXmlWriter writer = XmlWriterFactory.createXmlWriterForClients(webservice().getStorage().getClientStorage().getAll());
ClientsXmlWriter writer = new ClientsXmlWriter(webservice().getStorage().getClientStorage().getAll());
DomRepresentation dom = new DomRepresentation(MediaType.APPLICATION_XML,
writer.getXmlDocument());

Expand Down Expand Up @@ -123,7 +122,7 @@ public Representation createResource(Representation representation) {
}

setStatus(Status.SUCCESS_CREATED);
ClientXmlWriter writer = XmlWriterFactory.createXmlWriterForClient(newClient.get());
ClientXmlWriter writer = new ClientXmlWriter(newClient.get());
DomRepresentation dom = new DomRepresentation(MediaType.APPLICATION_XML, writer.getXmlDocument());
logResponse(dom);
return dom;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.daisy.pipeline.webservice.impl;

import org.daisy.pipeline.datatypes.DatatypeService;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;
import org.daisy.pipeline.webservice.xml.DatatypesXmlWriter;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand Down Expand Up @@ -42,9 +42,8 @@ public Representation getResource() {
DomRepresentation dom;
Iterable<DatatypeService> datatypes = webservice().getDatatypeRegistry().getDatatypes();
try {
dom = new DomRepresentation(MediaType.APPLICATION_XML,
XmlWriterFactory.
createXmlWriterForDatatypes(datatypes).getXmlDocument());
dom = new DomRepresentation(MediaType.APPLICATION_XML,
new DatatypesXmlWriter(datatypes).getXmlDocument());
} catch (Exception e) {

setStatus(Status.SERVER_ERROR_INTERNAL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.daisy.pipeline.job.JobIdFactory;
import org.daisy.pipeline.job.JobManager;
import org.daisy.pipeline.webservice.xml.JobsXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand Down Expand Up @@ -39,7 +38,7 @@ public Representation getResource() {
return null;
}
JobManager jobMan = webservice().getJobManager(this.getClient(),this.batchId);
JobsXmlWriter writer = XmlWriterFactory.createXmlWriterForJobs(jobMan.getJobs());
JobsXmlWriter writer = new JobsXmlWriter(jobMan.getJobs());
if(this.webservice().getConfiguration().isLocalFS()){
writer.withLocalPaths();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.daisy.pipeline.job.JobIdFactory;
import org.daisy.pipeline.job.JobManager;
import org.daisy.pipeline.webservice.xml.JobXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand Down Expand Up @@ -83,7 +82,7 @@ public Representation getResource() {
}

setStatus(Status.SUCCESS_OK);
JobXmlWriter writer = XmlWriterFactory.createXmlWriterForJob(job.get());
JobXmlWriter writer = new JobXmlWriter(job.get());

writer.withFullResults(true);
if(this.webservice().getConfiguration().isLocalFS()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.daisy.pipeline.webservice.xml.JobXmlWriter;
import org.daisy.pipeline.webservice.xml.JobsXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlUtils;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.Request;
import org.restlet.data.MediaType;
Expand Down Expand Up @@ -97,7 +96,7 @@ public Representation getResource() {
return null;
}
JobManager jobMan = webservice().getJobManager(this.getClient());
JobsXmlWriter writer = XmlWriterFactory.createXmlWriterForJobs(jobMan.getJobs());
JobsXmlWriter writer = new JobsXmlWriter(jobMan.getJobs());
if(this.webservice().getConfiguration().isLocalFS()){
writer.withLocalPaths();
}
Expand Down Expand Up @@ -197,7 +196,7 @@ public Representation createResource(Representation representation) {
webservice().getStorage().getJobConfigurationStorage()
.add(job.get().getId(), XmlUtils.nodeToString(doc));

JobXmlWriter writer = XmlWriterFactory.createXmlWriterForJob(job.get());
JobXmlWriter writer = new JobXmlWriter(job.get());
Document jobXml = writer.withAllMessages().withScriptDetails().getXmlDocument();
DomRepresentation dom = new DomRepresentation(MediaType.APPLICATION_XML, jobXml);
setStatus(Status.SUCCESS_CREATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.daisy.pipeline.webservice.Callback;
import org.daisy.pipeline.webservice.xml.JobXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlUtils;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -35,7 +34,7 @@ public class Poster {
public static void postMessages(Job job, List<Message> messages, int newerThan, BigDecimal progress, Callback callback) {
logger.debug("Posting messages to " + callback.getHref());
URI url = callback.getHref();
JobXmlWriter writer = XmlWriterFactory.createXmlWriterForJob(job);
JobXmlWriter writer = new JobXmlWriter(job);
writer.withMessages(messages, newerThan);
writer.withProgress(progress);
Document doc = writer.getXmlDocument();
Expand All @@ -45,7 +44,7 @@ public static void postMessages(Job job, List<Message> messages, int newerThan,
public static void postStatusUpdate(Job job, Status status,Callback callback) {
logger.debug("Posting status '" + status + "' to " + callback.getHref());
URI url = callback.getHref();
JobXmlWriter writer = XmlWriterFactory.createXmlWriterForJob(job);
JobXmlWriter writer = new JobXmlWriter(job);
writer.overwriteStatus(status);
Document doc = writer.getXmlDocument();
postXml(doc, url, callback.getClient());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.daisy.pipeline.job.JobIdFactory;
import org.daisy.pipeline.job.JobManager;
import org.daisy.pipeline.webservice.xml.QueueXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand Down Expand Up @@ -58,7 +57,7 @@ public Representation getResource() {
setStatus(Status.SUCCESS_OK);
this.move(this.queue,this.job.get().getId());
Collection<? extends Prioritizable< Job>> jobs=this.queue.asCollection();
QueueXmlWriter writer = XmlWriterFactory.createXmlWriterForQueue(jobs);
QueueXmlWriter writer = new QueueXmlWriter(jobs);
DomRepresentation dom = new DomRepresentation(MediaType.APPLICATION_XML,
writer.getXmlDocument());
logResponse(dom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.daisy.common.priority.Prioritizable;
import org.daisy.pipeline.job.Job;
import org.daisy.pipeline.webservice.xml.QueueXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand Down Expand Up @@ -39,7 +38,7 @@ public Representation getResource() {

setStatus(Status.SUCCESS_OK);
Collection<? extends Prioritizable<Job>> jobs=webservice().getJobManager(this.getClient()).getExecutionQueue().asCollection();
QueueXmlWriter writer = XmlWriterFactory.createXmlWriterForQueue(jobs);
QueueXmlWriter writer = new QueueXmlWriter(jobs);
DomRepresentation dom = new DomRepresentation(MediaType.APPLICATION_XML,
writer.getXmlDocument());
logResponse(dom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.daisy.pipeline.script.XProcScript;
import org.daisy.pipeline.script.XProcScriptService;
import org.daisy.pipeline.webservice.xml.ScriptXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand Down Expand Up @@ -69,7 +68,7 @@ public Representation getResource() {
return this.getErrorRepresentation("Script not found");
}
setStatus(Status.SUCCESS_OK);
ScriptXmlWriter writer = XmlWriterFactory.createXmlWriterForScript(script);
ScriptXmlWriter writer = new ScriptXmlWriter(script);
DomRepresentation dom = new DomRepresentation(
MediaType.APPLICATION_XML,
writer.withDetails().getXmlDocument());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.daisy.pipeline.script.XProcScript;
import org.daisy.pipeline.script.XProcScriptService;
import org.daisy.pipeline.webservice.xml.ScriptsXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand Down Expand Up @@ -57,7 +56,7 @@ public Representation getResource() {
}

this.setStatus(Status.SUCCESS_OK);
ScriptsXmlWriter writer = XmlWriterFactory.createXmlWriterForScripts(scripts);
ScriptsXmlWriter writer = new ScriptsXmlWriter(scripts);
DomRepresentation dom = new DomRepresentation(MediaType.APPLICATION_XML,
writer.getXmlDocument());
logResponse(dom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import org.daisy.pipeline.job.JobSize;
import org.daisy.pipeline.webservice.xml.JobsSizeXmlWriter;
import org.daisy.pipeline.webservice.xml.XmlUtils;
import org.daisy.pipeline.webservice.xml.XmlWriterFactory;

import org.restlet.data.MediaType;
import org.restlet.data.Status;
Expand Down Expand Up @@ -36,7 +34,7 @@ public Representation getResource() {

setStatus(Status.SUCCESS_OK);

JobsSizeXmlWriter writer = XmlWriterFactory.createXmlWriterForJobSizes(JobSize.getSizes(webservice().getJobManager(this.getClient()).getJobs()));
JobsSizeXmlWriter writer = new JobsSizeXmlWriter(JobSize.getSizes(webservice().getJobManager(this.getClient()).getJobs()));
DomRepresentation dom = new DomRepresentation(MediaType.APPLICATION_XML,
writer.getXmlDocument());
logResponse(dom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private Document clientsToXmlDoc() {
Element clientsElm = doc.getDocumentElement();
clientsElm.setAttribute("href", baseUri + Routes.CLIENTS_ROUTE);
for (Client client : clients) {
ClientXmlWriter writer = XmlWriterFactory.createXmlWriterForClient(client);
ClientXmlWriter writer = new ClientXmlWriter(client);
writer.addAsElementChild(clientsElm);
}
// for debugging only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private void addElementData(Job job, Element element) {
XProcScript script=job.getContext().getScript();
//return if no script was loadeded
if(script.getDescriptor()!=null){
ScriptXmlWriter writer = XmlWriterFactory.createXmlWriterForScript(script);
ScriptXmlWriter writer = new ScriptXmlWriter(script);
writer.addAsElementChild(element);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private Document scriptsToXml(Iterable<XProcScript> scripts) {
scriptsElm.setAttribute("href", baseUri + Routes.SCRIPTS_ROUTE);

for (XProcScript script : scripts) {
ScriptXmlWriter writer = XmlWriterFactory.createXmlWriterForScript(script);
ScriptXmlWriter writer = new ScriptXmlWriter(script);
writer.addAsElementChild(scriptsElm);
}

Expand Down

This file was deleted.

0 comments on commit ceafbe1

Please sign in to comment.