Pankraz76 commented on code in PR #2312:
URL: https://github.com/apache/maven/pull/2312#discussion_r2083939820
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java:
##########
@@ -35,93 +27,18 @@
import org.apache.maven.api.services.xml.XmlReaderRequest;
import org.apache.maven.api.services.xml.XmlWriterException;
import org.apache.maven.api.services.xml.XmlWriterRequest;
-import org.apache.maven.plugin.descriptor.io.PluginDescriptorStaxReader;
-import org.apache.maven.plugin.descriptor.io.PluginDescriptorStaxWriter;
-
-import static org.apache.maven.impl.ImplUtils.nonNull;
-import static org.apache.maven.impl.StaxLocation.getLocation;
-import static org.apache.maven.impl.StaxLocation.getMessage;
@Named
@Singleton
public class DefaultPluginXmlFactory implements PluginXmlFactory {
+
@Override
public PluginDescriptor read(@Nonnull XmlReaderRequest request) throws
XmlReaderException {
- nonNull(request, "request");
- Path path = request.getPath();
- URL url = request.getURL();
- Reader reader = request.getReader();
- InputStream inputStream = request.getInputStream();
- if (path == null && url == null && reader == null && inputStream ==
null) {
- throw new IllegalArgumentException("path, url, reader or
inputStream must be non null");
- }
- try {
- PluginDescriptorStaxReader xml = new PluginDescriptorStaxReader();
- xml.setAddDefaultEntities(request.isAddDefaultEntities());
- if (inputStream != null) {
- return xml.read(inputStream, request.isStrict());
- } else if (reader != null) {
- return xml.read(reader, request.isStrict());
- } else if (path != null) {
- try (InputStream is = Files.newInputStream(path)) {
- return xml.read(is, request.isStrict());
- }
- } else {
- try (InputStream is = url.openStream()) {
- return xml.read(is, request.isStrict());
- }
- }
- } catch (Exception e) {
- throw new XmlReaderException("Unable to read plugin: " +
getMessage(e), getLocation(e), e);
- }
+ return new ReadRequest(request).read();
}
@Override
public void write(XmlWriterRequest<PluginDescriptor> request) throws
XmlWriterException {
- nonNull(request, "request");
- PluginDescriptor content = nonNull(request.getContent(), "content");
- Path path = request.getPath();
- OutputStream outputStream = request.getOutputStream();
- Writer writer = request.getWriter();
- if (writer == null && outputStream == null && path == null) {
- throw new IllegalArgumentException("writer, outputStream or path
must be non null");
Review Comment:
how you like flow of code now? With proper dedicated software design the
architecture kick in taking over story telling. Orchestrating dedicated
concerns. @elharo
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]