Revision: 3930
Author: seba.wagner
Date: Sun Jul 3 04:52:02 2011
Log: Refactoring FileService::getPresentationPreviewFileExplorer
http://code.google.com/p/openmeetings/source/detail?r=3930
Added:
/trunk/singlewebapp/src/app/org/openmeetings/app/data/file/dto
/trunk/singlewebapp/src/app/org/openmeetings/app/data/file/dto/LibraryPresenationThumbs.java
/trunk/singlewebapp/src/app/org/openmeetings/app/data/file/dto/LibraryPresentation.java
/trunk/singlewebapp/src/app/org/openmeetings/app/data/file/dto/LibraryPresentationFile.java
/trunk/singlewebapp/src/app/org/openmeetings/app/data/file/dto/LibraryPresentationThumb.java
Modified:
/trunk/singlewebapp/WebContent/openmeetings/plugins/fileexplorer/presentations/presentationPreview.lzx
/trunk/singlewebapp/src/app/org/openmeetings/app/documents/LoadLibraryPresentation.java
/trunk/singlewebapp/src/app/org/openmeetings/app/remote/ConferenceLibrary.java
=======================================
--- /dev/null
+++
/trunk/singlewebapp/src/app/org/openmeetings/app/data/file/dto/LibraryPresenationThumbs.java
Sun Jul 3 04:52:02 2011
@@ -0,0 +1,20 @@
+package org.openmeetings.app.data.file.dto;
+
+public class LibraryPresenationThumbs {
+
+ private String name = "";
+ private LibraryPresentationThumb[] thumbs = null;
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public LibraryPresentationThumb[] getThumbs() {
+ return thumbs;
+ }
+ public void setThumbs(LibraryPresentationThumb[] thumbs) {
+ this.thumbs = thumbs;
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/singlewebapp/src/app/org/openmeetings/app/data/file/dto/LibraryPresentation.java
Sun Jul 3 04:52:02 2011
@@ -0,0 +1,35 @@
+package org.openmeetings.app.data.file.dto;
+
+public class LibraryPresentation {
+
+ private LibraryPresentationFile originalDocument = null;
+ private LibraryPresentationFile pdfDocument = null;
+ private LibraryPresentationFile swfDocument = null;
+ private LibraryPresenationThumbs thumbs = null;
+
+ public LibraryPresentationFile getOriginalDocument() {
+ return originalDocument;
+ }
+ public void setOriginalDocument(LibraryPresentationFile originalDocument)
{
+ this.originalDocument = originalDocument;
+ }
+ public LibraryPresentationFile getPdfDocument() {
+ return pdfDocument;
+ }
+ public void setPdfDocument(LibraryPresentationFile pdfDocument) {
+ this.pdfDocument = pdfDocument;
+ }
+ public LibraryPresentationFile getSwfDocument() {
+ return swfDocument;
+ }
+ public void setSwfDocument(LibraryPresentationFile swfDocument) {
+ this.swfDocument = swfDocument;
+ }
+ public LibraryPresenationThumbs getThumbs() {
+ return thumbs;
+ }
+ public void setThumbs(LibraryPresenationThumbs thumbs) {
+ this.thumbs = thumbs;
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/singlewebapp/src/app/org/openmeetings/app/data/file/dto/LibraryPresentationFile.java
Sun Jul 3 04:52:02 2011
@@ -0,0 +1,35 @@
+package org.openmeetings.app.data.file.dto;
+
+public class LibraryPresentationFile {
+
+ private String name = null;
+ private String filename = null;
+ private String lastmod = null;
+ private Long size = null;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getFilename() {
+ return filename;
+ }
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+ public String getLastmod() {
+ return lastmod;
+ }
+ public void setLastmod(String lastmod) {
+ this.lastmod = lastmod;
+ }
+ public Long getSize() {
+ return size;
+ }
+ public void setSize(Long size) {
+ this.size = size;
+ }
+
+}
=======================================
--- /dev/null
+++
/trunk/singlewebapp/src/app/org/openmeetings/app/data/file/dto/LibraryPresentationThumb.java
Sun Jul 3 04:52:02 2011
@@ -0,0 +1,35 @@
+package org.openmeetings.app.data.file.dto;
+
+public class LibraryPresentationThumb {
+
+ private String name = null;
+ private String filename = null;
+ private String lastmod = null;
+ private Long size = null;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getFilename() {
+ return filename;
+ }
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+ public String getLastmod() {
+ return lastmod;
+ }
+ public void setLastmod(String lastmod) {
+ this.lastmod = lastmod;
+ }
+ public Long getSize() {
+ return size;
+ }
+ public void setSize(Long size) {
+ this.size = size;
+ }
+
+}
=======================================
---
/trunk/singlewebapp/WebContent/openmeetings/plugins/fileexplorer/presentations/presentationPreview.lzx
Fri Apr 15 04:58:38 2011
+++
/trunk/singlewebapp/WebContent/openmeetings/plugins/fileexplorer/presentations/presentationPreview.lzx
Sun Jul 3 04:52:02 2011
@@ -10,66 +10,54 @@
<attribute name="miniButton" value="null" />
- <attribute name="uploadmoduleimgfolder" value="" type="string" />
-
<handler name="oninit">
- this.addFolderSequence(this.documentObj.fileHash);
+ this.addFolderSequence();
if ($debug) Debug.write("presentationPreview 1 ",this.width);
if ($debug) Debug.write("presentationPreview 2 ",this.height);
this.miniButton = this.refObjList._documentsTabs.addItem(this);
</handler>
- <method name="addFolderSequence" args="foldername">
+ <method name="addFolderSequence">
<![CDATA[
- if ($debug) Debug.write("foldername ",foldername);
- this.uploadmoduleimgfolder = '/';
- this.uploadmoduleimgfolder += foldername;
- canvas.uploadmoduleimgfolder = this.uploadmoduleimgfolder;
- this.getListOfFilesExplorer.doCall();
+ if ($debug) Debug.write("foldername ",this.documentObj.fileHash);
+ canvas.uploadmoduleimgfolder = '/'+this.documentObj.fileHash;
+ this.getPresentationPreviewFileExplorer.doCall();
]]>
</method>
- <netRemoteCallHib name="getListOfFilesExplorer"
funcname="fileservice.getListOfFilesExplorer"
+ <netRemoteCallHib name="getPresentationPreviewFileExplorer"
funcname="fileservice.getPresentationPreviewFileExplorer"
remotecontext="$once{ canvas.thishib }" >
<netparam><method name="getValue">return canvas.sessionId;
</method></netparam>
- <netparam><method name="getValue">return '';</method></netparam>
- <netparam><method name="getValue">return
parent.parent.uploadmoduleimgfolder;</method></netparam>
- <netparam><method name="getValue">return
hib.currentroomid;</method></netparam>
+ <netparam><method name="getValue">return
parent.parent.documentObj.fileHash;</method></netparam>
<handler name="ondata" args="value">
- if ($debug) Debug.write("getListOfFiles -1-: ",value);
- if ($debug) Debug.write("getListOfFiles -2-: ","");
- if ($debug) Debug.write("getListOfFiles
-3-: ",parent.uploadmoduleimgfolder);
+ if ($debug) Debug.write("getPresentationPreviewFileExplorer
-1-: ",value);
+ if ($debug) Debug.write("getPresentationPreviewFileExplorer
-3-: ",parent.documentObj.fileHash);
parent.renderItems(value);
</handler>
</netRemoteCallHib>
- <method name="renderItems" args="filesObj" >
+ <method name="renderItems" args="presentationObject" >
if ($debug) Debug.write("this: ",this);
- if ($debug) Debug.write("filesObj: ",filesObj);
+ if ($debug) Debug.write("presentationObject: ",presentationObject);
<![CDATA[
- var value = filesObj;
- if (value['presentationObject']==null){
- if ($debug) Debug.warn("This should not happen
value['presentationObject'] IS NULL");
- } else {
-
- if ($debug)
Debug.write("value.presentationObject: ",value.presentationObject);
-
- if
(typeof(value.presentationObject.pdfDocument)=="undefined"){
- //Is PDF only
- //Debug.write("Is PDF only");
-
this._imageslistdraw.addListpresentationFilePDF(value.presentationObject.originalDocument,value.presentationObject.swfDocument);
- } else {
- //Is original Document + PDF-Document
- //Debug.write("Is original Document + PDF-Document");
-
this._imageslistdraw.addListpresentationFileOrig(value.presentationObject.originalDocument,value.presentationObject.pdfDocument,value.presentationObject.swfDocument);
- }
-
- for (var
eg=0;eg<value.presentationObject.thumbs.thumbs.length;eg++){
-
////Debug.write(value.presentationObject.thumbs.thumbs[eg].filename);
-
this._imageslistdraw.addPresentationThumb(value.presentationObject.thumbs.thumbs[eg].filename,(eg+1));
- }
-
- }
+
+ if ($debug)
Debug.write("presentationObject: ",presentationObject);
+
+ if (typeof(presentationObject.pdfDocument)=="undefined"){
+ //Is PDF only
+ //Debug.write("Is PDF only");
+
this._imageslistdraw.addListpresentationFilePDF(presentationObject.originalDocument,presentationObject.swfDocument);
+ } else {
+ //Is original Document + PDF-Document
+ //Debug.write("Is original Document + PDF-Document");
+
this._imageslistdraw.addListpresentationFileOrig(presentationObject.originalDocument,presentationObject.pdfDocument,presentationObject.swfDocument);
+ }
+
+ for (var eg=0;eg<presentationObject.thumbs.thumbs.length;eg++){
+
////Debug.write(presentationObject.thumbs.thumbs[eg].filename);
+
this._imageslistdraw.addPresentationThumb(presentationObject.thumbs.thumbs[eg].filename,(eg+1));
+ }
+
]]>
</method>
=======================================
---
/trunk/singlewebapp/src/app/org/openmeetings/app/documents/LoadLibraryPresentation.java
Tue May 11 13:54:08 2010
+++
/trunk/singlewebapp/src/app/org/openmeetings/app/documents/LoadLibraryPresentation.java
Sun Jul 3 04:52:02 2011
@@ -5,6 +5,10 @@
import java.io.FileInputStream;
import org.slf4j.Logger;
+import org.openmeetings.app.data.file.dto.LibraryPresenationThumbs;
+import org.openmeetings.app.data.file.dto.LibraryPresentation;
+import org.openmeetings.app.data.file.dto.LibraryPresentationFile;
+import org.openmeetings.app.data.file.dto.LibraryPresentationThumb;
import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
import org.red5.logging.Red5LoggerFactory;
import org.dom4j.Document;
@@ -26,82 +30,112 @@
return instance;
}
- public LinkedHashMap<String,LinkedHashMap>
parseLibraryFileToObject(String filePath){
+ public LibraryPresentation parseLibraryFileToObject(String filePath){
try {
- LinkedHashMap<String,LinkedHashMap> lMap = new
LinkedHashMap<String,LinkedHashMap>();
+ LibraryPresentation lPresentation = new
LibraryPresentation();
SAXReader reader = new SAXReader();
Document document = reader.read( new FileInputStream(filePath)
);
Element root = document.getRootElement();
- Integer k = 0;
-
- for ( Iterator i = root.elementIterator(); i.hasNext(); ) {
- Element item = (Element) i.next();
+
+ for ( Iterator<Element> i = root.elementIterator(); i.hasNext();
) {
+
+ Element item = i.next();
+
log.debug(item.getName());
String nodeVal = item.getName();
- LinkedHashMap<String,Object> subMap = new
LinkedHashMap<String,Object>();
- subMap.put("name", nodeVal);
-
- if (nodeVal.equals("originalDocument") ||
nodeVal.equals("pdfDocument")
- ||
nodeVal.equals("swfDocument")){
-
this.createListObjectLibraryByFileDocument(item, subMap);
+ //LinkedHashMap<String,Object> subMap = new
LinkedHashMap<String,Object>();
+
+ //subMap.put("name", nodeVal);
+
+ if (nodeVal.equals("originalDocument")){
+
+
lPresentation.setOriginalDocument(this.createListObjectLibraryByFileDocument(item));
+
+ } else if (nodeVal.equals("pdfDocument")){
+
+
lPresentation.setPdfDocument(this.createListObjectLibraryByFileDocument(item));
+
+ } else if (nodeVal.equals("swfDocument")){
+
+
lPresentation.setSwfDocument(this.createListObjectLibraryByFileDocument(item));
+
} else if (nodeVal.equals("thumbs")) {
-
this.createListObjectLibraryByFileDocumentThumbs(item, subMap);
+
+
lPresentation.setThumbs(this.createListObjectLibraryByFileDocumentThumbs(item));
+
+ } else {
+ throw new Exception("Unkown Library type:
"+nodeVal);
}
- log.debug("parseLibraryFileToObject"+subMap);
- lMap.put(nodeVal, subMap);
-
- k++;
-
- }
-
- return lMap;
+ }
+
+ log.debug("Returning presentation file object");
+
+ return lPresentation;
} catch (Exception err) {
log.error("parseLibraryFileToObject",err);
return null;
}
}
- public void createListObjectLibraryByFileDocument(Element fileElement,
LinkedHashMap<String,Object> subMap){
+ public LibraryPresentationFile
createListObjectLibraryByFileDocument(Element fileElement){
try {
log.info("createListObjectLibraryByFileDocument"+fileElement);
-
- subMap.put("filename", fileElement.getText());
- subMap.put("lastmod",
fileElement.attribute("lastmod").getText());
- subMap.put("size",
Long.valueOf(fileElement.attribute("size").getText()).longValue());
+
+ LibraryPresentationFile libraryPresentationFile = new
LibraryPresentationFile();
+ libraryPresentationFile.setName(fileElement.getName());
+
libraryPresentationFile.setFilename(fileElement.getText());
+
libraryPresentationFile.setLastmod(fileElement.attribute("lastmod").getText());
+
libraryPresentationFile.setSize(Long.valueOf(fileElement.attribute("size").getText()).longValue());
+
+ return libraryPresentationFile;
} catch (Exception err) {
log.error("createListObjectLibraryByFileDocument",err);
}
+ return null;
}
- public void createListObjectLibraryByFileDocumentThumbs(Element
fileElement, LinkedHashMap<String,Object> subMap){
+ public LibraryPresenationThumbs
createListObjectLibraryByFileDocumentThumbs(Element fileElement){
try {
-
- LinkedHashMap<Integer,LinkedHashMap> thumbMap = new
LinkedHashMap<Integer,LinkedHashMap>();
+
+ LibraryPresenationThumbs thumbMap = new
LibraryPresenationThumbs();
+ thumbMap.setName(fileElement.getName());
+
Integer k = 0;
-
- for ( Iterator i = fileElement.elementIterator();
i.hasNext(); ) {
- Element thumbElement = (Element) i.next();
-
log.info("createListObjectLibraryByFileDocumentThumbs"+thumbElement);
- LinkedHashMap<String,Object> singleThumb = new
LinkedHashMap<String,Object>();
- singleThumb.put("name", thumbElement.getName());
- singleThumb.put("filename",
thumbElement.getText());
- singleThumb.put("lastmod",
thumbElement.attribute("lastmod").getText());
- singleThumb.put("size",
Long.valueOf(thumbElement.attribute("size").getText()).longValue());
- thumbMap.put(k, singleThumb);
+ for ( Iterator<Element> i = fileElement.elementIterator(); i.hasNext();
) {
+ Element thumbElement = i.next();
+ k++;
+ }
+
+ thumbMap.setThumbs(new LibraryPresentationThumb[k]);
+
+
+ k = 0;
+ for ( Iterator<Element> i = fileElement.elementIterator(); i.hasNext();
) {
+ Element thumbElement = i.next();
+
//log.info("createListObjectLibraryByFileDocumentThumbs"+thumbElement);
+ LibraryPresentationThumb singleThumb = new
LibraryPresentationThumb();
+ singleThumb.setName(thumbElement.getName());
+ singleThumb.setFilename(thumbElement.getText());
+
singleThumb.setLastmod(thumbElement.attribute("lastmod").getText());
+
singleThumb.setSize(Long.valueOf(thumbElement.attribute("size").getText()).longValue());
+ thumbMap.getThumbs()[k] = singleThumb;
k++;
}
- subMap.put("thumbs", thumbMap);
+
+
+ return thumbMap;
} catch (Exception err) {
log.error("createListObjectLibraryByFileDocumentThumbs",err);
}
+ return null;
}
}
=======================================
---
/trunk/singlewebapp/src/app/org/openmeetings/app/remote/ConferenceLibrary.java
Sun Jun 26 03:21:14 2011
+++
/trunk/singlewebapp/src/app/org/openmeetings/app/remote/ConferenceLibrary.java
Sun Jul 3 04:52:02 2011
@@ -27,6 +27,7 @@
import org.openmeetings.app.data.basic.files.FoldersObject;
import org.openmeetings.app.data.basic.files.LiberaryObject;
import org.openmeetings.app.data.file.dao.FileExplorerItemDaoImpl;
+import org.openmeetings.app.data.file.dto.LibraryPresentation;
import org.openmeetings.app.data.user.Usermanagement;
import org.openmeetings.app.documents.CreateLibraryPresentation;
import org.openmeetings.app.documents.LibraryChartLoader;
@@ -40,7 +41,6 @@
import org.openmeetings.app.remote.red5.ScopeApplicationAdapter;
import org.openmeetings.utils.StoredFile;
import org.openmeetings.utils.crypt.MD5;
-import org.openmeetings.utils.math.CalendarPatterns;
import org.red5.logging.Red5LoggerFactory;
import org.red5.server.api.IConnection;
import org.red5.server.api.Red5;
@@ -86,17 +86,11 @@
private ConferenceLibrary() {
}
- public LinkedHashMap<String, Object> getListOfFilesExplorer(String SID,
- String moduleName, String parentFolder, Long room_id) {
-
- LinkedHashMap<String, Object> returnMap = new
LinkedHashMap<String, Object>();
+ public LibraryPresentation getPresentationPreviewFileExplorer(String
SID,
+ String parentFolder) {
try {
- LinkedList<LinkedList<String>> filesMap = new
LinkedList<LinkedList<String>>();
- LinkedList<LinkedList<String>> foldersMap = new
LinkedList<LinkedList<String>>();
- LinkedHashMap<String, LinkedHashMap> presentationObject = null;
-
Long users_id =
Sessionmanagement.getInstance().checkSession(SID);
Long user_level =
Usermanagement.getInstance().getUserLevelByID(
users_id);
@@ -105,125 +99,30 @@
log.debug("#############user_level : " + user_level);
if
(AuthLevelmanagement.getInstance().checkUserLevel(user_level)) {
- String roomName = room_id.toString();
String current_dir = ScopeApplicationAdapter.webAppPath
+ File.separatorChar + "upload";
String working_dir = current_dir + File.separatorChar
+ "files"
- + parentFolder;
- log.debug("#############working_dir : " + working_dir);
-
- File dir = new File(working_dir);
-
- long dirSize = this.getDirSize(dir);
-
- // First get all Directories of this Folder
- FilenameFilter ff = new FilenameFilter() {
- public boolean accept(File b, String name) {
- String absPath = b.getAbsolutePath()
- + File.separatorChar + name;
- File f = new File(absPath);
- return f.isDirectory();
- }
- };
-
- String[] allfolders = dir.list(ff);
- if (allfolders != null) {
- for (int i = 0; i < allfolders.length; i++) {
- File file = new File(working_dir +
File.separatorChar
- + allfolders[i]);
- Date lastModifiedDate = new
Date(file.lastModified());
- String lastModified = formatDate(lastModifiedDate);
- String fileName = allfolders[i];
- log.debug("Found Folders, foldername: " +
fileName);
- LinkedList<String> fileInfo = new
LinkedList<String>();
- fileInfo.add("");
- fileInfo.add("");
- fileInfo.add(fileName);
- fileInfo.add(lastModified);
- foldersMap.add(fileInfo);
- }
- }
-
- // Second get all Files of this Folder
- FilenameFilter ff2 = new FilenameFilter() {
- public boolean accept(File b, String name) {
- String absPath = b.getAbsolutePath()
- + File.separatorChar + name;
- File f = new File(absPath);
- return f.isFile();
- }
- };
-
- String[] allfiles = dir.list(ff2);
- if (allfiles != null) {
- for (int i = 0; i < allfiles.length; i++) {
- File file = new File(working_dir +
File.separatorChar
- + allfiles[i]);
-
-
log.debug("working_dir+File.separatorChar+allfiles[i]: "
- + working_dir
- + File.separatorChar
- + allfiles[i]);
- if (allfiles[i].startsWith("_thumb_")) {
- // log.error("Found Thumbs: "+allfiles[i]);
- } else {
- String lastModified = formatDate(new Date(
- file.lastModified()));
- String fileName = allfiles[i];
- String fileBytes = new Long(file.length())
- .toString();
-
- LinkedList<String> fileInfo = new
LinkedList<String>();
-
- String fileNamePure = fileName.substring(0,
- fileName.length() - 4);
- String fileNameExt = fileName.substring(
- fileName.length() - 4,
fileName.length());
- String isimage = "y";
- StoredFile storedFile = new StoredFile(
- fileNamePure,
fileNameExt.toLowerCase());
- if (storedFile.isPresentation())
- isimage = "n";
- log.debug("Found File, fileName: " + fileName);
- fileInfo.add(fileName);
- fileInfo.add(fileNamePure);
- fileInfo.add(fileNameExt);
- fileInfo.add(lastModified);
- fileInfo.add(fileBytes);
- fileInfo.add(isimage);
- filesMap.add(fileInfo);
-
- if (fileName
- .equals(CreateLibraryPresentation.libraryFileName))
{
- presentationObject =
LoadLibraryPresentation
- .getInstance()
+ + File.separatorChar+ parentFolder;
+ log.debug("############# working_dir : " + working_dir);
+
+ File file = new File(working_dir + File.separatorChar
+ "library.xml");
+
+ if (!file.exists()) {
+ throw new Exception("library.xml does not
exist "+working_dir + File.separatorChar + "library.xml");
+ }
+
+ return LoadLibraryPresentation.getInstance()
.parseLibraryFileToObject(
file.getAbsolutePath());
- }
-
- }
- }
- }
-
- returnMap.put("presentationObject", presentationObject);
- returnMap.put("folders", foldersMap);
- returnMap.put("files", filesMap);
- returnMap.put("dirSize", dirSize);
- returnMap.put("error", "");
-
- return returnMap;
+
} else {
- log.error("not Authentificated");
- returnMap.put("error", "not authenificated");
- return returnMap;
+ throw new Exception("not Authenticated");
}
} catch (Exception e) {
log.error("[getListOfFilesByAbsolutePath]", e);
- e.printStackTrace();
- returnMap.put("error", e.getMessage());
- return returnMap;
+ return null;
}
}
@@ -308,10 +207,17 @@
return size;
}
+ /**
+ * @deprecated
+ * @param SID
+ * @param moduleName
+ * @param parentFolder
+ * @return
+ */
public LinkedHashMap<String, Object> getListOfFilesPlugin(String SID,
String moduleName, String parentFolder) {
- LinkedHashMap<String, Object> returnMap = new
LinkedHashMap<String, Object>();
+ /*LinkedHashMap<String, Object> returnMap = new
LinkedHashMap<String, Object>();
try {
@@ -444,7 +350,9 @@
e.printStackTrace();
returnMap.put("error", e.getMessage());
return returnMap;
- }
+ }*/
+
+ return null;
}
--
You received this message because you are subscribed to the Google Groups
"OpenMeetings developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/openmeetings-dev?hl=en.