// Path: src/main/java/org/cytoscape/rest/internal/task/HeadlessTaskMonitor.java
// public class HeadlessTaskMonitor implements TaskMonitor {
// 	
// 	private static final Logger logger = LoggerFactory.getLogger(HeadlessTaskMonitor.class);
// 
// 	private String taskName = "";
// 
// 	public void setTask(final Task task) {
// 		this.taskName = "Task (" + task.toString() + ")";
// 	}
// 
// 	
// 	@Override
// 	public void setTitle(final String title) {
// 		logger.info(taskName + " title: " + title);
// 	}
// 
// 	
// 	@Override
// 	public void setStatusMessage(final String statusMessage) {
// 		logger.info(taskName + " status: " + statusMessage);
// 	}
// 
// 	
// 	@Override
// 	public void setProgress(final double progress) {
// 	}
// 
// 
// 	@Override
// 	public void showMessage(Level level, String message) {
// 	}
// }


import java.io.File;
import javax.inject.Singleton;
import javax.validation.constraints.NotNull;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.cytoscape.rest.internal.task.HeadlessTaskMonitor;
import org.cytoscape.session.CySessionManager;
import org.cytoscape.task.create.NewSessionTaskFactory;
import org.cytoscape.task.read.OpenSessionTaskFactory;
import org.cytoscape.task.write.SaveSessionAsTaskFactory;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskIterator;
	 */
	@GET
	@Path("/name")
	@Produces(MediaType.APPLICATION_JSON)
	public String getSessionName() {
		String sessionName = sessionManager.getCurrentSessionFileName();
		if(sessionName == null || sessionName.isEmpty()) {
			sessionName = "";
		}
		
		return "{\"name\": \"" + sessionName +"\"}";
	}
	
	
	/**
	 * 
	 * @summary Delete current session and start new one
	 * 
	 * @return Success message
	 * 
	 */
	@DELETE
	@Path("/")
	@Produces(MediaType.APPLICATION_JSON)
	public String deleteSession() {
		
		try {
			TaskIterator itr = newSessionTaskFactory.createTaskIterator(true);
			while(itr.hasNext()) {
				final Task task = itr.next();
// Path: src/main/java/org/cytoscape/rest/internal/task/HeadlessTaskMonitor.java
// public class HeadlessTaskMonitor implements TaskMonitor {
// 	
// 	private static final Logger logger = LoggerFactory.getLogger(HeadlessTaskMonitor.class);
// 
// 	private String taskName = "";
// 
// 	public void setTask(final Task task) {
// 		this.taskName = "Task (" + task.toString() + ")";
// 	}
// 
// 	
// 	@Override
// 	public void setTitle(final String title) {
// 		logger.info(taskName + " title: " + title);
// 	}
// 
// 	
// 	@Override
// 	public void setStatusMessage(final String statusMessage) {
// 		logger.info(taskName + " status: " + statusMessage);
// 	}
// 
// 	
// 	@Override
// 	public void setProgress(final double progress) {
// 	}
// 
// 
// 	@Override
// 	public void showMessage(Level level, String message) {
// 	}
// }


// Path: src/main/java/org/cytoscape/rest/internal/resource/SessionResource.java
import java.io.File;
import javax.inject.Singleton;
import javax.validation.constraints.NotNull;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.cytoscape.rest.internal.task.HeadlessTaskMonitor;
import org.cytoscape.session.CySessionManager;
import org.cytoscape.task.create.NewSessionTaskFactory;
import org.cytoscape.task.read.OpenSessionTaskFactory;
import org.cytoscape.task.write.SaveSessionAsTaskFactory;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskIterator;

	 */
	@GET
	@Path("/name")
	@Produces(MediaType.APPLICATION_JSON)
	public String getSessionName() {
		String sessionName = sessionManager.getCurrentSessionFileName();
		if(sessionName == null || sessionName.isEmpty()) {
			sessionName = "";
		}
		
		return "{\"name\": \"" + sessionName +"\"}";
	}
	
	
	/**
	 * 
	 * @summary Delete current session and start new one
	 * 
	 * @return Success message
	 * 
	 */
	@DELETE
	@Path("/")
	@Produces(MediaType.APPLICATION_JSON)
	public String deleteSession() {
		
		try {
			TaskIterator itr = newSessionTaskFactory.createTaskIterator(true);
			while(itr.hasNext()) {
				final Task task = itr.next();
				task.run(new HeadlessTaskMonitor());