microsoft-azure-storage/src/com/microsoft/azure/storage/ServicePropertiesSerializer.java
private static void writeCorsProperties(final XmlSerializer xmlw, final CorsProperties cors)
            throws IllegalArgumentException, IllegalStateException, IOException {
        Utility.assertNotNull("CorsRules", cors.getCorsRules());

        // CORS
        xmlw.startTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_ELEMENT);

        for (CorsRule rule : cors.getCorsRules()) {
            if (rule.getAllowedOrigins().isEmpty() || rule.getAllowedMethods().isEmpty()
                    || rule.getMaxAgeInSeconds() < 0) {
                throw new IllegalArgumentException(SR.INVALID_CORS_RULE);
            }

            xmlw.startTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_RULE_ELEMENT);

            Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ALLOWED_ORIGINS_ELEMENT,
                    joinToString(rule.getAllowedOrigins(), ","));

            Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ALLOWED_METHODS_ELEMENT,
                    joinToString(rule.getAllowedMethods(), ","));

            Utility.serializeElement(xmlw, Constants.AnalyticsConstants.EXPOSED_HEADERS_ELEMENT,
                    joinToString(rule.getExposedHeaders(), ","));

            Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ALLOWED_HEADERS_ELEMENT,
                    joinToString(rule.getAllowedHeaders(), ","));

            Utility.serializeElement(xmlw, Constants.AnalyticsConstants.MAX_AGE_IN_SECONDS_ELEMENT,
                    Integer.toString(rule.getMaxAgeInSeconds()));

            xmlw.endTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_RULE_ELEMENT);
        }

        // end CORS
        xmlw.endTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_ELEMENT);
    }
private static void writeCorsProperties(final XmlSerializer xmlw, final CorsProperties cors)
            throws IllegalArgumentException, IllegalStateException, IOException {
        Utility.assertNotNull("CorsRules", cors.getCorsRules());

        // CORS
        xmlw.startTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_ELEMENT);

        for (CorsRule rule : cors.getCorsRules()) {
            if (rule.getAllowedOrigins().isEmpty() || rule.getAllowedMethods().isEmpty()
                    || rule.getMaxAgeInSeconds() < 0) {
                throw new IllegalArgumentException(SR.INVALID_CORS_RULE);
            }

            xmlw.startTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_RULE_ELEMENT);

            Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ALLOWED_ORIGINS_ELEMENT,
                    joinToString(rule.getAllowedOrigins(), ","));

            Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ALLOWED_METHODS_ELEMENT,
                    joinToString(rule.getAllowedMethods(), ","));

            Utility.serializeElement(xmlw, Constants.AnalyticsConstants.EXPOSED_HEADERS_ELEMENT,
                    joinToString(rule.getExposedHeaders(), ","));

            Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ALLOWED_HEADERS_ELEMENT,
                    joinToString(rule.getAllowedHeaders(), ","));

            Utility.serializeElement(xmlw, Constants.AnalyticsConstants.MAX_AGE_IN_SECONDS_ELEMENT,
                    Integer.toString(rule.getMaxAgeInSeconds()));

            xmlw.endTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_RULE_ELEMENT);
        }

        // end CORS
        xmlw.endTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_ELEMENT);
    }
private static void writeCorsProperties ( final XmlSerializer xmlw , final CorsProperties cors ) throws IllegalArgumentException , IllegalStateException , IOException { Utility . assertNotNull ( "CorsRules" , cors . getCorsRules ( ) ) ; // CORS xmlw . startTag ( Constants . EMPTY_STRING , Constants . AnalyticsConstants . CORS_ELEMENT ) ; for ( CorsRule rule : cors . getCorsRules ( ) ) { if ( rule . getAllowedOrigins ( ) . isEmpty ( ) || rule . getAllowedMethods ( ) . isEmpty ( ) || rule . getMaxAgeInSeconds ( ) < 0 ) { throw new IllegalArgumentException ( SR . INVALID_CORS_RULE ) ; } xmlw . startTag ( Constants . EMPTY_STRING , Constants . AnalyticsConstants . CORS_RULE_ELEMENT ) ; Utility . serializeElement ( xmlw , Constants . AnalyticsConstants . ALLOWED_ORIGINS_ELEMENT , joinToString ( rule . getAllowedOrigins ( ) , "," ) ) ; Utility . serializeElement ( xmlw , Constants . AnalyticsConstants . ALLOWED_METHODS_ELEMENT , joinToString ( rule . getAllowedMethods ( ) , "," ) ) ; Utility . serializeElement ( xmlw , Constants . AnalyticsConstants . EXPOSED_HEADERS_ELEMENT , joinToString ( rule . getExposedHeaders ( ) , "," ) ) ; Utility . serializeElement ( xmlw , Constants . AnalyticsConstants . ALLOWED_HEADERS_ELEMENT , joinToString ( rule . getAllowedHeaders ( ) , "," ) ) ; Utility . serializeElement ( xmlw , Constants . AnalyticsConstants . MAX_AGE_IN_SECONDS_ELEMENT , Integer . toString ( rule . getMaxAgeInSeconds ( ) ) ) ; xmlw . endTag ( Constants . EMPTY_STRING , Constants . AnalyticsConstants . CORS_RULE_ELEMENT ) ; } // end CORS xmlw . endTag ( Constants . EMPTY_STRING , Constants . AnalyticsConstants . CORS_ELEMENT ) ; }
Writes the given CORS properties to the XMLStreamWriter.

@param xmlw
the XMLStreamWriter to write to.
@param cors
the CORS Properties to be written.
@throws IOException
if there is an error writing the service properties.
@throws IllegalStateException
if there is an error writing the service properties.
@throws IllegalArgumentException
if there is an error writing the service properties.
Writes the given CORS properties to the XMLStreamWriter .