18 package org.turro.elephant.documents;
21 import java.io.IOException;
22 import java.util.Collection;
23 import java.util.Properties;
24 import java.util.Vector;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import org.amic.util.file.FileUtil;
28 import org.amic.util.string.Cipher;
29 import org.jdom.Element;
30 import org.turro.elephant.context.ElephantContext;
31 import org.turro.elephant.security.IUser;
32 import org.turro.i18n.I_;
40 private String realRoot, docsRoot, privateKey, selected;
41 private Element configuration;
45 this.docBean = docBean;
46 this.realRoot = realRoot;
47 this.docsRoot = realRoot + relativeRoot;
48 this.configuration = config;
49 privateKey = Cipher.digest(docsRoot, 30);
54 File userFolder =
new File(
getPath() +
"/" + user.
getId());
55 if(!userFolder.exists()) {
57 Properties props =
new Properties();
58 props.put(
"root.name", user.
getName());
66 File userFolder =
new File(
getPath() +
"/" + user.
getId());
67 if(!userFolder.exists()) {
75 getPath() +
"/" + folder +
"/.docs.properties");
80 getPath() +
"/" + folder +
"/.docs.properties");
92 this.selected = selected;
96 return new FileDocument(
this,
null, docsRoot + selected);
100 return configuration !=
null ? configuration.getAttributeValue(attrib) :
null;
128 if(path.startsWith(docsRoot)) {
129 return path.substring(docsRoot.length());
135 Vector v =
new Vector();
138 if(pattern ==
null || fd.getName().matches(pattern)) {
146 Vector v =
new Vector();
149 if(pattern ==
null || fd.getName().matches(pattern)) {
157 Vector v =
new Vector();
162 private void fillNotValidated(Vector v,
FileDocument root) {
167 else if (fd.isDirectory()) {
168 fillNotValidated(v, fd);
180 return props.getProperty(property);
187 new File(
getPath() +
"/" + ident).mkdirs();
188 Properties props =
new Properties();
189 props.put(
"root.name", name);
199 private void copyTemplate(String ident) {
203 }
catch (IOException ex) {
static String logMsg(String msg)
Properties getPropertiesFile(String file)
void savePropertiesFile(Properties props, String file)
boolean getCanDelFolder()
boolean getCanNewFolder()
ProcessMessages getMessages()
void setAttribute(String key, String value)
String readConfig(String property)
String getRelativePath(String path)
void savePropertiesToUser(Properties props, IUser user)
void addInsertionPoint(String ident, String name)
Collection< FileDocument > getNotValidated()
String getAttribute(String attrib)
DocumentsRoot(DocumentsBean docBean, String realRoot, String relativeRoot, Element config)
FileDocument getFileDocumentSelected()
boolean getCanNewFolder()
void savePropertiesTo(String folder, Properties props)
String readRootConfig(String property)
boolean getCanDelFolder()
FileDocument getFileDocumentRoot()
DocumentsBean getDocumentsBean()
Properties getPropertiesFromUser(IUser user)
void setFileDocumentSelected(String selected)
Properties getPropertiesFrom(String folder)
FileDocument[] getInsertionFolders()
Collection getInsertionPointsWrapped()
FileDocument[] getNotValidated()
String readConfig(String property)
void addMessage(String message)
void addError(String message)
static String get(String msg)