[jboss-svn-commits] JBL Code SVN: r35117 - labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/utils/webdav.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Sep 13 06:07:14 EDT 2010
Author: dennyxu
Date: 2010-09-13 06:07:14 -0400 (Mon, 13 Sep 2010)
New Revision: 35117
Modified:
labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/utils/webdav/StreamProcessingUtils.java
Log:
JBIDE-3746: EGT - BRMS-eclipse tool - properties shows odd syntax for timestamp
Modified: labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/utils/webdav/StreamProcessingUtils.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/utils/webdav/StreamProcessingUtils.java 2010-09-13 09:32:48 UTC (rev 35116)
+++ labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/utils/webdav/StreamProcessingUtils.java 2010-09-13 10:07:14 UTC (rev 35117)
@@ -20,6 +20,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URLDecoder;
+import java.text.DateFormatSymbols;
+import java.text.ParseException;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -50,6 +56,7 @@
private static String DAV_NS = "DAV:"; //$NON-NLS-1$
public static Map<String, ResourceProperties> parseListing(String base, InputStream is) throws Exception {
+
Map<String, ResourceProperties> res = new HashMap<String, ResourceProperties>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
@@ -72,7 +79,8 @@
}
propList = oneElem.getElementsByTagNameNS(DAV_NS, "creationdate"); //$NON-NLS-1$
if (propList.getLength() > 0) {
- props.setCreationDate(propList.item(0).getTextContent());
+ String dateStr = propList.item(0).getTextContent();
+ props.setCreationDate(formatDateTimeString(dateStr));
}
propList = oneElem.getElementsByTagNameNS(DAV_NS, "getlastmodified"); //$NON-NLS-1$
if (propList.getLength() > 0) {
@@ -86,6 +94,39 @@
return res;
}
+
+ //the method is Temporary workaround for the issue JBIDE-3746 which is a server side issue.
+ private static String formatDateTimeString(String dateStr) {
+
+ if (dateStr == null)
+ return null;
+ String val = dateStr;
+
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ if (!("".equals(val))) {
+ try {
+ Date date = formatter.parse(val);
+ val = formatter.format(date);
+ } catch (Exception e) {
+ if (val.indexOf("T") >= 0) {
+ val = val.replace("T", " ");
+ }
+ if (val.indexOf("Z") >= 0) {
+ val = val.replace("Z", "");
+ }
+ Date date;
+ try {
+ date = formatter.parse(val);
+ } catch (ParseException e1) {
+ return dateStr;
+ }
+ val = formatter.format(date);
+ }
+ }
+
+ return val;
+ }
+
private static String extractOverlap(String base, String extension) {
String res = null;
int pos = 0;
More information about the jboss-svn-commits
mailing list