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


Java NotFoundException类代码示例

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


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

示例1: changeState

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
private void changeState(String objectId, MachineState newState, Optional<SingularityMachineChangeRequest> changeRequest, Optional<String> user) {
  Optional<String> message = Optional.absent();

  if (changeRequest.isPresent()) {
    message = changeRequest.get().getMessage();
  }

  StateChangeResult result = manager.changeState(objectId, newState, message, user);

  switch (result) {
    case FAILURE_NOT_FOUND:
      throw new NotFoundException(String.format("Couldn't find an active %s with id %s (result: %s)", getObjectTypeString(), objectId, result.name()));
    case FAILURE_ALREADY_AT_STATE:
    case FAILURE_ILLEGAL_TRANSITION:
      throw new ConflictException(String.format("%s - %s %s is in %s state", result.name(), getObjectTypeString(), objectId, newState));
    default:
      break;
  }

}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:21,代码来源:AbstractMachineResource.java

示例2: deleteCollection

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@DELETE
@Path("/{collection}")
public Response deleteCollection(@PathParam("collection") String collection) throws Exception
{
  StarTreeConfig config = manager.getConfig(collection);
  if (config == null)
  {
    throw new NotFoundException("No collection " + collection);
  }

  manager.close(collection);

  try
  {
    dataUpdateManager.deleteCollection(collection);
  }
  catch (FileNotFoundException e)
  {
    throw new NotFoundException(e.getMessage());
  }

  return Response.noContent().build();
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:24,代码来源:CollectionsResource.java

示例3: getKafkaConfig

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@GET
@Path("/{collection}/kafkaConfig")
public byte[] getKafkaConfig(@PathParam("collection") String collection) throws Exception
{
  File kafkaConfigFile = new File(new File(rootDir, collection), StarTreeConstants.KAFKA_CONFIG_FILE_NAME);
  if (!kafkaConfigFile.exists())
  {
    throw new NotFoundException();
  }
  if (!kafkaConfigFile.isAbsolute())
  {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }

  return IOUtils.toByteArray(new FileInputStream(kafkaConfigFile));
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:17,代码来源:CollectionsResource.java

示例4: deleteKafkaConfig

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@DELETE
@Path("/{collection}/kafkaConfig")
public Response deleteKafkaConfig(@PathParam("collection") String collection) throws Exception
{
  File collectionDir = new File(rootDir, collection);
  if (!collectionDir.isAbsolute())
  {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }

  File kafkaConfigFile = new File(collectionDir, StarTreeConstants.KAFKA_CONFIG_FILE_NAME);
  if (!kafkaConfigFile.exists())
  {
    throw new NotFoundException();
  }

  FileUtils.forceDelete(kafkaConfigFile);

  return Response.noContent().build();
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:21,代码来源:CollectionsResource.java

示例5: checkEmpty

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
public QueryResult checkEmpty() throws NotFoundException {
  if (data.isEmpty()) {
    throw new NotFoundException("No dimension combinations in result");
  }

  boolean allEmpty = true;

  for (Map<String, Number[]> series : data.values()) {
    if (!series.isEmpty()) {
      allEmpty = false;
      break;
    }
  }

  if (allEmpty) {
    throw new NotFoundException("No data for any dimension combination");
  }

  return this;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:21,代码来源:QueryResult.java

示例6: buildPage

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
/**
 * build browsing native page with data
 *
 * @param artifactoryRequest  - encapsulate data related to request
 * @param artifactoryResponse - encapsulate data related to response
 * @return - native browsing html page
 */
private String buildPage(ArtifactoryRestRequest artifactoryRequest, RestResponse artifactoryResponse) {
    StringBuilder page = new StringBuilder();
    try {
        HttpServletRequest httpServletRequest = artifactoryRequest.getServletRequest();
        RepoPath repoPath = (RepoPath) httpServletRequest.getAttribute(ATTR_ARTIFACTORY_REPOSITORY_PATH);
        if (repoPath == null || StringUtils.isEmpty(repoPath.getRepoKey())) {
            throw new NotFoundException("Repository Path Not Found");
        }
        // fetch page props
        Properties requestProps = (Properties) httpServletRequest
                .getAttribute(ATTR_ARTIFACTORY_REQUEST_PROPERTIES);
        updatePageData(repoPath, requestProps, artifactoryResponse);
        // fetch page title
        String title = getPageTitle(repoPath);
        // fetch page body
        String body = getBody();
        // fetch page footer
        String addressFooter = getAddressFooter(httpServletRequest);
        // create html page
        createHtmlPage(page, title, body, addressFooter);
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage());
    }
    return page.toString();
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:33,代码来源:BrowseNativeService.java

示例7: gett

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@GET
@Path("/{id}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response gett(
		@PathParam("id") Long id,
		@QueryParam("revision") @DefaultValue("0") Long revision
		) throws Exception {
	
	Metadata metadata = fileService.load(id,revision);
	if(metadata == null) {
		throw new NotFoundException(); 
	}
	String header = String.format("attachment;filename=\"%s\"",metadata.getName());
	
	return Response.ok(metadata.getFile(),metadata.getMimeType()).header("Content-Disposition",header).build();
}
 
开发者ID:josecoelho,项目名称:yep-rest-file-server,代码行数:17,代码来源:FilesRest.java

示例8: lookupToo

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@GET
@Timed
@Path("lookup")
@UnitOfWork
public List<UserTO> lookupToo(@SessionUser User user, @QueryParam("text") String snippet,@QueryParam("p") String projectIdStr) {
	if(snippet == null) throw new NotFoundException();
	if(snippet.length() < 3) throw new NotFoundException();
	Project project = null;
	try {
		Long projectId = null;
		projectId = Long.parseLong(projectIdStr);
		project = this.projectDAO.findById(projectId);
	} catch(NumberFormatException nfe) {}
	User u = this.ud.findByPortionOfEmailUsername(snippet);
	if(u == null) return null;
	// now remove it, if it's already in existence.
	List<UserProject> current= this.upDAO.findByUserIdProjectId(u, project);
	if(current.size() > 0) throw new NotFoundException();
	ArrayList<UserTO> l = new ArrayList<UserTO>();
	l.add(new UserTO(u));
	return l;
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:23,代码来源:UserResource.java

示例9: getSettings

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
public ImmutableMap<String, String> getSettings(long id) {
	Builder<String, String> settings = ImmutableMap.<String, String> builder();

	openEntityManager();
	User user;
	try {
		user = find(User.class, id);
		if (user != null) {
			for (UserSetting setting : user.getUserSettings()) {
				settings.put(setting.getKey(), setting.getValue());
			}
		}

	} finally {
		closeEntityManager();
	}

	if (user == null) {
		throw new NotFoundException("No user found with id " + id);
	}
	return settings.build();
}
 
开发者ID:HuygensING,项目名称:elaborate4-backend,代码行数:23,代码来源:UserService.java

示例10: putUser

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@PUT
@Path(SLASH_USERNAME)
public Viewable putUser(@PathParam(USERNAME) String username, @FormParam(REALNAME) String realname, @FormParam(EMAIL) String emailAddress, @FormParam(ENABLED) String enabled,
		@FormParam(EXTERNAL_REF_ID) String externalRefId, @FormParam(MAX_INSTANCES) String maxInstancesStr, @FormParam(MAX_CORES) String maxCoresStr) {
	LOG.info(String.format("Updating a new user: username %s, real name %s, email %s, enabled %s, external ref id %s, maxInstances %s, maxCores %s", username, realname, emailAddress, enabled,
			externalRefId, maxInstancesStr, maxCoresStr));
	Boolean isEnabled = null;

	if (!StringUtils.isEmpty(enabled))
		isEnabled = validateAndGetEnabledBoolean(enabled);

	Integer maxInstances = validateAndGetMaxInstances(maxInstancesStr);
	Integer maxCores = validateAndGetMaxCores(maxCoresStr);
	try {
		userManagementService.updateUser(username, realname, emailAddress, isEnabled, externalRefId, maxInstances, maxCores);
	} catch (UserNotFoundException ex) {
		throw new NotFoundException("");
	}

	return getViewable(getUser(username));
}
 
开发者ID:barnyard,项目名称:pi,代码行数:22,代码来源:UsersController.java

示例11: getUser

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@Path(SLASH_USERNAME)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@GET
public ReadOnlyUser getUser(@PathParam(USERNAME) String username) {
	checkNotNullOrEmpty(username);

	LOG.debug("Getting user " + username);

	try {
		User user = userManagementService.getUser(username);
		if (user.isDeleted()) {
			throw new NotFoundException(USER_HAS_BEEN_DELETED);
		}
		return new ReadOnlyUser(user);
	} catch (UserNotFoundException e) {
		throw new NotFoundException(USER_DOES_NOT_EXIST);
	}
}
 
开发者ID:barnyard,项目名称:pi,代码行数:19,代码来源:UsersController.java

示例12: getUserByApiAccessKey

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@Path(SLASH_ACCESS_KEYS)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@GET
public ReadOnlyUser getUserByApiAccessKey(@PathParam(ACCESS_KEY) String accessKey) {
	checkNotNullOrEmpty(accessKey);

	LOG.debug(String.format("Getting user with access key %s", accessKey));

	try {
		User user = userManagementService.getUserByApiAccessKey(accessKey);
		if (user.isDeleted()) {
			throw new NotFoundException(USER_HAS_BEEN_DELETED);
		}
		return new ReadOnlyUser(user);
	} catch (UserNotFoundException e) {
		throw new NotFoundException(USER_DOES_NOT_EXIST);
	}
}
 
开发者ID:barnyard,项目名称:pi,代码行数:19,代码来源:UsersController.java

示例13: sendInstanceValidationEmail

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@POST
@Path(SLASH_USERNAME + SLASH_INSTANCEVALIDATION)
public Response sendInstanceValidationEmail(@PathParam(USERNAME) String username) {
	LOG.debug(String.format("sendInstanceValidationEmail(%s)", username));

	try {
		User user = userManagementService.getUser(username);
		if (user.isDeleted()) {
			throw new NotFoundException(USER_HAS_BEEN_DELETED);
		}
		this.usersInstanceValidationWatcher.sendEmail(user);
		return Response.ok().build();
	} catch (UserNotFoundException e) {
		throw new NotFoundException(USER_DOES_NOT_EXIST);
	}
}
 
开发者ID:barnyard,项目名称:pi,代码行数:17,代码来源:UsersController.java

示例14: getAllImages

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public List<ReadOnlyImage> getAllImages(@PathParam(USERNAME) String username) {
	LOG.debug("Getting all images for user " + username);

	Set<Image> images;
	try {
		images = imageService.describeImages(username, null);
	} catch (UserNotFoundException e) {
		throw new NotFoundException();
	}

	List<ReadOnlyImage> readOnlyImages = new ArrayList<ReadOnlyImage>(images.size());

	for (Image image : images) {
		readOnlyImages.add(new ReadOnlyImage(image));
	}

	return readOnlyImages;
}
 
开发者ID:barnyard,项目名称:pi,代码行数:21,代码来源:UserImages.java

示例15: getImage

import com.sun.jersey.api.NotFoundException; //导入依赖的package包/类
@Path(SLASH_IMAGEID)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@GET
public ReadOnlyImage getImage(@PathParam(USERNAME) String username, @PathParam(IMAGEID) String imageid) {
	checkNotNullOrEmpty(username);
	// String s = IMAGEID;
	LOG.debug("Getting user " + username);

	Set<Image> images;
	try {
		images = imageService.describeImages(username, Arrays.asList(imageid));
	} catch (UserNotFoundException e) {
		throw new NotFoundException();
	}
	return new ReadOnlyImage(images.iterator().next());
}
 
开发者ID:barnyard,项目名称:pi,代码行数:17,代码来源:UserImages.java


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