final String location; if(!b.isLocationKnown()) { location = session.getFeature(Location.class).getLocation(bucket).getIdentifier();
return cache.get(container); if(Location.unknown.equals(new SwiftRegion(container.attributes().getRegion()))) { final SwiftRegion region = new SwiftRegion(session.getHost().getRegion()); if(Location.unknown.equals(region)) { final Client client = session.getClient(); for(Region r : client.getRegions()) {
@Override public Set<Location.Name> getRegions() { final List<String> regions = this.list("Regions"); if(regions.isEmpty()) { return parent.getRegions(); } final Set<Location.Name> set = new HashSet<Location.Name>(); for(String region : regions) { set.add(new Location.Name(region)); } return set; }
bucketLocationField.setStringValue(location.toString());
public Region lookup(final Location.Name location) throws InteroperabilityException { if(!session.isConnected()) { log.warn("Cannot determine region if not connected"); return new Region(location.getIdentifier(), null, null); continue; if(region.getRegionId().equals(location.getIdentifier())) { return region;
public NSView getAccessoryView(final NSAlert alert) { if(this.hasLocation()) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); regionPopup = NSPopUpButton.buttonWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 26)); regions.stream().sorted(Comparator.comparing(Location.Name::toString)).forEach(region -> { regionPopup.addItemWithTitle(region.toString()); regionPopup.itemWithTitle(region.toString()).setRepresentedObject(region.getIdentifier()); if(region.getIdentifier().equals(PreferencesFactory.get().getProperty("s3.location"))) { regionPopup.selectItem(regionPopup.lastItem()); } }); // Override accessory view with location menu added regionPopup.setFrameOrigin(new NSPoint(0, 0)); view.addSubview(regionPopup); inputField.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(inputField); return view; } return super.getAccessoryView(alert); }
@Override public PathAttributes find(final Path file) throws BackgroundException { if(file.isRoot()) { return PathAttributes.EMPTY; } if(file.getType().contains(Path.Type.upload)) { return PathAttributes.EMPTY; } if(containerService.isContainer(file)) { final PathAttributes attributes = new PathAttributes(); attributes.setRegion(new S3LocationFeature(session, session.getClient().getRegionEndpointCache()).getLocation(file).getIdentifier()); return attributes; } return this.toAttributes(this.details(file)); }
public NSView getAccessoryView(final NSAlert alert) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); regionPopup = NSPopUpButton.buttonWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 26)); regionPopup.setFrameOrigin(new NSPoint(0, 0)); for(Location.Name region : regions) { regionPopup.addItemWithTitle(region.toString()); regionPopup.itemWithTitle(region.toString()).setRepresentedObject(region.getIdentifier()); if(region.getIdentifier().equals(PreferencesFactory.get().getProperty("s3.location"))) { regionPopup.selectItem(regionPopup.lastItem()); } } // Override accessory view with location menu added view.addSubview(regionPopup); return view; }
private AmazonCloudFront client(final Path container) throws BackgroundException { final AmazonCloudFrontClientBuilder builder = AmazonCloudFrontClientBuilder.standard() .withCredentials(AWSCredentialsConfigurator.toAWSCredentialsProvider(bookmark.getCredentials())) .withClientConfiguration(configuration); final Location.Name region = this.getRegion(container); if(Location.unknown.equals(region)) { builder.withRegion(Regions.DEFAULT_REGION); } else { builder.withRegion(region.getIdentifier()); } return builder.build(); }
@Override public Host find(final Location.Name region, final boolean tls) { final Protocol protocol; if(tls) { protocol = new UDTTLSProtocol(); } else { protocol = new UDTProtocol(); } return new Host(protocol, String.format("%s.qloudsonic.io", region.getIdentifier()), protocol.getScheme().getPort()); }
@Override public void configure(final boolean enable, final Path file) throws BackgroundException { final Location.Name location = session.getFeature(Location.class).getLocation(file); if(Location.unknown.equals(location)) { throw new AccessDeniedException("Cannot read bucket location"); } final UDTProxyConfigurator configurator = new UDTProxyConfigurator(location, this.provider(), new KeychainX509TrustManager(new DefaultTrustManagerHostnameCallback(session.getHost())), new KeychainX509KeyManager(session.getHost())); configurator.configure(session); }
private AWSKMS client(final Path container) throws BackgroundException { final AWSKMSClientBuilder builder = AWSKMSClientBuilder.standard() .withCredentials(AWSCredentialsConfigurator.toAWSCredentialsProvider(bookmark.getCredentials())) .withClientConfiguration(configuration); final Location.Name region = locationFeature.getLocation(container); if(Location.unknown.equals(region)) { builder.withRegion(Regions.DEFAULT_REGION); } else { builder.withRegion(region.getIdentifier()); } return builder.build(); }
public Region lookup(final Path file) throws BackgroundException { final Path container = containerService.getContainer(file); if(Location.unknown.equals(new SwiftLocationFeature.SwiftRegion(container.attributes().getRegion()))) { return this.lookup(location.getLocation(container)); } return this.lookup(new SwiftLocationFeature.SwiftRegion(container.attributes().getRegion())); }
public void setDefaultBucketLocation(NSPopUpButton b) { this.defaultBucketLocation = b; this.defaultBucketLocation.setAutoenablesItems(false); this.defaultBucketLocation.removeAllItems(); for(Location.Name location : new S3Protocol().getRegions()) { this.defaultBucketLocation.addItemWithTitle(location.toString()); this.defaultBucketLocation.lastItem().setRepresentedObject(location.getIdentifier()); } this.defaultBucketLocation.setTarget(this.id()); this.defaultBucketLocation.setAction(Foundation.selector("defaultBucketLocationClicked:")); this.defaultBucketLocation.selectItemWithTitle(LocaleFactory.localizedString(preferences.getProperty("s3.location"), "S3")); }
@Override public void callback(final int returncode) { switch(returncode) { case DEFAULT_OPTION: callback.callback(new Location.Name(regionPopup.selectedItem().representedObject())); break; } }