public void startElement()

in src/java/org/apache/ivy/plugins/report/XmlReportParser.java [70:197]


            public void startElement(String uri, String localName, String qName,
                    Attributes attributes) throws SAXException {
                switch (qName) {
                    case "module":
                        organisation = attributes.getValue("organisation");
                        module = attributes.getValue("name");
                        break;
                    case "revision":
                        revisionArtifacts = new ArrayList<>();
                        branch = attributes.getValue("branch");
                        revision = attributes.getValue("name");
                        isDefault = Boolean.valueOf(attributes.getValue("default"));
                        // retrieve position from file. If no position is found, it may be an old
                        // report generated with a previous version,
                        // in which case, we put it at the last position
                        String pos = attributes.getValue("position");
                        position = pos == null ? getMaxPos() + 1 : Integer.valueOf(pos);
                        if (attributes.getValue("error") != null) {
                            hasError = true;
                            skip = true;
                        } else if (attributes.getValue("evicted") != null) {
                            skip = true;
                        } else {
                            revisionsMap.put(position, revisionArtifacts);
                            mrid = ModuleRevisionId.newInstance(organisation, module, branch, revision,
                                    ExtendableItemHelper.getExtraAttributes(attributes, "extra-"));
                            mrids.add(mrid);
                            if (isDefault) {
                                defaultMrids.add(mrid);
                            } else {
                                Artifact metadataArtifact = DefaultArtifact.newIvyArtifact(mrid,
                                        pubdate);
                                MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(
                                        metadataArtifact);
                                metadataReports.put(mrid, madr);
                                realMrids.add(mrid);
                            }
                            try {
                                String pubDateAttr = attributes.getValue("pubdate");
                                if (pubDateAttr != null) {
                                    pubdate = DateUtil.parse(pubDateAttr);
                                }
                                skip = false;
                            } catch (ParseException e) {
                                throw new IllegalArgumentException("invalid publication date for "
                                        + organisation + " " + module + " " + revision + ": "
                                        + attributes.getValue("pubdate"));
                            }
                        }
                        break;
                    case "metadata-artifact":
                        if (skip) {
                            return;
                        }
                        MetadataArtifactDownloadReport madr = metadataReports.get(mrid);
                        if (madr != null) {
                            madr.setDownloadStatus(DownloadStatus.fromString(attributes
                                    .getValue("status")));
                            madr.setDownloadDetails(attributes.getValue("details"));
                            madr.setSize(Long.parseLong(attributes.getValue("size")));
                            madr.setDownloadTimeMillis(Long.parseLong(attributes.getValue("time")));
                            madr.setSearched(parseBoolean(attributes.getValue("searched")));
                            if (attributes.getValue("location") != null) {
                                madr.setLocalFile(new File(attributes.getValue("location")));
                            }
                            if (attributes.getValue("original-local-location") != null) {
                                madr.setOriginalLocalFile(new File(attributes
                                        .getValue("original-local-location")));
                            }
                            if (attributes.getValue("origin-location") != null) {
                                if (ArtifactOrigin.isUnknown(attributes.getValue("origin-location"))) {
                                    madr.setArtifactOrigin(ArtifactOrigin.unknown(madr.getArtifact()));
                                } else {
                                    madr.setArtifactOrigin(new ArtifactOrigin(madr.getArtifact(),
                                            parseBoolean(attributes.getValue("origin-is-local")),
                                            attributes.getValue("origin-location")));
                                }
                            }
                        }
                        break;
                    case "artifact":
                        if (skip) {
                            return;
                        }
                        String status = attributes.getValue("status");
                        String artifactName = attributes.getValue("name");
                        String type = attributes.getValue("type");
                        String ext = attributes.getValue("ext");
                        Artifact artifact = new DefaultArtifact(mrid, pubdate, artifactName, type, ext,
                                ExtendableItemHelper.getExtraAttributes(attributes, "extra-"));
                        ArtifactDownloadReport aReport = new ArtifactDownloadReport(artifact);
                        aReport.setDownloadStatus(DownloadStatus.fromString(status));
                        aReport.setDownloadDetails(attributes.getValue("details"));
                        aReport.setSize(Long.parseLong(attributes.getValue("size")));
                        aReport.setDownloadTimeMillis(Long.parseLong(attributes.getValue("time")));
                        if (attributes.getValue("location") != null) {
                            aReport.setLocalFile(new File(attributes.getValue("location")));
                        }
                        if (attributes.getValue("unpackedFile") != null) {
                            aReport.setUnpackedLocalFile(new File(attributes.getValue("unpackedFile")));
                        }
                        revisionArtifacts.add(aReport);
                        break;
                    case "origin-location":
                        if (skip) {
                            return;
                        }
                        ArtifactDownloadReport adr = revisionArtifacts
                                .get(revisionArtifacts.size() - 1);

                        if (ArtifactOrigin.isUnknown(attributes.getValue("location"))) {
                            adr.setArtifactOrigin(ArtifactOrigin.unknown(adr.getArtifact()));
                        } else {
                            adr.setArtifactOrigin(new ArtifactOrigin(adr.getArtifact(),
                                    parseBoolean(attributes.getValue("is-local")),
                                    attributes.getValue("location")));
                        }
                        break;
                    case "info":
                        String organisation = attributes.getValue("organisation");
                        String name = attributes.getValue("module");
                        String branch = attributes.getValue("branch");
                        String revision = attributes.getValue("revision");
                        mRevisionId = ModuleRevisionId.newInstance(organisation, name, branch, revision,
                            ExtendableItemHelper.getExtraAttributes(attributes, "extra-"));
                        break;
                }
            }