diff options
| author | guest <guest@f059d3a0-6783-47b7-97ff-1fe0bbf25129> | 2008-09-24 18:38:34 +0000 |
|---|---|---|
| committer | guest <guest@f059d3a0-6783-47b7-97ff-1fe0bbf25129> | 2008-09-24 18:38:34 +0000 |
| commit | f6825ebc115029fcf575033748e3372efb94c87d (patch) | |
| tree | b2f73b306231a6d108d3d85695f2c6f2622eecd4 /src | |
| parent | 057fd35e1a6186c2ca2859152b30eccbff514f10 (diff) | |
removed classes, which shouldn't be part of the server in yalp2.0
git-svn-id: http://manut.eu/svn/yalp/trunk@4 f059d3a0-6783-47b7-97ff-1fe0bbf25129
Diffstat (limited to 'src')
| -rwxr-xr-x | src/YalpServer/FileBrowser.java | 175 | ||||
| -rwxr-xr-x | src/YalpServer/FileFinder.java | 110 | ||||
| -rwxr-xr-x | src/YalpServer/FileInfoManager.java | 126 | ||||
| -rwxr-xr-x | src/YalpServer/InitServer.java | 75 | ||||
| -rwxr-xr-x | src/YalpServer/ServerControlImpl.java | 15 |
5 files changed, 12 insertions, 489 deletions
diff --git a/src/YalpServer/FileBrowser.java b/src/YalpServer/FileBrowser.java deleted file mode 100755 index 2f2a3a5..0000000 --- a/src/YalpServer/FileBrowser.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2006 Manuel Traut and Volker Dahnke - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: Manuel Traut and Volker Dahnke - */ - -package YalpServer; - -import java.util.ArrayList; -import java.io.File; -import java.io.Serializable; - -import YalpInterfaces.*; - -/* - * Class FileBrowser - * - * <em>each Admin Client has his own FileBrowser, to browse through the - * subDirectories of the as startDir defined Directory</em> - * - * @author Volker Dahnke / Manuel Traut - * - * @version 0.6 14-12-2005<br> - * - * @see client.GUI.Browser - */ - -public class FileBrowser { - - private File actualFile, startDir; - private String owner; - private String userName; - private ArrayList<YalpFile> fileList; - - /* t.b.d. add some more types */ - private String[] extensions = {".mp3",".mpg",".mpeg",".avi"}; - -/* - * Constructor starts Browsing in startDir - * - * @param startdir - * directory which could be browser recursively - * @param owner - * of the Browser (IP of the Client) - * @param userName - * of the Admin using this browser - */ - - public FileBrowser(String startdir, String owner,String userName) { - this.owner = owner; - this.userName=userName; - this.actualFile = new File(startdir); - this.startDir = new File(startdir); - this.fileList = new ArrayList<YalpFile>(); - } - -/* - * returns owner of the browser - * - * @return String - * owner - */ - - public String getOwner(){ - return this.owner; - } - -/* - * returns user of the browser - * - * @return String - * user - */ - - public String getUserName(){ - return this.userName; - } - -/* - * returns list of all files in actual Folder - * (none recursive) - * - * @return ArrayList<YalpFile> - * list of all files - */ - - public ArrayList<YalpFile> getFiles(){ - return this.fileList; - } - -/* - * returns list of all files in actual Folder - * (recursive) - * - * @return ArrayList<YalpFile> - * list of all files - */ - - public ArrayList<File> findAll() { - - System.out.println( "server.FileBrowser.findAll: lookin in - " + - this.actualFile.toString() ); - - FileFinder ff = new FileFinder(actualFile.getPath(), extensions); - return ff.getFiles(); - } - -/* - * change actual Folder - * - * @param dirName - * String dir to change to - */ - - public void changeDir(String dirName) { - - this.actualFile = new File(this.startDir+dirName); - this.fileList.clear(); - - if(actualFile.isDirectory()) { - for ( File aFile : this.actualFile.listFiles() ) { - /* add to fileList if extension is allowed or File is a Directory */ - if (match(aFile.getName(), extensions) || aFile.isDirectory()) - { - YalpFile tmp = new YalpFile(); - tmp.name = aFile.getName(); - tmp.isDir = aFile.isDirectory(); - tmp.parent = aFile.getParent(); - this.fileList.add( tmp ); - } - } - } - } - -/* - * prints current directory out to console - * - * (for debugging) - */ - - public void printActualDir(){ - for(YalpFile one : this.fileList){ - if(one.isDir) System.out.print("+"); - else System.out.print("|"); - System.out.println(one.name); - } - } - -/* - * checks if file extension matches or not - * - * @param s - * fileName including Extension - * @param suffixes - * Array of allowed Extensions - * @return boolean - * true if yalp can handle this extension, else false - */ - - private static boolean match( String s, String suffixes[] ) { - for ( String suffix : suffixes ) { - int huhu = s.length(); - int huhu2 = suffix.length(); - int huhu3 = huhu - huhu2; - if ( s.length() >= suffix.length() && - s.substring( huhu3, s.length()).equalsIgnoreCase(suffix) ) - return true; - } - return false; - } -} diff --git a/src/YalpServer/FileFinder.java b/src/YalpServer/FileFinder.java deleted file mode 100755 index 2d6527c..0000000 --- a/src/YalpServer/FileFinder.java +++ /dev/null @@ -1,110 +0,0 @@ -/*********************************************************************** - * - * Copyright (c) 2006 Manuel Traut and Volker Dahnke - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: Manuel Traut and Volker Dahnke - * - ***********************************************************************/ -package YalpServer; - -import java.io.*; -import java.util.*; - -/************************************************************************ - * - * Class FileFinder - * - * <em>algorithm for scanning files recursively</em> - * - * @author Volker Dahnke / Manuel Traut - * - * @version 0.6 14-12-2005<br> - * - * @see FileBrowser - * - ************************************************************************/ - -public class FileFinder -{ - private ArrayList<File> files; - - /** - * Constructor: scans subdirectories of commited directory - * uses only files with allowed extensions - * @param start - * directory to scan - * @param extensions - * allowed extensions - */ - public FileFinder( String start, String extensions[] ) { - - this.files = new ArrayList<File>(); - Stack<File> dirs = new Stack<File>(); - File startdir = new File(start); - - // push startdir to stack - if (startdir.isDirectory()) dirs.push(startdir); - // startdir is File - else { - if (match(startdir.getName(), extensions)) this.files.add(startdir); - return; - } - // for each dir on stack - while (dirs.size() > 0) { - // contents of dir on stack - for (File file : dirs.pop().listFiles()){ - try { - // add subdirectory to stack - if (file.isDirectory()) dirs.push(file); - // if file is of correct filetype add it to filelist - else if (match(file.getName(), extensions)) this.files.add(file); - } catch (NullPointerException e) { - System.out.println("FileFinder: "+ file.getName() +"Premission denied"); - } - } - } - } - - /** - * returns and prints out all Medias found - * @return ArrayList<File> - * all found Medias - */ - public ArrayList<File> getFiles(){ - print(); - return this.files; - } - - /** - * prints out found medias - * - */ - public void print() { - System.out.println( "Found " + files.size() + " file" + (files.size() == 1 ? "." : "s.") ); - for ( File f : files ) System.out.println( f.getAbsolutePath() ); - } - - /** - * checks if file extension matches or not - * - * @param s - * file to check - * @param suffixes - * allowed extensions - * - * @return boolean: true if it's a media, yalp can handle - */ - private static boolean match( String s, String suffixes[] ) { - for ( String suffix : suffixes ) { - int huhu = s.length(); - int huhu2 = suffix.length(); - int huhu3 = huhu - huhu2; - if ( s.length() >= suffix.length() && s.substring(huhu3, s.length()).equalsIgnoreCase(suffix) ) return true; - } - return false; - } -} diff --git a/src/YalpServer/FileInfoManager.java b/src/YalpServer/FileInfoManager.java deleted file mode 100755 index 34fe49b..0000000 --- a/src/YalpServer/FileInfoManager.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2006 Manuel Traut and Volker Dahnke - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: Manuel Traut and Volker Dahnke - */ - -package YalpServer; - -import java.io.File; -import java.io.IOException; -import java.io.FileNotFoundException; - -import de.hampelratte.id3.*; - -import YalpInterfaces.*; - -/* - * Class FileInfoManager - * - * <em>Creates a Result out of FileInformations (ID3, etc)</em> - * - * @author Volker Dahnke / Manuel Traut - * - * @version 0.1 14-12-2005<br> - * - * @see ServerControl - */ - -public class FileInfoManager { - - private Media fileInfo; - private EncodingType eType; - -/* - * Constructor: tries to get all Informations about a file - * - * @param file - */ - - public FileInfoManager(File file) { - - this.eType = EncodingType.UNKNOWN; - this.fileInfo = new Media(); - this.fileInfo.path = file.getParent()+file.separator; - this.fileInfo.fileName = file.getName(); - - /* check extensions is mp3 */ - if( this.fileInfo.fileName.substring( this.fileInfo.fileName.length() - 3, - this.fileInfo.fileName.length()).equalsIgnoreCase( "mp3" ) ) - { - this.eType = EncodingType.MP3; - } - - switch(this.eType.value()) { - case EncodingType._MP3: - try - { - /* opening mp3 file for reading and writing */ - MP3File mp3 = new de.hampelratte.id3.MP3File(file.toString(), "r"); - this.fileInfo.type = MediaType.SOUND; - - if(mp3.hasID3v1Tag){ - ID3v1Tag tag = mp3.readID3v1Tag(); - /* t.b.d. create StringProperties - this.fileInfo.album = tag.getAlbum(); - this.fileInfo.author = tag.getArtist(); - this.fileInfo.category = tag.getGenre(); - this.fileInfo.name = tag.getTrack() +" - "+tag.getTitle(); - this.fileInfo.year = tag.getYear(); - */ - } - - if(mp3.hasID3v2Tag){ - - // reading the ID3v2Tag - ID3v2Tag tag = mp3.readID3v2Tag(); - /* t.b.d. create StringProperties - this.fileInfo.album = tag.getAlbum(); - this.fileInfo.author = tag.getArtist(); - this.fileInfo.category = tag.getGenre(); - this.fileInfo.year = tag.getYear(); - */ - if( !(tag.getTrack().equals(""))){ - this.fileInfo.name = tag.getTrack() +" - "+tag.getTitle(); - } else { - this.fileInfo.name = tag.getTitle(); - } - } - - if (this.fileInfo.name.equals("")) { - - this.fileInfo.name = - file.getName().substring( 0, file.getName().length() - 4 ); - } - - mp3.close(); - } catch (Exception e) { - - this.fileInfo.name = - file.getName().substring(0,file.getName().length() - 4); - } - break; - - default: - this.fileInfo.name = - file.getName().substring(0,file.getName().length()-4); - - this.fileInfo.type = MediaType.VIDEO; - break; - } - } - -/* - * returns the information to an media, found - * @return MediaChange - * Informations about the media - */ - - public Media getInfo(){ - return this.fileInfo; - } -} diff --git a/src/YalpServer/InitServer.java b/src/YalpServer/InitServer.java index ac9d507..a5f7c99 100755 --- a/src/YalpServer/InitServer.java +++ b/src/YalpServer/InitServer.java @@ -12,7 +12,6 @@ package YalpServer; import java.net.Inet4Address; -import java.net.MalformedURLException; import java.net.UnknownHostException; import java.beans.XMLDecoder; @@ -29,8 +28,6 @@ import java.util.Properties; import java.security.*; -import java.sql.SQLException; - import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; @@ -62,7 +59,6 @@ public class InitServer { private String[] orbArgs; private POA poa; private String serverIP; - private ArrayList<FileBrowser> browseList; /* * Constructor: starts Server initialization @@ -72,8 +68,6 @@ public class InitServer { loadConfig("ServerSettings.xml"); writeConfig("ServerSettings.xml"); - this.browseList = new ArrayList<FileBrowser>(); - this.orbArgs = _orbArgs; // t.b.d. read orbargs from config xml try { @@ -211,73 +205,4 @@ public class InitServer { this.settings = set; return this.writeConfig("ServerConfiguration.xml"); } - -/* - * t.b.d. session management - * - * Client logon (give him,his fileBrowser) - * - * @param ipAdress - * of the Client - * @param userName - * using the Client - * - - public void newClient(String ipAdress,String userName) { - this.browseList.add( new FileBrowser( this.settings.startDir, - ipAdress, - userName ) ); - } - */ - -/* - * Client logoff (free memory of his fileBrowser - * - * @param ipAdress - * of the Client - * @param userName - * using the Client - */ - - public void remClient(String ipAdress, String userName) { - for( FileBrowser aBrowser : this.browseList ) { - if( aBrowser.getOwner().equals(ipAdress) && - aBrowser.getUserName().equals(userName) ) { - this.browseList.remove(aBrowser); - break; - } - } - } - -/* - * change Directory in fileBrowser - * - * @param ip - * of the Client - * @param dir - * to which should be changed - * @return ArrayList<YalpFile> - * content of the directory changed to - */ - - public ArrayList<YalpFile> changeDir(String ip, String dir) { - FileBrowser aBrowser = null; - for(FileBrowser oneMoreBrowser : this.browseList) { - if( oneMoreBrowser.getOwner().equals(ip) ) { - oneMoreBrowser.changeDir(dir); - aBrowser = oneMoreBrowser; - break; - } - } - return aBrowser.getFiles(); - } - -/* - * Server Shutdown - */ - - public void serverShutdown() { - System.out.println("Server shutdown - Server is going down"); - System.exit(0); - } } diff --git a/src/YalpServer/ServerControlImpl.java b/src/YalpServer/ServerControlImpl.java index a88445a..0f33ff6 100755 --- a/src/YalpServer/ServerControlImpl.java +++ b/src/YalpServer/ServerControlImpl.java @@ -80,10 +80,19 @@ public ServerControlImpl() { session.value = new Session();
session.value.id = 666;
session.value.me = new YalpUser();
+ session.value.me.id = 333;
+ session.value.me.name = userName;
+ session.value.me.realName = "huhu";
session.value.me.level = AccessRights.ADMIN;
+ session.value.ip = "127.0.0.1";
+ session.value.availablePlugins = new PluginInfo[0];
- err.value = new YalpError();
- err.value.code = YalpErrorCode.OK;
+ YalpError error = new YalpError();
+ error.code = YalpErrorCode.OK;
+ error.descr = "no error";
+ error.level = YalpErrorLevel.ERROR_LEVEL_DEBUG;
+ error.msg = "";
+ err.value = error;
} catch (Exception e) {
System.out.println(e.toString());
@@ -99,7 +108,7 @@ public ServerControlImpl() { */
public void clientLogoff( Session bye, YalpErrorHolder err) {
logger.debug("clientLogoff");
- srv.remClient( bye.ip, bye.me.name );
+ // srv.remClient( bye.ip, bye.me.name );
YalpError error = new YalpError();
error.code = YalpErrorCode.OK;
err = new YalpErrorHolder(error);
|
