Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
 
Go Back   Zimbra - Forums > Zimbra Collaboration Suite > Migration

Welcome to the Zimbra - Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-06-2007, 07:45 AM
Starter Member
 
Posts: 1
Default ical4j.data.ParserException

I Got the Exception


net.fortuna.ical4j.data.ParserException: Error at line 13: Unparseable date:
"20070920"
at net.fortuna.ical4j.data.CalendarParserImpl.parse(C alendarParserImpl.java:139)
at net.fortuna.ical4j.data.CalendarBuilder.build(Cale ndarBuilder.java:167)
at net.fortuna.ical4j.data.CalendarBuilder.build(Cale ndarBuilder.java:149)
at net.fortuna.ical4j.data.CalendarBuilder.build(Cale ndarBuilder.java:137)
at
net.gasaccounting.web.app.UpdateTasksFromIcal.exec ute(UpdateTasksFromIcal.java:91)
at
org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
at
org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:188)
at
net.gasaccounting.filters.PrivilegeManageFilter.do Filter(PrivilegeManageFilter.java:78)
at
org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:215)
at
org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:188)
at
net.gasaccounting.filters.SetCharacterEncodingFilt er.doFilter(SetCharacterEncodingFilter.java:122)
at
org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:215)
at
org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:210)
at
org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:117)
at
org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:870)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.text.ParseException: Unparseable date: "20070920"
at java.text.DateFormat.parse(DateFormat.java:335)
at net.fortuna.ical4j.model.DateTime.setTime(DateTime .java:204)
at net.fortuna.ical4j.model.DateTime.<init>(DateTime. java:172)
at net.fortuna.ical4j.model.property.DateProperty.set Value(DateProperty.java:140)
at net.fortuna.ical4j.data.CalendarBuilder.propertyVa lue(CalendarBuilder.java:277)
at
net.fortuna.ical4j.data.CalendarParserImpl.parsePr operty(CalendarParserImpl.java:236)
at
net.fortuna.ical4j.data.CalendarParserImpl.parsePr opertyList(CalendarParserImpl.java:167)
at
net.fortuna.ical4j.data.CalendarParserImpl.parseCo mponent(CalendarParserImpl.java:334)
at
net.fortuna.ical4j.data.CalendarParserImpl.parsePr opertyList(CalendarParserImpl.java:164)
at net.fortuna.ical4j.data.CalendarParserImpl.parse(C alendarParserImpl.java:107)
... 30 more


Any one can provide help me how to resolve this exception, here i m trying to
build calender builder.build(getMethod.getResponseBodyAsStream()) ,
getMethod.getResponseBodyAsStream()return a Inputstream ,by using this i m try
to build calander, i print this stream giving below.....plz provide me the solution

BEGIN:VCALENDAR
PRODID:-//Infoteria Corporation//c2talk.net 1.0//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:c2talk.net / 日付「2007/12/5 -」
BEGIN:VEVENT
UID:21030@event.c2talk.net
SUMMARY:伊勢海老まつり
DESCRIPTION:南伊豆の 盟宿泊施*で「伊勢えびまつり」が
行われます。\N決まった 所ではないそうです。詳しく
はWEBをどうぞ。
DTSTART:20070920 //Here
getting exception

DTEND:20071221
URL:ソーシャルカレンダー c2talk イベントギャラリー
Location:
X-INFT-IMAGE;VALUE=BINARY;FMTTYPE=image/jpeg:/9j/4AAQSkZJRgABAQEASABIAAD/2w

i m geting the exception @ line 13(DTSTART:20070920 see above)

plz help me to resolve it

& my code is giving below


package net.gasaccounting.web.app;

import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.Iterator;
import java.util.TimeZone;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.enclosing.util.HTTPGetRedirection;
import net.enclosing.util.HibernateSession;
import net.fortuna.ical4j.data.CalendarBuilder;
import net.fortuna.ical4j.data.CalendarParser;
import net.fortuna.ical4j.data.ContentHandler;
import net.fortuna.ical4j.model.Calendar;
import net.fortuna.ical4j.model.Component;
import net.fortuna.ical4j.model.Property;
import net.fortuna.ical4j.model.TimeZoneRegistry;
import net.fortuna.ical4j.model.TimeZoneRegistryFactory;
import net.fortuna.ical4j.model.component.VEvent;
import net.fortuna.ical4j.data.ParserException;
import net.gasaccounting.model.IntraUser;
import net.gasaccounting.model.StaticData;
import net.gasaccounting.model.Task;
import net.gasaccounting.model.TaskImpl;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCred entials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

public class UpdateTasksFromIcal extends Action{
/* (non-Javadoc)
* @see
org.apache.struts.action.Action#execute(org.apache .struts.action.ActionMapping,
org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse)
*/
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) throws Exception{
Session session = new HibernateSession().currentSession(this
.getServlet().getServletContext(),30);

IntraUser intraUser = (IntraUser) req.getAttribute("u");
Criteria criteriaStaticData = session.createCriteria(StaticData.class);
criteriaStaticData.add(Restrictions.eq("id", new Integer(1)));
StaticData staticData = (StaticData) criteriaStaticData.uniqueResult();

try {

String url =
"http://api.c2talk.net/event/rest?apid="+staticData.getApid()+"&method=event.li st&type=ics&startdate=2007/12/20";

HttpClient httpClient = new HttpClient();


httpClient.getState().setCredentials(
new AuthScope("api.c2talk.net", 80, "realm"),
// replace this line each user's c2talkaccount and
new UsernamePasswordCredentials(intraUser.getC2talkacc ount(),
intraUser.getC2talkpassword())
// new
);

//GetMethod getMethod = new GetMethod(intraUser.getIcalurl());

GetMethod getMethod = new GetMethod(url);

httpClient.executeMethod(getMethod);

//String manualxml = getMethod.getResponseBodyAsString();


TimeZoneRegistry registry =
TimeZoneRegistryFactory.getInstance().createRegist ry();
TimeZone timezone = registry.getTimeZone("Japan/Tokyo");
CalendarBuilder builder = new CalendarBuilder(registry);




Calendar calendar = builder.build(getMethod.getResponseBodyAsStream()) ;//Here
getting exception


System.out.println("-------6--------");

for (Iterator i = calendar.getComponents().iterator(); i.hasNext() {
System.out.println("-------7--------");
Component component = (Component) i.next();
if(component.getName().equals("VEVENT")){
VEvent event = (VEvent) component;


Criteria criteriaTask = session.createCriteria(Task.class);
criteriaTask.add(Restrictions.eq("icaluid", event.getUid().getValue()));
Task task = (Task) criteriaTask.uniqueResult();
if(task == null){
task = new TaskImpl();
}


try {
task.setName(event.getSummary().getValue());
task.setProcessed(false);
task.setTaskCategory(null);
task.setDate(event.getStartDate().getDate());
task.setIcaluid(event.getUid().getValue());


task.setHour(this.getHourFromStartAndEndDate(event .getStartDate().getDate(),event.getEndDate().getDa te()));
task.setIntraUser(intraUser);
task.setEnddate(event.getEndDate().getDate());
Transaction transaction = session.beginTransaction();
session.saveOrUpdate(task);
transaction.commit();
session.flush();
} catch (RuntimeException e) {
e.printStackTrace();
}

// task.setDate(component.get)
System.err.println("Component [" + component.getName() + "]");

for (Iterator j = component.getProperties().iterator(); j.hasNext() {
Property property = (Property) j.next();
System.err.println("Property [" + property.getName() + ", " +
property.getValue() + "]");
}
}
}



} catch (Exception e) {
e.printStackTrace();
}


new HTTPGetRedirection(req, res, "UpdateAttendancesFromTasksOfAUser.do", null);
return null;
}

private float getHourFromStartAndEndDate(Date startdate,Date enddate){
long hourlong = ( enddate.getTime() - startdate.getTime()) / (1000 * 60 * 60 );
return (float)hourlong;

}
}
Reply With Quote

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0