Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 61568 Details for
Bug 170540
Create servlets for uploading data to mylar.eclipse.org
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
updated patch for servlets
170540Patch.txt (text/plain), 25.94 KB, created by
meghan
on 2007-03-21 12:49:42 EDT
(
hide
)
Description:
updated patch for servlets
Filename:
MIME Type:
Creator:
meghan
Created:
2007-03-21 12:49:42 EDT
Size:
25.94 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.monitor.server >Index: .classpath >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.monitor.server/.classpath,v >retrieving revision 1.1 >diff -u -r1.1 .classpath >--- .classpath 26 Jan 2007 19:14:25 -0000 1.1 >+++ .classpath 21 Mar 2007 16:47:05 -0000 >@@ -1,6 +1,6 @@ > <?xml version="1.0" encoding="UTF-8"?> > <classpath> >- <classpathentry kind="src" path="src"/> >+ <classpathentry kind="src" path="WEB-INF/src"/> > <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"> > <accessrules> > <accessrule kind="accessible" pattern="**/TaskListImages"/> >@@ -12,5 +12,9 @@ > <accessrule kind="nonaccessible" pattern="com/sun/**"/> > </accessrules> > </classpathentry> >- <classpathentry kind="output" path="bin"/> >+ <classpathentry kind="lib" path="/org.eclipse.mylar/lib-httpclient/commons-httpclient-3.0.1.jar"/> >+ <classpathentry kind="lib" path="C:/Temp/tomcat/apache-tomcat-6.0.2/lib/servlet-api.jar"/> >+ <classpathentry kind="lib" path="WEB-INF/lib/commons-fileupload-1.1.1.jar"/> >+ <classpathentry kind="lib" path="WEB-INF/lib/commons-io-1.2.jar"/> >+ <classpathentry kind="output" path="WEB-INF/classes"/> > </classpath> >Index: lib/readme.txt >=================================================================== >RCS file: lib/readme.txt >diff -N lib/readme.txt >--- lib/readme.txt 26 Jan 2007 19:36:50 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,2 +0,0 @@ >- >-Download info for libraries. >\ No newline at end of file >Index: WEB-INF/src/upload/UsageAnalysis.java >=================================================================== >RCS file: WEB-INF/src/upload/UsageAnalysis.java >diff -N WEB-INF/src/upload/UsageAnalysis.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ WEB-INF/src/upload/UsageAnalysis.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,272 @@ >+package upload; >+ >+import java.io.File; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.PrintStream; >+import java.io.PrintWriter; >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.List; >+import java.util.Map; >+import java.util.zip.ZipEntry; >+import java.util.zip.ZipFile; >+ >+public class UsageAnalysis { >+ >+ Map<Integer, Map<String, Integer>> userToViewMap = new HashMap<Integer, Map<String, Integer>>(); >+ >+ Map<Integer, Integer> usersNumSelections = new HashMap<Integer, Integer>(); >+ >+ Map<String, Integer> totalNumSelections = new HashMap<String, Integer>(); >+ >+ final static String USAGE_DIRECTORY = MylarUsageUploadServlet.UPLOAD_DIRECTORY; >+ >+ final static String LOGGING_DIRECTORY = "home//study//logging//"; >+ >+ final static String ERROR_LOGGING_FILE = "MylarUsageAnalysisErrorLog.txt"; >+ >+ final static String USAGE_SUMMARY_FILE = "usageSummary.txt"; >+ >+ int MAX_NUM_VIEWS_TO_REPORT = 10; >+ >+ int totalSelections = 0; >+ >+ public static void main(String []args) { >+ UsageAnalysis ua = new UsageAnalysis(); >+ ua.analyzeLogs(); >+ } >+ public void analyzeLogs() { >+ >+ try { >+ String[] files = new File(USAGE_DIRECTORY).list(); >+ int userID = 0; >+ >+ for (String filename : files) { >+ File currFile = new File(USAGE_DIRECTORY, filename); >+ >+ userID = this.getUserId(currFile); >+ >+ int numSelections = 0; >+ if (usersNumSelections.containsKey(userID)) { >+ numSelections = usersNumSelections.get(userID); >+ } >+ >+ Map<String, Integer> viewToNumberMap = userToViewMap.get(userID); >+ if (viewToNumberMap == null) { >+ viewToNumberMap = new HashMap<String, Integer>(); >+ userToViewMap.put(userID, viewToNumberMap); >+ } >+ >+ int index; >+ int endIndex; >+ String currOriginId; >+ String buf = ""; >+ byte[] buffer = new byte[1000]; >+ int bytesRead = 0; >+ String beginningTag = "<originId>"; >+ String endTag = "</originId>"; >+ >+ String kindTag = "<kind>"; >+ String matchKind = "selection"; >+ >+ // they should all be zip files, ignore anything that's not >+ if (currFile.getName().endsWith(".zip")) { >+ ZipFile zip = new ZipFile(currFile); >+ >+ if (zip.entries().hasMoreElements()) { >+ ZipEntry entry = zip.entries().nextElement(); >+ InputStream stream = zip.getInputStream(entry); >+ >+ while ((bytesRead = stream.read(buffer)) != -1) { >+ buf = buf + new String(buffer, 0, bytesRead); >+ >+ while ((endIndex = buf.indexOf(endTag)) != -1) { >+ index = buf.indexOf(beginningTag); >+ index += beginningTag.length(); >+ >+ int kindIndex = buf.indexOf(kindTag); >+ kindIndex += kindTag.length(); >+ >+ if (buf.substring(kindIndex, kindIndex + matchKind.length()).equals(matchKind)) { >+ >+ numSelections++; >+ totalSelections++; >+ >+ currOriginId = buf.substring(index, endIndex); >+ >+ if (!viewToNumberMap.containsKey(currOriginId)) { >+ viewToNumberMap.put(currOriginId, 0); >+ } >+ int numViews = viewToNumberMap.get(currOriginId) + 1; >+ viewToNumberMap.put(currOriginId, numViews); >+ >+ if (!totalNumSelections.containsKey(currOriginId)) { >+ totalNumSelections.put(currOriginId, 0); >+ } >+ int totalNumViews = totalNumSelections.get(currOriginId) + 1; >+ totalNumSelections.put(currOriginId, totalNumViews); >+ >+ } >+ >+ buf = buf.substring(endIndex + endTag.length(), buf.length()); >+ >+ } >+ >+ buffer = new byte[1000]; >+ } >+ } >+ } >+ usersNumSelections.put(userID, numSelections); >+ >+ } >+ // print to a file. >+ printSummaryToFile(); >+ } catch (IOException ioe) { >+ logError(ioe.getMessage()); >+ } >+ >+ } >+ >+ private static void logError(String error) { >+ File errorLogFile = new File(LOGGING_DIRECTORY, ERROR_LOGGING_FILE); >+ try { >+ if (!errorLogFile.exists()) { >+ errorLogFile.createNewFile(); >+ } >+ >+ PrintStream errorLogStream = new PrintStream(new FileOutputStream(errorLogFile, true)); >+ >+ errorLogStream.println(error); >+ >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } >+ } >+ >+ /** >+ * Assuming the file naming convention of <phase>-<version>-usage-<userID>-<date >+ * and time>.zip >+ * >+ * copied from: org.eclipse.mylar.monitor.usage.core.ReportGenerator author: >+ * Mik Kersten >+ */ >+ private int getUserId(File source) { >+ String userIDText = source.getName(); >+ int userId = -1; >+ String prefix = "-usage-"; >+ >+ if (source.getName().indexOf(prefix) >= 0) { >+ try { >+ userIDText = userIDText.substring(userIDText.indexOf(prefix) + prefix.length(), userIDText.length()); >+ userIDText = userIDText.substring(0, userIDText.indexOf("-")); >+ userId = Integer.valueOf(userIDText); >+ } catch (Throwable t) { >+ logError(t.getMessage()); >+ } >+ } >+ >+ return userId; >+ } >+ >+ private String formatAsPercentage(float viewUse) { >+ String formattedViewUse = ("" + viewUse * 100); >+ >+ // sometimes the floats are so small that formattedViewUsage ends up >+ // being >+ // something like 7.68334E-4, which would get formatted to 7.68% without >+ // this check >+ if (formattedViewUse.contains("E")) { >+ return "0.00%"; >+ } >+ int indexOf2ndDecimal = formattedViewUse.indexOf('.') + 3; >+ if (indexOf2ndDecimal <= formattedViewUse.length()) { >+ formattedViewUse = formattedViewUse.substring(0, indexOf2ndDecimal); >+ } >+ return formattedViewUse + "%"; >+ } >+ >+ static public String getSummaryFilePath() { >+ File summaryFile = new File(USAGE_DIRECTORY, USAGE_SUMMARY_FILE); >+ if (!summaryFile.exists()) { >+ try { >+ summaryFile.createNewFile(); >+ } catch (IOException e) { >+ logError(e.getMessage()); >+ } >+ } >+ >+ return summaryFile.getAbsolutePath(); >+ } >+ >+ public void printSummaryToFile() { >+ >+ File summaryFile = new File(USAGE_DIRECTORY, USAGE_SUMMARY_FILE); >+ try { >+ if (!summaryFile.exists()) { >+ summaryFile.createNewFile(); >+ } else { >+ summaryFile.delete(); >+ summaryFile.createNewFile(); >+ } >+ >+ PrintStream summaryLogStream = new PrintStream(new FileOutputStream(summaryFile, true)); >+ >+ summaryLogStream.println("Total events: " + totalSelections); >+ summaryLogStream.println("Number of unique users: " + userToViewMap.entrySet().size()); >+ summaryLogStream.println(); >+ >+ summaryLogStream.println(MAX_NUM_VIEWS_TO_REPORT + " most used views:"); >+ >+ List<String> viewUsage = new ArrayList<String>(); >+ for (String view : totalNumSelections.keySet()) { >+ float numSelections = (float) (totalNumSelections.get(view)); >+ float viewUse = numSelections / totalSelections; >+ String formattedViewUse = formatAsPercentage(viewUse); >+ viewUsage.add(formattedViewUse + ": " + view + " (" + totalNumSelections.get(view) + ")"); >+ } >+ Collections.sort(viewUsage, new PercentUsageComparator()); >+ int numViewsToReport = 0; >+ for (String viewUsageSummary : viewUsage) { >+ if (MAX_NUM_VIEWS_TO_REPORT == -1 || numViewsToReport < MAX_NUM_VIEWS_TO_REPORT) { >+ >+ summaryLogStream.println(viewUsageSummary); >+ numViewsToReport++; >+ } >+ } >+ >+ } catch (IOException e) { >+ logError(e.getMessage()); >+ } >+ >+ } >+ >+ public void printSummary(int userId, PrintWriter out) { >+ Map<String, Integer> normalViewSelections = userToViewMap.get(userId); >+ >+ float numSelections = usersNumSelections.get(userId); >+ >+ List<String> viewUsage = new ArrayList<String>(); >+ for (String view : normalViewSelections.keySet()) { >+ float viewUse = ((float) (normalViewSelections.get(view))) / numSelections; >+ String formattedViewUse = formatAsPercentage(viewUse); >+ viewUsage.add(formattedViewUse + ": " + view + " (" + normalViewSelections.get(view) + ")" + "<br>"); >+ } >+ Collections.sort(viewUsage, new PercentUsageComparator()); >+ int numViewsToReport = 0; >+ for (String viewUsageSummary : viewUsage) { >+ if (MAX_NUM_VIEWS_TO_REPORT == -1 || numViewsToReport < MAX_NUM_VIEWS_TO_REPORT) { >+ out.println(viewUsageSummary); >+ numViewsToReport++; >+ } >+ } >+ } >+ >+ public void printReport(PrintWriter out) { >+ for (int userId : userToViewMap.keySet()) { >+ printSummary(userId, out); >+ } >+ } >+} >Index: WEB-INF/src/upload/GetUserIDServlet.java >=================================================================== >RCS file: WEB-INF/src/upload/GetUserIDServlet.java >diff -N WEB-INF/src/upload/GetUserIDServlet.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ WEB-INF/src/upload/GetUserIDServlet.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,104 @@ >+package upload; >+ >+import java.io.BufferedWriter; >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.FileOutputStream; >+import java.io.FileWriter; >+import java.io.IOException; >+import java.io.PrintStream; >+import java.io.PrintWriter; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServlet; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+/** >+ * @author - Meghan Allen >+ */ >+public class GetUserIDServlet extends HttpServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ private static final String USER_ID_PARAM = "MylarUserID"; >+ >+ private static final String USER_ID_DIRECTORY = "//home//study//userIDS//"; >+ >+ private static final String NEXT_USER_ID_FILENAME = "MylarNextUserID.txt"; >+ >+ private static final String MYLAR_USER_IDS_FILENAME = "MylarUserIDs.txt"; >+ >+ private static final String LOGGING_DIRECTORY = "//home//study//logging//"; >+ >+ private static final String ERROR_LOGGING_FILE = "MylarUsageGetUIDErrorLog.txt"; >+ >+ private static final int SIZE_OF_INT = 8; >+ >+ protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { >+ String userIDRequest = req.getParameter(USER_ID_PARAM); >+ >+ if (userIDRequest == null) { >+ res.sendError(HttpServletResponse.SC_BAD_REQUEST); >+ return; >+ } >+ >+ res.setContentType("text/plain"); >+ PrintWriter out = res.getWriter(); >+ try { >+ out.print("" + this.getNewUserID()); >+ res.setStatus(HttpServletResponse.SC_OK); >+ } catch (IOException ioe) { >+ logError("GetUserIDServlet:doPost out.print() failed " + ioe.getMessage()); >+ res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); >+ } >+ } >+ >+ private synchronized int getNewUserID() throws IOException { >+ File nextUserIDFile = new File(USER_ID_DIRECTORY, NEXT_USER_ID_FILENAME); >+ if (!nextUserIDFile.exists()) { >+ throw new IOException(USER_ID_DIRECTORY + NEXT_USER_ID_FILENAME + " does not exist"); >+ } >+ >+ FileInputStream fileInputStream = new FileInputStream(nextUserIDFile); >+ byte[] buffer = new byte[SIZE_OF_INT]; >+ int numBytesRead = fileInputStream.read(buffer); >+ int uID = new Integer(new String(buffer, 0, numBytesRead)).intValue(); >+ fileInputStream.close(); >+ >+ BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(nextUserIDFile)); >+ int nextUId = uID + 17; >+ bufferedWriter.write(new Integer(nextUId).toString()); >+ bufferedWriter.close(); >+ >+ File allUserIDFile = new File(USER_ID_DIRECTORY, MYLAR_USER_IDS_FILENAME); >+ if (!allUserIDFile.exists()) { >+ throw new IOException(USER_ID_DIRECTORY + MYLAR_USER_IDS_FILENAME + " does not exist"); >+ } >+ >+ PrintStream printStreamAllIds = new PrintStream(new FileOutputStream(allUserIDFile, true)); >+ >+ printStreamAllIds.println(new Integer(uID).toString()); >+ printStreamAllIds.flush(); >+ >+ printStreamAllIds.close(); >+ >+ return uID; >+ } >+ >+ private void logError(String errorMessage) { >+ File errorLogFile = new File(LOGGING_DIRECTORY, ERROR_LOGGING_FILE); >+ try { >+ if (!errorLogFile.exists()) { >+ errorLogFile.createNewFile(); >+ } >+ >+ PrintStream errorLogStream = new PrintStream(new FileOutputStream(errorLogFile, true)); >+ >+ errorLogStream.println(errorMessage); >+ >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } >+ } >+} >Index: .refactorings/2007/2/6/refactorings.history >=================================================================== >RCS file: .refactorings/2007/2/6/refactorings.history >diff -N .refactorings/2007/2/6/refactorings.history >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2007/2/6/refactorings.history 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+<?xml version="1.0" encoding="utf-8"?> >+<session version="1.0"> >+<refactoring comment="Move 1 elements(s) to 'WEB-INF' - Original project: 'org.eclipse.mylar.monitor.server' - Destination element: 'WEB-INF' - Original element: 'lib'" description="Move folder" element1="lib" files="0" flags="589830" folders="1" id="org.eclipse.jdt.ui.move" policy="org.eclipse.jdt.ui.moveResources" qualified="false" references="true" stamp="1170886725833" target="/org.eclipse.mylar.monitor.server/WEB-INF" units="0" version="1.0"/> >+</session> >Index: .refactorings/2007/3/12/refactorings.history >=================================================================== >RCS file: .refactorings/2007/3/12/refactorings.history >diff -N .refactorings/2007/3/12/refactorings.history >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2007/3/12/refactorings.history 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+<?xml version="1.0" encoding="utf-8"?> >+<session version="1.0"> >+<refactoring accessors="true" comment="Delete 1 element(s) from project 'org.eclipse.mylar.monitor.server' - Original project: 'org.eclipse.mylar.monitor.server' - Original element: 'bin'" description="Delete element" element1="bin" elements="0" flags="589830" id="org.eclipse.jdt.ui.delete" resources="1" stamp="1174495277568" subPackages="false" version="1.0"/> >+<refactoring accessors="true" comment="Delete 1 element(s) from project 'org.eclipse.mylar.monitor.server' - Original project: 'org.eclipse.mylar.monitor.server' - Original element: 'lib'" description="Delete element" element1="lib" elements="0" flags="589830" id="org.eclipse.jdt.ui.delete" resources="1" stamp="1174495283724" subPackages="false" version="1.0"/> >+</session> >Index: WEB-INF/src/upload/MylarUsageUploadServlet.java >=================================================================== >RCS file: WEB-INF/src/upload/MylarUsageUploadServlet.java >diff -N WEB-INF/src/upload/MylarUsageUploadServlet.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ WEB-INF/src/upload/MylarUsageUploadServlet.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+package upload; >+ >+import java.io.File; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.io.PrintStream; >+import java.text.SimpleDateFormat; >+import java.util.Date; >+import java.util.List; >+ >+import javax.servlet.http.HttpServlet; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.apache.commons.fileupload.FileItem; >+import org.apache.commons.fileupload.FileItemFactory; >+import org.apache.commons.fileupload.FileUploadException; >+import org.apache.commons.fileupload.disk.DiskFileItemFactory; >+import org.apache.commons.fileupload.servlet.ServletFileUpload; >+ >+/** >+ * @author - Meghan Allen >+ */ >+public class MylarUsageUploadServlet extends HttpServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ public static final String UPLOAD_DIRECTORY = "//home//study//uploads//"; >+ >+ private static final String LOGGING_DIRECTORY = "//home//study//logging//"; >+ >+ private static final String ERROR_LOGGING_FILE = "MylarUsageUploadErrorLog.txt"; >+ >+ // 4 digit year, 2 digit month, 2 digit day, 2 digit hour, 2 digit minute >+ // 2 digit second, 3 digit millisecond >+ private static final String DATE_FORMAT_STRING = "yyyy.MM.dd.HH.mm.ss.SSS"; >+ >+ // Supress warnings because >+ // org.apache.commons.fileupload.servlet.ServletFileUpload >+ // parseRequest doesn't use generics (suppress unchecked), and >+ // ServletFileUpload.isMultipartContent is deprecated (suppress deprecation) >+ @SuppressWarnings( { "unchecked", "deprecation" }) >+ @Override >+ protected void doPost(HttpServletRequest request, HttpServletResponse response) { >+ >+ boolean isMultipart = ServletFileUpload.isMultipartContent(request); >+ >+ try { >+ >+ if (isMultipart) { >+ >+ // Create a factory for disk-based file items >+ FileItemFactory factory = new DiskFileItemFactory(); >+ >+ // Create a new file upload handler >+ ServletFileUpload upload = new ServletFileUpload(factory); >+ >+ // Parse the request >+ List<FileItem> items = upload.parseRequest(request); >+ >+ for (FileItem fi : items) { >+ >+ String oldFilename = fi.getName(); >+ >+ int indexFirstDot = oldFilename.indexOf("."); >+ >+ String uid = oldFilename.substring(0, indexFirstDot); >+ String extension = oldFilename.substring(oldFilename.length() - 4, oldFilename.length()); >+ >+ String name = "USAGE-1.0-usage-" + uid + "-" >+ + new SimpleDateFormat(DATE_FORMAT_STRING).format(new Date()) + extension; >+ >+ File destFile = new File(UPLOAD_DIRECTORY, name); >+ destFile.createNewFile(); >+ >+ try { >+ fi.write(destFile); >+ } catch (Exception e) { >+ logError("MylarUsageUploadServlet:doPost fi.write() failed " + e.getMessage()); >+ >+ } >+ >+ } >+ >+ } >+ } catch (FileUploadException fue) { >+ logError("MylarUsageUploadServlet:doPost upload.parseRequest(request) failed " + fue.getMessage()); >+ >+ } catch (IOException ioe) { >+ logError("MylarUsageUploadServlet:doPost destFile.createNewFile() failed " + ioe.getMessage()); >+ } >+ } >+ >+ private void logError(String errorMessage) { >+ File errorLogFile = new File(LOGGING_DIRECTORY, ERROR_LOGGING_FILE); >+ try { >+ if (!errorLogFile.exists()) { >+ errorLogFile.createNewFile(); >+ } >+ >+ PrintStream errorLogStream = new PrintStream(new FileOutputStream(errorLogFile, true)); >+ >+ errorLogStream.println(errorMessage); >+ >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } >+ } >+} >Index: WEB-INF/web.xml >=================================================================== >RCS file: WEB-INF/web.xml >diff -N WEB-INF/web.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ WEB-INF/web.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,43 @@ >+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" >+"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> >+ >+<web-app> >+ >+<servlet> >+<servlet-name>MylarUsageUploadServlet</servlet-name> >+<display-name>MylarUsageUploadServlet</display-name> >+<servlet-class>upload.MylarUsageUploadServlet</servlet-class> >+</servlet> >+ >+<servlet-mapping> >+<servlet-name>MylarUsageUploadServlet</servlet-name> >+<url-pattern>/MylarUsageUploadServlet</url-pattern> >+</servlet-mapping> >+ >+ >+<servlet> >+<servlet-name>GetUserIDServlet</servlet-name> >+<display-name>GetUserIDServlet</display-name> >+<servlet-class>upload.GetUserIDServlet</servlet-class> >+</servlet> >+ >+<servlet-mapping> >+<servlet-name>GetUserIDServlet</servlet-name> >+<url-pattern>/GetUserIDServlet</url-pattern> >+</servlet-mapping> >+ >+ >+ >+<servlet> >+<servlet-name>UsageAnalysisServlet</servlet-name> >+<display-name>UsageAnalysisServlet</display-name> >+<servlet-class>upload.UsageAnalysisServlet</servlet-class> >+</servlet> >+ >+<servlet-mapping> >+<servlet-name>UsageAnalysisServlet</servlet-name> >+<url-pattern>/UsageAnalysisServlet</url-pattern> >+</servlet-mapping> >+ >+ >+</web-app> >Index: .refactorings/2007/2/6/refactorings.index >=================================================================== >RCS file: .refactorings/2007/2/6/refactorings.index >diff -N .refactorings/2007/2/6/refactorings.index >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2007/2/6/refactorings.index 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1 @@ >+1170886725833 Move folder >Index: WEB-INF/lib/readme.txt >=================================================================== >RCS file: WEB-INF/lib/readme.txt >diff -N WEB-INF/lib/readme.txt >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ WEB-INF/lib/readme.txt 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+This plugin depends on two Apache libraries that must be downloaded independently of Mylar. >+ >+ >+commons-fileupload-1.1.1.jar can be downloaded from here: >+http://jakarta.apache.org/site/downloads/downloads_commons-fileupload.cgi >+ >+commons-io-1.2.jar can be downloaded from here: >+http://archive.apache.org/dist/jakarta/commons/io/binaries/ >Index: .refactorings/2007/3/12/refactorings.index >=================================================================== >RCS file: .refactorings/2007/3/12/refactorings.index >diff -N .refactorings/2007/3/12/refactorings.index >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2007/3/12/refactorings.index 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,2 @@ >+1174495277568 Delete element >+1174495283724 Delete element >Index: WEB-INF/lib/.cvsignore >=================================================================== >RCS file: WEB-INF/lib/.cvsignore >diff -N WEB-INF/lib/.cvsignore >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ WEB-INF/lib/.cvsignore 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,2 @@ >+commons-io-1.2.jar >+commons-fileupload-1.1.1.jar >Index: WEB-INF/src/upload/UsageAnalysisServlet.java >=================================================================== >RCS file: WEB-INF/src/upload/UsageAnalysisServlet.java >diff -N WEB-INF/src/upload/UsageAnalysisServlet.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ WEB-INF/src/upload/UsageAnalysisServlet.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+package upload; >+ >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.IOException; >+import java.io.PrintWriter; >+ >+import javax.servlet.ServletException; >+import javax.servlet.http.HttpServlet; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+public class UsageAnalysisServlet extends HttpServlet { >+ >+ private static final long serialVersionUID = 1L; >+ >+ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { >+ PrintWriter out = res.getWriter(); >+ >+// run the analysis as a cron job >+// UsageAnalysis usageAnalysis = new UsageAnalysis(); >+// usageAnalysis.analyzeLogs(); >+ >+ String filePath = UsageAnalysis.getSummaryFilePath(); >+ >+ File summaryFile = new File(filePath); >+ >+ FileInputStream inputStream = new FileInputStream(summaryFile); >+ >+ int bytesRead = 0; >+ byte[] buffer = new byte[1000]; >+ >+ while ((bytesRead = inputStream.read(buffer)) != -1) { >+ out.print(new String(buffer, 0, bytesRead)); >+ >+ } >+ >+ } >+ >+} >Index: WEB-INF/src/upload/PercentUsageComparator.java >=================================================================== >RCS file: WEB-INF/src/upload/PercentUsageComparator.java >diff -N WEB-INF/src/upload/PercentUsageComparator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ WEB-INF/src/upload/PercentUsageComparator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package upload; >+ >+import java.util.Comparator; >+ >+/** >+ * This class was copied from >+ * org.eclipse.mylar.internal.monitor.core.collection. >+ * >+ * >+ * @author Mik Kersten and Leah Findlater >+ */ >+class PercentUsageComparator implements Comparator<String> { >+ public int compare(String o1, String o2) { >+ int index1 = o1.indexOf('%'); >+ int index2 = o2.indexOf('%'); >+ if (index1 != -1 && index2 != -1) { >+ String s1 = o1.substring(0, index1); >+ String s2 = o2.substring(0, index2); >+ return (-1) * new Float(s1).compareTo(new Float(s2)); >+ } else { >+ return 0; >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 170540
:
57158
|
58678
|
58679
| 61568 |
61754