// Path: common/src/main/java/org/apache/hms/common/util/JAXBUtil.java
// public class JAXBUtil {
// 
//   private static ObjectMapper mapper = new ObjectMapper();
//   private static AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
//   
//   public JAXBUtil() {
//     mapper.getDeserializationConfig().setAnnotationIntrospector(introspector);
//     mapper.getSerializationConfig().setAnnotationIntrospector(introspector);    
//   }
//   
//   public static byte[] write(RestSource x) throws IOException {
//     try {
//       return mapper.writeValueAsBytes(x);
//     } catch (Throwable e) {
//       throw new IOException(e);
//     }
//   }
//   
//   public static <T> T read(byte[] buffer, java.lang.Class<T> c) throws IOException {
//     return (T) mapper.readValue(buffer, 0, buffer.length, c);
//   }
// 
//   public static String print(RestSource x) throws IOException {
//     try {
//       JsonFactory jf = new JsonFactory();
//       StringWriter sw = new StringWriter();
//       JsonGenerator jp = jf.createJsonGenerator(sw);
//       jp.useDefaultPrettyPrinter();
//       mapper.writeValue(jp, x);
//       jp.close();
//       String buffer = sw.toString(); 
//       return buffer;
//     } catch (Throwable e) {
//       throw new IOException(e);
//     }    
//   }
// }


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.hms.common.util.JAXBUtil;
import com.sun.jersey.api.client.WebResource;
  }
  
  public void load() throws IOException {
    if(nodes!=null && nodes.getUrl()!=null && nodes.getRoles()==null) {
      URL url = nodes.getUrl();
      nodes = fetch(url, NodesManifest.class);
      nodes.setUrl(url);
    }
    if(software!=null && software.getUrl()!=null && software.getRoles()==null) {
      URL url = software.getUrl();
      software = fetch(url, SoftwareManifest.class);
      software.setUrl(url);
    }
    if(config!=null && config.getUrl()!=null && config.getActions()==null) {
      URL url = config.getUrl();
      config = fetch(url, ConfigManifest.class);
      config.setUrl(url);
      config.expand(nodes);
    }
  }
  
  private <T> T fetch(URL url, java.lang.Class<T> c) throws IOException {
    if(url.getProtocol().toLowerCase().equals("file")) {
      FileReader fstream = new FileReader(url.getPath());
      BufferedReader in = new BufferedReader(fstream);
      StringBuilder buffer = new StringBuilder();
      String str;
      while((str = in.readLine()) != null) {
        buffer.append(str);
      }
// Path: common/src/main/java/org/apache/hms/common/util/JAXBUtil.java
// public class JAXBUtil {
// 
//   private static ObjectMapper mapper = new ObjectMapper();
//   private static AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
//   
//   public JAXBUtil() {
//     mapper.getDeserializationConfig().setAnnotationIntrospector(introspector);
//     mapper.getSerializationConfig().setAnnotationIntrospector(introspector);    
//   }
//   
//   public static byte[] write(RestSource x) throws IOException {
//     try {
//       return mapper.writeValueAsBytes(x);
//     } catch (Throwable e) {
//       throw new IOException(e);
//     }
//   }
//   
//   public static <T> T read(byte[] buffer, java.lang.Class<T> c) throws IOException {
//     return (T) mapper.readValue(buffer, 0, buffer.length, c);
//   }
// 
//   public static String print(RestSource x) throws IOException {
//     try {
//       JsonFactory jf = new JsonFactory();
//       StringWriter sw = new StringWriter();
//       JsonGenerator jp = jf.createJsonGenerator(sw);
//       jp.useDefaultPrettyPrinter();
//       mapper.writeValue(jp, x);
//       jp.close();
//       String buffer = sw.toString(); 
//       return buffer;
//     } catch (Throwable e) {
//       throw new IOException(e);
//     }    
//   }
// }


// Path: common/src/main/java/org/apache/hms/common/entity/manifest/ClusterManifest.java
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.hms.common.util.JAXBUtil;
import com.sun.jersey.api.client.WebResource;

  }
  
  public void load() throws IOException {
    if(nodes!=null && nodes.getUrl()!=null && nodes.getRoles()==null) {
      URL url = nodes.getUrl();
      nodes = fetch(url, NodesManifest.class);
      nodes.setUrl(url);
    }
    if(software!=null && software.getUrl()!=null && software.getRoles()==null) {
      URL url = software.getUrl();
      software = fetch(url, SoftwareManifest.class);
      software.setUrl(url);
    }
    if(config!=null && config.getUrl()!=null && config.getActions()==null) {
      URL url = config.getUrl();
      config = fetch(url, ConfigManifest.class);
      config.setUrl(url);
      config.expand(nodes);
    }
  }
  
  private <T> T fetch(URL url, java.lang.Class<T> c) throws IOException {
    if(url.getProtocol().toLowerCase().equals("file")) {
      FileReader fstream = new FileReader(url.getPath());
      BufferedReader in = new BufferedReader(fstream);
      StringBuilder buffer = new StringBuilder();
      String str;
      while((str = in.readLine()) != null) {
        buffer.append(str);
      }
      return JAXBUtil.read(buffer.toString().getBytes(), c);