本文整理汇总了Java中com.stacksync.commons.models.Workspace类的典型用法代码示例。如果您正苦于以下问题:Java Workspace类的具体用法?Java Workspace怎么用?Java Workspace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Workspace类属于com.stacksync.commons.models包,在下文中一共展示了Workspace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUserWorkspaceFromResultSet
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
public static UserWorkspace getUserWorkspaceFromResultSet(ResultSet result)
throws SQLException {
User user = new User();
user.setId(UUID.fromString(result.getString("id")));
user.setName(result.getString("name"));
user.setEmail(result.getString("email"));
Workspace workspace = new Workspace();
workspace.setId(UUID.fromString(result.getString("workspace_id")));
UserWorkspace userWorkspace = new UserWorkspace(user, workspace);
userWorkspace.setOwner(result.getBoolean("is_owner"));
userWorkspace.setJoinedAt(result.getDate("joined_at"));
return userWorkspace;
}
示例2: getItemFromResultSet
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
public static Item getItemFromResultSet(ResultSet result) throws SQLException {
Item item = new Item();
item.setId(result.getLong("id"));
item.setLatestVersion(result.getLong("latest_version"));
item.setFilename(result.getString("filename"));
item.setMimetype(result.getString("mimetype"));
item.setIsFolder(result.getBoolean("is_folder"));
item.setClientParentFileVersion((getLongFromResultSet(result, "client_parent_file_version")));
Workspace w = new Workspace();
w.setId(UUID.fromString(result.getString("workspace_id")));
item.setWorkspace(w);
Item parent = new Item();
parent.setId(result.getLong("parent_id"));
item.setParent(parent);
return item;
}
示例3: commit
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
@Override
public void commit(CommitRequest request) {
logger.debug(request);
try {
User user = new User();
user.setId(request.getUserId());
Device device = new Device(request.getDeviceId());
Workspace workspace = new Workspace(request.getWorkspaceId());
CommitNotification result = getHandler().doCommit(user, workspace, device, request.getItems());
result.setRequestId(request.getRequestId());
UUID id = workspace.getId();
RemoteWorkspace commitNotifier = broker.lookupMulti(id.toString(), RemoteWorkspace.class);
commitNotifier.notifyCommit(result);
logger.debug("Consumer: Response sent to workspace \"" + workspace + "\"");
} catch (Exception e) {
logger.error(e);
}
}
示例4: doGetWorkspaceMembers
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
public List<UserWorkspace> doGetWorkspaceMembers(User user, Workspace workspace) throws InternalServerError {
// TODO: check user permissions.
List<UserWorkspace> members;
try {
members = workspaceDAO.getMembersById(workspace.getId());
} catch (DAOException e) {
logger.error(e);
throw new InternalServerError(e);
}
if (members == null || members.isEmpty()) {
throw new InternalServerError("No members found in workspace.");
}
return members;
}
示例5: getById
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
@Override
public Workspace getById(UUID workspaceID) throws DAOException {
ResultSet resultSet = null;
Workspace workspace = null;
String query = "SELECT * FROM workspace w INNER JOIN workspace_user wu ON wu.workspace_id = w.id WHERE w.id = ?::uuid";
try {
resultSet = executeQuery(query, new Object[] { workspaceID });
if (resultSet.next()) {
workspace = mapWorkspace(resultSet);
}
} catch (SQLException e) {
logger.error(e);
throw new DAOException(DAOError.INTERNAL_SERVER_ERROR);
}
return workspace;
}
示例6: 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);
}
}
示例7: update
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
@Override
public void update(User user, Workspace workspace) throws DAOException {
if (workspace.getId() == null || user.getId() == null) {
throw new IllegalArgumentException("Attributes not set");
}
Long parentItemId = null;
if (workspace.getParentItem() != null) {
parentItemId = workspace.getParentItem().getId();
}
Object[] values = { workspace.getName(), parentItemId, workspace.getId(), user.getId() };
String query = "UPDATE workspace_user " + " SET workspace_name = ?, parent_item_id = ?, modified_at = now() "
+ " WHERE workspace_id = ?::uuid AND user_id = ?::uuid";
executeUpdate(query, values);
}
示例8: mapWorkspace
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
private Workspace mapWorkspace(ResultSet result) throws SQLException {
Workspace workspace = new Workspace();
workspace.setId(UUID.fromString(result.getString("id")));
workspace.setLatestRevision(result.getInt("latest_revision"));
workspace.setShared(result.getBoolean("is_shared"));
workspace.setEncrypted(result.getBoolean("is_encrypted"));
workspace.setName(result.getString("workspace_name"));
workspace.setSwiftContainer(result.getString("swift_container"));
workspace.setSwiftUrl(result.getString("swift_url"));
Long parentItemId = result.getLong("parent_item_id");
if (parentItemId == 0L){
parentItemId = null;
}
workspace.setParentItem(new Item(parentItemId));
User owner = new User();
owner.setId(UUID.fromString(result.getString("owner_id")));
workspace.setOwner(owner);
return workspace;
}
示例9: addUser
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
@Override
public void addUser(User user, Workspace workspace) throws DAOException {
if (user == null || !user.isValid()) {
throw new IllegalArgumentException("User not valid");
} else if (workspace == null || !workspace.isValid()) {
throw new IllegalArgumentException("Workspace not valid");
}
Long parentItemId = null;
if (workspace.getParentItem() != null) {
parentItemId = workspace.getParentItem().getId();
}
Object[] values = { workspace.getId(), user.getId(), workspace.getName(), parentItemId };
String query = "INSERT INTO workspace_user (workspace_id, user_id, workspace_name, parent_item_id) VALUES (?::uuid, ?::uuid, ?, ?)";
executeUpdate(query, values);
}
示例10: getByItemId
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
@Override
public Workspace getByItemId(Long itemId) throws DAOException {
ResultSet resultSet = null;
Workspace workspace = null;
String query = "SELECT * FROM workspace w " +
" INNER JOIN workspace_user wu ON wu.workspace_id = w.id " +
" INNER JOIN item i ON w.id = i.workspace_id " +
" WHERE i.id = ?";
try {
resultSet = executeQuery(query, new Object[] { itemId });
if (resultSet.next()) {
workspace = mapWorkspace(resultSet);
}
} catch (SQLException e) {
logger.error(e);
throw new DAOException(DAOError.INTERNAL_SERVER_ERROR);
}
return workspace;
}
示例11: main
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Config.loadProperties();
String datasource = Config.getDatasource();
ConnectionPool pool = ConnectionPoolFactory.getConnectionPool(datasource);
Handler handler = new SQLSyncHandler(pool);
String metadata = CommonFunctions.generateObjects(1, Constants.DEVICE_ID);
long startTotal = System.currentTimeMillis();
JsonArray rawObjects = new JsonParser().parse(metadata).getAsJsonArray();
List<ItemMetadata> objects = getObjectMetadata(rawObjects);
User user = new User();
user.setId(Constants.USER);
Device device = new Device( Constants.DEVICE_ID);
Workspace workspace = new Workspace(Constants.WORKSPACE_ID);
handler.doCommit(user, workspace, device, objects);
long totalTime = System.currentTimeMillis() - startTotal;
// System.out.println("Objects -> " + ((GetChangesResponseMessage)
// response).getMetadata().size());
System.out.println("Total level time --> " + totalTime + " ms");
}
示例12: generateLevel
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
public ArrayList<Item> generateLevel(Workspace workspace, Device device, Item parent) {
int objectsLevel = randGenerator.nextInt(MAX_FILES_LEVEL);
ArrayList<Item> objects = new ArrayList<Item>();
for (int i = 0; i < objectsLevel; i++) {
Item currentObject;
int folderValue = randGenerator.nextInt(totalPercentage);
boolean folder = false;
if (folderValue < folderPercentage) {
folder = true;
}
currentObject = this.generateMetadata(workspace, device, parent, folder);
objects.add(currentObject);
}
return objects;
}
示例13: createAndStoreMetadata
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
public void createAndStoreMetadata(Workspace workspace, Device device, int currentLevel, Item parent)
throws IllegalArgumentException, DAOException {
if (currentLevel >= this.fsDepth) {
return;
}
List<Item> objectsLevel = metadataGen.generateLevel(workspace, device, parent);
this.dbHelper.storeObjects(objectsLevel);
for (Item object : objectsLevel) {
if (object.isFolder()) {
createAndStoreMetadata(workspace, device, currentLevel + 1, object);
}
}
System.out.println("***** " + name + " --> Stored objects: " + objectsLevel.size() + " at level: " + currentLevel);
}
示例14: testCreateNewWorkspaceValidOwner
import com.stacksync.commons.models.Workspace; //导入依赖的package包/类
@Test
public void testCreateNewWorkspaceValidOwner() throws IllegalArgumentException, DAOException {
User user = new User();
user.setName(nextString());
user.setId(UUID.randomUUID());
user.setEmail(nextString());
user.setQuotaLimit(2048L);
user.setQuotaUsedLogical(1403L);
user.setQuotaUsedReal(1024L);
userDao.add(user);
Workspace workspace = new Workspace();
workspace.setLatestRevision(0);
workspace.setOwner(user);
try {
workspaceDAO.add(workspace);
assertTrue(true);
} catch (DAOException e) {
assertTrue(e.toString(), false);
}
}
示例15: 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);
}
}
}