|
|
|
|
@ -2,13 +2,17 @@ package shst.medicina.fichasclinicas.webservices.jaxrs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.ws.rs.Consumes;
|
|
|
|
|
@ -1303,6 +1307,72 @@ public class FichasClinicasImpl {
|
|
|
|
|
return Response.status(200).entity(rsp).build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getViews")
|
|
|
|
|
@Produces(MediaType.TEXT_HTML)
|
|
|
|
|
public Response getViews(@Context HttpServletRequest req) {
|
|
|
|
|
|
|
|
|
|
String html = "";
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DirectoryFileUtils dff = new DirectoryFileUtils();
|
|
|
|
|
|
|
|
|
|
//TODO: check the alternative to getRealPath
|
|
|
|
|
String basePath = req.getRealPath("/static/html/app");
|
|
|
|
|
|
|
|
|
|
File baseFolder = new File(basePath);
|
|
|
|
|
|
|
|
|
|
List<String> foundFiles = dff.getFilesContents(baseFolder, ".html");
|
|
|
|
|
|
|
|
|
|
for(int i=0; i < foundFiles.toArray().length; i++){
|
|
|
|
|
|
|
|
|
|
html += foundFiles.get(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Response.status(200).entity(html).build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO: place this class elsewhere
|
|
|
|
|
public class DirectoryFileUtils {
|
|
|
|
|
private List<String> fileContents = new ArrayList<String>();
|
|
|
|
|
|
|
|
|
|
private String content;
|
|
|
|
|
private Scanner scanner;
|
|
|
|
|
|
|
|
|
|
public List<String> getFilesContents(File file, String extension) throws FileNotFoundException {
|
|
|
|
|
|
|
|
|
|
if (file.isFile() && file.getName().endsWith(extension)) {
|
|
|
|
|
|
|
|
|
|
scanner = new Scanner(new File(file.getAbsoluteFile().toString()));
|
|
|
|
|
content = scanner.useDelimiter("\\Z").next();
|
|
|
|
|
fileContents.add(content);
|
|
|
|
|
|
|
|
|
|
} else if (file.isDirectory()) {
|
|
|
|
|
|
|
|
|
|
File[] listOfFiles = file.listFiles();
|
|
|
|
|
if (listOfFiles != null) {
|
|
|
|
|
for (int i = 0; i < listOfFiles.length; i++){
|
|
|
|
|
getFilesContents(listOfFiles[i], extension);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("[ACCESS DENIED]");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return fileContents;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|