Compare commits

...
Sign in to create a new pull request.

7 commits

Author SHA1 Message Date
Patrick Huang
26cfacc6a0 patch to remove xom 2014-07-17 02:21:29 -04:00
Patrick Huang
00e76c2d8c remove xom dependency 2014-07-17 02:20:42 -04:00
Patrick Huang
1eca2390ef rebuild 2014-06-04 18:49:27 -04:00
Patrick Huang
9c9e02a02c remove xom restriction 2014-06-02 00:51:19 -04:00
Patrick Huang
599e7f9379 upload source 2014-06-01 23:53:58 -04:00
Patrick Huang
4f3a377c51 upgrade to latest upstream 3.3.0 2014-06-01 23:53:08 -04:00
Patrick Huang
78f75c7ef3 upgrade to latest upstream version 2014-01-30 21:07:39 -05:00
4 changed files with 359 additions and 40 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
/common-2.2.1.zip
/common-3.0.1.zip
/common-3.0.2.zip
/common-3.1.0.zip
/common-3.3.0.zip

312
remove-xom.patch Normal file
View file

@ -0,0 +1,312 @@
diff --git zanata-common-util/pom.xml zanata-common-util/pom.xml
index 4586f63..ba563ab 100644
--- zanata-common-util/pom.xml
+++ zanata-common-util/pom.xml
@@ -83,10 +83,6 @@
<artifactId>stax-api</artifactId>
</dependency>
- <dependency>
- <groupId>xom</groupId>
- <artifactId>xom</artifactId>
- </dependency>
</dependencies>
diff --git zanata-common-util/src/main/java/org/zanata/common/util/ElementBuilder.java zanata-common-util/src/main/java/org/zanata/common/util/ElementBuilder.java
deleted file mode 100644
index ace5a04..0000000
--- zanata-common-util/src/main/java/org/zanata/common/util/ElementBuilder.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright 2013, Red Hat, Inc. and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.zanata.common.util;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static javax.xml.stream.XMLStreamConstants.*;
-
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.Characters;
-import javax.xml.stream.events.StartElement;
-import javax.xml.stream.events.XMLEvent;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.stax.StAXSource;
-
-import nu.xom.Attribute.Type;
-import nu.xom.Element;
-import nu.xom.converters.DOMConverter;
-
-import org.w3c.dom.Document;
-
-/**
- * ElementBuilder consumes a complete element from a StAX XMLStreamReader or
- * XMLEventReader and returns it as a xom Element.
- * <p>
- * {@link nux.xom.io.StaxParser} implements a similar idea.
- *
- * @author Sean Flanigan <a
- * href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
- */
-public class ElementBuilder {
-
- /**
- * Converts the element and subelements at the reader's current position
- * into a xom Element tree
- *
- * @param reader
- * must be in START_ELEMENT state
- * @return
- * @throws XMLStreamException
- */
- public static Element buildElement(XMLStreamReader reader)
- throws XMLStreamException {
- int eventType = reader.getEventType();
- assert eventType == START_ELEMENT;
- String localName = reader.getLocalName();
- String qualName = getName(reader.getPrefix(), localName);
- Element xElem = new Element(qualName, reader.getNamespaceURI());
- copyAttributes(reader, xElem);
-
- while (reader.hasNext() && eventType != END_ELEMENT) {
- eventType = reader.next();
- switch (eventType) {
- case START_ELEMENT:
- Element startElement = buildElement(reader);
- xElem.appendChild(startElement);
- break;
- case END_ELEMENT:
- break;
- case CHARACTERS:
- xElem.appendChild(reader.getText());
- break;
- case SPACE:
- break;
- default:
- throw new RuntimeException("unhandled event type: " + eventType);
- }
- }
- return xElem;
- }
-
- /**
- * Converts the element and subsequent subelements at the reader's current
- * position into a xom Element tree
- *
- * @param startElem
- * @param reader
- * must be just past the START_ELEMENT event
- * @return
- * @throws XMLStreamException
- */
- public static Element buildElement(StartElement startElem,
- XMLEventReader reader) throws XMLStreamException {
- QName name = startElem.getName();
- String qualName = getName(name);
- Element xElem = new Element(qualName, name.getNamespaceURI());
- copyAttributes(startElem, xElem);
-
- while (reader.hasNext() && !reader.peek().isEndElement()) {
- XMLEvent event = reader.nextEvent();
- if (event.isStartElement()) {
- Element startElement =
- buildElement(event.asStartElement(), reader);
- xElem.appendChild(startElement);
- } else if (event.isCharacters()) {
- Characters characters = event.asCharacters();
- if (!characters.isIgnorableWhiteSpace()) {
- xElem.appendChild(characters.getData());
- }
- } else {
- throw new RuntimeException("unhandled event type: "
- + event.getEventType());
- }
- }
- if (reader.hasNext())
- reader.nextEvent();
- return xElem;
- }
-
- public static void copyAttributes(XMLStreamReader reader, Element toElem) {
- assert reader.getEventType() == START_ELEMENT;
- for (int i = 0; i < reader.getAttributeCount(); i++) {
- String prefix = reader.getAttributePrefix(i);
- String localName = reader.getAttributeLocalName(i);
- String name = getName(prefix, localName);
- String uri = reader.getAttributeNamespace(i);
- String value = reader.getAttributeValue(i);
- Type attrType = getAttributeType(reader.getAttributeType(i));
- nu.xom.Attribute xAttr =
- new nu.xom.Attribute(name, uri, value, attrType);
- toElem.addAttribute(xAttr);
- }
- }
-
- public static void copyAttributes(StartElement fromElem, Element toElem) {
- Iterator<Attribute> attributes = (Iterator<Attribute>) fromElem.getAttributes();
- while (attributes.hasNext()) {
- Attribute attr = attributes.next();
- QName qName = attr.getName();
- String name = getName(qName);
- String uri = qName.getNamespaceURI();
- String value = attr.getValue();
- Type attrType = getAttributeType(attr.getDTDType());
- nu.xom.Attribute xAttr =
- new nu.xom.Attribute(name, uri, value, attrType);
- toElem.addAttribute(xAttr);
- }
- }
-
- private static String getName(String prefix, String localName) {
- String xPrefix = isNullOrEmpty(prefix) ? "" : prefix + ":";
- String prefixedName = xPrefix + localName;
- return prefixedName;
- }
-
- private static String getName(QName name) {
- String prefix = name.getPrefix();
- String xPrefix = isNullOrEmpty(prefix) ? "" : prefix + ":";
- String prefixedName = xPrefix + name.getLocalPart();
- return prefixedName;
- }
-
- private static Type getAttributeType(String name) {
- try {
- if (name.equals("ENUMERATED"))
- return Type.ENUMERATION;
- return (Type) Type.class.getField(name).get(null);
- } catch (NoSuchFieldException e) {
- throw new RuntimeException("unknown DTD type: " + name);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Converts the element and subelements at the reader's current position
- * into a xom Element tree
- *
- * @param reader
- * @param transformer
- * the provided Transformer must support StAXSource
- * @return
- * @throws TransformerException
- */
- static nu.xom.Element buildElement(XMLStreamReader reader,
- Transformer transformer) throws TransformerException {
- DOMResult result = new DOMResult();
- transformer.transform(new StAXSource(reader), result);
- Document docNode = (Document) result.getNode();
- org.w3c.dom.Element elem =
- (org.w3c.dom.Element) docNode.getFirstChild();
- nu.xom.Element element = DOMConverter.convert(elem);
- return element;
- }
-
-}
diff --git zanata-common-util/src/test/java/org/zanata/common/util/ElementBuilderTest.java zanata-common-util/src/test/java/org/zanata/common/util/ElementBuilderTest.java
deleted file mode 100644
index d9b2b23..0000000
--- zanata-common-util/src/test/java/org/zanata/common/util/ElementBuilderTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.zanata.common.util;
-
-import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.events.XMLEvent;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class ElementBuilderTest {
-
- @Before
- public void before() throws IOException {
- is = getClass().getResourceAsStream("ElementBuilderTest.xml");
- }
-
- private XMLInputFactory xif = XMLInputFactory.newInstance();
- private InputStream is;
-
- @Test
- public void buildElementXMLStreamReader() throws Exception {
- XMLStreamReader reader = xif.createXMLStreamReader(is);
- while (reader.hasNext()) {
- int eventType = reader.next();
- if (eventType == START_ELEMENT
- && reader.getLocalName().equals("tu")) {
- ElementBuilder.buildElement(reader).toXML();
- }
- }
- }
-
- @Test
- public void buildElementStartElementXMLEventReader() throws Exception {
- XMLEventReader reader = xif.createXMLEventReader(is);
- while (reader.hasNext()) {
- XMLEvent event = reader.nextEvent();
- if (event.isStartElement()
- && event.asStartElement().getName().getLocalPart()
- .equals("tu")) {
- ElementBuilder.buildElement(event.asStartElement(), reader)
- .toXML();
- }
- }
- }
-
- @Test
- @Ignore
- public void buildElementXMLStreamReaderTransformer() throws Exception {
- // Nasty way to ensure that we get a Transformer which supports
- // StAXSource:
- System.setProperty("javax.xml.transform.TransformerFactory",
- "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
- Transformer t = TransformerFactory.newInstance().newTransformer();
-
- XMLStreamReader reader = xif.createXMLStreamReader(is);
- while (reader.hasNext()) {
- int eventType = reader.next();
- if (eventType == START_ELEMENT
- && reader.getLocalName().equals("tu")) {
- ElementBuilder.buildElement(reader, t).toXML();
- }
- }
- }
-}

View file

@ -1 +1 @@
cec5eeec36d1202eff6ad6ab82211811 common-3.0.2.zip
c425615b4aa15f2ccebf92dd3324fc33 common-3.3.0.zip

View file

@ -7,66 +7,39 @@
%global submodule_glossary zanata-adapter-glossary
Name: zanata-%{shortname}
Version: 3.0.2
Release: 1%{?dist}
Version: 3.3.0
Release: 4%{?dist}
Summary: Zanata common modules
Group: Development/Libraries
License: LGPLv2+
URL: https://github.com/zanata/%{name}
Source0: https://github.com/zanata/%{name}/archive/%{shortname}-%{version}.zip
Patch0: remove-xom.patch
BuildArch: noarch
BuildRequires: maven-local
BuildRequires: maven-enforcer-plugin
BuildRequires: maven-surefire-provider-testng
# dependencies in pom
BuildRequires: maven-local
BuildRequires: zanata-parent
BuildRequires: mvn(net.sourceforge.findbugs:annotations)
BuildRequires: zanata-api
BuildRequires: slf4j
BuildRequires: testng
BuildRequires: hamcrest
# dependencies in zanata-common-util
BuildRequires: openprops
BuildRequires: jgettext
BuildRequires: opencsv
BuildRequires: jackson
BuildRequires: guava
BuildRequires: apache-commons-io
BuildRequires: apache-commons-codec
BuildRequires: junit
BuildRequires: xom
# dependencies in zanata-adapter-po
BuildRequires: jgettext
BuildRequires: apache-commons-lang
# dependencies in zanata-adapter-properties
BuildRequires: openprops
# dependencies in zanata-adapter-xliff (no extra)
# dependencies in zanata-adapter-glossary
BuildRequires: opencsv
Requires: jpackage-utils
Requires: java
Requires: zanata-api
Requires: openprops
Requires: jgettext
Requires: opencsv
Requires: slf4j
Requires: jackson
Requires: guava
Requires: apache-commons-io
Requires: apache-commons-codec
Requires: xom
Requires: jgettext
Requires: apache-commons-lang
Requires: openprops
Requires: opencsv
%description
Zanata common modules
@ -88,7 +61,9 @@ This includes submodules:
%prep
%setup -q -n %{name}-%{shortname}-%{version}
%pom_remove_plugin :maven-dependency-plugin
%patch0
%pom_remove_dep com.google.code.findbugs:annotations %{submodule_util}
%pom_xpath_inject "pom:dependencies" "<dependency><groupId>net.sourceforge.findbugs</groupId><artifactId>annotations</artifactId><version>2.0.2</version></dependency>" %{submodule_util}
%build
%mvn_build
@ -104,6 +79,36 @@ This includes submodules:
%changelog
* Thu Jul 17 2014 Patrick Huang <pahuang@redhat.com> - 3.3.0-4
- Remove xom dependency
* Thu Jun 05 2014 Patrick Huang <pahuang@redhat.com> - 3.3.0-3
- Rebuild in f20
* Mon Jun 02 2014 Patrick Huang <pahuang@redhat.com> - 3.3.0-2
- Remove xom version restriction
* Mon Jun 02 2014 Patrick Huang <pahuang@redhat.com> - 3.3.0-1
- Upgrade to latest upstream version
* Fri Mar 28 2014 Michael Simacek <msimacek@redhat.com> - 3.1.0-6
- Use Requires: java-headless rebuild (#1067528)
* Wed Jan 29 2014 Patrick Huang <pahuang@redhat.com> 3.1.0-5
- require xom greater than specific version
* Wed Jan 29 2014 Patrick Huang <pahuang@redhat.com> 3.1.0-4
- rebuild for xom fix
* Mon Jan 20 2014 Patrick Huang <pahuang@redhat.com> 3.1.0-3
- Explicit listing BR and R
* Fri Jan 17 2014 Patrick Huang <pahuang@redhat.com> 3.1.0-2
- Add requires
* Thu Jan 09 2014 Patrick Huang <pahuang@redhat.com> 3.1.0-1
- Latest upstream version
* Wed Sep 4 2013 Patrick Huang <pahuang@redhat.com> 3.0.2-1
- Latest upstream version