I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Friday, 25 April 2014

for loop with spaces

I used to use a "for"-loop over a result of a `cat file` in order to apply on each line. But this does not work very well with spaces... Therefore I looked for a better solution which I kept forgetting. The trick is to use the "read command a in the example below:
find ... | while read -r dir
do
    something with "$dir"
done

Wednesday, 26 March 2014

Gerrit - Code Review for Git Based projects

While preparing for a talk on testing and playing along with git. I had the opportunity to take a closer look
at gerrit. Gerrit is a Framework which allows decentralised teams to
have a code review mechanism, as illustrated in the Gerrit documentation (see the quick intro).

This could be a very nice way to introduce code quality in a team, as well as to ensure scalability.

Friday, 24 January 2014

Git and Sharing

This page sums up different ways of sharing repositories with git:http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository/. I have not had time yet to check it completely, but it seems to answer a few questions I had been asking myself.

Sunday, 1 September 2013

Tricky Generation with stupid error with List<JAXBElement> getContent()

I spent too much time trying to understand why my schema did not get generated correctly. So I want to describe here the problem.


I have wsdl with a schema element:

<xsd:complexType name="Person">
   <xsd:sequence>
     <xsd:element name="id" type="xsd:long" minOccurs="0" maxOccurs="1" />
     <xsd:element name="title" type="xsd:string" />
     <xsd:element name="firstName" minOccurs="1" maxOccurs="1" type="xsd:string" />
     <xsd:element name="firstName" minOccurs="1" maxOccurs="1" type="xsd:string" />
   </xsd:sequence maxOccurs="1">
</xsd:complexType>

I was wondering why the generated Element Person did not have the correct fields but instead

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Person", propOrder = {
"content"
})
public class Person
   @XmlElementRefs({
     @XmlElementRef(name = "title", namespace = "http://www.cgi.com/cgicv/", type = JAXBElement.class, required = false),
     @XmlElementRef(name = "id", namespace = "http://www.cgi.com/cgicv/", type = JAXBElement.class, required = false),
     @XmlElementRef(name = "birthDay", namespace = "http://www.cgi.com/cgicv/", type = JAXBElement.class, required = false),
     @XmlElementRef(name = "middleName", namespace = "http://www.cgi.com/cgicv/", type = JAXBElement.class, required = false),
     @XmlElementRef(name = "lastName", namespace = "http://www.cgi.com/cgicv/", type = JAXBElement.class, required = false),
     @XmlElementRef(name = "firstName", namespace = "http://www.cgi.com/cgicv/", type = JAXBElement.class, required = false)
   })
   protected List<JAXBElement<?>> content;




The problem comes from the mistaken firstName twice in the element definition. I spent a long time looking for the answer.
The javadoc contained some kind of unclear warning. As soon as the right info is written, the content is generated correctly:



@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Person", propOrder = {
   "id",
   "title",
   "firstName",
   "lastName",
   "middleName",
   "birthDay",
   "address"
})
public class Person {

Saturday, 20 July 2013

Apache Log Files Analysis

I might be doing this a lot of apache log file analysis in a few days so might as well take look at the the open source (and others) project there are t to perform this task.

I discovered the following projects:

  • logQL (GPL v3)
  • WebLog Expert ( with an Lite Freeware version)

The first one seems nice simple and the GUI is kept very simple. While the second one seems to have a lot of features. However, I have not tried to see exactly which one are available in the lite version.

I might also add a number of other libraires here.

Friday, 12 July 2013

Axiom - XML Processing for Axis and others

I have been taking a look at the Apache Axis2 Web Service framework. Reading the documentation, I was reminded of the Axiom framework used for the processing of XML. Therefore, I will gather here a few informations which I find useful. These info come partially from quickstart-samples. The example are changed a little to be adapted to my way of thinking. This is also a documentation for me.


In addition to be used to process XML efficiently, Axiom can be used to process MTOM messages which are used in SOAP to transport binary data.
Again on the quickstart-samples page, there are some examples. But I will use a separate POST for this.


How to retrieve child elements from root:

public void processXmlFile(File file, String namespace, String elementName) throws IOException, OMException {
// initialize the file input stream to be closed in this method
InputStream in = new FileInputStream(file);
// get the root element
OMElement root = OMXMLBuilderFactory.createOMBuilder(in).getDocumentElement();

// Process the content of the file
OMElement element = root.getFirstChildWithName(
new QName("-http://maven.apache.org/POM/4.0.0", "url"));
if (element == null) {
System.out.println("No <"+elementName+"> element found");
} else {
System.out.println(elementName" = " + element.getText());
}

// Because Axiom uses deferred parsing, the stream must be closed AFTER
// processing the document (unless OMElement#build() is called)
in.close();
}

Schema validation

How to perform partial schema validation (from quickstart-samples).

public void validate(InputStream in, URL schemaUrl) throws Exception {
  SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(in, "UTF-8");
  SOAPEnvelope envelope = builder.getSOAPEnvelope();
  OMElement bodyContent = envelope.getBody().getFirstElement();
  SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  Schema schema = schemaFactory.newSchema(schemaUrl);
  Validator validator = schema.newValidator();
  validator.validate(bodyContent.getSAXSource(true));
}

quickstart-samples presents also a way to do it with a DOMSource instead of the SAXSource.


Perform on chunks of an XML Document


Often it is useful to perform just on a particular chunk of the XML document.

public interface FragmentProcessor {

    public QName getTagName();

    public void processFragment(OEMElement);

}

  public void processFragments(InputStream in, FragmentProcessor fragmentProcessor) throws XMLStreamException {
    // Create an XMLStreamReader without building the object model
    XMLStreamReader reader =
       OMXMLBuilderFactory.createOMBuilder(in).getDocument().getXMLStreamReader(false);
    QName tagName = fragmentProcessor.getTagName();
    while (reader.hasNext()) {
       if (reader.getEventType() == XMLStreamReader.START_ELEMENT &&
          reader.getName().equals(tagName)) {
             OMElement element =
                OMXMLBuilderFactory.createStAXOMBuilder(reader).getDocumentElement();
             // Make sure that all events belonging to the element are consumed so that
             // that the XMLStreamReader points to a well defined location (namely the
             // event immediately following the END_ELEMENT event).
             element.build();
             // Now process the element.
             fragmentProcessor.processFragment(element);
          } else {
             reader.next();
          }
       }
   }

Wednesday, 10 July 2013

Maven Apt and Code Snippets

For a documentation and course I will give I am using the document creation properties from apt of maven. For a documentation of the format see:
the APT format. In order to give an example, you can use a very simple snippet:

    ------
    The APT format ( or the html title of the document)
    ------
    Me the author
    ------
    2013-7-9


The title at the top of the page (not indented)

  The first introduction paragraph.... which is indented so that it is clear that it is a paragraph.

* The first subsection

  Another paragraph also indented

** a subsection with two * in order to mark it as a sub subsection

  A third paragraph followed by an ordered list with numbers

    [[1]] first element

    [[1]] second element


This create the following snippet HTML fragment (in a given generated page).



<h2>The title at the top of the page (not indented)
<a name="The_title_at_the_top_of_the_page_not_indented"></a></h2>

<p>The first introduction paragraph.... which is indented so that it is clear that it is a paragraph.</p>

<div class="section"><h3>The first subsection

<a name="The_first_subsection"></a>

</h3><p>Another paragraph</p>

<div class="section"><h4>a subsection with two * in order to mark it as a sub subsection<a name="a_subsection_with_two__in_order_to_mark_it_as_a_sub_subsection"></a></h4>

<p>A third paragraph followed by an ordered list with numbers</p>

<ol style="list-style-type: decimal"><li>first element</li><li>second element</li></ol></div></div></div>

In order to get snippets, then I use snippet macros as described in: Guide to the Snippet Macro.

Thursday, 4 July 2013

Eclipse installation Problem onWindows7 with cygwin unzip

Once or twice I had problem using unzip to unpack the eclipse code under windows7. Thanks to this answer, it could start eclipse normally. After downloading eclipse:

$> cd dirtoput-eclipse
$> unzip pathwhere-eclipsezipis/eclipse...-version.zip
$> cd eclipse
$> find . -name "*.dll" -exec chmod +x {} \;

Saturday, 29 June 2013

GDM Configuration

Well I learned something about the GDM configuration by reading the well written gnome gdm manual. However, that did not solve my Gnome cofiguration problems.

But at least I know a little bit more how to configure the user screen and put useful on it through the use of an Xwilling script.

Friday, 28 June 2013

Systemd und service control under fedora

I must say I am currently a bit lost in the different mechanisms to start and stop services. I used to perform these tasks with the standard /etc/init.d/... scripts. But it seems that it does not work completely in this way. There seems to be now systemctl, service and chkconfig commands.

service sshd start

to start the ssh daemon.

service sshd stop

to stop the ssh daemon.

chkconfig sshd on

to enable the ssh daemon so as to start it after boot.


To use systemd, the following commands come handy:

systemctl start sshd.service

to start the ssh daemon.

systemctl stop sshd.service

to stop the ssh daemon.

systemctl enable sshd.service

to enable the ssh daemon so as to start it after boot.