• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UpdateConflictException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.ektorp.UpdateConflictException的典型用法代码示例。如果您正苦于以下问题:Java UpdateConflictException类的具体用法?Java UpdateConflictException怎么用?Java UpdateConflictException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UpdateConflictException类属于org.ektorp包,在下文中一共展示了UpdateConflictException类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testUpdateConflictException

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
@Test
public void testUpdateConflictException(@Mocked Response response, @Mocked ResponseBuilder builder) {
    exMapper.toResponse(new UpdateConflictException("TestDocument", "Revision"));

    new Verifications() {{
        ResponseBuilder rb;
        Status s;
        String json;

        rb = Response.status(s = withCapture()); times = 1;
        rb.entity(json = withCapture()); times = 1;

        Assert.assertEquals(Response.Status.CONFLICT, s);
        Assert.assertTrue("Stringified json should include status 409: [" + json + "]",
                json.contains("\"status\":409"));
        Assert.assertTrue("Stringified json should include message containing exception's message: [" + json + "]",
                json.contains("\"message\":\"document update conflict: id: TestDocument rev: Revision\""));
        Assert.assertFalse("Stringified json should not include info: [" + json + "]",
                json.contains("more_info"));
    }};
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:22,代码来源:ErrorResponseMapperTest.java


示例2: testConnectRoomUpdateConflict

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
@Test(expected=MapModificationException.class)
public void testConnectRoomUpdateConflict() {

    List<Site> sites = Arrays.asList(site, site);

    new Expectations() {{
        dbc.queryView((ViewQuery) any, Site.class); returns(sites);
        dbc.queryView((ViewQuery) any, JsonNode.class); returns(Collections.emptyList(), sites);
        dbc.update(site); result = new UpdateConflictException(); result = null;
    }};

    docs.connectRoom(owner, info);
    System.out.println(site);

    new Verifications() {{
        dbc.create(any); times = 4;
        dbc.update(site); times = 2;
        assertNotNull( "createdOn should be set: " + site, site.getCreatedOn());
        assertNotNull( "assignedOn should be set: " + site, site.getAssignedOn());
    }};
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:22,代码来源:SiteCreateMockedTest.java


示例3: testUpdateConflictException

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
@Test
public void testUpdateConflictException(@Mocked Response response, @Mocked ResponseBuilder builder) {
    exMapper.toResponse(new UpdateConflictException("TestDocument", "Revision"));
    
    new Verifications() {{
        ResponseBuilder rb;
        Status s;
        String json;
        
        rb = Response.status(s = withCapture()); times = 1;
        rb.entity(json = withCapture()); times = 1;
        
        Assert.assertEquals(Response.Status.CONFLICT, s);
        Assert.assertTrue("Stringified json should include status 409: [" + json + "]", 
                json.contains("\"status\":409"));
        Assert.assertTrue("Stringified json should include message containing exception's message: [" + json + "]", 
                json.contains("\"message\":\"document update conflict: id: TestDocument rev: Revision\""));
        Assert.assertFalse("Stringified json should not include info: [" + json + "]", 
                json.contains("more_info"));
    }};
}
 
开发者ID:gameontext,项目名称:gameon-player,代码行数:22,代码来源:ErrorResponseMapperTest.java


示例4: checkServerLocationUpdateMatchingIdConflict

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
@Test(expected = UpdateConflictException.class)
public void checkServerLocationUpdateMatchingIdConflict(@Mocked Response response, @Mocked ResponseBuilder builder) throws IOException {
    String playerId = "fish";

    PlayerDbRecord dbEntry = new PlayerDbRecord();
    dbEntry.setApiKey("ShinyShoes");
    dbEntry.setName("Kitten");
    dbEntry.setFavoriteColor("Tangerine");
    dbEntry.setId(playerId);
    dbEntry.setLocation("Earth");

    LocationChange locChange = new LocationChange();
    locChange.setOldLocation("Earth");
    locChange.setNewLocation("Mars");

    Claims claims = Jwts.claims();
    claims.setAudience("server");
    new Expectations() {{
        tested.systemId = "game-on.org";
        request.getAttribute("player.claims"); returns(claims);
        dbi.get(PlayerDbRecord.class, playerId); returns(dbEntry);
        dbi.update(any); result = new UpdateConflictException();
    }};

    tested.updatePlayerLocation(playerId, locChange);
}
 
开发者ID:gameontext,项目名称:gameon-player,代码行数:27,代码来源:PlayerResourceTest.java


示例5: delete

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
private int delete(final ViewResult comments) {
	if (comments.isEmpty()) {
		return 0;
	}
	/* TODO: use bulk delete */
	for (final ViewResult.Row row : comments.getRows()) {
		try {
			db.delete(row.getId(), row.getValueAsNode().get("rev").asText());
		} catch (final UpdateConflictException e) {
			logger.error("Could not delete comments.", e);
		}
	}

	/* This does account for failed deletions */
	dbLogger.log("delete", "type", "comment", "commentCount", comments.getSize());

	return comments.getSize();
}
 
开发者ID:thm-projects,项目名称:arsnova-backend,代码行数:19,代码来源:CouchDbCommentRepository.java


示例6: updateSessionOwnerActivity

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
@CachePut(value = "sessions")
private Session updateSessionOwnerActivity(final Session session) {
	try {
		/* Do not clutter CouchDB. Only update once every 3 hours. */
		if (session.getLastOwnerActivity() > System.currentTimeMillis() - 3 * 3600000) {
			return session;
		}

		session.setLastOwnerActivity(System.currentTimeMillis());
		save(session);

		return session;
	} catch (final UpdateConflictException e) {
		logger.error("Failed to update lastOwnerActivity for session {}.", session, e);
		return session;
	}
}
 
开发者ID:thm-projects,项目名称:arsnova-backend,代码行数:18,代码来源:SessionServiceImpl.java


示例7: assignEmptySite

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
protected Site assignEmptySite(String owner, RoomInfo newRoom) {

        // Get an unassigned empty site
        Site candidateSite = getEmptySite();
        Log.mapOperations(Level.FINEST, this, "Found empty node: {0}", candidateSite);

        candidateSite.setOwner(owner);
        candidateSite.setInfo(newRoom);
        candidateSite.setType("room");

        try {
            db.update(candidateSite);
        } catch (UpdateConflictException ex) {
            // If there is a conflict, we'll return null so that the caller tries again.
            // RETURN NULL: Caller should retry
            return null;
        }

        // Check again for duplicate owner/room name
        List<JsonNode> rooms = listSites(owner, newRoom.getName());
        if ( rooms.size() > 1 ) {
            // we have a duplicate. *le sigh*

            candidateSite.setOwner(null);
            candidateSite.setInfo(null);
            candidateSite.setType("empty");
            db.update(candidateSite);

            throw new MapModificationException(Response.Status.CONFLICT,
                    "Unable to place room in the map",
                    "A room with this name ("+newRoom.getName()+") already exists for owner ("+owner+")");
        }

        // Return the new/shiny site!
        return candidateSite;
    }
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:37,代码来源:SiteDocuments.java


示例8: toResponse

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
@Override
public Response toResponse(Exception exception) {

    ObjectNode objNode = mapper.createObjectNode();

    Response.Status status = Response.Status.INTERNAL_SERVER_ERROR;
    String message = exception.getMessage();

    if ( exception instanceof DocumentNotFoundException ) {
        DocumentNotFoundException dne = (DocumentNotFoundException) exception;
        status = Response.Status.NOT_FOUND;
        message = dne.getPath();
        objNode.set("more_info", dne.getBody());

    } else if ( exception instanceof UpdateConflictException ) {
        status = Response.Status.CONFLICT;

    } else if ( exception instanceof JsonParseException ) {
        status = Response.Status.BAD_REQUEST;

    } else if ( exception instanceof JsonMappingException ) {
        status = Response.Status.BAD_REQUEST;

    } else if ( exception instanceof PlayerAccountModificationException ) {
        PlayerAccountModificationException mme = (PlayerAccountModificationException) exception;
        status = mme.getStatus();
        message = mme.getMessage();
        String moreInfo = mme.getMoreInfo();
        if ( moreInfo != null )
            objNode.put("more_info", moreInfo);
    }

    objNode.put("status", status.getStatusCode());
    objNode.put("message", message);

    return Response.status(status).entity(objNode.toString()).build();
}
 
开发者ID:gameontext,项目名称:gameon-player,代码行数:38,代码来源:ErrorResponseMapper.java


示例9: checkAlreadyKnownId

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
@Test(expected=UpdateConflictException.class)
public void checkAlreadyKnownId() throws IOException{
    Claims claims = Jwts.claims();
    claims.put("email","[email protected]");
    new Expectations() {{
        request.getAttribute("player.id"); returns(playerArg.getId());
        request.getAttribute("player.claims"); returns(claims);
        dbi.create(withAny(PlayerDbRecord.class)); result = new UpdateConflictException();
    }};

    tested.createPlayer(playerArg);
}
 
开发者ID:gameontext,项目名称:gameon-player,代码行数:13,代码来源:AllPlayersResourceTest.java


示例10: storeStatementAndReturnDoc

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
private StatementDocument storeStatementAndReturnDoc(Statement statement)
		throws DuplicateIdException {
	StatementDocument cDBStatement = new StatementDocument();
	cDBStatement.setStatement(statement);
	String statementId = statement.getId();
	if (statementId == null) {
		// TODO sequential!
		statement.setId(UUID.randomUUID().toString());
	}
	cDBStatement.setId(statement.getId());
	boolean timestampGenerated= false;
	try {
		Date now= new Date();
		statement.setStored(now);
		/* 
		 * xAPI 1.0.1 4.1 regarding timestamp: 
		 * 'If not provided, LRS should set this to the value of "stored" time.'
		 */
		if (statement.getTimestamp() == null) {
			statement.setTimestamp(now);
			timestampGenerated= true;
		}
		connector.create(cDBStatement);
		if (++storeCounter > INDEXING_THRESHOLD) {
			scheduleIndex();
			storeCounter = 0;
		}
	} catch (UpdateConflictException e) {
		statement.setStored(null);
		if (timestampGenerated) {
			statement.setTimestamp(null);
		}
		throw new DuplicateIdException(e, cDBStatement.getId());
	}
	return cDBStatement;
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:Larissa,代码行数:37,代码来源:CouchDbStatementRepository.java


示例11: registerAsOnlineUser

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
@Override
public LoggedIn registerAsOnlineUser(final User user, final Session session) {
	LoggedIn loggedIn = new LoggedIn();
	try {
		final List<LoggedIn> loggedInList = db.queryView(createQuery("all").designDocId("_design/LoggedIn").key(user.getUsername()), LoggedIn.class);

		if (!loggedInList.isEmpty()) {
			loggedIn = loggedInList.get(0);

			/* Do not clutter CouchDB. Only update once every 3 hours per session. */
			if (loggedIn.getSessionId().equals(session.getId()) && loggedIn.getTimestamp() > System.currentTimeMillis() - 3 * 3600000) {
				return loggedIn;
			}
		}

		loggedIn.setUser(user.getUsername());
		loggedIn.setSessionId(session.getId());
		loggedIn.addVisitedSession(session);
		loggedIn.updateTimestamp();

		if (loggedIn.getId() == null) {
			db.create(loggedIn);
		} else {
			db.update(loggedIn);
		}
	} catch (final UpdateConflictException e) {
		logger.error("Could not save LoggedIn document of {}.", user.getUsername(), e);
	}

	return loggedIn;
}
 
开发者ID:thm-projects,项目名称:arsnova-backend,代码行数:32,代码来源:CouchDbSessionRepository.java


示例12: executeWriteOperation

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
private int executeWriteOperation(String key, StringToStringMap dataToWrite){
	try{
		dataToWrite.put("_id", key);
		this.dbConnector.create(dataToWrite);
	} catch(UpdateConflictException exc){
		return UPDATE_CONFLICT;
	}
	return OK;
}
 
开发者ID:arnaudsjs,项目名称:YCSB-couchdb-binding,代码行数:10,代码来源:CouchdbClient.java


示例13: executeDeleteOperation

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
private int executeDeleteOperation(StringToStringMap dataToDelete){
	try{
		this.dbConnector.delete(dataToDelete);
	} catch(UpdateConflictException exc){
		return UPDATE_CONFLICT;
	}
	return OK;
}
 
开发者ID:arnaudsjs,项目名称:YCSB-couchdb-binding,代码行数:9,代码来源:CouchdbClient.java


示例14: executeUpdateOperation

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
private int executeUpdateOperation(StringToStringMap dataToUpdate){
	try{
		this.dbConnector.update(dataToUpdate);
	} catch(UpdateConflictException exc){
		return UPDATE_CONFLICT;
	}
	return OK;
}
 
开发者ID:arnaudsjs,项目名称:YCSB-couchdb-binding,代码行数:9,代码来源:CouchdbClient.java


示例15: toResponse

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
@Override
public Response toResponse(Exception exception) {

    ObjectNode objNode = mapper.createObjectNode();

    Response.Status status = Response.Status.INTERNAL_SERVER_ERROR;
    String message = exception.getMessage();

    if ( exception instanceof MapModificationException ) {
        MapModificationException mme = (MapModificationException) exception;
        status = mme.getStatus();
        message = mme.getMessage();
        String moreInfo = mme.getMoreInfo();
        if ( moreInfo != null )
            objNode.put("more_info", moreInfo);

    } else if ( exception instanceof DocumentNotFoundException ) {
        DocumentNotFoundException dne = (DocumentNotFoundException) exception;
        status = Response.Status.NOT_FOUND;
        message = dne.getPath();
        objNode.set("more_info", dne.getBody());

    } else if ( exception instanceof UpdateConflictException ) {
        status = Response.Status.CONFLICT;
    } else if ( exception instanceof JsonParseException ) {
        status = Response.Status.BAD_REQUEST;

    } else if ( exception instanceof JsonMappingException ) {
        status = Response.Status.BAD_REQUEST;
    } else if ( exception instanceof WebApplicationException) {
        int code = ((WebApplicationException) exception).getResponse().getStatus();
        status = Response.Status.fromStatusCode(code);
    } else {
        //if we're going to handle every unknown type, lets log them so we
        //have an opportunity to debug them in future.
        Log.log(Level.SEVERE, this, "ErrorResponseMapper handling unknown exception type: {0} {1}", exception.getClass(), exception);
    }

    objNode.put("status", status.getStatusCode());
    objNode.put("message", message);

    return Response.status(status).entity(objNode.toString()).build();
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:44,代码来源:ErrorResponseMapper.java


示例16: DuplicateIdException

import org.ektorp.UpdateConflictException; //导入依赖的package包/类
public DuplicateIdException(UpdateConflictException e, String id) {
	super(e);
	this.id = id;
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:Larissa,代码行数:5,代码来源:DuplicateIdException.java



注:本文中的org.ektorp.UpdateConflictException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ISO9796d2Signer类代码示例发布时间:2022-05-22
下一篇:
Java ParquetFileWriter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap