// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/StarterUtil.java
// public class StarterUtil {
// 
// 	private static final Logger log = Logger.getLogger(StarterUtil.class.getName());
// 
// 	private static String serverOutputDir;
// 
// 	public static final String WORKAREA = "workarea";
// 	public static final String APP_ACCELERATOR_WORKAREA = "appAccelerator";
// 	public static final String PACKAGE_DIR = "package";
// 
// 	private static String processPath(String string) {
// 		if(string == null){
// 			return "";
// 		}
// 		return string.replace('\\', '/');
// 	}
// 
// 	private static String getServerOutputDir() {
// 		if(serverOutputDir == null){
// 			try{
// 				serverOutputDir = processPath(((String)(new InitialContext().lookup("serverOutputDir"))));
// 				if(!serverOutputDir.endsWith("/")){
// 					serverOutputDir += "/";
// 				}
// 				log.info("serverOutputDir=" + serverOutputDir);
// 			}catch (NamingException ne){
// 				log.severe("NamingException occurred while retrieving the value of 'serverOutputDir': " + ne);
// 				throw new ValidationException("NamingException occurred while retrieving the value of 'serverOutputDir': " + ne);
// 			}
// 		}
// 		return serverOutputDir;
// 	}
// 
// 	public static String getWorkspaceDir(String workspaceId){
// 		return getServerOutputDir() + WORKAREA + "/" + APP_ACCELERATOR_WORKAREA + "/" + workspaceId;
// 	}
// 
// 	/**
// 	 * Generate the list of files in the directory and all of its sub-directories (recursive)
// 	 * 
// 	 * @param dir - The directory
// 	 * @param filesListInDir - List to store the files
// 	 */
// 	public static void populateFilesList(File dir, List<File> filesListInDir) {
// 		File[] files = dir.listFiles();
// 		for(File file : files){
// 			if(file.isFile()){
// 				filesListInDir.add(file);
// 			}else{
// 				populateFilesList(file, filesListInDir);
// 			}
// 		}
// 	}
// 
// 	public static String createCleanWorkspace() throws IOException {
// 		String uuid = UUID.randomUUID().toString();
// 
// 		//Clean up workspace directory if it already exists (from previous server run)
// 		String workspaceDirPath = StarterUtil.getWorkspaceDir(uuid);
// 		File workspaceDir = new File(workspaceDirPath);
// 		if(workspaceDir.exists()){
// 			log.log(Level.FINE, "Workspace directory already exists : " + workspaceDirPath);
// 			FileUtils.deleteDirectory(workspaceDir);
// 			log.log(Level.FINE, "Deleted workspace directory : " + workspaceDirPath);
// 		}
// 		return uuid;
// 	}
// 	
// }


import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.StreamingOutput;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.NameFileFilter;
import com.ibm.liberty.starter.StarterUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
/*******************************************************************************
 * Copyright (c) 2016,2017 IBM Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package com.ibm.liberty.starter.api.v1;






@Path("v1/workspace")
@Api(value = "Workspace Identifier")
public class WorkspaceEndpoint {
    
    private static final Logger log = Logger.getLogger(WorkspaceEndpoint.class.getName());
    
    @GET
    @Path("/")
// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/StarterUtil.java
// public class StarterUtil {
// 
// 	private static final Logger log = Logger.getLogger(StarterUtil.class.getName());
// 
// 	private static String serverOutputDir;
// 
// 	public static final String WORKAREA = "workarea";
// 	public static final String APP_ACCELERATOR_WORKAREA = "appAccelerator";
// 	public static final String PACKAGE_DIR = "package";
// 
// 	private static String processPath(String string) {
// 		if(string == null){
// 			return "";
// 		}
// 		return string.replace('\\', '/');
// 	}
// 
// 	private static String getServerOutputDir() {
// 		if(serverOutputDir == null){
// 			try{
// 				serverOutputDir = processPath(((String)(new InitialContext().lookup("serverOutputDir"))));
// 				if(!serverOutputDir.endsWith("/")){
// 					serverOutputDir += "/";
// 				}
// 				log.info("serverOutputDir=" + serverOutputDir);
// 			}catch (NamingException ne){
// 				log.severe("NamingException occurred while retrieving the value of 'serverOutputDir': " + ne);
// 				throw new ValidationException("NamingException occurred while retrieving the value of 'serverOutputDir': " + ne);
// 			}
// 		}
// 		return serverOutputDir;
// 	}
// 
// 	public static String getWorkspaceDir(String workspaceId){
// 		return getServerOutputDir() + WORKAREA + "/" + APP_ACCELERATOR_WORKAREA + "/" + workspaceId;
// 	}
// 
// 	/**
// 	 * Generate the list of files in the directory and all of its sub-directories (recursive)
// 	 * 
// 	 * @param dir - The directory
// 	 * @param filesListInDir - List to store the files
// 	 */
// 	public static void populateFilesList(File dir, List<File> filesListInDir) {
// 		File[] files = dir.listFiles();
// 		for(File file : files){
// 			if(file.isFile()){
// 				filesListInDir.add(file);
// 			}else{
// 				populateFilesList(file, filesListInDir);
// 			}
// 		}
// 	}
// 
// 	public static String createCleanWorkspace() throws IOException {
// 		String uuid = UUID.randomUUID().toString();
// 
// 		//Clean up workspace directory if it already exists (from previous server run)
// 		String workspaceDirPath = StarterUtil.getWorkspaceDir(uuid);
// 		File workspaceDir = new File(workspaceDirPath);
// 		if(workspaceDir.exists()){
// 			log.log(Level.FINE, "Workspace directory already exists : " + workspaceDirPath);
// 			FileUtils.deleteDirectory(workspaceDir);
// 			log.log(Level.FINE, "Deleted workspace directory : " + workspaceDirPath);
// 		}
// 		return uuid;
// 	}
// 	
// }


// Path: liberty-starter-application/src/main/java/com/ibm/liberty/starter/api/v1/WorkspaceEndpoint.java
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.StreamingOutput;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.NameFileFilter;
import com.ibm.liberty.starter.StarterUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

/*******************************************************************************
 * Copyright (c) 2016,2017 IBM Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package com.ibm.liberty.starter.api.v1;






@Path("v1/workspace")
@Api(value = "Workspace Identifier")
public class WorkspaceEndpoint {
    
    private static final Logger log = Logger.getLogger(WorkspaceEndpoint.class.getName());
    
    @GET
    @Path("/")
    @Produces(MediaType.TEXT_PLAIN)