本文整理汇总了Java中com.stacksync.commons.models.Workspace.getSwiftContainer方法的典型用法代码示例。如果您正苦于以下问题:Java Workspace.getSwiftContainer方法的具体用法?Java Workspace.getSwiftContainer怎么用?Java Workspace.getSwiftContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.stacksync.commons.models.Workspace
的用法示例。
在下文中一共展示了Workspace.getSwiftContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void add(Workspace workspace) throws DAOException {
if (!workspace.isValid()) {
throw new IllegalArgumentException("Workspace attributes not set");
}
Object[] values = { workspace.getLatestRevision(), workspace.getOwner().getId(), workspace.isShared(), workspace.isEncrypted(),
workspace.getSwiftContainer(), workspace.getSwiftUrl() };
String query = "INSERT INTO workspace (latest_revision, owner_id, is_shared, is_encrypted, swift_container, swift_url) VALUES (?, ?, ?, ?, ?, ?)";
UUID id = (UUID)executeUpdate(query, values);
if (id != null) {
workspace.setId(id);
}
}
示例2: bindUsersToWorkspace
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
private void bindUsersToWorkspace(Workspace workspace, Long folderId) {
// Create notification
ShareProposalNotification notification = new ShareProposalNotification(workspace.getId(),
workspace.getName(), folderId, workspace.getOwner().getId(), workspace.getOwner().getName(),
workspace.getSwiftContainer(), workspace.getSwiftUrl(), workspace.isEncrypted());
notification.setRequestId("");
// Send notification to owner
RemoteClient client;
try {
client = broker.lookupMulti(workspace.getOwner().getId().toString(), RemoteClient.class);
client.notifyShareProposal(notification);
} catch (RemoteException e1) {
logger.error(String.format("Could not notify user: '%s'", workspace.getOwner().getId()), e1);
}
// Send notifications to users
for (User addressee : workspace.getUsers()) {
try {
client = broker.lookupMulti(addressee.getId().toString(), RemoteClient.class);
client.notifyShareProposal(notification);
} catch (RemoteException e) {
logger.error(String.format("Could not notify user: '%s'", addressee.getId()), e);
}
}
}
示例3: unBindUsersToWorkspace
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
private void unBindUsersToWorkspace(Workspace workspace, List<User> usersToRemove, boolean isUnshared, Long folderId) {
// Create notification
UnshareNotification notification = new UnshareNotification(workspace.getId(),
workspace.getName(), folderId, workspace.getOwner().getId(), workspace.getOwner().getName(),
workspace.getSwiftContainer(), workspace.getSwiftUrl(), workspace.isEncrypted());
notification.setRequestId("");
RemoteClient client;
// Send notification to owner
if (isUnshared) {
try {
client = broker.lookupMulti(workspace.getOwner().getId().toString(), RemoteClient.class);
client.notifyUnshare(notification);
} catch (RemoteException e1) {
logger.error(String.format("Could not notify user: '%s'", workspace.getOwner().getId()), e1);
}
}
// Send notifications to users
for (User addressee : usersToRemove) {
try {
client = broker.lookupMulti(addressee.getId().toString(), RemoteClient.class);
client.notifyUnshare(notification);
} catch (RemoteException e) {
logger.error(String.format("Could not notify user: '%s'", addressee.getId()), e);
}
}
}
示例4: createShareProposal
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void createShareProposal(ShareProposalRequest request) throws ShareProposalNotCreatedException,
UserNotFoundException {
logger.debug(request);
User user = new User();
user.setId(request.getUserId());
Item item = new Item(request.getItemId());
// Create share proposal
Workspace workspace = getHandler().doShareFolder(user, request.getEmails(), item, request.isEncrypted());
// Create notification
ShareProposalNotification notification = new ShareProposalNotification(workspace.getId(),
workspace.getName(), item.getId(), workspace.getOwner().getId(), workspace.getOwner().getName(),
workspace.getSwiftContainer(), workspace.getSwiftUrl(), workspace.isEncrypted());
notification.setRequestId(request.getRequestId());
// Send notification to owner
RemoteClient client;
try {
client = broker.lookupMulti(user.getId().toString(), RemoteClient.class);
client.notifyShareProposal(notification);
} catch (RemoteException e1) {
logger.error(String.format("Could not notify user: '%s'", user.getId()), e1);
}
// Send notifications to users
for (User addressee : workspace.getUsers()) {
try {
client = broker.lookupMulti(addressee.getId().toString(), RemoteClient.class);
client.notifyShareProposal(notification);
} catch (RemoteException e) {
logger.error(String.format("Could not notify user: '%s'", addressee.getId()), e);
}
}
}
示例5: createNewWorkspace
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void createNewWorkspace(Workspace workspace) throws Exception {
if (!isTokenActive()) {
login();
}
HttpClient httpClient = new DefaultHttpClient();
String url = this.storageUrl + "/" + workspace.getSwiftContainer();
try {
HttpPut request = new HttpPut(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("401 User unauthorized");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例6: deleteChunk
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void deleteChunk(Workspace workspace, String chunkName) throws Exception {
if (!isTokenActive()) {
login();
}
HttpClient httpClient = new DefaultHttpClient();
String url = this.storageUrl + "/" + workspace.getSwiftContainer() + "/" + chunkName;
try {
HttpDelete request = new HttpDelete(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("401 User unauthorized");
}
if (swiftResponse.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
throw new ObjectNotFoundException("404 Not Found");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例7: deleteWorkspace
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void deleteWorkspace(Workspace workspace) throws Exception {
if (!isTokenActive()) {
login();
}
HttpClient httpClient = new DefaultHttpClient();
String url = this.storageUrl + "/" + workspace.getSwiftContainer();
try {
HttpDelete request = new HttpDelete(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("401 User unauthorized");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例8: removeUserToWorkspace
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void removeUserToWorkspace(User owner, User user, Workspace workspace) throws Exception {
if (!isTokenActive()) {
login();
}
String permissions = getWorkspacePermissions(owner, workspace);
String tenantUser = Config.getSwiftTenant() + ":" + user.getSwiftUser();
if (permissions.contains("," + tenantUser)) {
permissions.replace("," + tenantUser, "");
} else if (permissions.contains(tenantUser)) {
permissions.replace(tenantUser, "");
} else {
return;
}
HttpClient httpClient = new DefaultHttpClient();
String url = this.storageUrl + "/" + workspace.getSwiftContainer();
try {
HttpPut request = new HttpPut(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
request.setHeader(SwiftResponse.X_CONTAINER_READ, permissions);
request.setHeader(SwiftResponse.X_CONTAINER_WRITE, permissions);
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("404 User unauthorized");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例9: grantUserToWorkspace
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void grantUserToWorkspace(User owner, User user, Workspace workspace) throws Exception {
if (!isTokenActive()) {
login();
}
String permissions = getWorkspacePermissions(owner, workspace);
String tenantUser = Config.getSwiftTenant() + ":" + user.getSwiftUser();
if (permissions.contains(tenantUser)) {
return;
}
permissions += "," + tenantUser;
HttpClient httpClient = new DefaultHttpClient();
String url = this.storageUrl + "/" + workspace.getSwiftContainer();
try {
HttpPut request = new HttpPut(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
request.setHeader(SwiftResponse.X_CONTAINER_READ, permissions);
request.setHeader(SwiftResponse.X_CONTAINER_WRITE, permissions);
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("404 User unauthorized");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例10: copyChunk
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void copyChunk(Workspace sourceWorkspace, Workspace destinationWorkspace, String chunkName) throws Exception {
if (!isTokenActive()) {
login();
}
HttpClient httpClient = new DefaultHttpClient();
String url = this.storageUrl + "/" + destinationWorkspace.getSwiftContainer() + "/"
+ chunkName;
String copyFrom = "/" + sourceWorkspace.getSwiftContainer() + "/" + chunkName;
try {
HttpPut request = new HttpPut(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
request.setHeader(SwiftResponse.X_COPY_FROM, copyFrom);
//request.setHeader("Content-Length", "0");
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("401 User unauthorized");
}
if (swiftResponse.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
throw new ObjectNotFoundException("404 Not Found");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例11: createNewWorkspace
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void createNewWorkspace(Workspace workspace) throws Exception {
if (!isTokenActive()) {
login();
}
TrustStrategy acceptingTrustStrategy = new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] certificate, String authType) {
return true;
}
};
SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("https", 5000, sf));
ClientConnectionManager ccm = new SingleClientConnManager(registry);
HttpClient httpClient = new DefaultHttpClient(ccm);
String url = this.storageUrl + "/" + workspace.getSwiftContainer();
try {
HttpPut request = new HttpPut(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("401 User unauthorized");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例12: removeUserToWorkspace
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void removeUserToWorkspace(User owner, User user, Workspace workspace) throws Exception {
if (!isTokenActive()) {
login();
}
String permissions = getWorkspacePermissions(owner, workspace);
String tenantUser = Config.getSwiftTenant() + ":" + user.getSwiftUser();
if (permissions.contains("," + tenantUser)) {
permissions.replace("," + tenantUser, "");
} else if (permissions.contains(tenantUser)) {
permissions.replace(tenantUser, "");
} else {
return;
}
TrustStrategy acceptingTrustStrategy = new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] certificate, String authType) {
return true;
}
};
SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("https", 5000, sf));
ClientConnectionManager ccm = new SingleClientConnManager(registry);
HttpClient httpClient = new DefaultHttpClient(ccm);
String url = this.storageUrl + "/" + workspace.getSwiftContainer();
try {
HttpPut request = new HttpPut(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
request.setHeader(SwiftResponse.X_CONTAINER_READ, permissions);
request.setHeader(SwiftResponse.X_CONTAINER_WRITE, permissions);
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("404 User unauthorized");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例13: grantUserToWorkspace
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void grantUserToWorkspace(User owner, User user, Workspace workspace) throws Exception {
if (!isTokenActive()) {
login();
}
String permissions = getWorkspacePermissions(owner, workspace);
String tenantUser = Config.getSwiftTenant() + ":" + user.getSwiftUser();
if (permissions.contains(tenantUser)) {
return;
}
permissions += "," + tenantUser;
TrustStrategy acceptingTrustStrategy = new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] certificate, String authType) {
return true;
}
};
SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("https", 5000, sf));
ClientConnectionManager ccm = new SingleClientConnManager(registry);
HttpClient httpClient = new DefaultHttpClient(ccm);
String url = this.storageUrl + "/" + workspace.getSwiftContainer();
try {
HttpPut request = new HttpPut(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
request.setHeader(SwiftResponse.X_CONTAINER_READ, permissions);
request.setHeader(SwiftResponse.X_CONTAINER_WRITE, permissions);
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("404 User unauthorized");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例14: copyChunk
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void copyChunk(Workspace sourceWorkspace, Workspace destinationWorkspace, String chunkName) throws Exception {
if (!isTokenActive()) {
login();
}
chunkName = "chk-" + chunkName;
TrustStrategy acceptingTrustStrategy = new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] certificate, String authType) {
return true;
}
};
SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("https", 5000, sf));
ClientConnectionManager ccm = new SingleClientConnManager(registry);
HttpClient httpClient = new DefaultHttpClient(ccm);
String url = this.storageUrl + "/" + destinationWorkspace.getSwiftContainer() + "/"
+ chunkName;
String copyFrom = "/" + sourceWorkspace.getSwiftContainer() + "/" + chunkName;
try {
HttpPut request = new HttpPut(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
request.setHeader(SwiftResponse.X_COPY_FROM, copyFrom);
//request.setHeader("Content-Length", "0");
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("401 User unauthorized");
}
if (swiftResponse.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
throw new ObjectNotFoundException("404 Not Found");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}
示例15: deleteWorkspace
import com.stacksync.commons.models.Workspace; //导入方法依赖的package包/类
@Override
public void deleteWorkspace(Workspace workspace) throws Exception {
if (!isTokenActive()) {
login();
}
TrustStrategy acceptingTrustStrategy = new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] certificate, String authType) {
return true;
}
};
SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("https", 5000, sf));
ClientConnectionManager ccm = new SingleClientConnManager(registry);
HttpClient httpClient = new DefaultHttpClient(ccm);
String url = this.storageUrl + "/" + workspace.getSwiftContainer();
try {
HttpDelete request = new HttpDelete(url);
request.setHeader(SwiftResponse.X_AUTH_TOKEN, authToken);
HttpResponse response = httpClient.execute(request);
SwiftResponse swiftResponse = new SwiftResponse(response);
if (swiftResponse.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
throw new UnauthorizedException("401 User unauthorized");
}
if (swiftResponse.getStatusCode() < 200 || swiftResponse.getStatusCode() >= 300) {
throw new UnexpectedStatusCodeException("Unexpected status code: " + swiftResponse.getStatusCode());
}
} finally {
httpClient.getConnectionManager().shutdown();
}
}