当前位置: 首页>>代码示例>>Java>>正文


Java DocumentNotFoundException类代码示例

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


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

示例1: deleteSite

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
/**
 * DELETE
 *
 * @param user Owner(?) of the room
 * @param id of site to delete
 * @return the revision of the deleted document
 */
public String deleteSite(String user, String id) throws DocumentNotFoundException {
    // Get the site first (need the coordinates)
    Site site = db.get(Site.class, id);

    // Revisit this with orgs.. *sigh*
    if ( site.getOwner() == null || !site.getOwner().equals(user) ) {
        throw new MapModificationException(Response.Status.FORBIDDEN,
                "Room " + id + " could not be deleted",
                user + " is not allowed to delete room " + id);
    }

    Coordinates coord = site.getCoord();
    String revision = db.delete(site);

    // Replace this site with an empty placeholder
    createEmptySite(coord);

    return revision;
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:27,代码来源:SiteDocuments.java

示例2: testDocumentNotFoundException

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
@Test
public void testDocumentNotFoundException(@Mocked Response response, @Mocked ResponseBuilder builder) {
    ObjectNode node = JsonNodeFactory.instance.objectNode();
    node.put("body", "ex_body");

    exMapper.toResponse(new DocumentNotFoundException("TestException", node));

    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.NOT_FOUND, s);
        Assert.assertTrue("Stringified json should include status 404: [" + json + "]",
                json.contains("\"status\":404"));
        Assert.assertTrue("Stringified json should include message containing exception's message: [" + json + "]",
                json.contains("\"message\":\"TestException\""));
        Assert.assertTrue("Stringified json should include info: [" + json + "]",
                json.contains("\"more_info\":{\"body\":\"ex_body\"}"));
    }};
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:25,代码来源:ErrorResponseMapperTest.java

示例3: delete

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
/**
 * Deletes the entry with the given id.
 */
@DELETE
@Path("{id}")
public Response delete(@PathParam("id") String id) {
  LOGGER.info("Deleting analysis with id " + id);

  PIEntryRepository repo = new PIEntryRepository(Database.instance());
  PIEntry piEntry;
  try {
    piEntry = repo.get(id);
  } catch (DocumentNotFoundException e) {
    return Response.noContent().build();
  }

  repo.remove(piEntry);
  return Response.ok().build();
}
 
开发者ID:IBM-Cloud,项目名称:local-liberty-tutorial,代码行数:20,代码来源:PIResource.java

示例4: testDocumentNotFoundException

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
@Test
public void testDocumentNotFoundException(@Mocked Response response, @Mocked ResponseBuilder builder) {
    ObjectNode node = JsonNodeFactory.instance.objectNode();
    node.put("body", "ex_body");
    
    exMapper.toResponse(new DocumentNotFoundException("TestException", node));
    
    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.NOT_FOUND, s);
        Assert.assertTrue("Stringified json should include status 404: [" + json + "]", 
                json.contains("\"status\":404"));
        Assert.assertTrue("Stringified json should include message containing exception's message: [" + json + "]", 
                json.contains("\"message\":\"TestException\""));
        Assert.assertTrue("Stringified json should include info: [" + json + "]", 
                json.contains("\"more_info\":{\"body\":\"ex_body\"}"));
    }};
}
 
开发者ID:gameontext,项目名称:gameon-player,代码行数:25,代码来源:ErrorResponseMapperTest.java

示例5: checkClientUpdateMissingDbEntry

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

    Claims claims = Jwts.claims();
    claims.setAudience("client");
    new Expectations() {{
        tested.systemId = "game-on.org";
        request.getAttribute("player.id"); returns("game-on.org");
        dbi.get(PlayerDbRecord.class, playerId); result = new DocumentNotFoundException("player.id");
    }};

    PlayerArgument proposed = new PlayerArgument();
    proposed.setName("AnotherName");
    proposed.setFavoriteColor("AnotherColor");
    proposed.setId(playerId);

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

示例6: addAdapter

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
@PUT
@Path("/{adapterId}")
public EplAdapter addAdapter(
		@RestrictedTo(Role.ADMIN) User user,
		@PathParam("adapterId") String adapterId,
		@Valid EplAdapterDescription adapterDescription) {

	try {
		adapterManager.get(adapterId);
		throw RestUtils.createJsonFormattedException("adapter already exists", 409);
	} catch (DocumentNotFoundException dnfe) {
		// all good
	}

	EplAdapter adapter = new EplAdapter(adapterId, adapterDescription.getEplBlueprint(), adapterDescription.getRequiredArguments());
	adapterManager.add(adapter);
	return adapter;
}
 
开发者ID:jvalue,项目名称:cep-service,代码行数:19,代码来源:EplAdapterApi.java

示例7: get

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
@Cacheable("contents")
@Override
public Content get(final String id) {
	try {
		final Content content = super.get(id);
		if (!"freetext".equals(content.getQuestionType()) && 0 == content.getPiRound()) {
		/* needed for legacy questions whose piRound property has not been set */
			content.setPiRound(1);
		}
		content.updateRoundManagementState();
		//content.setSessionKeyword(sessionRepository.getSessionFromId(content.getSessionId()).getKeyword());

		return content;
	} catch (final DocumentNotFoundException e) {
		logger.error("Could not get question {}.", id, e);
	}

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

示例8: sendMessage

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
@Override
public synchronized void sendMessage(TransportMessage transportMessage) {
	if (transportMessage.getSessionId() == null) {
		LOG.warn("Sending message without session ID.");
	}

	if (transportMessage.getId() == null) {
		transportMessage.setId(DateTime.now(DateTimeZone.UTC).toString());
		db.create(transportMessage);
	} else {
		try {
			TransportMessage oldMsg = db.get(TransportMessage.class,
					transportMessage.getId());
			transportMessage.setRevision(oldMsg.getRevision());

			db.update(transportMessage);
		} catch (DocumentNotFoundException e) {
			db.create(transportMessage);
		}
	}
}
 
开发者ID:SiphonSquirrel,项目名称:jepperscore,代码行数:22,代码来源:CouchDbMessageDestination.java

示例9: getSite

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
/**
 * RETRIEVE
 * Get site by id, fill in with related exit/neighbor information
 *
 * @param id Site/Room id
 * @return Complete information for the specified room/site
 * @throws DocumentNotFoundException for unknown room
 */
public Site getSite(String id) throws DocumentNotFoundException {
    Site site = getSiteWithoutExits(id);
    if ( site != null ) {
        Exits exits = getExits(site.getCoord());
        site.setExits(exits);
    }

    return site;
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:18,代码来源:SiteDocuments.java

示例10: getSiteWithoutExits

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
private Site getSiteWithoutExits(String id) throws DocumentNotFoundException{
    if (id == null || id.isEmpty()) {
        throw new MapModificationException(Response.Status.BAD_REQUEST,
                "Site id must be set.",
                "Site id passed in is " + id);
    }
    // get the document from the DB
    Site site = db.get(Site.class, id);
    return site;
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:11,代码来源:SiteDocuments.java

示例11: testSwapRoomsNonExistentRoom

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
@Test
public void testSwapRoomsNonExistentRoom() {
    DocumentNotFoundException e = null;
    try {
        repo.swapRooms(swapRoomsAccessPolicy, roomOwner, "roomId1", "roomId2");
    } catch (DocumentNotFoundException ex) {
        e = ex;
    }
    assertNotNull("Swap request should result in DocumentNotFoundException.", e);
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:11,代码来源:TestLiveRoomSwap.java

示例12: testSiteDelete

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
@Test
public void testSiteDelete() throws JsonProcessingException {
    String roomName = test.getMethodName() + "-1";

    Site testSite = new Site();
    testSite.setOwner("test");
    testSite.setId(roomName);
    testSite.setCoord(new Coordinates(Integer.MAX_VALUE, Integer.MAX_VALUE));

    // Create the document directly, way off in the corner.
    // We're skipping creation of surrounding empty links
    repo.sites.db.create(testSite);
    Assert.assertNotNull(testSite.getId());

    // RETRIEVE
    Site before = repo.sites.getSite(testSite.getId());
    Assert.assertEquals("Original and result should have the same id", testSite.getId(), before.getId());
    Assert.assertEquals("Original and result should have the same revision", testSite.getRev(), before.getRev());
    System.out.println(debugWriter.writeValueAsString(before));

    // DELETE
    String revision = repo.sites.deleteSite("test", testSite.getId());
    Assert.assertNotNull("Deleted revision should not be null", revision);

    try {
        repo.sites.getSite(testSite.getId());
        Assert.fail("Expected DocumentNotFoundException when requesting a deleted document");
    } catch(DocumentNotFoundException dne) {
    }

    List<Site> xy_replace = repo.sites.getByCoordinate(Integer.MAX_VALUE, Integer.MAX_VALUE);
    Assert.assertEquals("A single replacement should be created for the same coordinates", 1, xy_replace.size());

    // attempt to delete the replacement
    repo.sites.db.delete(xy_replace.get(0));
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:37,代码来源:TestLiveMapPlacement.java

示例13: get

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
/**
 * @return the entry with the given id.
 */
@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response get(@PathParam("id") String id) {
  LOGGER.info("Retrieving analysis with id " + id);

  PIEntryRepository repo = new PIEntryRepository(Database.instance());
  try {
    return Response.ok(gson.toJson(repo.get(id))).build();
  } catch (DocumentNotFoundException e) {
    return Response.noContent().build();
  }
}
 
开发者ID:IBM-Cloud,项目名称:local-liberty-tutorial,代码行数:17,代码来源:PIResource.java

示例14: cleanDb

import org.ektorp.DocumentNotFoundException; //导入依赖的package包/类
@Override
public void cleanDb(String dbName)
{
	try
	{
		deleteDatabase(dbName);
	} catch (DocumentNotFoundException e)
	{
		System.err.println("Database doesnt exist: " + dbName);
	}
}
 
开发者ID:catedrasaes-umu,项目名称:NoSQLDataEngineering,代码行数:12,代码来源:CouchDbClient.java

示例15: toResponse

import org.ektorp.DocumentNotFoundException; //导入依赖的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


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