1 25 26 package org.snipsnap.semanticweb; 27 28 import org.snipsnap.app.Application; 29 import org.snipsnap.config.Configuration; 30 import org.snipsnap.snip.Snip; 31 32 import java.text.SimpleDateFormat ; 33 import java.util.HashMap ; 34 import java.util.Map ; 35 import java.util.TimeZone ; 36 37 45 46 public class DublinCore { 47 private static SimpleDateFormat sf = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss"); 49 private static SimpleDateFormat year = new SimpleDateFormat ("yyyy"); 50 51 public static Map generate(Snip snip) { 52 Configuration conf = Application.get().getConfiguration(); 53 sf.setTimeZone(TimeZone.getTimeZone(conf.getTimezone())); 54 55 Map dublinCore = new HashMap (); 56 dublinCore.put("creator", snip.getCUser()); 58 dublinCore.put("title", snip.getName()); 59 String date = sf.format(snip.getModified().getmTime()); 60 String timeZone = conf.getTimezone(); 61 if (timeZone != null && timeZone.length() > 3) { 62 if(timeZone.startsWith("GMT")) { timeZone = timeZone.substring(3); } 63 date = date + timeZone; 64 } 65 dublinCore.put("date", date); 66 dublinCore.put("type", "Text"); 67 dublinCore.put("identifier", Application.get().getConfiguration().getSnipUrl(snip.getNameEncoded())); 68 dublinCore.put("language", conf.getLocale().getLanguage()); 70 return dublinCore; 71 } 72 73 202 } 203 | Popular Tags |