Package org.opencustomer.db.dao.calendar

Examples of org.opencustomer.db.dao.calendar.EventCalendarDAO


                if(!getPanel().isEditable()) {
                    if(log.isDebugEnabled())
                        log.debug("save changes to event calendar without requesting save: "+userEventCalendar);
                   
                    try {
                        new EventCalendarDAO().update(userEventCalendar);
                    } catch(HibernateException e) {
                        log.error("could not save eventCalendar", e);
                    }
                }
            }
View Full Code Here


     */
    public void exportIcal(CalendarVO calendar, UserVO user , OutputStream out) throws IOException, ValidationException, ParseException
    {
        ResourceBundle resourceBundle = ResourceBundle.getBundle("WebResources", user.getLocale());
       
        List<EventCalendarVO> eventcalendars = new EventCalendarDAO().getByCalendar(calendar, true);
        List<EventVO> eventList = new ArrayList<EventVO>();
       
        EventVO event = null;
           
        for(EventCalendarVO eventcalendar : eventcalendars)
View Full Code Here

     * @throws AccessDeniedException thown if there is no write access for this user to the calendar or event.
     */
    public void importIcal(InputStream ical, CalendarVO calendar, UserVO user, EventHandling handling) throws IOException, ParserException, ParseException, AccessDeniedException
    {
        EventDAO eventdao = new EventDAO();
        EventCalendarDAO eventcalendardao = new EventCalendarDAO();

        List<EventVO> events = IcalParser.getInstance().fromIcal(ical);
        List<EventVO> insertList = new ArrayList<EventVO>();
        for(EventVO event : events)
        {
            if(log.isDebugEnabled())
                log.debug("start import: " + event);
           
            if(event.getId() != null// parser found oc id
            {    
                EventVO event2 = eventdao.getById(event.getId());
                if(event2 != null)
                {
                    EventCalendarVO hostEventCalendar = null;
                    EventCalendarVO myEventCalendar = null;
                   
                    for(EventCalendarVO eventCalendar : event2.getEventCalendars()) { // search for myEventCalendar
                        if(calendar.equals(eventCalendar.getCalendar())) {
                            myEventCalendar = eventCalendar;
                        }
                    }
                   
                    for(EventCalendarVO eventCalendar : event2.getEventCalendars()) { // search for the hostEventCalendar entity
                        if(EventCalendarVO.ParticipiantType.HOST.equals(eventCalendar.getParticipiantType())) {
                            hostEventCalendar = eventCalendar;
                        }
                    }
                   
                    if(EntityAccessUtility.isAccessGranted(user,myEventCalendar,Access.WRITE)
                            && EntityAccessUtility.isAccessGranted(calendar.getUser(),hostEventCalendar,Access.WRITE)) // write access ?
                    {
                        event2.setDescription(event.getDescription());
                        event2.setTitle(event.getTitle());
                        event2.setAllDay(event.isAllDay());
                        event2.setEndDate(event.getEndDate());
                        event2.setStartDate(event.getStartDate());
                        event2.setRecurrenceCycle(event.getRecurrenceCycle());
                        event2.setRecurrenceCycleUnit(event.getRecurrenceCycleUnit());
                        event2.setRecurrenceEndDate(event.getRecurrenceEndDate());
                        event2.setRecurrenceStartDate(event.getRecurrenceStartDate());
                        event2.setRecurrenceInMonth(event.getRecurrenceInMonth());
                        event2.setRecurrenceInWeek(event.getRecurrenceInWeek());
                        event2.setRecurrenceNumberOfTimes(event.getRecurrenceNumberOfTimes());
                        event2.setRecurrenceType(event.getRecurrenceType());
                        event2.setRecurrenceUntilDate(event.getRecurrenceUntilDate());
                                              
                        if(log.isDebugEnabled())
                            log.debug("event updated: " + event2);
                       
                        eventdao.update(event2);
                        insertList.add(event2);
                    }
                    else
                    {
                        if(log.isDebugEnabled())
                            log.debug("event update denied: " + event2);
                        insertList.add(event2);
                        throw new AccessDeniedException(calendar.getName(),user.getUserName(),"WRITE");
                    }
                }
                else
                {
                    if(log.isInfoEnabled())
                        log.info("event " + event.getId() + " not found, id incorrect?");
                }
            }
            else
            {     
                // create new Event, no eventid found
                if(EntityAccessUtility.isAccessGranted(user,calendar,Access.WRITE))
                {
                    EventCalendarVO ecvo = new EventCalendarVO(event,calendar);
                    ecvo.setParticipiantType(ParticipiantType.HOST);
                    ecvo.setInvitationStatus(InvitationStatus.ACCEPTED);
                   
                    ecvo.setOwnerUser(calendar.getOwnerUser());
                    ecvo.setOwnerGroup(calendar.getOwnerGroup());
                    ecvo.setAccessUser(calendar.getAccessUser());
                    ecvo.setAccessGroup(calendar.getAccessGroup());
                    ecvo.setAccessGlobal(calendar.getAccessGlobal());
                   
                    event.getEventCalendars().add(ecvo);
                   
                    if(log.isDebugEnabled())
                        log.debug("new event created: " + event);
                   
                    eventdao.insert(event);
                    insertList.add(event);
                                      
                }
                else
                {
                    if(log.isDebugEnabled())
                        log.debug("create event denied: " + event);
                   
                    insertList.add(event);
                    throw new AccessDeniedException(calendar.getName(),user.getUserName(),"WRITE");
                }   
            }     
        }
       
        if(handling == EventHandling.DELETE// deleting events not in insertList
        {
            List<EventCalendarVO> actualList = eventcalendardao.getByCalendar(calendar, true);
            for(EventCalendarVO eventCalendar : actualList)
            {
                if(!insertList.contains(eventCalendar.getEvent()))
                {
                    if(log.isDebugEnabled())
View Full Code Here

            log.debug("found user " + user);
       
        List<CalendarVO> calendars = new CalendarDAO().getAvailableCalendars(user);
        for(CalendarVO calendar : calendars)
        {
            if(!new EventCalendarDAO().getByCalendar(calendar, false).isEmpty())
                calendarmap.put("/files/" + calendar.getUser().getUserName() + ".ics", calendar);
        }
        if(log.isInfoEnabled())
            log.info("webdav connect for user [" + user.getUserName() + "]");
    }
View Full Code Here

TOP

Related Classes of org.opencustomer.db.dao.calendar.EventCalendarDAO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.