import org.collectionspace.services.collectionobject.CollectionobjectsCommon;\r
import org.collectionspace.services.collectionobject.TitleGroup;\r
import org.collectionspace.services.collectionobject.TitleGroupList;\r
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;\r
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;\r
import org.collectionspace.services.intake.IntakesCommon;\r
import org.collectionspace.services.relation.RelationsCommon;\r
import org.jboss.resteasy.client.ClientResponse;\r
import org.collectionspace.services.concept.ConceptAuthorityResource;
import org.collectionspace.services.taxonomy.TaxonomyAuthorityResource;
import org.collectionspace.services.movement.MovementResource;
-import org.collectionspace.services.relation.RelationResource;
import org.collectionspace.services.report.ReportResource;
import org.collectionspace.services.acquisition.AcquisitionResource;
import org.collectionspace.services.dimension.DimensionResource;
import org.collectionspace.services.common.ResourceMap;
import org.collectionspace.services.common.ResourceMapHolder;
import org.collectionspace.services.common.ResourceMapImpl;
+import org.collectionspace.services.common.relation.RelationResource;
import org.collectionspace.services.common.security.SecurityInterceptor;
import org.jboss.resteasy.core.Dispatcher;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.acquisition.AcquisitionsCommon;
import org.collectionspace.services.client.CollectionSpaceClientUtils;
import org.collectionspace.services.common.ResourceBase;
import org.collectionspace.services.common.ResourceMap;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.invocable.InvocationContext;
import org.collectionspace.services.common.invocable.InvocationResults;
import org.collectionspace.services.client.LoanoutClient;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.IQueryManager;
+import org.collectionspace.services.client.Profiler;
import org.collectionspace.services.common.ResourceBase;
-import org.collectionspace.services.common.profile.Profiler;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.relation.RelationResource;
import org.collectionspace.services.relation.RelationsCommonList;
import org.collectionspace.services.relation.RelationshipType;
import org.jboss.resteasy.util.HttpResponseCodes;
--- /dev/null
+package org.collectionspace.services.common.api;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DateUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
+
+ final static String ISO_8601_DATE_PATTERN = "yyyy-MM-dd";
+ final static String UTC_TIMEZONE_IDENTIFIER = "UTC";
+ final static String ISO_8601_UTC_TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+ final static Locale NULL_LOCALE = null;
+ public final static List<String> isoLanguageCodes = new ArrayList(Arrays.asList(Locale.getISOLanguages()));
+
+ /**
+ * Returns the UTC time zone.
+ *
+ * @return The UTC time zone. Defaults to the closely-related GMT time zone,
+ * if for some reason the UTC time zone identifier cannot be understood.
+ */
+ public static TimeZone UTCTimeZone() {
+ return TimeZone.getTimeZone(UTC_TIMEZONE_IDENTIFIER);
+ }
+
+ /**
+ * Parses a presumptive date or date/time, using a supplied format pattern.
+ *
+ * @param str a String, possibly a date or date/time String.
+ * @param pattern A date or date/time pattern.
+ *
+ * @return A date value, resulting from parsing the String using the
+ * supplied pattern. Returns null if the parsing attempt fails.
+ */
+ public static Date parseDate(String str, String pattern) {
+ if (pattern == null || pattern.trim().isEmpty()) {
+ return null;
+ }
+ if (str == null || str.trim().isEmpty()) {
+ return null;
+ }
+ DateFormat df = null;
+ Date date = null;
+ try {
+ df = new SimpleDateFormat(pattern);
+ date = parseDate(str, df);
+ } catch (IllegalArgumentException iae) {
+ return null;
+ }
+ return date;
+ }
+
+ /**
+ * Parses a presumptive date or date/time, using a supplied format pattern.
+ *
+ * @param str a String, possibly a date or date/time String.
+ * @param df A date formatter.
+ *
+ * @return A date value, resulting from parsing the String using the
+ * supplied formatter. Returns null if the parsing attempt fails.
+ */
+ public static Date parseDate(String str, DateFormat df) {
+ if (df == null) {
+ return null;
+ }
+ if (str == null || str.trim().isEmpty()) {
+ return null;
+ }
+ Date date = null;
+ try {
+ df.setLenient(false);
+ date = df.parse(str);
+ } catch (ParseException pe) {
+ return null;
+ }
+ return date;
+ }
+
+ /**
+ * Returns the locale associated with a supplied ISO 639-1 language code.
+ *
+ * @param lang A language code.
+ *
+ * @return A locale based on that language code; or null
+ * if the code was null, empty, or invalid.
+ */
+ public static Locale getLocale(String lang) {
+ if (lang == null || lang.trim().isEmpty()) {
+ logger.warn("Null or empty date language code was provided when getting locale.");
+ return NULL_LOCALE;
+ }
+ if (!isoLanguageCodes.contains(lang.trim())) {
+ logger.warn("Invalid language code '" + lang + "'");
+ return NULL_LOCALE;
+ }
+ return new Locale(lang);
+ }
+
+ /**
+ * Returns a date formatter for a provided date or date/time pattern.
+ *
+ * @param pattern A date or date/time pattern.
+ *
+ * @return A date formatter using that pattern, or null
+ * if the pattern was null, empty, or invalid.
+ */
+ public static DateFormat getDateFormatter(String pattern) {
+ return getDateFormatter(pattern, NULL_LOCALE);
+ }
+
+ /**
+ * Returns a date formatter for a supplied date or date/time pattern,
+ * in the supplied locale (if any).
+ *
+ * @param pattern A date or date/time pattern.
+ * @param locale A locale.
+ *
+ * @return A date formatter using that pattern and locale (if any), or null
+ * if the pattern was null, empty, or invalid.
+ */
+ public static DateFormat getDateFormatter(String pattern, Locale locale) {
+ DateFormat df = null;
+ if (pattern == null || pattern.trim().isEmpty()) {
+ logger.warn("Null or empty date pattern string was provided when getting date formatter.");
+ return df;
+ }
+ try {
+ if (locale == null) {
+ df = new SimpleDateFormat(pattern);
+ } else {
+ df = new SimpleDateFormat(pattern, locale);
+ }
+ df.setLenient(false);
+ } catch (IllegalArgumentException iae) {
+ logger.warn("Invalid date pattern string '" + pattern + "': " + iae.getMessage());
+ }
+ return df;
+ }
+
+ /**
+ * Identifies whether a presumptive date or date/time can be parsed
+ * by a date parser, using a supplied format pattern.
+ *
+ * @param str a String, possibly a date or date/time String.
+ * @param pattern A date or date/time pattern.
+ *
+ * @return true, if the String can be parsed, using the pattern;
+ * false if the String cannot be parsed by the pattern,
+ * or if the String or pattern are null.
+ */
+ public static boolean isParseableByDatePattern(String str, String pattern) {
+ if (pattern == null || pattern.trim().isEmpty()) {
+ return false;
+ }
+ if (str == null || str.trim().isEmpty()) {
+ return false;
+ }
+ DateFormat df = null;
+ try {
+ df = new SimpleDateFormat(pattern);
+ df.parse(str);
+ } catch (ParseException pe) {
+ return false;
+ } catch (IllegalArgumentException iae) {
+ return false;
+ }
+ return true;
+ }
+
+}
--- /dev/null
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+
+ * Copyright © 2009 University of California at Berkeley
+
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+
+ * You may obtain a copy of the ECL 2.0 License at
+
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ */
+package org.collectionspace.services.common.api;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * GregorianCalendarDateTimeUtils.java
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ *
+ */
+public class GregorianCalendarDateTimeUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(GregorianCalendarDateTimeUtils.class);
+
+ /**
+ * Returns a String representing the current date and time instance.
+ * in the UTC time zone, formatted as an ISO 8601 timestamp.
+ *
+ * @return A String representing the current date and time instance.
+ */
+ public static String timestampUTC() {
+ return formatAsISO8601Timestamp(currentDateAndTime(DateUtils.UTCTimeZone()));
+ }
+
+ /**
+ * Returns a String representing the current date and time instance.
+ * in the UTC time zone, formatted as an ISO 8601 date.
+ *
+ * @return A String representing the current date and time instance.
+ */
+ public static String currentDateUTC() {
+ return formatAsISO8601Date(currentDateAndTime(DateUtils.UTCTimeZone()));
+ }
+
+ /**
+ * Returns a calendar date, representing the current date and time instance
+ * in the UTC time zone.
+ *
+ * @return The current date and time instance in the UTC time zone.
+ */
+ public static GregorianCalendar currentDateAndTimeUTC() {
+ return currentDateAndTime(DateUtils.UTCTimeZone());
+ }
+
+ /**
+ * Returns a calendar date, representing the current date and time instance
+ * in the specified time zone.
+ *
+ * @return The current date and time instance in the specified time zone.
+ * If the time zone is null, will return the current time and
+ * date in the time zone intrinsic to a new Calendar instance.
+ */
+ public static GregorianCalendar currentDateAndTime(TimeZone tz) {
+ GregorianCalendar gcal = new GregorianCalendar();
+ if (tz != null) {
+ gcal.setTimeZone(tz);
+ }
+ Date now = new Date();
+ gcal.setTime(now);
+ return gcal;
+ }
+
+
+ /**
+ * Returns a representation of a calendar date and time instance,
+ * as an ISO 8601-formatted timestamp in the UTC time zone.
+ *
+ * @param cal a calendar date and time instance.
+ *
+ * @return a representation of that calendar date and time instance,
+ * as an ISO 8601-formatted timestamp in the UTC time zone.
+ */
+ public static String formatAsISO8601Timestamp(GregorianCalendar cal) {
+ return formatGregorianCalendarDate(cal, DateUtils.UTCTimeZone(),
+ DateUtils.getDateFormatter(DateUtils.ISO_8601_UTC_TIMESTAMP_PATTERN));
+ }
+
+ /**
+ * Returns a representation of a calendar date and time instance,
+ * as an ISO 8601-formatted date.
+ *
+ * @param cal a calendar date and time instance.
+ *
+ * @return a representation of that calendar date and time instance,
+ * as an ISO 8601-formatted date.
+ */
+ public static String formatAsISO8601Date(GregorianCalendar cal) {
+ return formatGregorianCalendarDate(cal, DateUtils.UTCTimeZone(),
+ DateUtils.getDateFormatter(DateUtils.ISO_8601_DATE_PATTERN));
+ }
+
+ /**
+ * Formats a provided calendar date using a supplied date formatter,
+ * in the default system time zone.
+ *
+ * @param date A calendar date to format.
+ * @param df A date formatter to apply.
+ *
+ * @return A formatted date string, or the empty string
+ * if one or more of the parameter values were invalid.
+ */
+ public static String formatGregorianCalendarDate(GregorianCalendar gcal, DateFormat df) {
+ return formatGregorianCalendarDate(gcal, TimeZone.getDefault(), df);
+ }
+
+ /**
+ * Formats a provided calendar date using a provided date formatter,
+ * in a provided time zone.
+ *
+ * @param date A calendar date to format.
+ * @param tz The time zone qualifier for the calendar date to format.
+ * @param df A date formatter to apply.
+ *
+ * @return A formatted date string, or the empty string
+ * if one or more of the parameter values were invalid.
+ */
+ public static String formatGregorianCalendarDate(GregorianCalendar gcal, TimeZone tz, DateFormat df) {
+ String formattedDate = "";
+ if (gcal == null) {
+ logger.warn("Null calendar date was provided when a non-null calendar date was required.");
+ return formattedDate;
+ }
+ if (tz == null) {
+ logger.warn("Null time zone was provided when a non-null time zone was required.");
+ return formattedDate;
+ }
+ if (df == null) {
+ logger.warn("Null date formatter was provided when a non-null date formatter was required.");
+ return formattedDate;
+ }
+ gcal.setTimeZone(tz);
+ Date date = gcal.getTime();
+ df.setTimeZone(tz);
+ formattedDate = df.format(date);
+ return formattedDate;
+ }
+}
import java.util.TimeZone;
import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.api.DateUtils;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
import org.collectionspace.services.common.config.TenantBindingUtils;
import org.collectionspace.services.common.context.ServiceContext;
private static final Logger logger = LoggerFactory.getLogger(DateTimeFormatUtils.class);
final static String DATE_FORMAT_PATTERN_PROPERTY_NAME = "datePattern";
final static String LOCALE_LANGUAGE_CODE_PROPERTY_NAME = "localeLanguage";
- final static Locale NULL_LOCALE = null;
- final static List<String> isoLanguageCodes = new ArrayList(Arrays.asList(Locale.getISOLanguages()));
- final static String ISO_8601_DATE_PATTERN = "yyyy-MM-dd";
- final static String ISO_8601_UTC_TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
static Map<String,List<DateFormat>> dateFormatters = new HashMap<String,List<DateFormat>>();
static Map<String,List<String>> datePatterns = new HashMap<String,List<String>>();
static Map<String,List<String>> localeLanguageCodes = new HashMap<String,List<String>>();
if (hasLanguageCodes) {
for (String languageCode : languageCodes) {
if (languageCode != null && ! languageCode.trim().isEmpty()) {
- locale = getLocale(languageCode);
+ locale = DateUtils.getLocale(languageCode);
for (String pattern : patterns) {
- df = getDateFormatter(pattern, locale);
+ df = DateUtils.getDateFormatter(pattern, locale);
if (df != null) {
formatters.add(df);
}
}
} else {
for (String pattern : patterns) {
- df = getDateFormatter(pattern, locale);
+ df = DateUtils.getDateFormatter(pattern, locale);
if (df != null) {
formatters.add(df);
}
List<String> validPatterns = new ArrayList<String>();
for (String pattern : patterns) {
try {
- df = getDateFormatter(pattern);
+ df = DateUtils.getDateFormatter(pattern);
validPatterns.add(pattern);
} catch (IllegalArgumentException iae) {
logger.warn("Invalid " + DATE_FORMAT_PATTERN_PROPERTY_NAME + " property: " + pattern);
}
List<String> validLanguageCodes = new ArrayList<String>();
for (String code : languageCodes) {
- if (code != null && isoLanguageCodes.contains(code.trim())) {
+ if (code != null && DateUtils.isoLanguageCodes.contains(code.trim())) {
validLanguageCodes.add(code);
}
}
Date date = null;
List<DateFormat> formatters = getDateFormattersForTenant(tenantId);
for (DateFormat formatter : formatters) {
- date = parseDate(dateStr, formatter);
+ date = DateUtils.parseDate(dateStr, formatter);
if (date != null) {
break;
}
} else {
GregorianCalendar gcal = new GregorianCalendar();
gcal.setTime(date);
- String isoStr = formatAsISO8601Timestamp(gcal);
+ String isoStr = GregorianCalendarDateTimeUtils.formatAsISO8601Timestamp(gcal);
return isoStr;
}
}
-
- /**
- * Returns a representation of a calendar date and time instance,
- * as an ISO 8601-formatted timestamp in the UTC time zone.
- *
- * @param cal a calendar date and time instance.
- *
- * @return a representation of that calendar date and time instance,
- * as an ISO 8601-formatted timestamp in the UTC time zone.
- */
- public static String formatAsISO8601Timestamp(GregorianCalendar cal) {
- return formatGregorianCalendarDate(cal, GregorianCalendarDateTimeUtils.UTCTimeZone(),
- getDateFormatter(ISO_8601_UTC_TIMESTAMP_PATTERN));
- }
-
- /**
- * Returns a representation of a calendar date and time instance,
- * as an ISO 8601-formatted date.
- *
- * @param cal a calendar date and time instance.
- *
- * @return a representation of that calendar date and time instance,
- * as an ISO 8601-formatted date.
- */
- public static String formatAsISO8601Date(GregorianCalendar cal) {
- return formatGregorianCalendarDate(cal, GregorianCalendarDateTimeUtils.UTCTimeZone(),
- getDateFormatter(ISO_8601_DATE_PATTERN));
- }
-
- /**
- * Formats a provided calendar date using a supplied date formatter,
- * in the default system time zone.
- *
- * @param date A calendar date to format.
- * @param df A date formatter to apply.
- *
- * @return A formatted date string, or the empty string
- * if one or more of the parameter values were invalid.
- */
- public static String formatGregorianCalendarDate(GregorianCalendar gcal, DateFormat df) {
- return formatGregorianCalendarDate(gcal, TimeZone.getDefault(), df);
- }
-
- /**
- * Formats a provided calendar date using a provided date formatter,
- * in a provided time zone.
- *
- * @param date A calendar date to format.
- * @param tz The time zone qualifier for the calendar date to format.
- * @param df A date formatter to apply.
- *
- * @return A formatted date string, or the empty string
- * if one or more of the parameter values were invalid.
- */
- public static String formatGregorianCalendarDate(GregorianCalendar gcal, TimeZone tz, DateFormat df) {
- String formattedDate = "";
- if (gcal == null) {
- logger.warn("Null calendar date was provided when a non-null calendar date was required.");
- return formattedDate;
- }
- if (tz == null) {
- logger.warn("Null time zone was provided when a non-null time zone was required.");
- return formattedDate;
- }
- if (df == null) {
- logger.warn("Null date formatter was provided when a non-null date formatter was required.");
- return formattedDate;
- }
- gcal.setTimeZone(tz);
- Date date = gcal.getTime();
- df.setTimeZone(tz);
- formattedDate = df.format(date);
- return formattedDate;
- }
-
- /**
- * Identifies whether a presumptive date or date/time can be parsed
- * by a date parser, using a supplied format pattern.
- *
- * @param str a String, possibly a date or date/time String.
- * @param pattern A date or date/time pattern.
- *
- * @return true, if the String can be parsed, using the pattern;
- * false if the String cannot be parsed by the pattern,
- * or if the String or pattern are null.
- */
- public static boolean isParseableByDatePattern(String str, String pattern) {
- if (pattern == null || pattern.trim().isEmpty()) {
- return false;
- }
- if (str == null || str.trim().isEmpty()) {
- return false;
- }
- DateFormat df = null;
- try {
- df = new SimpleDateFormat(pattern);
- df.parse(str);
- } catch (ParseException pe) {
- return false;
- } catch (IllegalArgumentException iae) {
- return false;
- }
- return true;
- }
-
- /**
- * Parses a presumptive date or date/time, using a supplied format pattern.
- *
- * @param str a String, possibly a date or date/time String.
- * @param pattern A date or date/time pattern.
- *
- * @return A date value, resulting from parsing the String using the
- * supplied pattern. Returns null if the parsing attempt fails.
- */
- public static Date parseDate(String str, String pattern) {
- if (pattern == null || pattern.trim().isEmpty()) {
- return null;
- }
- if (str == null || str.trim().isEmpty()) {
- return null;
- }
- DateFormat df = null;
- Date date = null;
- try {
- df = new SimpleDateFormat(pattern);
- date = parseDate(str, df);
- } catch (IllegalArgumentException iae) {
- return null;
- }
- return date;
- }
-
- /**
- * Parses a presumptive date or date/time, using a supplied format pattern.
- *
- * @param str a String, possibly a date or date/time String.
- * @param df A date formatter.
- *
- * @return A date value, resulting from parsing the String using the
- * supplied formatter. Returns null if the parsing attempt fails.
- */
- public static Date parseDate(String str, DateFormat df) {
- if (df == null) {
- return null;
- }
- if (str == null || str.trim().isEmpty()) {
- return null;
- }
- Date date = null;
- try {
- df.setLenient(false);
- date = df.parse(str);
- } catch (ParseException pe) {
- return null;
- }
- return date;
- }
-
- /**
- * Returns the locale associated with a supplied ISO 639-1 language code.
- *
- * @param lang A language code.
- *
- * @return A locale based on that language code; or null
- * if the code was null, empty, or invalid.
- */
- public static Locale getLocale(String lang) {
- if (lang == null || lang.trim().isEmpty()) {
- logger.warn("Null or empty date language code was provided when getting locale.");
- return NULL_LOCALE;
- }
- if (! isoLanguageCodes.contains(lang.trim())) {
- logger.warn("Invalid language code '" + lang + "'");
- return NULL_LOCALE;
- }
- return new Locale(lang);
- }
-
- /**
- * Returns a date formatter for a provided date or date/time pattern.
- *
- * @param pattern A date or date/time pattern.
- *
- * @return A date formatter using that pattern, or null
- * if the pattern was null, empty, or invalid.
- */
- public static DateFormat getDateFormatter(String pattern) {
- return getDateFormatter(pattern, NULL_LOCALE);
- }
-
- /**
- * Returns a date formatter for a supplied date or date/time pattern,
- * in the supplied locale (if any).
- *
- * @param pattern A date or date/time pattern.
- * @param locale A locale.
- *
- * @return A date formatter using that pattern and locale (if any), or null
- * if the pattern was null, empty, or invalid.
- */
- public static DateFormat getDateFormatter(String pattern, Locale locale) {
- DateFormat df = null;
- if (pattern == null || pattern.trim().isEmpty()) {
- logger.warn("Null or empty date pattern string was provided when getting date formatter.");
- return df;
- }
- try {
- if (locale == null) {
- df = new SimpleDateFormat(pattern);
- } else {
- df = new SimpleDateFormat(pattern, locale);
- }
- df.setLenient(false);
- } catch (IllegalArgumentException iae) {
- logger.warn("Invalid date pattern string '" + pattern + "': " + iae.getMessage());
- }
- return df;
- }
-
}
+++ /dev/null
-/**
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
-
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
-
- * Copyright © 2009 University of California at Berkeley
-
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
-
- * You may obtain a copy of the ECL 2.0 License at
-
- * https://source.collectionspace.org/collection-space/LICENSE.txt
- */
-package org.collectionspace.services.common.datetime;
-
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- * GregorianCalendarDateTimeUtils.java
- *
- * $LastChangedRevision: $
- * $LastChangedDate: $
- *
- */
-public class GregorianCalendarDateTimeUtils {
-
- private static final Logger logger = LoggerFactory.getLogger(GregorianCalendarDateTimeUtils.class);
-
- final static String UTC_TIMEZONE_IDENTIFIER = "UTC";
- final static String ISO_8601_UTC_TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
-
- /**
- * Returns the UTC time zone.
- *
- * @return The UTC time zone. Defaults to the closely-related GMT time zone,
- * if for some reason the UTC time zone identifier cannot be understood.
- */
- public static TimeZone UTCTimeZone() {
- return TimeZone.getTimeZone(UTC_TIMEZONE_IDENTIFIER);
- }
-
- /**
- * Returns a calendar date, representing the current date and time instance
- * in the UTC time zone.
- *
- * @return The current date and time instance in the UTC time zone.
- */
- public static GregorianCalendar currentDateAndTimeUTC() {
- return currentDateAndTime(UTCTimeZone());
- }
-
- /**
- * Returns a calendar date, representing the current date and time instance
- * in the specified time zone.
- *
- * @return The current date and time instance in the specified time zone.
- * If the time zone is null, will return the current time and
- * date in the time zone intrinsic to a new Calendar instance.
- */
- public static GregorianCalendar currentDateAndTime(TimeZone tz) {
- GregorianCalendar gcal = new GregorianCalendar();
- if (tz != null) {
- gcal.setTimeZone(tz);
- }
- Date now = new Date();
- gcal.setTime(now);
- return gcal;
- }
-
- /**
- * Returns a String representing the current date and time instance.
- * in the UTC time zone, formatted as an ISO 8601 timestamp.
- *
- * @return A String representing the current date and time instance.
- */
- public static String timestampUTC() {
- return DateTimeFormatUtils.formatAsISO8601Timestamp(currentDateAndTime(UTCTimeZone()));
- }
-
- /**
- * Returns a String representing the current date and time instance.
- * in the UTC time zone, formatted as an ISO 8601 date.
- *
- * @return A String representing the current date and time instance.
- */
- public static String currentDateUTC() {
- return DateTimeFormatUtils.formatAsISO8601Date(currentDateAndTime(UTCTimeZone()));
- }
-
-}
*/\r
package org.collectionspace.services.common.imaging.nuxeo;\r
\r
-import java.awt.Color;\r
-import java.awt.Font;\r
-import java.awt.Graphics;\r
-import java.awt.image.BufferedImage;\r
-import java.io.ByteArrayInputStream;\r
import java.io.File;\r
import java.io.ByteArrayOutputStream;\r
-import java.io.FileDescriptor;\r
-import java.io.FileInputStream;\r
import java.io.FileNotFoundException;\r
import java.io.InputStream;\r
import java.io.BufferedInputStream;\r
import java.util.HashMap;\r
import java.util.List;\r
import java.util.Map;\r
-import java.util.Random;\r
-import java.util.Set;\r
-import java.lang.reflect.Field;\r
-\r
-import javax.imageio.ImageIO;\r
\r
import org.nuxeo.runtime.api.Framework;\r
//import org.nuxeo.runtime.api.ServiceManager;\r
import org.collectionspace.services.common.ServiceMain;\r
import org.collectionspace.services.common.blob.BlobInput;\r
import org.collectionspace.services.common.context.ServiceContext;\r
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;\r
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;\r
import org.collectionspace.services.blob.BlobsCommon;\r
import org.collectionspace.services.blob.DimensionSubGroup;\r
import org.collectionspace.services.blob.DimensionSubGroupList;\r
import org.collectionspace.services.client.IQueryManager;\r
import org.collectionspace.services.client.IRelationsManager;\r
import org.collectionspace.services.common.ReflectionMapper;\r
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;\r
import org.collectionspace.services.common.api.Tools;\r
import org.collectionspace.services.common.context.AbstractServiceContextImpl;\r
-import org.collectionspace.services.common.context.MultipartServiceContext;\r
-import org.collectionspace.services.common.datetime.DateTimeFormatUtils;\r
import org.collectionspace.services.common.document.DocumentException;\r
import org.collectionspace.services.common.document.DocumentWrapper;\r
import org.collectionspace.services.common.query.QueryContext;\r
import org.collectionspace.services.common.relation.nuxeo.RelationsUtils;\r
import org.collectionspace.services.config.service.DocHandlerParams;\r
import org.collectionspace.services.config.service.ListResultField;\r
-import org.collectionspace.services.config.service.ServiceBindingType;\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
import org.collectionspace.services.nuxeo.client.java.CommonList;\r
import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;\r
GregorianCalendar cal = (GregorianCalendar)\r
docModel.getProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,\r
CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_AT);\r
- String updatedAt = DateTimeFormatUtils.formatAsISO8601Timestamp(cal);\r
+ String updatedAt = GregorianCalendarDateTimeUtils.formatAsISO8601Timestamp(cal);\r
return updatedAt;\r
}\r
\r
import org.collectionspace.services.client.IRelationsManager;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
import org.collectionspace.services.common.context.ServiceContext;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.client.IQueryManager;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.context.ServiceBindingUtils;
import org.collectionspace.services.common.context.ServiceContext;
if (value == null) {
// Nothing to do - leave returnVal null
} else if (value instanceof GregorianCalendar) {
- returnVal = DateTimeFormatUtils.formatAsISO8601Timestamp((GregorianCalendar) value);
+ returnVal = GregorianCalendarDateTimeUtils.formatAsISO8601Timestamp((GregorianCalendar) value);
} else {
returnVal = value.toString();
}
import org.collectionspace.services.client.ConceptAuthorityClient;
import org.collectionspace.services.client.ConceptAuthorityClientUtils;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
-import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.concept.ConceptTermGroup;
import org.collectionspace.services.concept.ConceptTermGroupList;
import org.collectionspace.services.concept.ConceptauthoritiesCommon;
import org.collectionspace.services.common.XmlSaxFragmenter;
import org.collectionspace.services.common.XmlTools;
import org.collectionspace.services.common.api.FileTools;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
import org.collectionspace.services.common.config.URIUtils;
import org.collectionspace.services.common.context.ServiceBindingUtils;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.config.service.ServiceBindingType;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.dom4j.Attribute;
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.intake.ConditionCheckerOrAssessorList;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.intake.InsurerList;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.intake.EntryMethodList;
import org.collectionspace.services.intake.FieldCollectionEventNameList;
import org.collectionspace.services.intake.CurrentLocationGroup;
import org.collectionspace.services.client.OrgAuthorityClientUtils;\r
import org.collectionspace.services.client.PayloadOutputPart;\r
import org.collectionspace.services.client.PoxPayloadOut;\r
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;\r
import org.collectionspace.services.common.authorityref.AuthorityRefDocList;\r
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;\r
import org.collectionspace.services.intake.ConditionCheckerOrAssessorList;\r
import org.collectionspace.services.intake.IntakesCommon;\r
import org.collectionspace.services.intake.InsurerList;\r
import org.collectionspace.services.client.PersonAuthorityClient;
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.intake.ConditionCheckerOrAssessorList;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.intake.InsurerList;
import java.util.List;
import java.util.Map;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.collectionspace.services.PersonJAXBSchema;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanin.LenderGroup;
import org.collectionspace.services.loanin.LenderGroupList;
//import java.util.ArrayList;
import java.util.List;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanin.LenderGroup;
import org.collectionspace.services.loanin.LenderGroupList;
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanout.LoansoutCommon;
import org.collectionspace.services.person.PersonTermGroup;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanout.LoanStatusGroup;
import org.collectionspace.services.loanout.LoanStatusGroupList;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.client.LocationAuthorityClient;
import org.collectionspace.services.client.LocationAuthorityClientUtils;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.location.LocTermGroup;
import org.collectionspace.services.location.LocTermGroupList;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.movement.MovementsCommon;
import org.collectionspace.services.person.PersonTermGroup;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.MovementClient;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.objectexit.StructuredDateGroup;
import org.collectionspace.services.objectexit.ObjectexitCommon;