@Override public void endElement(String name, String elementText) { if (name.equals("MainPageSuffix")) { this.indexDocumentSuffix = elementText; } else if (name.equals("NotFoundPage")) { this.errorDocumentKey = elementText; } else if (name.equals("WebsiteConfiguration")) { this.websiteConfig = new GSWebsiteConfig( indexDocumentSuffix, errorDocumentKey); } } }
/** * * @return * An XML representation of the object suitable for use as an input to the REST/HTTP interface. * * @throws javax.xml.parsers.FactoryConfigurationError * @throws javax.xml.parsers.ParserConfigurationException * @throws javax.xml.transform.TransformerException */ public String toXml() throws ParserConfigurationException, FactoryConfigurationError, TransformerException { XMLBuilder builder = XMLBuilder.create("WebsiteConfiguration") .attr("xmlns", Constants.XML_NAMESPACE) .up(); if (this.getIndexDocumentSuffix() != null && this.getIndexDocumentSuffix().length() > 0) { builder.elem("MainPageSuffix").text(this.getIndexDocumentSuffix()); } if (this.getErrorDocumentKey() != null && this.getErrorDocumentKey().length() > 0) { builder.elem("NotFoundPage").text(this.getErrorDocumentKey()); } return builder.asString(); }
/** * * @return * An XML representation of the object suitable for use as an input to the REST/HTTP interface. * * @throws javax.xml.parsers.FactoryConfigurationError * @throws javax.xml.parsers.ParserConfigurationException * @throws javax.xml.transform.TransformerException */ public String toXml() throws ParserConfigurationException, FactoryConfigurationError, TransformerException { XMLBuilder builder = XMLBuilder.create("WebsiteConfiguration") .attr("xmlns", Constants.XML_NAMESPACE) .up(); if (this.getIndexDocumentSuffix() != null && this.getIndexDocumentSuffix().length() > 0) { builder.elem("MainPageSuffix").text(this.getIndexDocumentSuffix()); } if (this.getErrorDocumentKey() != null && this.getErrorDocumentKey().length() > 0) { builder.elem("NotFoundPage").text(this.getErrorDocumentKey()); } return builder.asString(); }
@Override public void endElement(String name, String elementText) { if (name.equals("MainPageSuffix")) { this.indexDocumentSuffix = elementText; } else if (name.equals("NotFoundPage")) { this.errorDocumentKey = elementText; } else if (name.equals("WebsiteConfiguration")) { this.websiteConfig = new GSWebsiteConfig( indexDocumentSuffix, errorDocumentKey); } } }
@Override protected void deleteWebsiteConfigImpl(String bucketName) throws ServiceException { // To remove the website configuration, you just send an empty website // configuration (with no MainPageSuffix and NotFoundPage elements) this.setWebsiteConfigImpl(bucketName, new GSWebsiteConfig()); } }
@Override protected void deleteWebsiteConfigImpl(String bucketName) throws ServiceException { // To remove the website configuration, you just send an empty website // configuration (with no MainPageSuffix and NotFoundPage elements) this.setWebsiteConfigImpl(bucketName, new GSWebsiteConfig()); } }
@Override public void write(final Path file, final Distribution distribution, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); try { if(distribution.isEnabled()) { String suffix = "index.html"; if(StringUtils.isNotBlank(distribution.getIndexDocument())) { suffix = PathNormalizer.name(distribution.getIndexDocument()); } // Enable website endpoint session.getClient().setWebsiteConfigImpl(container.getName(), new GSWebsiteConfig(suffix)); final DistributionLogging logging = this.getFeature(DistributionLogging.class, distribution.getMethod()); if(logging != null) { new GoogleStorageLoggingFeature(session).setConfiguration(container, new LoggingConfiguration( distribution.isEnabled(), distribution.getLoggingContainer())); } } else { // Disable website endpoint session.getClient().setWebsiteConfigImpl(container.getName(), new GSWebsiteConfig()); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Cannot write website configuration", e); } }