Utility.assertNotNull("logging.LogOperationTypes", logging.getLogOperationTypes()); xmlw.writeCharacters(logging.getVersion()); xmlw.writeEndElement(); xmlw.writeCharacters(logging.getLogOperationTypes().contains(LoggingOperations.DELETE) ? Constants.TRUE : Constants.FALSE); xmlw.writeEndElement(); xmlw.writeCharacters(logging.getLogOperationTypes().contains(LoggingOperations.READ) ? Constants.TRUE : Constants.FALSE); xmlw.writeEndElement(); xmlw.writeCharacters(logging.getLogOperationTypes().contains(LoggingOperations.WRITE) ? Constants.TRUE : Constants.FALSE); xmlw.writeEndElement(); writeRetentionPolicy(xmlw, logging.getRetentionIntervalInDays());
@Override public void setConfiguration(final Path container, final LoggingConfiguration configuration) throws BackgroundException { try { final ServiceProperties properties = session.getClient().downloadServiceProperties(null, context); final LoggingProperties l = new LoggingProperties(); if(configuration.isEnabled()) { l.setLogOperationTypes(EnumSet.allOf(LoggingOperations.class)); } else { l.setLogOperationTypes(EnumSet.noneOf(LoggingOperations.class)); } properties.setLogging(l); session.getClient().uploadServiceProperties(properties, null, context); } catch(StorageException e) { throw new AzureExceptionMappingService().map("Failure to write attributes of {0}", e, container); } } }
this.props.getLogging().setRetentionIntervalInDays(this.retentionPolicyDays); this.props.getLogging().setVersion(value); this.props.getLogging().getLogOperationTypes().add(LoggingOperations.DELETE); this.props.getLogging().getLogOperationTypes().add(LoggingOperations.READ); this.props.getLogging().getLogOperationTypes().add(LoggingOperations.WRITE);
private void testAnalyticsLoggingOperations(ServiceClient client, ServiceProperties props) throws StorageException, InterruptedException { // None props.getLogging().setLogOperationTypes(EnumSet.noneOf(LoggingOperations.class)); props.getLogging().setRetentionIntervalInDays(null); props.getLogging().setVersion("1.0"); callUploadServiceProps(client, props, null); assertServicePropertiesAreEqual(props, callDownloadServiceProperties(client)); // None props.getLogging().setLogOperationTypes(EnumSet.allOf(LoggingOperations.class)); callUploadServiceProps(client, props, null); assertServicePropertiesAreEqual(props, callDownloadServiceProperties(client)); }
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { this.elementStack.push(localName); if (Constants.AnalyticsConstants.CORS_RULE_ELEMENT.equals(localName)) { this.rule = new CorsRule(); } else if (Constants.AnalyticsConstants.LOGGING_ELEMENT.equals(localName)) { this.props.setLogging(new LoggingProperties()); } else if (Constants.AnalyticsConstants.HOUR_METRICS_ELEMENT.equals(localName)) { this.props.setHourMetrics(new MetricsProperties()); } else if (Constants.AnalyticsConstants.MINUTE_METRICS_ELEMENT.equals(localName)) { this.props.setMinuteMetrics(new MetricsProperties()); } else if (Constants.AnalyticsConstants.CORS_ELEMENT.equals(localName)) { this.props.setCors(new CorsProperties()); } }
props.getLogging().setRetentionIntervalInDays(null); props.getLogging().setLogOperationTypes(EnumSet.noneOf(LoggingOperations.class)); callUploadServiceProps(client, props, null); props.getLogging().setRetentionIntervalInDays(3); props.getLogging().setLogOperationTypes(EnumSet.noneOf(LoggingOperations.class)); callUploadServiceProps(client, props, null); props.getLogging().setRetentionIntervalInDays(null); props.getLogging().setLogOperationTypes(EnumSet.allOf(LoggingOperations.class)); callUploadServiceProps(client, props, null); props.getLogging().setRetentionIntervalInDays(4); props.getLogging().setLogOperationTypes(EnumSet.allOf(LoggingOperations.class)); callUploadServiceProps(client, props, null);
@Override public LoggingConfiguration getConfiguration(final Path container) throws BackgroundException { try { final ServiceProperties properties = session.getClient().downloadServiceProperties(null, context); final LoggingConfiguration configuration = new LoggingConfiguration( !properties.getLogging().getLogOperationTypes().isEmpty(), "$logs" ); // When you have configured Storage Logging to log request data from your storage account, it saves the log data // to blobs in a container named $logs in your storage account. configuration.setContainers(Collections.singletonList( new Path("/$logs", EnumSet.of(Path.Type.volume, Path.Type.directory))) ); return configuration; } catch(StorageException e) { throw new AzureExceptionMappingService().map("Cannot read container configuration", e); } }
private void testAnalyticsDisable(ServiceClient client, ServiceProperties props) throws StorageException, InterruptedException { props.getLogging().setLogOperationTypes(EnumSet.noneOf(LoggingOperations.class)); props.getLogging().setRetentionIntervalInDays(null); props.getLogging().setVersion("1.0"); props.getHourMetrics().setMetricsLevel(MetricsLevel.DISABLED); props.getHourMetrics().setRetentionIntervalInDays(null); props.getHourMetrics().setVersion("1.0"); props.getMinuteMetrics().setMetricsLevel(MetricsLevel.DISABLED); props.getMinuteMetrics().setRetentionIntervalInDays(null); props.getMinuteMetrics().setVersion("1.0"); props.getCors().getCorsRules().clear(); callUploadServiceProps(client, props, null); assertServicePropertiesAreEqual(props, callDownloadServiceProperties(client)); }
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { this.elementStack.push(localName); if (Constants.AnalyticsConstants.CORS_RULE_ELEMENT.equals(localName)) { this.rule = new CorsRule(); } else if (Constants.AnalyticsConstants.LOGGING_ELEMENT.equals(localName)) { this.props.setLogging(new LoggingProperties()); } else if (Constants.AnalyticsConstants.HOUR_METRICS_ELEMENT.equals(localName)) { this.props.setHourMetrics(new MetricsProperties()); } else if (Constants.AnalyticsConstants.MINUTE_METRICS_ELEMENT.equals(localName)) { this.props.setMinuteMetrics(new MetricsProperties()); } else if (Constants.AnalyticsConstants.CORS_ELEMENT.equals(localName)) { this.props.setCors(new CorsProperties()); } else if (Constants.AnalyticsConstants.DELETE_RETENTION_POLICY_ELEMENT.equals(localName)) { this.props.setDeleteRetentionPolicy(new DeleteRetentionPolicy()); } else if (Constants.AnalyticsConstants.STATIC_WEBSITE_ELEMENT.equals(localName)) { this.props.setStaticWebsiteProperties(new StaticWebsiteProperties()); } }
Utility.assertNotNull("logging.LogOperationTypes", logging.getLogOperationTypes()); Utility.serializeElement(xmlw, Constants.AnalyticsConstants.VERSION_ELEMENT, logging.getVersion()); Utility.serializeElement(xmlw, Constants.AnalyticsConstants.DELETE_ELEMENT, logging.getLogOperationTypes() .contains(LoggingOperations.DELETE) ? Constants.TRUE : Constants.FALSE); Utility.serializeElement(xmlw, Constants.AnalyticsConstants.READ_ELEMENT, logging.getLogOperationTypes() .contains(LoggingOperations.READ) ? Constants.TRUE : Constants.FALSE); Utility.serializeElement(xmlw, Constants.AnalyticsConstants.WRITE_ELEMENT, logging.getLogOperationTypes() .contains(LoggingOperations.WRITE) ? Constants.TRUE : Constants.FALSE); writeRetentionPolicy(xmlw, logging.getRetentionIntervalInDays());
this.props.getLogging().setRetentionIntervalInDays(this.retentionPolicyDays); this.props.getLogging().setVersion(value); this.props.getLogging().getLogOperationTypes().add(LoggingOperations.DELETE); this.props.getLogging().getLogOperationTypes().add(LoggingOperations.READ); this.props.getLogging().getLogOperationTypes().add(LoggingOperations.WRITE);
private void testOptionalServiceProperties(ServiceClient client, ServiceProperties props) throws StorageException, InterruptedException { props.getLogging().setLogOperationTypes(EnumSet.of(LoggingOperations.READ, LoggingOperations.WRITE)); props.getLogging().setRetentionIntervalInDays(5); props.getLogging().setVersion("1.0");
/** * Initializes a new instances of the ServiceProperties class. */ public ServiceProperties() { this.setLogging(new LoggingProperties()); this.setHourMetrics(new MetricsProperties()); this.setMinuteMetrics(new MetricsProperties()); this.setCors(new CorsProperties()); }
assertTrue(propsA.getLogging().getLogOperationTypes().equals(propsB.getLogging().getLogOperationTypes())); assertEquals(propsA.getLogging().getRetentionIntervalInDays(), propsB.getLogging() .getRetentionIntervalInDays()); assertEquals(propsA.getLogging().getVersion(), propsB.getLogging().getVersion());
/** * Initializes a new instances of the ServiceProperties class. */ public ServiceProperties() { this.setLogging(new LoggingProperties()); this.setHourMetrics(new MetricsProperties()); this.setMinuteMetrics(new MetricsProperties()); this.setCors(new CorsProperties()); // DeleteRetentionPolicy and StaticWebsiteProperties are not included by default because they are not accepted by services other than blob. }