diff --git a/core/src/main/java/org/osaf/cosmo/calendar/FreeBusyUtils.java b/core/src/main/java/org/osaf/cosmo/calendar/FreeBusyUtils.java index cb1551c..8013c3c 100644 --- a/core/src/main/java/org/osaf/cosmo/calendar/FreeBusyUtils.java +++ b/core/src/main/java/org/osaf/cosmo/calendar/FreeBusyUtils.java @@ -1,12 +1,12 @@ /* * Copyright 2007 Open Source Applications Foundation - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ import java.util.Iterator; import java.util.List; - +import java.util.UUID; import net.fortuna.ical4j.model.Parameter; import net.fortuna.ical4j.model.Period; import net.fortuna.ical4j.model.PeriodList; @@ -31,13 +31,8 @@ import net.fortuna.ical4j.model.property.FreeBusy; import net.fortuna.ical4j.model.property.Uid; -import org.apache.commons.id.uuid.VersionFourGenerator; - public class FreeBusyUtils { - - private static final VersionFourGenerator uuidGenerator = - new VersionFourGenerator(); - + /** A VFREEBUSY component overlaps a given time range if the condition for the corresponding component state specified in the table below @@ -46,13 +41,13 @@ public class FreeBusyUtils { FREEBUSY properties in the absence of DTSTART and DTEND. Any DURATION property is ignored, as it has a special meaning when used in a VFREEBUSY component. - + When only FREEBUSY properties are used, each period in each FREEBUSY property is compared against the time range, irrespective of the type of free busy information (free, busy, busy-tentative, busy-unavailable) represented by the property. - - + + +------------------------------------------------------+ | VFREEBUSY has both the DTSTART and DTEND properties? | | +--------------------------------------------------+ @@ -74,21 +69,21 @@ of the type of free busy information (free, busy, busy-tentative, * @return true if component overlaps specified range, false otherwise */ public static boolean overlapsPeriod(VFreeBusy freeBusy, Period period, TimeZone tz){ - + DtStart start = freeBusy.getStartDate(); DtEnd end = freeBusy.getEndDate(); - + if (start != null && end != null) { InstanceList instances = new InstanceList(); instances.setTimezone(tz); instances.addComponent(freeBusy, period.getStart(),period.getEnd()); return !instances.isEmpty(); } - + PropertyList props = freeBusy.getProperties(Property.FREEBUSY); if(props.isEmpty()) return false; - + Iterator it = props.iterator(); while(it.hasNext()) { FreeBusy fb = it.next(); @@ -100,10 +95,10 @@ public static boolean overlapsPeriod(VFreeBusy freeBusy, Period period, TimeZone return true; } } - + return false; } - + /** * Merge multiple VFREEBUSY components into a single VFREEBUSY * component. @@ -121,7 +116,7 @@ public static VFreeBusy mergeComponents(List components, PeriodList busyPeriods = new PeriodList(); PeriodList busyTentativePeriods = new PeriodList(); PeriodList busyUnavailablePeriods = new PeriodList(); - + for(VFreeBusy vfb: components) { PropertyList props = vfb.getProperties(Property.FREEBUSY); for(Iterator it = props.iterator();it.hasNext();) { @@ -137,18 +132,18 @@ public static VFreeBusy mergeComponents(List components, } } } - + // Merge periods busyPeriods = busyPeriods.normalise(); busyTentativePeriods = busyTentativePeriods.normalise(); busyUnavailablePeriods = busyUnavailablePeriods.normalise(); - + // Construct new VFREEBUSY VFreeBusy vfb = new VFreeBusy(range.getStart(), range.getEnd()); - String uid = uuidGenerator.nextIdentifier().toString(); + String uid = UUID.randomUUID().toString(); vfb.getProperties().add(new Uid(uid)); - + // Add all periods to the VFREEBUSY if (!busyPeriods.isEmpty()) { FreeBusy fb = new FreeBusy(busyPeriods); @@ -164,8 +159,8 @@ public static VFreeBusy mergeComponents(List components, fb.getParameters().add(FbType.BUSY_UNAVAILABLE); vfb.getProperties().add(fb); } - + return vfb; } - + } diff --git a/core/src/main/java/org/osaf/cosmo/calendar/query/impl/StandardCalendarQueryProcessor.java b/core/src/main/java/org/osaf/cosmo/calendar/query/impl/StandardCalendarQueryProcessor.java index bfaf0eb..1e32124 100644 --- a/core/src/main/java/org/osaf/cosmo/calendar/query/impl/StandardCalendarQueryProcessor.java +++ b/core/src/main/java/org/osaf/cosmo/calendar/query/impl/StandardCalendarQueryProcessor.java @@ -15,7 +15,19 @@ */ package org.osaf.cosmo.calendar.query.impl; -import net.fortuna.ical4j.model.*; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import net.fortuna.ical4j.model.Calendar; +import net.fortuna.ical4j.model.Component; +import net.fortuna.ical4j.model.ComponentList; +import net.fortuna.ical4j.model.DateTime; +import net.fortuna.ical4j.model.Parameter; +import net.fortuna.ical4j.model.Period; +import net.fortuna.ical4j.model.PeriodList; +import net.fortuna.ical4j.model.Property; +import net.fortuna.ical4j.model.PropertyList; +import net.fortuna.ical4j.model.TimeZone; import net.fortuna.ical4j.model.component.CalendarComponent; import net.fortuna.ical4j.model.component.VEvent; import net.fortuna.ical4j.model.component.VFreeBusy; @@ -24,19 +36,26 @@ import net.fortuna.ical4j.model.property.Status; import net.fortuna.ical4j.model.property.Transp; import net.fortuna.ical4j.model.property.Uid; -import org.apache.commons.id.uuid.VersionFourGenerator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osaf.cosmo.calendar.EntityConverter; import org.osaf.cosmo.calendar.Instance; import org.osaf.cosmo.calendar.InstanceList; -import org.osaf.cosmo.calendar.query.*; +import org.osaf.cosmo.calendar.query.CalendarFilter; +import org.osaf.cosmo.calendar.query.CalendarFilterEvaluater; +import org.osaf.cosmo.calendar.query.CalendarQueryProcessor; +import org.osaf.cosmo.calendar.query.ComponentFilter; +import org.osaf.cosmo.calendar.query.TimeRangeFilter; import org.osaf.cosmo.dao.CalendarDao; import org.osaf.cosmo.dao.ContentDao; -import org.osaf.cosmo.model.*; - -import java.util.HashSet; -import java.util.Set; +import org.osaf.cosmo.model.CalendarCollectionStamp; +import org.osaf.cosmo.model.CollectionItem; +import org.osaf.cosmo.model.ContentItem; +import org.osaf.cosmo.model.HomeCollectionItem; +import org.osaf.cosmo.model.ICalendarItem; +import org.osaf.cosmo.model.Item; +import org.osaf.cosmo.model.StampUtils; +import org.osaf.cosmo.model.User; /** * CalendarQueryProcessor implementation that uses CalendarDao. @@ -46,8 +65,6 @@ public class StandardCalendarQueryProcessor implements CalendarQueryProcessor { private static final Log log = LogFactory.getLog(StandardCalendarQueryProcessor.class); - protected static final VersionFourGenerator uuidGenerator = - new VersionFourGenerator(); private CalendarDao calendarDao = null; private ContentDao contentDao = null; @@ -339,7 +356,7 @@ protected VFreeBusy createVFreeBusy(PeriodList busyPeriods, // Now create a VFREEBUSY VFreeBusy vfb = new VFreeBusy(period.getStart(), period.getEnd()); - String uid = uuidGenerator.nextIdentifier().toString(); + String uid = UUID.randomUUID().toString(); vfb.getProperties().add(new Uid(uid)); // Add all periods to the VFREEBUSY diff --git a/core/src/main/java/org/osaf/cosmo/model/hibernate/HibEntityFactory.java b/core/src/main/java/org/osaf/cosmo/model/hibernate/HibEntityFactory.java index da1e3f3..ca0681a 100644 --- a/core/src/main/java/org/osaf/cosmo/model/hibernate/HibEntityFactory.java +++ b/core/src/main/java/org/osaf/cosmo/model/hibernate/HibEntityFactory.java @@ -15,15 +15,34 @@ */ package org.osaf.cosmo.model.hibernate; -import org.apache.commons.id.IdentifierGenerator; -import org.apache.commons.id.uuid.VersionFourGenerator; -import org.osaf.cosmo.model.*; -import org.w3c.dom.Element; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; import java.util.Calendar; +import java.util.UUID; +import org.osaf.cosmo.model.AvailabilityItem; +import org.osaf.cosmo.model.BinaryAttribute; +import org.osaf.cosmo.model.CalendarAttribute; +import org.osaf.cosmo.model.CalendarCollectionStamp; +import org.osaf.cosmo.model.CollectionItem; +import org.osaf.cosmo.model.CollectionSubscription; +import org.osaf.cosmo.model.DecimalAttribute; +import org.osaf.cosmo.model.EntityFactory; +import org.osaf.cosmo.model.EventExceptionStamp; +import org.osaf.cosmo.model.EventStamp; +import org.osaf.cosmo.model.FileItem; +import org.osaf.cosmo.model.FreeBusyItem; +import org.osaf.cosmo.model.IntegerAttribute; +import org.osaf.cosmo.model.MessageStamp; +import org.osaf.cosmo.model.NoteItem; +import org.osaf.cosmo.model.PasswordRecovery; +import org.osaf.cosmo.model.QName; +import org.osaf.cosmo.model.StringAttribute; +import org.osaf.cosmo.model.TaskStamp; +import org.osaf.cosmo.model.TextAttribute; +import org.osaf.cosmo.model.User; +import org.osaf.cosmo.model.XmlAttribute; +import org.w3c.dom.Element; /** * EntityFactory implementation that uses Hibernate @@ -31,8 +50,6 @@ */ public class HibEntityFactory implements EntityFactory { - private IdentifierGenerator idGenerator = new VersionFourGenerator(); - public CollectionItem createCollection() { return new HibCollectionItem(); } @@ -122,7 +139,7 @@ public User createUser() { } public String generateUid() { - return idGenerator.nextIdentifier().toString(); + return UUID.randomUUID().toString(); } } diff --git a/core/src/test/java/org/osaf/cosmo/dao/mock/MockUserDao.java b/core/src/test/java/org/osaf/cosmo/dao/mock/MockUserDao.java index 702a384..af16bcd 100644 --- a/core/src/test/java/org/osaf/cosmo/dao/mock/MockUserDao.java +++ b/core/src/test/java/org/osaf/cosmo/dao/mock/MockUserDao.java @@ -15,19 +15,28 @@ */ package org.osaf.cosmo.dao.mock; -import org.apache.commons.id.uuid.VersionFourGenerator; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.UUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osaf.cosmo.dao.UserDao; -import org.osaf.cosmo.model.*; +import org.osaf.cosmo.model.CollectionSubscription; +import org.osaf.cosmo.model.DuplicateEmailException; +import org.osaf.cosmo.model.DuplicateUsernameException; +import org.osaf.cosmo.model.PasswordRecovery; +import org.osaf.cosmo.model.User; import org.osaf.cosmo.model.mock.MockAuditableObject; import org.osaf.cosmo.model.mock.MockUser; import org.osaf.cosmo.util.ArrayPagedList; import org.osaf.cosmo.util.PageCriteria; import org.osaf.cosmo.util.PagedList; -import java.util.*; - /** * Mock implementation of {@link UserDao} useful for testing. */ @@ -44,8 +53,6 @@ public class MockUserDao implements UserDao { private MockDaoStorage storage = null; - private VersionFourGenerator idGenerator = new VersionFourGenerator(); - /** */ public MockUserDao(MockDaoStorage storage) { @@ -135,7 +142,7 @@ public User createUser(User user) { throw new IllegalArgumentException("null user"); } - user.setUid(idGenerator.nextIdentifier().toString()); + user.setUid(UUID.randomUUID().toString()); // Set create/modified date, etag for User and associated subscriptions // and perferences. diff --git a/core/src/test/java/org/osaf/cosmo/model/mock/MockEntityFactory.java b/core/src/test/java/org/osaf/cosmo/model/mock/MockEntityFactory.java index a7a3015..4331ab6 100644 --- a/core/src/test/java/org/osaf/cosmo/model/mock/MockEntityFactory.java +++ b/core/src/test/java/org/osaf/cosmo/model/mock/MockEntityFactory.java @@ -15,23 +15,40 @@ */ package org.osaf.cosmo.model.mock; -import org.apache.commons.id.IdentifierGenerator; -import org.apache.commons.id.uuid.VersionFourGenerator; -import org.osaf.cosmo.model.*; -import org.w3c.dom.Element; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; import java.util.Calendar; +import java.util.UUID; +import org.osaf.cosmo.model.AvailabilityItem; +import org.osaf.cosmo.model.BinaryAttribute; +import org.osaf.cosmo.model.CalendarAttribute; +import org.osaf.cosmo.model.CalendarCollectionStamp; +import org.osaf.cosmo.model.CollectionItem; +import org.osaf.cosmo.model.CollectionSubscription; +import org.osaf.cosmo.model.DecimalAttribute; +import org.osaf.cosmo.model.EntityFactory; +import org.osaf.cosmo.model.EventExceptionStamp; +import org.osaf.cosmo.model.EventStamp; +import org.osaf.cosmo.model.FileItem; +import org.osaf.cosmo.model.FreeBusyItem; +import org.osaf.cosmo.model.IntegerAttribute; +import org.osaf.cosmo.model.MessageStamp; +import org.osaf.cosmo.model.NoteItem; +import org.osaf.cosmo.model.PasswordRecovery; +import org.osaf.cosmo.model.QName; +import org.osaf.cosmo.model.StringAttribute; +import org.osaf.cosmo.model.TaskStamp; +import org.osaf.cosmo.model.TextAttribute; +import org.osaf.cosmo.model.User; +import org.osaf.cosmo.model.XmlAttribute; +import org.w3c.dom.Element; /** * EntityFactory implementation that uses mock objects. */ public class MockEntityFactory implements EntityFactory { - private IdentifierGenerator idGenerator = new VersionFourGenerator(); - public CollectionItem createCollection() { return new MockCollectionItem(); } @@ -121,7 +138,7 @@ public User createUser() { } public String generateUid() { - return idGenerator.nextIdentifier().toString(); + return UUID.randomUUID().toString(); } }