View Javadoc

1   /*
2    * Copyright 2012 DTO Labs, Inc. (http://dtolabs.com)
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  
18  /*
19  * DeleteParser.java
20  * 
21  * User: Greg Schueler <a href="mailto:greg@dtosolutions.com">greg@dtosolutions.com</a>
22  * Created: 10/1/12 3:52 PM
23  * 
24  */
25  package org.rundeck.api.parser;
26  
27  import org.apache.commons.lang.StringUtils;
28  import org.dom4j.Node;
29  import org.rundeck.api.domain.RundeckJobDelete;
30  
31  
32  /**
33   * DeleteParser is ...
34   *
35   * @author Greg Schueler <a href="mailto:greg@dtosolutions.com">greg@dtosolutions.com</a>
36   */
37  public class DeleteParser extends BaseXpathParser<RundeckJobDelete> {
38  
39  
40      public DeleteParser(final String xpath) {
41          super(xpath);
42      }
43  
44      public DeleteParser() {
45          super();
46      }
47  
48      @Override
49      public RundeckJobDelete parse(Node resultNode) {
50  
51          final RundeckJobDelete delete = new RundeckJobDelete();
52          delete.setError(StringUtils.trimToNull(resultNode.valueOf("error")));
53          delete.setErrorCode(StringUtils.trimToNull(resultNode.valueOf("@errorCode")));
54          delete.setId(StringUtils.trimToNull(resultNode.valueOf("@id")));
55          delete.setMessage(StringUtils.trimToNull(resultNode.valueOf("message")));
56          delete.setSuccessful(null == delete.getError() && null == delete.getErrorCode());
57  
58          return delete;
59      }
60  }