| | |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.schema; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.TimeZone; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.ApproximateMatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.opends.messages.MessageBuilder; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | * The lock that will be used to provide threadsafe access to the date |
| | | * formatter. |
| | | */ |
| | | private static ReentrantLock dateFormatLock; |
| | | private static Object dateFormatLock; |
| | | |
| | | |
| | | |
| | |
| | | dateFormat.setLenient(false); |
| | | dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); |
| | | |
| | | dateFormatLock = new ReentrantLock(); |
| | | dateFormatLock = new Object(); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | String valueString; |
| | | |
| | | dateFormatLock.lock(); |
| | | |
| | | try |
| | | synchronized (dateFormatLock) |
| | | { |
| | | valueString = dateFormat.format(d); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | // This should never happen. |
| | | valueString = null; |
| | | } |
| | | finally |
| | | { |
| | | dateFormatLock.unlock(); |
| | | } |
| | | |
| | | return new AttributeValue(new ASN1OctetString(valueString), |
| | | new ASN1OctetString(valueString)); |
| | |
| | | String valueString = normalizedValue.stringValue(); |
| | | try |
| | | { |
| | | dateFormatLock.lock(); |
| | | |
| | | try |
| | | synchronized (dateFormatLock) |
| | | { |
| | | return dateFormat.parse(valueString); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // We'll let this be handled by the outer loop. |
| | | throw e; |
| | | } |
| | | finally |
| | | { |
| | | dateFormatLock.unlock(); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |