[P2play-commit] SF.net SVN: p2play: [44] trunk/P2PlayAdmin/src
Status: Pre-Alpha
Brought to you by:
tisoft
|
From: <ti...@us...> - 2007-03-20 12:07:00
|
Revision: 44
http://p2play.svn.sourceforge.net/p2play/?rev=44&view=rev
Author: tisoft
Date: 2007-03-20 05:07:00 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Initial import.
Added Paths:
-----------
trunk/P2PlayAdmin/src/main/
trunk/P2PlayAdmin/src/main/java/
trunk/P2PlayAdmin/src/main/java/org/
trunk/P2PlayAdmin/src/main/java/org/p2play/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/service/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/service/ServiceFactory.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/VFS.gwt.xml
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileInfo.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileTreeItem.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFS.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSService.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSServiceAsync.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/VFS.html
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/css/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/css/style.css
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/server/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/server/VFSServiceImpl.java
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/service/ServiceFactory.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/service/ServiceFactory.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/service/ServiceFactory.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.web.service;
+
+import java.net.MalformedURLException;
+
+import javax.jws.WebService;
+
+import org.codehaus.xfire.client.XFireProxyFactory;
+import org.codehaus.xfire.service.Service;
+import org.codehaus.xfire.service.binding.ObjectServiceFactory;
+
+public class ServiceFactory {
+ private String baseURL;
+
+ private ObjectServiceFactory serviceFactory = new ObjectServiceFactory();
+
+ public ServiceFactory(String baseURL) {
+ super();
+ this.baseURL = baseURL;
+ if (!this.baseURL.endsWith("/"))
+ this.baseURL += "/";
+ }
+
+ @SuppressWarnings("unchecked")
+ public <A> A getServiceInstance(Class<A> clazz) throws MalformedURLException {
+ Service serviceModel = serviceFactory.create(clazz);
+
+ String serviceName = clazz
+ .getAnnotation(WebService.class).serviceName();
+
+ return (A)new XFireProxyFactory().create(serviceModel, baseURL
+ + serviceName);
+ }
+
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/VFS.gwt.xml
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/VFS.gwt.xml (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/VFS.gwt.xml 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?><module>
+
+ <!-- Inherit the core Web Toolkit stuff. -->
+ <inherits name="com.google.gwt.user.User"/>
+
+ <!-- Specify the app entry point class. -->
+ <entry-point class="org.p2play.web.vfs.client.VFS"/>
+
+<servlet class="org.p2play.web.vfs.server.VFSServiceImpl" path="/VFSService"/></module>
\ No newline at end of file
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileInfo.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileInfo.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileInfo.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.web.vfs.client;
+
+import com.google.gwt.user.client.rpc.IsSerializable;
+
+public class FileInfo implements IsSerializable {
+ private FileInfo parent;
+
+ private String name;
+
+ public FileInfo() {
+ // needed for serialisation
+ }
+
+ public FileInfo(FileInfo parent, String name) {
+ super();
+ this.parent = parent;
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public FileInfo getParent() {
+ return parent;
+ }
+
+ public String getFullName() {
+ String full = "";
+ if (getParent() != null)
+ full += parent.getFullName();
+
+ full += "/" + getName();
+ return full;
+ }
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileTreeItem.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileTreeItem.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileTreeItem.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.web.vfs.client;
+
+import com.google.gwt.user.client.ui.TreeItem;
+
+public class FileTreeItem extends TreeItem {
+
+ public FileTreeItem(FileInfo fileInfo) {
+ super(fileInfo.getName());
+ setUserObject(fileInfo);
+ }
+
+ public FileInfo getFileInfo() {
+ return (FileInfo) getUserObject();
+ }
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFS.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFS.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFS.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.web.vfs.client;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.DialogBox;
+import com.google.gwt.user.client.ui.PasswordTextBox;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Tree;
+import com.google.gwt.user.client.ui.TreeItem;
+import com.google.gwt.user.client.ui.TreeListener;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * @author markus
+ *
+ */
+public class VFS implements EntryPoint {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
+ */
+ public void onModuleLoad() {
+ final Tree tree = new Tree();
+ final TreeItem root = new FileTreeItem(new FileInfo(null, "/"));
+
+ tree.addItem(root);
+
+ updateChildren(root);
+
+ tree.addTreeListener(new TreeListener() {
+ public void onTreeItemSelected(TreeItem arg0) {
+ // do nothing
+ }
+
+ public void onTreeItemStateChanged(TreeItem arg0) {
+ if (arg0.getState()) {
+ for (int i = 0; i < arg0.getChildCount(); i++) {
+ updateChildren(arg0.getChild(i));
+ }
+ }
+
+ }
+ });
+
+ RootPanel.get().add(tree);
+
+ final TextBox createDirectoryBox = new TextBox();
+ Button createDirectoryButton = new Button("Verzeichnis erstellen");
+ createDirectoryButton.addClickListener(new ClickListener() {
+ public void onClick(Widget arg0) {
+ final TreeItem selectedItem = tree.getSelectedItem();
+ VFSService.Util.getInstance().addFolder(
+ new FileInfo((FileInfo) selectedItem.getUserObject(),
+ createDirectoryBox.getText()),
+ new AsyncCallback() {
+ public void onFailure(Throwable arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onSuccess(Object arg0) {
+ if (createDirectoryBox.getText()
+ .startsWith("/"))
+ updateChildren(root);
+ else
+ updateChildren(selectedItem);
+ }
+ });
+ }
+ });
+
+ RootPanel.get().add(createDirectoryBox);
+ RootPanel.get().add(createDirectoryButton);
+
+ createLoginDialog().show();
+
+ }
+
+ private void updateChildren(final TreeItem item) {
+ VFSService.Util.getInstance().getChildren(
+ (FileInfo) item.getUserObject(), new AsyncCallback() {
+ public void onFailure(Throwable arg0) {
+ arg0.printStackTrace();
+
+ }
+
+ public void onSuccess(Object arg0) {
+ item.removeItems();
+ FileInfo[] children = (FileInfo[]) arg0;
+ for (int i = 0; i < children.length; i++) {
+ item.addItem(new FileTreeItem(children[i]));
+ }
+ }
+ });
+ }
+
+ private DialogBox createLoginDialog() {
+ final DialogBox dialogBox = new DialogBox();
+ dialogBox.setTitle("Login");
+ final TextBox userTextBox = new TextBox();
+ final PasswordTextBox passwordTextBox = new PasswordTextBox();
+ Button loginButton = new Button("Login");
+ loginButton.addClickListener(new ClickListener() {
+ public void onClick(Widget arg0) {
+ VFSService.Util.getInstance().login(userTextBox.getText(),
+ passwordTextBox.getText().toCharArray(),
+ new AsyncCallback() {
+ public void onFailure(Throwable arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onSuccess(Object arg0) {
+ if (Boolean.TRUE.equals(arg0))
+ dialogBox.hide();
+ else
+ System.out.println("Login incorrect");
+ }
+ });
+
+ }
+ });
+
+ VerticalPanel flowPanel = new VerticalPanel();
+
+ flowPanel.add(userTextBox);
+ flowPanel.add(passwordTextBox);
+ flowPanel.add(loginButton);
+
+ dialogBox.setWidget(flowPanel);
+
+ return dialogBox;
+ }
+
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSService.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSService.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSService.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.p2play.web.vfs.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.ServiceDefTarget;
+
+/**
+ * @author markus
+ *
+ */
+public interface VFSService extends RemoteService {
+
+ public static final String SERVICE_URI = "/VFSService";
+
+ public static class Util {
+
+ public static VFSServiceAsync getInstance() {
+
+ VFSServiceAsync instance = (VFSServiceAsync) GWT
+ .create(VFSService.class);
+ ServiceDefTarget target = (ServiceDefTarget) instance;
+ target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
+ return instance;
+ }
+ }
+
+ FileInfo[] getChildren(FileInfo parent);
+
+ void addFolder(FileInfo newFolder);
+
+ boolean login(String user, char[] password);
+
+ void logout();
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSServiceAsync.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSServiceAsync.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSServiceAsync.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.p2play.web.vfs.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.ServiceDefTarget;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+/**
+ * @author markus
+ *
+ */
+public interface VFSServiceAsync {
+
+ void getChildren(FileInfo parent, AsyncCallback callback);
+
+ void addFolder(FileInfo newFolder, AsyncCallback callback);
+
+ void login(String user, char[] password, AsyncCallback callback);
+
+ void logout(AsyncCallback callback);
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/VFS.html
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/VFS.html (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/VFS.html 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,48 @@
+<html>
+ <head>
+
+ <!-- -->
+ <!-- Any title is fine -->
+ <!-- -->
+ <title>Wrapper HTML for VFS</title>
+
+ <!-- -->
+ <!-- Use normal html, such as style -->
+ <!-- -->
+ <style>
+ body,td,a,div,.p{font-family:arial,sans-serif}
+ div,td{color:#000000}
+ a:link,.w,.w a:link{color:#0000cc}
+ a:visited{color:#551a8b}
+ a:active{color:#ff0000}
+ </style>
+
+ <link rel="stylesheet" href="css/style.css">
+
+ <!-- -->
+ <!-- The module reference below is the link -->
+ <!-- between html and your Web Toolkit module -->
+ <!-- -->
+ <meta name='gwt:module' content='org.p2play.web.vfs.VFS'>
+
+ </head>
+
+ <!-- -->
+ <!-- The body can have arbitrary html, or -->
+ <!-- you can leave the body empty if you want -->
+ <!-- to create a completely dynamic ui -->
+ <!-- -->
+ <body>
+
+ <!-- -->
+ <!-- This script is required bootstrap stuff. -->
+ <!-- You can put it in the HEAD, but startup -->
+ <!-- is slightly faster if you include it here. -->
+ <!-- -->
+ <script language="javascript" src="gwt.js"></script>
+
+ <!-- OPTIONAL: include this if you want history support -->
+ <iframe id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
+
+ </body>
+</html>
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/css/style.css
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/css/style.css (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/css/style.css 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,173 @@
+body {
+ background-color: white;
+ color: black;
+ font-family: Arial, sans-serif;
+ font-size: smaller;
+ margin: 20px 20px 20px 20px;
+}
+
+code {
+ font-size: small;
+}
+
+a {
+ color: darkblue;
+}
+
+a:visited {
+ color: darkblue;
+}
+
+.gwt-BorderedPanel {
+}
+
+.gwt-Button {
+}
+
+.gwt-Canvas {
+}
+
+.gwt-CheckBox {
+ font-size: smaller;
+}
+
+.gwt-DialogBox {
+ sborder: 8px solid #C3D9FF;
+ border: 2px outset;
+ background-color: white;
+}
+
+.gwt-DialogBox .Caption {
+ background-color: #C3D9FF;
+ padding: 3px;
+ margin: 2px;
+ font-weight: bold;
+ cursor: default;
+}
+
+.gwt-FileUpload {
+}
+
+.gwt-Frame {
+}
+
+.gwt-HorizontalSplitter .Bar {
+ width: 8px;
+ background-color: #C3D9FF;
+}
+
+.gwt-VerticalSplitter .Bar {
+ height: 8px;
+ background-color: #C3D9FF;
+}
+
+.gwt-HTML {
+ font-size: smaller;
+}
+
+.gwt-Hyperlink {
+}
+
+.gwt-Image {
+}
+
+.gwt-Label {
+ font-size: smaller;
+}
+
+.gwt-ListBox {
+}
+
+.gwt-MenuBar {
+ background-color: #C3D9FF;
+ border: 1px solid #87B3FF;
+ cursor: default;
+}
+
+.gwt-MenuBar .gwt-MenuItem {
+ padding: 1px 4px 1px 4px;
+ font-size: smaller;
+ cursor: default;
+}
+
+.gwt-MenuBar .gwt-MenuItem-selected {
+ background-color: #E8EEF7;
+}
+
+.gwt-PasswordTextBox {
+}
+
+.gwt-RadioButton {
+ font-size: smaller;
+}
+
+.gwt-TabPanel {
+}
+
+.gwt-TabPanelBottom {
+ border-left: 1px solid #87B3FF;
+}
+
+.gwt-TabBar {
+ background-color: #C3D9FF;
+ font-size: smaller;
+}
+
+.gwt-TabBar .gwt-TabBarFirst {
+ height: 100%;
+ border-bottom: 1px solid #87B3FF;
+ padding-left: 3px;
+}
+
+.gwt-TabBar .gwt-TabBarRest {
+ border-bottom: 1px solid #87B3FF;
+ padding-right: 3px;
+}
+
+.gwt-TabBar .gwt-TabBarItem {
+ border-top: 1px solid #C3D9FF;
+ border-bottom: 1px solid #87B3FF;
+ padding: 2px;
+ cursor: pointer;
+ cursor: hand;
+}
+
+.gwt-TabBar .gwt-TabBarItem-selected {
+ font-weight: bold;
+ background-color: #E8EEF7;
+ border-top: 1px solid #87B3FF;
+ border-left: 1px solid #87B3FF;
+ border-right: 1px solid #87B3FF;
+ border-bottom: 1px solid #E8EEF7;
+ padding: 2px;
+ cursor: default;
+}
+
+.gwt-TextArea {
+}
+
+.gwt-TextBox {
+}
+
+.gwt-Tree {
+}
+
+.gwt-Tree .gwt-TreeItem {
+ font-size: smaller;
+}
+
+.gwt-Tree .gwt-TreeItem-selected {
+ background-color: #C3D9FF;
+}
+
+.gwt-StackPanel {
+}
+
+.gwt-StackPanel .gwt-StackPanelItem {
+ background-color: #C3D9FF;
+ cursor: pointer;
+ cursor: hand;
+}
+
+.gwt-StackPanel .gwt-StackPanelItem-selected {
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/server/VFSServiceImpl.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/server/VFSServiceImpl.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/server/VFSServiceImpl.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */package org.p2play.web.vfs.server;
+
+import javax.servlet.http.HttpSession;
+
+import org.p2play.service.AuthenticationService;
+import org.p2play.service.P2PlayVfsService;
+import org.p2play.service.object.AuthenticationToken;
+import org.p2play.web.service.ServiceFactory;
+import org.p2play.web.vfs.client.FileInfo;
+import org.p2play.web.vfs.client.VFSService;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+public class VFSServiceImpl extends RemoteServiceServlet implements VFSService {
+ private static final ServiceFactory serviceFactory = new ServiceFactory(
+ "http://localhost:8081/");
+
+ public FileInfo[] getChildren(FileInfo parent) {
+ HttpSession session = getThreadLocalRequest().getSession();
+
+ if (session != null)
+ System.out.println(session.getAttribute("use"));
+
+ try {
+ P2PlayVfsService service = serviceFactory
+ .getServiceInstance(P2PlayVfsService.class);
+
+ String[] children = service.getChildren(getTokenFromSession(),
+ parent.getFullName());
+ FileInfo[] childStrings = new FileInfo[children.length];
+
+ for (int i = 0; i < children.length; i++) {
+ childStrings[i] = new FileInfo(parent, children[i]);
+ }
+
+ return childStrings;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void addFolder(FileInfo newFolder) {
+ HttpSession session = getThreadLocalRequest().getSession();
+
+ if (session != null)
+ System.out.println(session.getAttribute("use"));
+
+ try {
+ P2PlayVfsService service = serviceFactory
+ .getServiceInstance(P2PlayVfsService.class);
+ service.addFolder(getTokenFromSession(), newFolder.getFullName());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public boolean login(String user, char[] password) {
+ HttpSession session = getThreadLocalRequest().getSession(true);
+ try {
+ AuthenticationService service = serviceFactory
+ .getServiceInstance(AuthenticationService.class);
+ AuthenticationToken token = service.login(user, password);
+ session.setAttribute("user", user);
+ session.setAttribute("token", token);
+ return true;
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ session.invalidate();
+ return false;
+ }
+ }
+
+ private AuthenticationToken getTokenFromSession() {
+ return (AuthenticationToken) getThreadLocalRequest().getSession()
+ .getAttribute("token");
+ }
+
+ public void logout() {
+ HttpSession session = getThreadLocalRequest().getSession();
+
+ session.invalidate();
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|