Package com.amazonaws.util

Examples of com.amazonaws.util.DateUtils


                    @Override
                    public Object unmarshall(AttributeValue value) throws ParseException {
                        Set<Date> argument = new HashSet<Date>();
                        for ( String s : value.getSS() ) {
                            argument.add(new DateUtils().parseIso8601Date(s));
                        }
                        return argument;
                    }
                };
            } else {
                unmarshaller = new SUnmarshaller() {

                    @Override
                    public Object unmarshall(AttributeValue value) throws ParseException {
                        return new DateUtils().parseIso8601Date(value.getS());
                    }
                };
            }
        } else if ( Calendar.class.isAssignableFrom(paramType) ) {
            if ( isCollection ) {
                unmarshaller = new SSUnmarshaller() {

                    @Override
                    public Object unmarshall(AttributeValue value) throws ParseException {
                        Set<Calendar> argument = new HashSet<Calendar>();
                        for ( String s : value.getSS() ) {
                            Calendar cal = GregorianCalendar.getInstance();
                            cal.setTime(new DateUtils().parseIso8601Date(s));
                            argument.add(cal);
                        }
                        return argument;
                    }
                };
            } else {
                unmarshaller = new SUnmarshaller() {

                    @Override
                    public Object unmarshall(AttributeValue value) throws ParseException {
                        Calendar cal = GregorianCalendar.getInstance();
                        cal.setTime(new DateUtils().parseIso8601Date(value.getS()));
                        return cal;
                    }
                };
            }
        } else if (ByteBuffer.class.isAssignableFrom(paramType)) {
View Full Code Here


                    @Override
                    public AttributeValue marshall(Object obj) {
                        List<String> timestamps = new LinkedList<String>();
                        for ( Object o : (Set<?>) obj ) {
                            timestamps.add(new DateUtils().formatIso8601Date((Date) o));
                        }
                        return new AttributeValue().withSS(timestamps);
                    }
                };
            } else if ( Calendar.class.isAssignableFrom(returnType) ) {
                marshaller = new ArgumentMarshaller() {

                    @Override
                    public AttributeValue marshall(Object obj) {
                        List<String> timestamps = new LinkedList<String>();
                        for ( Object o : (Set<?>) obj ) {
                            timestamps.add(new DateUtils().formatIso8601Date(((Calendar) o).getTime()));
                        }
                        return new AttributeValue().withSS(timestamps);
                    }
                };
            } else if ( boolean.class.isAssignableFrom(returnType)
                    || Boolean.class.isAssignableFrom(returnType) ) {
                marshaller = new ArgumentMarshaller() {

                    @Override
                    public AttributeValue marshall(Object obj) {
                        List<String> booleanAttributes = new ArrayList<String>();
                        for ( Object b : (Set<?>) obj ) {
                            if ( b == null || !(Boolean) b ) {
                                booleanAttributes.add("0");
                            } else {
                                booleanAttributes.add("1");
                            }
                        }
                        return new AttributeValue().withNS(booleanAttributes);
                    }
                };
            } else if ( returnType.isPrimitive() || Number.class.isAssignableFrom(returnType) ) {
                marshaller = new ArgumentMarshaller() {

                    @Override
                    public AttributeValue marshall(Object obj) {
                        List<String> attributes = new ArrayList<String>();
                        for ( Object o : (Set<?>) obj ) {
                            attributes.add(String.valueOf(o));
                        }
                        return new AttributeValue().withNS(attributes);
                    }
                };
            } else if (ByteBuffer.class.isAssignableFrom(returnType)) {
                 marshaller = new ArgumentMarshaller() {

                     @Override
                     public AttributeValue marshall(Object obj) {
                         List<ByteBuffer> attributes = new ArrayList<ByteBuffer>();
                         for ( Object o : (Set<?>) obj ) {
                             attributes.add((ByteBuffer) o);
                         }
                         return new AttributeValue().withBS(attributes);
                     }
                 };
            } else if (byte[].class.isAssignableFrom(returnType)) {
                 marshaller = new ArgumentMarshaller() {

                     @Override
                     public AttributeValue marshall(Object obj) {
                         List<ByteBuffer> attributes = new ArrayList<ByteBuffer>();
                         for ( Object o : (Set<?>) obj ) {
                             attributes.add(ByteBuffer.wrap((byte[])o));
                         }
                         return new AttributeValue().withBS(attributes);
                     }
                 };
            } else {
                // subclass may extend the behavior by overriding the
                // defaultCollectionArgumentMarshaller method
                marshaller = defaultCollectionArgumentMarshaller(returnType);
            }
        } else if ( Collection.class.isAssignableFrom(returnType) ) {
            throw new DynamoDBMappingException("Non-set collections aren't supported: "
                    + (getter.getDeclaringClass() + "." + getter.getName()));
        } else { // Non-set return type
            if ( Date.class.isAssignableFrom(returnType) ) {
                marshaller = new ArgumentMarshaller() {

                    @Override
                    public AttributeValue marshall(Object obj) {
                        return new AttributeValue().withS(new DateUtils().formatIso8601Date((Date) obj));
                    }
                };
            } else if ( Calendar.class.isAssignableFrom(returnType) ) {
                marshaller = new ArgumentMarshaller() {

                    @Override
                    public AttributeValue marshall(Object obj) {
                        return new AttributeValue().withS(new DateUtils()
                                .formatIso8601Date(((Calendar) obj).getTime()));
                    }
                };
            } else if ( boolean.class.isAssignableFrom(returnType)
                    || Boolean.class.isAssignableFrom(returnType) ) {
View Full Code Here

        String msg = body.substring(startPos+1, endPos);
        return msg;
    }
   
    private int parseClockSkewOffset(org.apache.http.HttpResponse response, AmazonServiceException exception) {
        DateUtils dateUtils = new DateUtils();
        Date deviceDate = new Date();
        Date serverDate = null;
        String serverDateStr = null;
        Header[] responseDateHeader = response.getHeaders("Date");
       
        try {

            if(responseDateHeader.length == 0) {
                // SQS doesn't return Date header
                serverDateStr = getServerDateFromException(exception.getMessage());
                serverDate = dateUtils.parseCompressedIso8601Date(serverDateStr);
            } else {
                serverDateStr = responseDateHeader[0].getValue();
                serverDate = dateUtils.parseRfc822Date(serverDateStr);
            }

        } catch (ParseException e) {
            log.warn("Unable to parse clock skew offset from response: "
                     + serverDateStr,
View Full Code Here

            }
        }

        Date httpExpiresDate = metadata.getHttpExpiresDate();
        if (httpExpiresDate != null) {
            request.addHeader(Headers.EXPIRES, new DateUtils().formatRfc822Date(httpExpiresDate));
        }

        Map<String, String> userMetadata = metadata.getUserMetadata();
        if (userMetadata != null) {
            for (Entry<String, String> entry : userMetadata.entrySet()) {
View Full Code Here

        String msg = body.substring(startPos+1, endPos);
        return msg;
    }

    private int parseClockSkewOffset(org.apache.http.HttpResponse response, AmazonServiceException exception) {
        DateUtils dateUtils = new DateUtils();
        Date deviceDate = new Date();
        Date serverDate = null;
        String serverDateStr = null;
        Header[] responseDateHeader = response.getHeaders("Date");

        try {

            if(responseDateHeader.length == 0) {
                // SQS doesn't return Date header
                serverDateStr = getServerDateFromException(exception.getMessage());
                serverDate = dateUtils.parseCompressedIso8601Date(serverDateStr);
            } else {
                serverDateStr = responseDateHeader[0].getValue();
                serverDate = dateUtils.parseRfc822Date(serverDateStr);
            }

        } catch (ParseException e) {
            log.warn("Unable to parse clock skew offset from response: "
                     + serverDateStr,
View Full Code Here

            }
        }

        Date httpExpiresDate = metadata.getHttpExpiresDate();
        if (httpExpiresDate != null) {
            request.addHeader(Headers.EXPIRES, new DateUtils().formatRfc822Date(httpExpiresDate));
        }

        Map<String, String> userMetadata = metadata.getUserMetadata();
        if (userMetadata != null) {
            for (Entry<String, String> entry : userMetadata.entrySet()) {
View Full Code Here

                    @Override
                    public Object unmarshall(AttributeValue value) throws ParseException {
                        Set<Date> argument = new HashSet<Date>();
                        for ( String s : value.getSS() ) {
                            argument.add(new DateUtils().parseIso8601Date(s));
                        }
                        return argument;
                    }
                };
            } else {
                unmarshaller = new SUnmarshaller() {

                    @Override
                    public Object unmarshall(AttributeValue value) throws ParseException {
                        return new DateUtils().parseIso8601Date(value.getS());
                    }
                };
            }
        } else if ( Calendar.class.isAssignableFrom(paramType) ) {
            if ( isCollection ) {
                unmarshaller = new SSUnmarshaller() {

                    @Override
                    public Object unmarshall(AttributeValue value) throws ParseException {
                        Set<Calendar> argument = new HashSet<Calendar>();
                        for ( String s : value.getSS() ) {
                            Calendar cal = GregorianCalendar.getInstance();
                            cal.setTime(new DateUtils().parseIso8601Date(s));
                            argument.add(cal);
                        }
                        return argument;
                    }
                };
            } else {
                unmarshaller = new SUnmarshaller() {
                 
                    @Override
                    public Object unmarshall(AttributeValue value) throws ParseException {
                        Calendar cal = GregorianCalendar.getInstance();
                        cal.setTime(new DateUtils().parseIso8601Date(value.getS()));
                        return cal;
                    }
                };
            }
        } else if (ByteBuffer.class.isAssignableFrom(paramType)) {
View Full Code Here

                    @Override
                    public AttributeValue marshall(Object obj) {
                        List<String> timestamps = new LinkedList<String>();
                        for ( Object o : (Set<?>) obj ) {
                            timestamps.add(new DateUtils().formatIso8601Date((Date) o));
                        }
                        return new AttributeValue().withSS(timestamps);
                    }
                };
            } else if ( Calendar.class.isAssignableFrom(returnType) ) {
                marshaller = new ArgumentMarshaller() {

                    @Override
                    public AttributeValue marshall(Object obj) {
                        List<String> timestamps = new LinkedList<String>();
                        for ( Object o : (Set<?>) obj ) {
                            timestamps.add(new DateUtils().formatIso8601Date(((Calendar) o).getTime()));
                        }
                        return new AttributeValue().withSS(timestamps);
                    }
                };
            } else if ( boolean.class.isAssignableFrom(returnType)
                    || Boolean.class.isAssignableFrom(returnType) ) {
                marshaller = new ArgumentMarshaller() {

                    @Override
                    public AttributeValue marshall(Object obj) {
                        List<String> booleanAttributes = new ArrayList<String>();
                        for ( Object b : (Set<?>) obj ) {
                            if ( b == null || !(Boolean) b ) {
                                booleanAttributes.add("0");
                            } else {
                                booleanAttributes.add("1");
                            }
                        }
                        return new AttributeValue().withNS(booleanAttributes);
                    }
                };
            } else if ( returnType.isPrimitive() || Number.class.isAssignableFrom(returnType) ) {
                marshaller = new ArgumentMarshaller() {

                    @Override
                    public AttributeValue marshall(Object obj) {
                        List<String> attributes = new ArrayList<String>();
                        for ( Object o : (Set<?>) obj ) {
                            attributes.add(String.valueOf(o));
                        }
                        return new AttributeValue().withNS(attributes);
                    }
                };
            } else if (ByteBuffer.class.isAssignableFrom(returnType)) {
                 marshaller = new ArgumentMarshaller() {

                     @Override
                     public AttributeValue marshall(Object obj) {
                         List<ByteBuffer> attributes = new ArrayList<ByteBuffer>();
                         for ( Object o : (Set<?>) obj ) {
                             attributes.add((ByteBuffer) o);
                         }
                         return new AttributeValue().withBS(attributes);
                     }
                 };
            } else if (byte[].class.isAssignableFrom(returnType)) {
                 marshaller = new ArgumentMarshaller() {

                     @Override
                     public AttributeValue marshall(Object obj) {
                         List<ByteBuffer> attributes = new ArrayList<ByteBuffer>();
                         for ( Object o : (Set<?>) obj ) {
                             attributes.add(ByteBuffer.wrap((byte[])o));
                         }
                         return new AttributeValue().withBS(attributes);
                     }
                 };
            } else {
                // subclass may extend the behavior by overriding the
                // defaultCollectionArgumentMarshaller method
                marshaller = defaultCollectionArgumentMarshaller(returnType);
            }
        } else if ( Collection.class.isAssignableFrom(returnType) ) {
            throw new DynamoDBMappingException("Non-set collections aren't supported: "
                    + (getter.getDeclaringClass() + "." + getter.getName()));
        } else { // Non-set return type
            if ( Date.class.isAssignableFrom(returnType) ) {
                marshaller = new ArgumentMarshaller() {

                    @Override
                    public AttributeValue marshall(Object obj) {
                        return new AttributeValue().withS(new DateUtils().formatIso8601Date((Date) obj));
                    }
                };
            } else if ( Calendar.class.isAssignableFrom(returnType) ) {
                marshaller = new ArgumentMarshaller() {

                    @Override
                    public AttributeValue marshall(Object obj) {
                        return new AttributeValue().withS(new DateUtils()
                                .formatIso8601Date(((Calendar) obj).getTime()));
                    }
                };
            } else if ( boolean.class.isAssignableFrom(returnType)
                    || Boolean.class.isAssignableFrom(returnType) ) {
View Full Code Here

        String msg = body.substring(startPos+1, endPos);
        return msg;
    }
   
    private int parseClockSkewOffset(org.apache.http.HttpResponse response, AmazonServiceException exception) {
        DateUtils dateUtils = new DateUtils();
        Date deviceDate = new Date();
        Date serverDate = null;
        String serverDateStr = null;
        Header[] responseDateHeader = response.getHeaders("Date");
       
        try {

            if(responseDateHeader.length == 0) {
                // SQS doesn't return Date header
                serverDateStr = getServerDateFromException(exception.getMessage());
                serverDate = dateUtils.parseCompressedIso8601Date(serverDateStr);
            } else {
                serverDateStr = responseDateHeader[0].getValue();
                serverDate = dateUtils.parseRfc822Date(serverDateStr);
            }

        } catch (ParseException e) {
            log.warn("Unable to parse clock skew offset from response: "
                     + serverDateStr,
View Full Code Here

        if ( sanitizedCredentials instanceof AWSSessionCredentials ) {
            addSessionCredentials(request, (AWSSessionCredentials) sanitizedCredentials);
        }

        Date signDate = getSignatureDate(getTimeOffset(request));
        String date = new DateUtils().formatRfc822Date(signDate);
        request.addHeader("Date", date);
        String canonicalString = date;
        log.debug("Calculated string to sign:\n\"" + canonicalString + "\"");

        String signature = super.signAndBase64Encode(canonicalString, sanitizedCredentials.getAWSSecretKey(), SigningAlgorithm.HmacSHA1);
View Full Code Here

TOP

Related Classes of com.amazonaws.util.DateUtils

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.