Java Code Examples for lotus.domino.Session#getCalendar()

The following examples show how to use lotus.domino.Session#getCalendar() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotesCalendarStore.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
public String getEvent(String id, String recurrenceId)
        throws StoreException {
    String result = null;
    NotesCalendar calendar = null;
    
    try {
        Session session = _database.getParent();
        calendar = session.getCalendar(_database);
        NotesCalendarEntry entry = calendar.getEntry(id);
        result = entry.read(recurrenceId);
    }
    catch (NotesException e) {
        throw new StoreException("Error reading event", mapError(e.id), e); // $NLX-NotesEventStore.Errorreadingevent-1$
    }
    finally {
        BackendUtil.safeRecycle(calendar);
    }
    
    return result;
}
 
Example 2
Source File: NotesCalendarStore.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
public String createEvent(String event, int flags) throws StoreException {
    String result = null;
    NotesCalendar calendar = null;
    
    try {
        Session session = _database.getParent();
        calendar = session.getCalendar(_database);
        NotesCalendarEntry entry = calendar.createEntry(event, translateFlags(flags));
        result = entry.read();
    }
    catch (NotesException e) {
        throw new StoreException("Error creating event", mapError(e.id), e); // $NLX-NotesEventStore.Errorcreatingevent-1$
    }
    finally {
        BackendUtil.safeRecycle(calendar);
    }
    
    return result;
}
 
Example 3
Source File: NotesCalendarStore.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
public String updateEvent(String event, String id, String recurrenceId,
        String comments, int flags) throws StoreException {
    String result = null;
    NotesCalendar calendar = null;
    
    try {
        Session session = _database.getParent();
        calendar = session.getCalendar(_database);
        NotesCalendarEntry entry = calendar.getEntry(id);
        entry.update(event, comments, translateFlags(flags), recurrenceId);
        result = entry.read(recurrenceId);
    }
    catch (NotesException e) {
        throw new StoreException("Error updating event", mapError(e.id), e); // $NLX-NotesEventStore.Errorupdatingevent-1$
    }
    finally {
        BackendUtil.safeRecycle(calendar);
    }
    
    return result;
}
 
Example 4
Source File: NotesCalendarStore.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
public String getNotice(String id) throws StoreException {

        String result = null;
        NotesCalendar calendar = null;
        
        try {
            Session session = _database.getParent();
            calendar = session.getCalendar(_database);
            NotesCalendarNotice notice = null;

            notice = calendar.getNoticeByUNID(id);
            if ( notice != null ) {
                result = notice.read();
            }
        }
        catch (NotesException e) {
            throw new StoreException("Error getting calendar notice", mapError(e.id), e); // $NLX-NotesEventStore.Errorgettingnotice-1$
        }
        finally {
            BackendUtil.safeRecycle(calendar);
        }
        
        return result;
    }
 
Example 5
Source File: NotesCalendarStore.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public void deleteEvent(String id, String recurrenceId,
        RecurrenceRange range, int flags) throws StoreException {
    NotesCalendar calendar = null;
    
    try {
        Session session = _database.getParent();
        calendar = session.getCalendar(_database);
        NotesCalendarEntry entry = calendar.getEntry(id);
        
        if ( (flags & ICalendarStore.FLAG_NO_WORKFLOW) != 0 ) {
            calendar.setAutoSendNotices(false);
        }
        
        if ( recurrenceId == null ) {
            entry.remove(NotesCalendarEntry.CS_RANGE_REPEAT_ALL, null);
        }
        else {
            entry.remove(rangeToInt(range), recurrenceId);
        }
    }
    catch (NotesException e) {
        throw new StoreException("Error deleting event", mapError(e.id), e); // $NLX-NotesEventStore.Errordeletingevent-1$
    }
    finally {
        BackendUtil.safeRecycle(calendar);
    }
}
 
Example 6
Source File: NotesCalendarStore.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public String[] getUnappliedNotices(String id) throws StoreException {
    
    String iCalendarNotices[] = null;
    NotesCalendar calendar = null;
    
    try {
        Session session = _database.getParent();
        calendar = session.getCalendar(_database);
        Vector<Object> list = null;
        
        NotesCalendarEntry entry = calendar.getEntry(id);
        if ( entry != null ) {
            list = entry.getNotices();
        }

        // Convert Vector<NotesCalendarNotice> to an array of iCalendar notices.
        
        if ( list != null && list.size() > 0 ) {
            iCalendarNotices = new String[list.size()];
            
            Iterator<Object> iterator = list.iterator();
            int i = 0;
            while (iterator.hasNext()) {
                Object obj = iterator.next();
                if ( obj instanceof NotesCalendarNotice) {
                    NotesCalendarNotice notice = (NotesCalendarNotice)obj;
                    iCalendarNotices[i++] = notice.read();
                }
            }
        }
    }
    catch (NotesException e) {
        throw new StoreException("Error getting unapplied notices", mapError(e.id), e); // $NLX-NotesEventStore.Errorgettingunappliednotices-1$
    }
    finally {
        BackendUtil.safeRecycle(calendar);
    }
    
    return iCalendarNotices;
}
 
Example 7
Source File: NotesCalendarStore.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public EventSet getEvents(Date fromDate, Date toDate, int skipCount, int maxEvents, ArrayList<String> rangeFieldsFilter) throws StoreException {
    EventSet result = null;
    NotesCalendar calendar = null;
    DateTime dtstart = null;
    DateTime dtend = null;
    
    try {
        Session session = _database.getParent();
        calendar = session.getCalendar(_database);
        
        // TODO:  Should we set the mask back to the default when we are done?
        int newMask = 0;
        boolean useDefaultFilterMask = true;
        if( rangeFieldsFilter!=null ){
            Iterator<String> rangeFieldsFilterIterator = rangeFieldsFilter.iterator();
            while(rangeFieldsFilterIterator.hasNext()){
                String filter = rangeFieldsFilterIterator.next();
                if(SUPPORT_RANGE_FILTER.containsKey(filter)){
                    newMask |= SUPPORT_RANGE_FILTER.get(filter);
                    useDefaultFilterMask = false;
                }
            }
        }
        if(useDefaultFilterMask){
            newMask = READ_RANGE_ALL;             
        }

        // Convert Java dates to DateTime objects 
        
        if ( fromDate == null ) {
            if ( toDate == null ) {
                // Start and end dates are null.  Read one year of
                // events starting today.
                Date now = new Date();
                dtstart = session.createDateTime(now);
                dtend = session.createDateTime(new Date(now.getTime() + ONE_YEAR));
            }
            else {
                // Start date is null, but end date is not.  Read 
                // one year of events ending on the given date.
                dtstart = session.createDateTime(new Date(toDate.getTime() - ONE_YEAR));
                dtend = session.createDateTime(toDate);
            }
        }
        else {
            if ( toDate == null ) {
                // End date is null, but start date is not.  Read 
                // one year of events starting on the given date.
                dtstart = session.createDateTime(fromDate);
                dtend = session.createDateTime( new Date(fromDate.getTime() + ONE_YEAR) );
            }
            else {
                dtstart = session.createDateTime(fromDate);
                dtend = session.createDateTime(toDate);
            }
        }
        
        calendar.setReadRangeMask1(newMask);
        String events = calendar.readRange(dtstart, dtend, skipCount, maxEvents);
        result = new EventSet(events, calendar.getEntriesProcessed() - skipCount); 
    }
    catch (NotesException e) {
        throw new StoreException("Error reading events", mapError(e.id), e);  // $NLX-NotesCalendarStore.Errorreadingevents-1$
    }
    finally {
        BackendUtil.safeRecycle(dtstart);
        BackendUtil.safeRecycle(dtend);
        BackendUtil.safeRecycle(calendar);
    }
    
    return result;
}
 
Example 8
Source File: NotesCalendarStore.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public void processEventAction(String id, String recurrenceId,
        RecurrenceRange range, Action action) throws StoreException {
    NotesCalendar calendar =  null;
    
    try {
        Session session = _database.getParent();
        calendar = session.getCalendar(_database);
        NotesCalendarEntry entry = calendar.getEntry(id);
        boolean keepInformed = false;
        
        switch(action.getActionType()) {
        
        case Action.ACTION_ACCEPT:
            entry.accept(action.getComments(), rangeToInt(range), recurrenceId);
            break;
            
        case Action.ACTION_CANCEL:
            entry.cancel(action.getComments(), rangeToInt(range), recurrenceId);
            break;
            
        case Action.ACTION_COUNTER:
            CounterAction ca = (CounterAction)action;
            DateTime start = session.createDateTime(ca.getStart());
            DateTime end = session.createDateTime(ca.getEnd());
            entry.counter(action.getComments(), start, end, rangeToInt(range), recurrenceId);
            break;
            
        case Action.ACTION_DECLINE:
            DeclineAction decline = (DeclineAction)action;
            if ( decline.getKeepInformed() != null ) {
                // This logic is not exactly right.  We need a way to tell decline()
                // to use the user's default value for keepInformed.  TODO: Fix 
                // this when we have the right variant of decline().
                keepInformed = decline.getKeepInformed().booleanValue();
            }
            entry.decline(action.getComments(), keepInformed, rangeToInt(range), recurrenceId);
            break;
            
        case Action.ACTION_DELEGATE:
            DelegateAction delegate = (DelegateAction)action;
            if ( delegate.getKeepInformed() != null ) {
                // This logic is not exactly right.  We need a way to tell delegate()
                // to use the user's default value for keepInformed.  TODO: Fix 
                // this when we have the right variant of delegate().
                keepInformed = delegate.getKeepInformed().booleanValue();
            }
            entry.delegate(delegate.getComments(), delegate.getDelegateTo(), keepInformed, rangeToInt(range), recurrenceId);
            break;
            
        case Action.ACTION_DELETE:
            entry.remove(rangeToInt(range),recurrenceId);
            break;
            
        case Action.ACTION_REMOVE_CANCEL:
            // TODO: What does this map to?
            break;
            
        case Action.ACTION_REQUEST_INFO:
            entry.requestInfo(action.getComments(),recurrenceId);
            break;
            
        case Action.ACTION_TENTATIVE:
            entry.tentativelyAccept(action.getComments(), rangeToInt(range), recurrenceId);
            break;
            
        case Action.ACTION_PROCESS_ALL:
            // TODO: Figure what this maps to.  The processAll method is no longer
            // exported from the back end.
            
            //entry.processAll();
            break;
            
        default:                
            throw new StoreException("Error processing event action", StoreException.ERR_BAD_ACTION,new NotesException()); // $NLX-NotesCalendarStore.Errorprocessingeventaction-1$
            
        }
        
    }
    catch (NotesException e) {
        throw new StoreException("Error processing event action", mapError(e.id), e); // $NLX-NotesEventStore.Errorprocessingeventaction-1$
    }
    finally {
        BackendUtil.safeRecycle(calendar);
    }
}
 
Example 9
Source File: NotesCalendarStore.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public void processNoticeAction(String id, Action action)
        throws StoreException {
    NotesCalendar calendar = null;
    
    try {
        Session session = _database.getParent();
        calendar = session.getCalendar(_database);
        NotesCalendarNotice notice = calendar.getNoticeByUNID(id);
        boolean keepInformed = false;
        
        switch(action.getActionType()) {
        
        case Action.ACTION_ACCEPT:
            notice.accept(action.getComments());
            break;
            
        case Action.ACTION_COUNTER:
            CounterAction ca = (CounterAction)action;
            DateTime start = session.createDateTime(ca.getStart());
            DateTime end = session.createDateTime(ca.getEnd());
            notice.counter(action.getComments(), start, end);
            break;
            
        case Action.ACTION_DECLINE:
            DeclineAction decline = (DeclineAction)action;
            if ( decline.getKeepInformed() != null ) {
                // This logic is not exactly right.  We need a way to tell decline()
                // to use the user's default value for keepInformed.  TODO: Fix 
                // this when we have the right variant of decline().
                keepInformed = decline.getKeepInformed().booleanValue();
            }
            // Without keepInformed equal keepInformed false
            notice.decline(action.getComments(), keepInformed);               
            break;
            
        case Action.ACTION_DELEGATE:
            DelegateAction delegate = (DelegateAction)action;
            if ( delegate.getKeepInformed() != null ) {
                // This logic is not exactly right.  We need a way to tell delegate()
                // to use the user's default value for keepInformed.  TODO: Fix 
                // this when we have the right variant of delegate().
                keepInformed = delegate.getKeepInformed().booleanValue();
            }
            notice.delegate(delegate.getComments(), delegate.getDelegateTo(), keepInformed);
            break;
            
        case Action.ACTION_REMOVE_CANCEL:
            notice.removeCancelled();
            break;
            
        case Action.ACTION_REQUEST_INFO:
            notice.requestInfo(action.getComments());
            break;
            
        case Action.ACTION_TENTATIVE:
            notice.tentativelyAccept(action.getComments());
            break;
           
        default:                
            throw new StoreException("Error processing notice action", StoreException.ERR_ACTION_NOT_SUPPORTED,new NotesException()); // $NLX-NotesCalendarStore.Errorprocessingnoticeaction-1$
        }
        
    }
    catch (NotesException e) {
        throw new StoreException("Error processing notice action", mapError(e.id), e); // $NLX-NotesEventStore.Errorprocessingnoticeaction-1$
    }
    finally {
        BackendUtil.safeRecycle(calendar);
    }
}