is-collector/src/org/gcube/informationsystem/collector/impl/utils/MetadataReader.java

54 lines
1.4 KiB
Java

package org.gcube.informationsystem.collector.impl.utils;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import org.w3c.dom.Document;
/**
*
* Reader for resource's metadata
*
* @author Manuele Simi (ISTI-CNR)
*
*/
public class MetadataReader {
private Document metadata;
public MetadataReader(Document metadata) {
this.metadata = metadata;
}
public String getType(){
return this.metadata.getElementsByTagName("Type").item(0).getTextContent();
}
public String getSource() {
return this.metadata.getElementsByTagName("Source").item(0).getTextContent();
}
public Calendar getTerminationTime() {
//value is in seconds
String value = this.metadata.getElementsByTagName("TerminationTime").item(0).getTextContent();
Calendar now = new GregorianCalendar();
now.setTimeZone(TimeZone.getTimeZone("GMT"));
//add seconds to obtain the effective termination time
now.add(Calendar.SECOND, Integer.valueOf(value));
return now;
}
public String getGroupKey() {
return this.metadata.getElementsByTagName("GroupKey").item(0).getTextContent();
}
public String getEntryKey() {
return this.metadata.getElementsByTagName("EntryKey").item(0).getTextContent();
}
public String getKey() {
return this.metadata.getElementsByTagName("Key").item(0).getTextContent();
}
}