當前位置: 首頁>>代碼示例>>Java>>正文


Java Workspace類代碼示例

本文整理匯總了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;
}
 
開發者ID:stacksync,項目名稱:stacksync-quota-server,代碼行數:18,代碼來源:DAOUtil.java

示例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;
	}
 
開發者ID:stacksync,項目名稱:stacksync-quota-server,代碼行數:21,代碼來源:DAOUtil.java

示例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);
	}
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:26,代碼來源:SyncServiceImp.java

示例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;
    }
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:20,代碼來源:Handler.java

示例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;
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:21,代碼來源:PostgresqlWorkspaceDAO.java

示例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);
	}

}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:19,代碼來源:PostgresqlWorkspaceDAO.java

示例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);
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:19,代碼來源:PostgresqlWorkspaceDAO.java

示例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;
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:27,代碼來源:PostgresqlWorkspaceDAO.java

示例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);
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:20,代碼來源:PostgresqlWorkspaceDAO.java

示例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;
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:24,代碼來源:PostgresqlWorkspaceDAO.java

示例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");
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:26,代碼來源:TestCommit.java

示例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;
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:20,代碼來源:MetadataGenerator.java

示例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);
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:19,代碼來源:DBBenchmark.java

示例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);
	}
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:24,代碼來源:PostgresqlDAOTest.java

示例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);
            }
        }

    }
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:30,代碼來源:XmlRpcSyncHandler.java


注:本文中的com.stacksync.commons.models.Workspace類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。