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


Java Task.getIsDeleted方法代码示例

本文整理汇总了Java中org.ndexbio.model.object.Task.getIsDeleted方法的典型用法代码示例。如果您正苦于以下问题:Java Task.getIsDeleted方法的具体用法?Java Task.getIsDeleted怎么用?Java Task.getIsDeleted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ndexbio.model.object.Task的用法示例。


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

示例1: getTask

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
/**************************************************************************
   * Gets a task by ID.
   * 
   * @param taskId
   *            The task ID.
   * @throws IllegalArgumentException
   *            Bad input.
   * @throws SecurityException
   *            The user doesn't own the task.
   * @throws NdexException
   *            Failed to query the database.
    * @throws SQLException 
    * @throws IOException 
    * @throws JsonMappingException 
    * @throws JsonParseException 
   **************************************************************************/
   @GET
   @Path("/{taskId}")
   @Produces("application/json")
@ApiDoc("Return a JSON task object for the task specified by taskId. Errors if no task found or if authenticated user does not own task.")
   public Task getTask(@PathParam("taskId")final String taskIdStr) throws  UnauthorizedOperationException, NdexException, SQLException, JsonParseException, JsonMappingException, IOException
   {
   	logger.info("[start: get task {}] ", taskIdStr);
   	
   	Preconditions.checkArgument(!Strings.isNullOrEmpty(taskIdStr), "A task id is required");
   	
   	UUID taskId = UUID.fromString(taskIdStr);

   	try (TaskDAO tdao= new TaskDAO()) {
           
           final Task task = tdao.getTaskByUUID(taskId);
           
           if (task == null || task.getIsDeleted()) {
       		logger.info("[end: Task {} not found]", taskIdStr);
               throw new ObjectNotFoundException("Task", taskIdStr);
           }    
           
           else if (!task.getTaskOwnerId().equals(this.getLoggedInUser().getExternalId())) {
       		logger.info("[end: User {} is unauthorized to query task {}]", 
       				getLoggedInUser().getExternalId(), taskId);            
               throw new UnauthorizedOperationException("Can't query task " + taskId + 
               		" for user " + this.getLoggedInUser().getUserName());
           }

       	logger.info("[end: Return task {} to user] ", taskIdStr);
       	return task;
       }
   }
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:49,代码来源:TaskService.java

示例2: getTask

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
/**************************************************************************
   * Gets a task by ID.
   * 
   * @param taskId
   *            The task ID.

   **************************************************************************/
   @GET
   @Path("/{taskid}")
   @Produces("application/json")
@ApiDoc("Return a JSON task object for the task specified by taskId. Errors if no task found or if authenticated user does not own task.")
   public Task getTask(@PathParam("taskid")final String taskIdStr) throws  UnauthorizedOperationException, NdexException, SQLException, JsonParseException, JsonMappingException, IOException
   {
   	logger.info("[start: get task {}] ", taskIdStr);
   	
   	Preconditions.checkArgument(!Strings.isNullOrEmpty(taskIdStr), "A task id is required");
   	
   	UUID taskId = UUID.fromString(taskIdStr);

   	try (TaskDAO tdao= new TaskDAO()) {
           
           final Task task = tdao.getTaskByUUID(taskId);
           
           if (task == null || task.getIsDeleted()) {
       		logger.info("[end: Task {} not found]", taskIdStr);
               throw new ObjectNotFoundException("Task", taskIdStr);
           }    
           
           else if (!task.getTaskOwnerId().equals(this.getLoggedInUser().getExternalId())) {
       		logger.info("[end: User {} is unauthorized to query task {}]", 
       				getLoggedInUser().getExternalId(), taskId);            
               throw new UnauthorizedOperationException("Can't query task " + taskId + 
               		" for user " + this.getLoggedInUser().getUserName());
           }

       	logger.info("[end: Return task {} to user] ", taskIdStr);
       	return task;
       }
   }
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:40,代码来源:TaskServiceV2.java

示例3: deleteTask

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
/**************************************************************************
   * Deletes a task. 
   * 
   * @param taskId
   *            The task ID.
   * @throws IllegalArgumentException
   *            Bad input.
   * @throws ObjectNotFoundException
   *            The task doesn't exist.
   * @throws SecurityException
   *            The user doesn't own the task.
   * @throws NdexException
   *            Failed to delete the task from the database.
   **************************************************************************/
   /*
    * refactored for non-transactional database operations
    */
   @DELETE
   @Path("/{taskId}")
   @Produces("application/json")
@ApiDoc("Delete the task specified by taskId. Errors if no task found or if authenticated user does not own task.")
   public void deleteTask(@PathParam("taskId")final String taskUUID) throws IllegalArgumentException, ObjectNotFoundException, UnauthorizedOperationException, NdexException
   {
	logger.info("[start: Start deleting task {}]", taskUUID);

   	Preconditions.checkArgument(!Strings.isNullOrEmpty(taskUUID), 
   			"A task id is required");
 
   	UUID taskId = UUID.fromString(taskUUID);
   	try (TaskDAO tdao= new TaskDAO()) {
           
           final Task taskToDelete = tdao.getTaskByUUID(taskId);
           
           if (taskToDelete == null) {
       		logger.info("[end: Task {} not found. Throwing ObjectNotFoundException.]", 
       				taskUUID);
               throw new ObjectNotFoundException("Task with ID: " + taskUUID + " doesn't exist.");
           }    
           else if (!taskToDelete.getTaskOwnerId().equals(this.getLoggedInUser().getExternalId())) {
       		logger.info(
       			"[end: You cannot delete task {} because you don't own it. Throwing UnauthorizedOperationException...]", 
       			taskUUID);         		
               throw new UnauthorizedOperationException("You cannot delete a task you don't own.");
           }
           if ( taskToDelete.getIsDeleted()) {
           	logger.info("[end: Task {} is already deleted by user {}]", 
           			taskUUID,this.getLoggedInUser().getUserName());            
           } else {
           	tdao.deleteTask(taskToDelete.getExternalId());
           
           	tdao.commit();
           	logger.info("[end: Task {} is deleted by user {}]", 
           			taskUUID,this.getLoggedInUser().getUserName());
           }
       }
       catch (UnauthorizedOperationException | ObjectNotFoundException onfe)
       {
       	logger.error("[end: Failed to delete task {}. Exception caught:]{}", 
       			taskUUID , onfe);
           throw onfe;
       }
       catch (Exception e)
       {
       	logger.error("[end: Failed to delete task {}. Exception caught:]{}", 
       			taskUUID , e);
       	
       	if (e.getMessage().indexOf("cluster: null") > -1) {	
       		throw new ObjectNotFoundException("Task with ID: " + taskUUID + " doesn't exist.");
           }
        
           throw new NdexException("Failed to delete task " + taskUUID);
       }
   }
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:74,代码来源:TaskService.java

示例4: deleteTask

import org.ndexbio.model.object.Task; //导入方法依赖的package包/类
/**************************************************************************
   * Deletes a task. 
   * 
   * @param taskId
   *            The task ID.
    * @throws SQLException 
    * @throws IOException 
    * @throws JsonMappingException 
    * @throws JsonParseException 

   **************************************************************************/
   /*
    * refactored for non-transactional database operations
    */
   @DELETE
   @Path("/{taskid}")
   @Produces("application/json")
@ApiDoc("Delete the task specified by taskId. Errors if no task found or if authenticated user does not own task.")
   public void deleteTask(@PathParam("taskid")final String taskUUID) throws IllegalArgumentException, ObjectNotFoundException, UnauthorizedOperationException, NdexException, SQLException, JsonParseException, JsonMappingException, IOException
   {

   	UUID taskId = UUID.fromString(taskUUID);
   	try (TaskDAO tdao= new TaskDAO()) {
           
           final Task taskToDelete = tdao.getTaskByUUID(taskId);
           
           if (taskToDelete == null) {
               throw new ObjectNotFoundException("Task with ID: " + taskUUID + " doesn't exist.");
           }    
           else if (!taskToDelete.getTaskOwnerId().equals(this.getLoggedInUser().getExternalId())) {
               throw new UnauthorizedOperationException("You cannot delete a task you don't own.");
           }
           if ( taskToDelete.getIsDeleted()) {
           	logger.info("[end: Task {} is already deleted by user {}]", 
           			taskUUID,this.getLoggedInUser().getUserName());            
           } else {
           	tdao.deleteTask(taskToDelete.getExternalId());
           	tdao.commit();
           	
           	if (taskToDelete.getTaskType() == TaskType.EXPORT_NETWORK_TO_FILE) { //delete the exported file assume all exported files started with the taskId
           		            		
           		Files.list(Paths.get(Configuration.getInstance().getNdexRoot() + "/workspace/" +taskToDelete.getTaskOwnerId()))
           		.filter(p -> p.toString().contains("/" + taskToDelete.getExternalId().toString() + ".")).forEach((p) -> {
           		    try {
           		        Files.deleteIfExists(p);
           		    } catch (Exception e) {
           		        e.printStackTrace();
           		    }
           		});

           	}
           }
       }

   }
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:56,代码来源:TaskServiceV2.java


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