Skip to content
Browse files

Merge branch 'master' of github.com:GlobalsDB/Challenges

  • Loading branch information...
2 parents c4e0003 + 42afc2c commit 24785cb980f5eb058e1a1a572edaf644bcbeb1b6 @daimor daimor committed
View
11 2/uosipa/logspusher/src/main/java/com/uosipa/globalsdb/logspusher/Main.java
@@ -2,6 +2,7 @@
import com.uosipa.globalsdb.LogParser;
import com.uosipa.globalsdb.dao.LogDao;
+import com.uosipa.globalsdb.model.Log;
import com.uosipa.globalsdb.model.Service;
import com.uosipa.globalsdb.model.User;
import org.apache.commons.cli.*;
@@ -32,15 +33,15 @@ private static void run() throws IOException {
StringBuilder log = new StringBuilder();
String logLine;
//noinspection InfiniteLoopStatement
- //exit:
+ exit:
while (true) {
while ((logLine = reader.readLine()) == null) {
try {
Thread.sleep(50);
} catch (InterruptedException ignored) {
}
-/*
- break exit;*/
+
+ break exit;
}
if (LogParser.isNewLogStart(logLine, service)) {
@@ -59,10 +60,10 @@ private static void run() throws IOException {
}
log.append(logLine);
}
-/*
+
for (Log logg : LogDao.getInstance().findLogs(user, service, Log.Severity.FATAL)) {
System.out.println(logg.getDate() + " " + logg.getMessage());
- }*/
+ }
}
public static void parseArguments(String[] args) throws ParseException {
View
23 2/uosipa/model/src/main/java/com/uosipa/globalsdb/dao/LogDao.java
@@ -1,5 +1,6 @@
package com.uosipa.globalsdb.dao;
+import com.intersys.globals.ValueList;
import com.uosipa.globalsdb.database.Database;
import com.uosipa.globalsdb.model.Log;
import com.uosipa.globalsdb.model.Service;
@@ -30,18 +31,20 @@ private LogDao() {
);
for (String subscript : subscripts) {
- Log log = new Log();
- log.setService(service);
- log.setSeverity(severity);
- log.setDate(new Date(Long.parseLong(subscript)));
-
- log.setMessage(
- Database.getNodeValue(
- user.getLogin(), service.toString(), severity.toString(), Long.parseLong(subscript)
- )
+ ValueList logs = Database.getNodeValue(
+ user.getLogin(), service.toString(), severity.toString(), Long.parseLong(subscript)
);
- result.add(log);
+ for (int i = 0; i < logs.length(); ++i) {
+ Log log = new Log();
+ log.setService(service);
+ log.setSeverity(severity);
+ log.setDate(new Date(Long.parseLong(subscript)));
+
+ log.setMessage(logs.getNextString());
+
+ result.add(log);
+ }
}
}
View
21 2/uosipa/model/src/main/java/com/uosipa/globalsdb/database/Database.java
@@ -1,9 +1,6 @@
package com.uosipa.globalsdb.database;
-import com.intersys.globals.Connection;
-import com.intersys.globals.ConnectionContext;
-import com.intersys.globals.NodeReference;
-import com.intersys.globals.ProductInfo;
+import com.intersys.globals.*;
import java.io.IOException;
import java.util.ArrayList;
@@ -66,10 +63,20 @@ public static void addToNode(String value, Object... subscripts) {
}
}
- nodeReference.set(value);
+ //TODO proper locking
+ ValueList valueList;
+ if (nodeReference.exists()) {
+ valueList = nodeReference.getList();
+ } else {
+ valueList = connection.createList();
+ }
+
+ valueList.append(value);
+
+ nodeReference.set(valueList);
}
- public static String getNodeValue(Object... subscripts) {
+ public static ValueList getNodeValue(Object... subscripts) {
NodeReference nodeReference = connection.createNodeReference("logs");
for (Object subscript : subscripts) {
if (subscript instanceof Long) {
@@ -79,7 +86,7 @@ public static String getNodeValue(Object... subscripts) {
}
}
- return nodeReference.getString();
+ return nodeReference.getList();
}
public static List<String> getAllSubscripts(String... subscripts) {
View
24 2/yonatang/runner/pom.xml
@@ -88,6 +88,30 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.5</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <manifestEntries>
+ <Main-Class>me.yonatan.globalsdb.c2.Main</Main-Class>
+ <SplashScreen-Image>snowboarder2.png</SplashScreen-Image>
+ </manifestEntries>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
<!-- <plugin> -->
<!-- <artifactId>maven-assembly-plugin</artifactId> -->
View
64 2/yonatang/runner/src/main/java/me/yonatan/globalsdb/c2/Main.java
@@ -1,11 +1,11 @@
package me.yonatan.globalsdb.c2;
import java.awt.BorderLayout;
+import java.awt.SplashScreen;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Locale;
import javax.servlet.ServletException;
import javax.swing.JFrame;
@@ -20,6 +20,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.taglibs.standard.extra.spath.SPathFilter;
import chrriis.common.UIUtils;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
@@ -31,21 +32,22 @@
* @throws IOException
*/
public static void main(String[] args) throws IOException {
- //TODO - splash screen
- //TODO - proper cleanup on close
- //TODO manual war input, when not found
- //TODO random port hook
- //TODO proper logging
-
- Tomcat tomcat = new Tomcat();
-
- final int port=2000+(int)(Math.random()*(65500-2000));
-
- File tempWar = File.createTempFile("war", ".war");
+ // TODO - splash screen
+ // TODO manual war input, when not found
+ // TODO proper logging
+
+ final Tomcat tomcat = new Tomcat();
+
+ final int port = 2000 + (int) (Math.random() * (65500 - 2000));
+
+ final File tempWar = File.createTempFile("war", ".war");
+
+ final SplashScreen splashScreen = SplashScreen.getSplashScreen();
+
InputStream warInputStream = ClassLoader.getSystemResourceAsStream("war.war");
IOUtils.copy(warInputStream, new FileOutputStream(tempWar));
- File tempUsers = File.createTempFile("tomcat-users", ".xml");
+ final File tempUsers = File.createTempFile("tomcat-users", ".xml");
InputStream usersInputStream = ClassLoader.getSystemResourceAsStream("tomcat-users.xml");
IOUtils.copy(usersInputStream, new FileOutputStream(tempUsers));
@@ -65,51 +67,53 @@ public static void main(String[] args) throws IOException {
Host host = tomcat.getHost();
- // host.setDeployOnStartup(false);
- // host.setAutoDeploy(false);
Server server = tomcat.getServer();
AprLifecycleListener listener = new AprLifecycleListener();
server.addLifecycleListener(listener);
String contextPath = "/app";
host.setAppBase("");
try {
+
tomcat.addWebapp(contextPath, appBase);
tomcat.start();
System.out.println("Starting desktop");
UIUtils.setPreferredLookAndFeel();
+ final JFrame frame = new JFrame("Logfile viewer");
NativeInterface.open();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
- JFrame frame = new JFrame("Logfile viewer");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().add(new Window("http://localhost:"+port+"/app/viewer.jsf"), BorderLayout.CENTER);
+ frame.getContentPane().add(new Window("http://localhost:" + port + "/app/viewer.jsf"), BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
});
- NativeInterface.runEventPump();
+ Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
+ @Override
+ public void run() {
+ System.out.println("Shutting down.");
+
+ try {
+ tomcat.stop();
+ tomcat.destroy();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
- System.out.println("Shutting down");
- tomcat.stop();
- FileUtils.deleteQuietly(tempWar);
- FileUtils.deleteQuietly(tempUsers);
- // server.await();
+ FileUtils.deleteQuietly(tempWar);
+ FileUtils.deleteQuietly(tempUsers);
+ }
+ }));
+ NativeInterface.runEventPump();
} catch (LifecycleException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- // } catch (URISyntaxException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
}
- // TODO Auto-generated method stub
-
}
-
}
View
BIN 2/yonatang/runner/src/main/resources/snowboarder2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
19 2/yonatang/war/src/main/webapp/hi.xhtml
@@ -1,19 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:p="http://primefaces.org/ui">
-
-<!--
- Replace path to template, title, header and body
- with actual data.
- -->
-<h:head>
-</h:head>
-<h:body>
- <h:outputText value="Hi!" />
- <p:spinner />
-</h:body>
-
-</html>
View
5 2/yonatang/war/src/main/webapp/index.html
@@ -1,5 +0,0 @@
-<html>
- <body>
- <h1>!!Hello, World!!</h1>
- </body>
-</html>
View
15 2/yonatang/war/src/main/webapp/viewer.xhtml
@@ -17,13 +17,6 @@
</style>
</h:head>
<h:body>
- <script type="text/javascript">
- function handlePollComplete(xhr, status, args) {
- console.log("Done!",status,args);
- }
-
-
-</script>
<h:form id="menuForm">
<p:menubar>
<p:submenu label="File">
@@ -44,7 +37,7 @@
<p:tab title="#{logTable.logFile.name}" closable="true">
<p:remoteCommand name="refreshTable" update="logTable"></p:remoteCommand>
<p:poll async="true" listener="#{logTable.pollForChanges}"
- interval="10" oncomplete="handlePollComplete(xhr, status, args)"></p:poll>
+ interval="10"></p:poll>
<p:hotkey bind="right"
handler="$(logTableWidget.getPaginator().nextLink[0]).click();"></p:hotkey>
@@ -165,10 +158,8 @@
</h:panelGroup>
<h:panelGroup style="padding-top:20px;" layout="block">
<p:commandButton id="openButton" value="Open" ajax="true"
- widgetVar="openButtonWidget"
- action="#{fileImportBean.openLocal()}"
- onstart="return startLoading();"
- update="tabsForm"
+ widgetVar="openButtonWidget" action="#{fileImportBean.openLocal()}"
+ onstart="return startLoading();" update="tabsForm"
onsuccess="localFileDialog.hide();" oncomplete="stopLoading();"></p:commandButton>
<p:commandButton id="closeButton" value="Cancel"
widgetVar="closeButtonWidget" onclick="localFileDialog.hide();" />

0 comments on commit 24785cb

Please sign in to comment.
Something went wrong with that request. Please try again.