/** * {@inheritDoc} */ @Override public String getStorageProviderType() { return type.name(); }
private S3StorageProvider getS3StorageProvider() { if (!storageAccountManager.isInitialized()) { throw new DuraCloudRuntimeException("storageAccountManager is not initialized!!!"); } final StorageAccount account = storageAccountManager.getPrimaryStorageAccount(); return new S3StorageProvider(account.getUsername(), account.getPassword(), account.getOptions()); } }
protected boolean isWritable(StorageAccount acct) { return Boolean.valueOf(acct.getOptions().get(StorageAccount.OPTS.WRITABLE.name())); }
protected void loadDbConfig(DatabaseConfig databaseConfig, String key, String value) { String suffix = getSuffix(key); if (suffix.equalsIgnoreCase("username")) { databaseConfig.setUsername(value); } else if (suffix.equalsIgnoreCase("password")) { databaseConfig.setPassword(value); } else if (suffix.equalsIgnoreCase("host")) { databaseConfig.setHost(value); } else if (suffix.equalsIgnoreCase("port")) { databaseConfig.setPort(Integer.parseInt(value)); } else if (suffix.equalsIgnoreCase("name")) { databaseConfig.setName(value); } } }
public IrodsStorageProvider(String username, String password, Map<String, String> options) { if (options == null) { throw new StorageException("Missing required options"); } this.password = password; this.username = username; this.zone = getOptionString(ZONE.name(), options); this.port = getOptionInt(PORT.name(), options); this.host = getOptionString(HOST.name(), options); this.baseDirectory = getOptionString(BASE_DIRECTORY.name(), options); this.storageResource = getOptionString(RESOURCE.name(), options); log.trace("Creating new irods provider " + username + "#" + zone + "@" + host + ":" + port + baseDirectory + " rsrc " + storageResource); }
private void loadAudit(String key, String value) { String suffix = getSuffix(key); if (suffix.equalsIgnoreCase(usernameKey)) { auditConfig.setAuditUsername(value); } else if (suffix.equalsIgnoreCase(passwordKey)) { auditConfig.setAuditPassword(value); } else if (suffix.equalsIgnoreCase(queueKey)) { auditConfig.setAuditQueueName(value); } else if (suffix.equalsIgnoreCase(logSpaceIdKey)) { auditConfig.setAuditLogSpaceId(value); } }
public void setStorageAccounts(Set<StorageAccount> storageAccts) { this.storageAccounts = new HashMap<>(); for (StorageAccount storageAcct : storageAccts) { this.storageAccounts.put(storageAcct.getId(), storageAcct); } }
public String asXml() { boolean includeCredentials = true; boolean includeOptions = true; DuraStoreInitConfig initConfig = new DuraStoreInitConfig(); initConfig.setAuditConfig(getAuditConfig()); initConfig.setMillDbConfig(getMillDbConfig()); List<StorageAccount> accounts = new ArrayList<>(getStorageAccounts()); initConfig.setStorageAccounts(accounts); return documentBinding.createXmlFrom(initConfig, includeCredentials, includeOptions); }
/** * {@inheritDoc} */ public Iterator<String> getSpaceContents(String spaceId, String prefix) { log.debug("getSpaceContents(" + spaceId + ", " + prefix); throwIfSpaceNotExist(spaceId); return new ContentIterator(this, spaceId, prefix); }
/** * {@inheritDoc} */ public ContentStore getPrimaryContentStore(int maxRetries) throws ContentStoreException { StorageAccountManager acctManager = getStorageAccounts(); StorageAccount acct = acctManager.getPrimaryStorageAccount(); return newContentStoreImpl(acct, maxRetries); }
/** * Retrieves string data given its token. * * If no data is associated with the provided token, returns null * * @param token * @return */ public String retrieveData(String token) { try { RetrievedContent data = this.s3StorageProvider.getContent(this.hiddenSpaceName, token); return IOUtil.readStringFromStream(data.getContentStream()); } catch (NotFoundException ex) { return null; } catch (Exception ex) { throw new DuraCloudRuntimeException(ex); } }
public static ResourceType fromStorageProviderType(StorageProviderType type) { return new ResourceType(type.toString()); }
/** * {@inheritDoc} */ public ContentStore getContentStore(String storeID, int maxRetries) throws ContentStoreException { StorageAccountManager acctManager = getStorageAccounts(); StorageAccount acct = acctManager.getStorageAccount(storeID); if (acct == null) { throw new ContentStoreException("Content store with id = '" + storeID + "' not found."); } return newContentStoreImpl(acct, maxRetries); }
public String getName() { return name(); } }
public static AmazonS3Client getAmazonS3Client(String accessKey, String secretKey, Map<String, String> options) { AmazonS3Client client = s3Clients.get(key(accessKey, secretKey)); if (null == client) { Region region = null; if (options != null && options.get(StorageAccount.OPTS.AWS_REGION.name()) != null) { region = com.amazonaws.services.s3.model.Region.fromValue( options.get(StorageAccount.OPTS.AWS_REGION.name())).toAWSRegion(); } client = newS3Client(accessKey, secretKey, region); s3Clients.put(key(accessKey, secretKey), client); } return client; }
/** * {@inheritDoc} */ public Iterator<String> getSpaceContents(String spaceId, String prefix) { log.debug("getSpaceContents(" + spaceId + ", " + prefix); throwIfSpaceNotExist(spaceId); return new ContentIterator(this, spaceId, prefix); }