Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 376 → Rev 380

/impl/importRoutines.xml
20,4 → 20,7
<target name="summaries">
<java classname="pt.estgp.estgweb.services.sigesimports.ImportSumaries" classpath="${build.dir.classes}" classpathref="pathToToolsLib"/>
</target>
<target name="setAreas">
<java fork="true" classname="pt.estgp.estgweb.services.courses.SetUserArea" classpath="${build.dir.classes}" classpathref="pathToToolsLib"/>
</target>
</project>
/impl/conf/app.properties
110,7 → 110,7
 
 
server.casaTestes=http://localhost:8080
server.casaTestes.start.path=/static
server.casaTestes.start.path=/templates
casaTestes.encoding=ISO-8859-1
casaTestes.proxy.host=
casaTestes.proxy.port=
/impl/conf/directories/directory.xsd
38,6 → 38,22
<xs:documentation>Grouping purposes in styling</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="showNav" type="xs:boolean" use="optional">
<xs:annotation>
<xs:documentation>Show link to this node in navigation menus, true by default</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="type" use="optional">
<xs:annotation>
<xs:documentation>Type of node, by default HTTP link</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="ftp"/>
<xs:enumeration value="http"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="id" type="xs:ID" use="required"/>
</xs:complexType>
<xs:complexType name="leafT">
45,6 → 61,13
<xs:documentation>A leaf is an URL for an external or internal WEB site</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>A leaf can be a root of some diferent system like FTP server Directory</xs:documentation>
</xs:annotation>
<xs:element name="node" type="nodeT"/>
<xs:element name="leaf" type="leafT"/>
</xs:choice>
<xs:element name="rights" type="rightsT" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="url" type="xs:string" use="required"/>
81,6 → 104,33
<xs:documentation>Grouping purposes in styling</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ftpDirectory" type="xs:boolean"/>
<xs:attribute name="size" use="optional">
<xs:annotation>
<xs:documentation>Size of content in Kb</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="mimeType" use="optional">
<xs:annotation>
<xs:documentation>Mime Type of content in Kb</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="lastModification" use="optional">
<xs:annotation>
<xs:documentation>Last Modification of content in Kb</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="visualization" use="optional">
<xs:annotation>
<xs:documentation>Type of node, by default HTTP link</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="filesystem"/>
<xs:enumeration value="normal"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="groupDeclarationT">
<xs:sequence>
/impl/conf/directories/utils.xsl
13,7 → 13,15
<xsl:template match="d:node" mode="link">
<a>
<xsl:attribute name="href">
<xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/>
<xsl:choose>
<xsl:when test="@idPrefixSize">
<xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="substring(@id,@idPrefixSize+1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="." mode="label"/>
</a>
26,7 → 34,15
<xsl:value-of select="@url"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/><xsl:value-of select="@url"/>
<xsl:choose>
<xsl:when test="@idPrefixSize"><xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="substring(@id,@idPrefixSize+1)"/></xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="./*[@ftpDirectory]"><xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/><xsl:value-of select="@url"/></xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
35,7 → 51,15
</xsl:template>
<xsl:template match="d:directory" mode="linkParent">/<xsl:value-of select="@id"/></xsl:template>
<xsl:template match="d:node" mode="linkParent">
<xsl:choose>
<xsl:when test="@idPrefixSize"><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="substring(@id,@idPrefixSize+1)"/></xsl:when>
<xsl:otherwise><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="d:leaf" mode="linkParent">
<xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/>
</xsl:template>
/impl/conf/directories/style1.xsl
10,7 → 10,8
<xsl:param name="roles">professor,administrador</xsl:param>
<!--<xsl:param name="ACTUAL">pagina_a1.2.1</xsl:param>-->
<!--<xsl:param name="ACTUAL">ficha_trabalhoIncluido</xsl:param>-->
<xsl:param name="ACTUAL">pagina_teste.html</xsl:param>
<xsl:param name="ACTUAL">ionline</xsl:param>
<xsl:param name="ACTUAL_REMOTE_CHILD">FTP_3_Trabalhos</xsl:param>
<xsl:param name="includeXML">oai_dc.xml</xsl:param>
<xsl:template match="/">
380,12 → 381,100
<xsl:apply-templates select=".." mode="latNav"/>
</td>
<td class="contentPortal">
<xsl:apply-templates select="." mode="bodyContent"/>
<xsl:choose>
<xsl:when test="not(./d:*[@ftpDirectory])">
<xsl:apply-templates select="." mode="bodyContent"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="//*[@id=$ACTUAL_REMOTE_CHILD]">
<xsl:apply-templates select="//*[@id=$ACTUAL_REMOTE_CHILD]" mode="remoteChildsContent"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="remoteChildsContent"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="d:*" mode="remoteChildsContent">
<xsl:apply-templates select="." mode="topNavRemote"/>
<div class="files">
<table cellpadding="0" cellspacing="0">
<tr>
<th>
Nome do ficheiro/pasta
</th>
<th>
Data de Modificação
</th>
<th>
Tamanho
</th>
</tr>
<xsl:apply-templates select="./d:leaf[@ftpDirectory='true']" mode="ftpLine"/>
<xsl:apply-templates select="./d:leaf[@ftpDirectory='false']" mode="ftpLine"/>
</table>
</div>
</xsl:template>
<xsl:template match="d:leaf" mode="ftpLine">
<xsl:choose>
<xsl:when test="./@ftpDirectory='true'">
<tr class="dir">
<td colspan="3" >
<img>
<xsl:attribute name="src"><xsl:value-of select="$contextPath"/>/imgs/folder.gif</xsl:attribute>
</img>
<xsl:text> </xsl:text>
<xsl:apply-templates select="." mode="link"/>
</td>
</tr>
</xsl:when>
<xsl:otherwise>
<tr class="file">
<td>
<xsl:apply-templates select="." mode="mime"/><xsl:text> </xsl:text>
<xsl:apply-templates select="." mode="link"/>
</td>
<td>
<xsl:value-of select="./@lastModification"/>
</td>
<td>
<xsl:value-of select="./@size"/>
</td>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="d:leaf" mode="mime">
<img>
<xsl:attribute name="alt"><xsl:value-of select="."/></xsl:attribute>
<xsl:attribute name="src">
<xsl:choose>
<xsl:when test="contains(@extension, 'rtf')"><xsl:value-of select="$contextPath"/>/imgs/mime/doc.gif</xsl:when>
<xsl:when test="contains(@extension, 'doc')"><xsl:value-of select="$contextPath"/>/imgs/mime/doc.gif</xsl:when>
<xsl:when test="contains(@extension, 'docx')"><xsl:value-of select="$contextPath"/>/imgs/mime/doc.gif</xsl:when>
<xsl:when test="contains(@extension, 'pdf')"><xsl:value-of select="$contextPath"/>/imgs/mime/pdf.gif</xsl:when>
<xsl:when test="contains(@extension, 'ppt')"><xsl:value-of select="$contextPath"/>/imgs/mime/ppt.gif</xsl:when>
<xsl:when test="contains(@extension, 'zip')"><xsl:value-of select="$contextPath"/>/imgs/mime/zip.gif</xsl:when>
<xsl:when test="contains(@extension, 'gz')"><xsl:value-of select="$contextPath"/>/imgs/mime/zip.gif</xsl:when>
<xsl:when test="contains(@extension, 'tgz')"><xsl:value-of select="$contextPath"/>/imgs/mime/zip.gif</xsl:when>
<xsl:when test="contains(@extension, 'rar')"><xsl:value-of select="$contextPath"/>/imgs/mime/rar.gif</xsl:when>
<xsl:when test="contains(@extension, 'html')"><xsl:value-of select="$contextPath"/>/imgs/mime/html.gif</xsl:when>
<xsl:when test="contains(@extension, 'html')"><xsl:value-of select="$contextPath"/>/imgs/mime/html.gif</xsl:when>
<xsl:when test="contains(@extension, 'xls')"><xsl:value-of select="$contextPath"/>/imgs/mime/xls.gif</xsl:when>
<xsl:when test="contains(@extension, 'xlsx')"><xsl:value-of select="$contextPath"/>/imgs/mime/xls.gif</xsl:when>
<xsl:when test="contains(@extension, 'txt')"><xsl:value-of select="$contextPath"/>/imgs/mime/txt.gif</xsl:when>
<xsl:otherwise><xsl:value-of select="$contextPath"/>/imgs/mime/unknown.gif</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</img>
</xsl:template>
<!--<xsl:function name="d:parse" as="document-node()">
<xsl:param name="s" as="xs:string"/>
<xsl:sequence select="doc(concat('data:text/xml','&lt;ola&gt;teste&lt;/ola&gt;'))"/>
400,6 → 489,7
===========================================================
-->
 
<xsl:template match="d:leaf" mode="topNav">
<div id="topnav">
<ul>
439,7 → 529,28
</div>-->
</xsl:template>
<xsl:template match="d:leaf" mode="topNavRemote">
<div id="topnav">
<ul>
<li class="navPlace">
<xsl:value-of select="@label"/></li>
</ul>
</div>
</xsl:template>
<xsl:template match="d:node" mode="topNavRemote">
<div id="topnav">
<ul>
<xsl:apply-templates select=".." mode="navBackRemote"/>
<li class="navPlace">
&gt;
<xsl:apply-templates select="." mode="label"/>
</li>
</ul>
</div>
</xsl:template>
<xsl:template match="d:directory" mode="navBack">
<li class="navPlace">
<xsl:call-template name="homeLink"/>
459,6 → 570,28
</li>
</xsl:template>
<xsl:template match="d:leaf" mode="navBack">
<xsl:apply-templates select=".." mode="navBack"/>
<li class="navPlace">
&gt;
<xsl:apply-templates select="." mode="link"/>
</li>
</xsl:template>
<xsl:template match="d:leaf" mode="navBackRemote">
<li class="navPlace">
<xsl:apply-templates select="." mode="link"/>
</li>
</xsl:template>
<xsl:template match="d:node" mode="navBackRemote">
<xsl:apply-templates select=".." mode="navBackRemote"/>
<li class="navPlace">
&gt;
<xsl:apply-templates select="." mode="link"/>
</li>
</xsl:template>
<!--
===========================================================
| Barra de Navegação Lateral Esquerda
466,6 → 599,7
-->
<xsl:template match="d:node" mode="latNav">
<xsl:if test="./d:leaf or ./d:node">
<div class="linkMenuBlock">
<div class="linkMenuBlockTitle"><xsl:apply-templates select="." mode="label"/></div>
<div class="linkLeftMenu">
495,6 → 629,37
</xsl:if>
</xsl:template>
<xsl:template match="d:leaf" mode="latNav">
<xsl:if test="./d:leaf or ./d:node">
<div class="linkMenuBlock">
<div class="linkMenuBlockTitle"><xsl:apply-templates select="." mode="label"/></div>
<div class="linkLeftMenu">
<div class="listClean">
<ul id="portalMenu">
<xsl:for-each select="./d:node">
<xsl:choose>
<xsl:when test="@id = $ACTUAL">
<li class="navPlace selected">
<xsl:apply-templates select="." mode="label"/>
</li>
</xsl:when>
<xsl:otherwise>
<li class="navPlace">
<xsl:apply-templates select="." mode="link"/>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="./d:leaf">
<li class="navPlace">...<xsl:apply-templates select="." mode="link"/></li>
</xsl:for-each>
</ul>
</div>
</div>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="d:directory" mode="latNav">
<xsl:if test="./d:leaf or ./d:node">
<div class="linkMenuBlock">
/impl/src/java/jomm/web/ftp/impl/FtpFile.java
34,6 → 34,7
private String path;
private boolean directory;
private String completeUrl;
private String extension = "";
FileType fileType;
 
 
45,7 → 46,8
this.name = ftpFile.getName();
this.directory = ftpFile.isDirectory();
this.size = ftpFile.getSize();
 
if(name.lastIndexOf('.')>=0)
this.extension = name.substring(name.lastIndexOf('.'));
if (ftpFile.getType() == FTPFile.DIRECTORY_TYPE)
fileType = FileType.DIRECTORY;
else if (ftpFile.getType() == FTPFile.FILE_TYPE)
80,6 → 82,11
{
return name;
}
 
public String getExtension()
{
return extension;
}
public String getName(HttpServletRequest request) throws URIException
{
String queryAux = NavPlace.getAuxiliaryQueryString(request);
141,4 → 148,18
}
return navPlaces;
}
 
public static List<IFile> init(FTPFile[] files, String server, String path) throws URIException
{
List<IFile> iFiles = new ArrayList<IFile>();
for (FTPFile ftpFile : files)
{
IFile iFile;
if (path.endsWith("/"))
iFile = new FtpFile(ftpFile, server + URIUtil.encodePath(path +ftpFile.getName(),"ISO-8859-1"), path);
else iFile = new FtpFile(ftpFile, server + URIUtil.encodePath(path + "/" + ftpFile.getName(),"ISO-8859-1"), path);
iFiles.add(iFile);
}
return iFiles;
}
}
/impl/src/java/jomm/web/ftp/IFile.java
22,6 → 22,7
public InputStream getInputStream() throws IOException;
public Date getLastUpdate();
public String getName();
public String getExtension();
public String getName(HttpServletRequest request) throws URIException;
public long getSize();
public String getOriginalPath();
/impl/src/java/pt/estgp/estgweb/utils/Dom4jUtil.java
13,6 → 13,7
import java.net.URL;
import java.util.Hashtable;
import java.util.Map;
import java.util.HashMap;
 
import pt.estgp.estgweb.Globals;
import javax.xml.transform.TransformerFactory;
65,9 → 66,51
});
}
 
private static Map<String,byte[]> sourceXmls = new HashMap<String,byte[]>();
 
/**
* Search for Source Document in cache
*
* @param file in src tree
* @return bytes
* @throws java.io.IOException on read error
*/
public static byte[] getSourceFile(String file) throws IOException
{
byte[] bytes;
if((bytes = sourceXmls.get(file)) != null)
{
return bytes;
}
 
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
ByteArrayOutputStream output = new ByteArrayOutputStream();
int read;
byte[] buffer = new byte[1024];
while((read = stream.read(buffer)) > 0)
{
output.write(buffer,0,read);
}
output.close();
stream.close();
bytes = output.toByteArray();
sourceXmls.put(file, bytes);
return bytes;
}
 
public static Document parseSourceFileFromCache(String file) throws DocumentException, IOException
{
byte[] bytes = getSourceFile(file);
SAXReader reader = new SAXReader();
reader.setValidation(false);
createIgnoreErrorHandler(reader);
return reader.read(new ByteArrayInputStream(bytes));
}
 
public static Document parseSourceFile(String file) throws DocumentException, IOException
{
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
SAXReader reader = new SAXReader();
reader.setValidation(false);
createIgnoreErrorHandler(reader);
/impl/src/java/pt/estgp/estgweb/services/courses/CoursesCommonServices.java
107,7 → 107,7
int missing = DaoFactory.getCourseUnitDaoImpl().countMissingProgramGivenCourse(course.getId());
if(missing > 0)
{
DefaultToDo defaultToDo = new DefaultToDo(course.getName(),null,null, "course.courseunit.program.objectives.todo",""+missing,"/user/startLoadDirectedCoordinatedCoursesFromHome.do#" + course.getId());
DefaultToDo defaultToDo = new DefaultToDo(course.getName(),null,null, "course.courseunit.program.objectives.todo",""+missing,"/user/startLoadCoursesProgramsFromHome.do?area=" + course.getArea() +"#" + course.getId());
todos.add(defaultToDo);
}
}
/impl/src/java/pt/estgp/estgweb/services/common/impl/DefaultResult.java
11,6 → 11,7
public class DefaultResult implements IResult
{
 
 
private String title;
private String subTitle;
21,8 → 22,10
private boolean subTitleKey = false;
private boolean textKey = false;
 
private LabelGroup subTitlesGroup = null;
 
 
 
public DefaultResult() {
}
 
90,4 → 93,15
public void setSubTitleKey(boolean subTitleKey) {
this.subTitleKey = subTitleKey;
}
 
 
public LabelGroup getSubTitlesGroup()
{
return subTitlesGroup;
}
 
public void setSubTitlesGroup(LabelGroup subTitlesGroup)
{
this.subTitlesGroup = subTitlesGroup;
}
}
/impl/src/java/pt/estgp/estgweb/services/common/IResult.java
1,5 → 1,8
package pt.estgp.estgweb.services.common;
 
import java.util.List;
import java.util.ArrayList;
 
/**
* @author Jorge Machado
* @date 24/Abr/2008
16,4 → 19,85
public String getText();
public boolean isTextKey();
public String getUrl();
public LabelGroup getSubTitlesGroup();
 
/**
* Class to support groups of labels
* usefull to add groups of message keys
*/
public static class LabelGroup
{
private String title;
private boolean key;
 
private List<Label> labels;
 
public LabelGroup()
{
labels = new ArrayList<Label>();
}
 
public List<Label> getLabels()
{
return labels;
}
 
public void setLabels(List<Label> labels)
{
this.labels = labels;
}
 
 
public String getTitle()
{
return title;
}
 
public void setTitle(String title)
{
this.title = title;
}
 
public boolean isKey()
{
return key;
}
 
public void setKey(boolean key)
{
this.key = key;
}
}
public static class Label
{
private String label;
private boolean key;
 
 
public Label(String label, boolean key)
{
this.label = label;
this.key = key;
}
 
public String getLabel()
{
return label;
}
 
public void setLabel(String label)
{
this.label = label;
}
 
public boolean isKey()
{
return key;
}
 
public void setKey(boolean key)
{
this.key = key;
}
}
}
/impl/src/java/pt/estgp/estgweb/services/profile/ProfileCommonServices.java
8,6 → 8,7
import pt.estgp.estgweb.services.courseunits.CourseUnitsCommonServices;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.Globals;
import org.apache.log4j.Logger;
 
import java.util.List;
57,6 → 58,25
{
DefaultResult defaultResult = new DefaultResult();
defaultResult.setTitle(u.getName());
defaultResult.setSubTitleKey(true);
 
if(u.hasRole(Globals.TEACHER_ROLE))
{
defaultResult.setSubTitle("user.role." + Globals.TEACHER_ROLE);
}
else if(u.hasRole(Globals.STUDENT_ROLE))
{
defaultResult.setSubTitle("user.role." + Globals.STUDENT_ROLE);
}else if(u.isSuperuser())
{
defaultResult.setSubTitle("superuser");
}
else if(u.isAdmin())
{
defaultResult.setSubTitle("user.role." + Globals.ADMIN_ROLE);
}
 
if (from == null)
defaultResult.setUrl("/startProfile.do?userView.id=" + u.getId());
else
/impl/src/java/pt/estgp/estgweb/domain/GenericUserImpl.java
9,6 → 9,10
 
import org.apache.log4j.Logger;
 
import javax.servlet.http.HttpServletRequest;
 
import jomm.utils.MessageResources;
 
/**
* @author Jorge Machado
* @date 2/Mar/2008
97,4 → 101,19
{
return isSuperuser() || isAdmin();
}
 
public String getRolesDescription(HttpServletRequest request,String separator)
{
String sep = "";
StringBuilder strBuilder = new StringBuilder();
for (String role : getRolesList())
{
if (!role.equals(Globals.SUPER_USER_ROLE))
{
strBuilder.append(sep + MessageResources.getMessage(request, "user.role." + role));
sep = separator;
}
}
return strBuilder.toString();
}
}
/impl/src/java/pt/estgp/estgweb/web/DirWebProxy.java
2,8 → 2,9
 
import org.apache.log4j.Logger;
import org.apache.commons.httpclient.util.URIUtil;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.dom4j.*;
import org.dom4j.io.OutputFormat;
 
import javax.servlet.http.HttpServlet;
13,9 → 14,7
import javax.servlet.jsp.JspWriter;
import java.io.*;
import java.net.*;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import java.util.*;
import java.util.zip.ZipInputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
25,6 → 24,10
import pt.estgp.estgweb.domain.UserSession;
import freemarker.template.utility.HtmlEscape;
import com.lowagie.text.html.HtmlEncoder;
import jomm.web.ftp.IFile;
import jomm.web.ftp.FileType;
import jomm.web.ftp.impl.FtpFile;
import jomm.web.utils.NavPlace;
 
/**
* @author Jorge Machado
50,19 → 53,18
{
 
String element = (String) request.getAttribute("element");
if(element.equals("node"))
if (element.equals("node"))
{
processNode(request,response);
processNode(request, response);
}
else
{
processLeaf(request,response);
processLeaf(request, response);
}
}
 
 
/**
*
* @param request
* @param response
* @throws ServletException
72,16 → 74,19
protected static void processNode(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
styleDirectory(request,response);
styleDirectory(request, response);
}
 
protected static void processLeaf(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String path = (String) request.getAttribute("path");
String startPath = (String) request.getAttribute("startPath");
String leafUrl = (String) request.getAttribute("leaf.url");
String server = (String) request.getAttribute("server");
String useOutputStream = (String) request.getAttribute("useOutputStream");
String encoding = (String) request.getAttribute("encoding");
String proxyKey = (String) request.getAttribute("proxyKey");
String proxyHost = (String) request.getAttribute("proxy.host");
String proxyPort = (String) request.getAttribute("proxy.port");
boolean style = Boolean.parseBoolean((String) request.getAttribute("style"));
90,6 → 95,7
 
logger.info("server:" + server);
logger.info("path:" + path);
logger.info("proxyKey:" + proxyKey);
logger.info("proxyHost:" + proxyHost);
logger.info("proxyPort:" + proxyPort);
logger.info("xml:" + xml);
108,34 → 114,53
 
 
String finalURL = server + URIUtil.encodePath(path, "ISO-8859-1");
URL url = new URL(finalURL);
 
if (!finalURL.startsWith("ftp://"))
{
URL url = new URL(finalURL);
 
if (useOutputStream != null && useOutputStream.equals("true"))
{
InputStream stream = openStream(finalURL,proxy);
URLConnection con = url.openConnection();
response.setContentType(con.getContentType());
if(xml == null || xml.equals("false"))
response.setCharacterEncoding(encoding);
response.setContentLength(con.getContentLength());
writeDirectStream(response,stream);
if (useOutputStream != null && useOutputStream.equals("true"))
{
InputStream stream = openStream(finalURL, proxy);
URLConnection con = url.openConnection();
response.setContentType(con.getContentType());
if (xml == null || xml.equals("false"))
response.setCharacterEncoding(encoding);
response.setContentLength(con.getContentLength());
writeDirectStream(response, stream);
}
else if (xml == null || xml.equals("false"))
{
InputStream stream = openStream(finalURL, proxy);
String content = readContent2String(stream, encoding);
generateOutputLeaf(response, request, content, style);
}
else
{
URLConnection con = new URL(finalURL).openConnection();
con.connect();
if (con.getContentLength() > 0)
{
// Document dom = Dom4jUtil.parse(stream);
generateOutputLeafXml(response, request, finalURL, proxy, style);
}
}
}
else if(xml == null || xml.equals("false"))
else
{
InputStream stream = openStream(finalURL,proxy);
String content = readContent2String(stream,encoding);
generateOutputLeaf(response,request,content,style);
}
else
{
URLConnection con = new URL(finalURL).openConnection();
con.connect();
if(con.getContentLength()>0)
Document directoryDocument = (Document) request.getAttribute("directoryDocument");
if(leafUrl != null && leafUrl.length() > 0)
{
// Document dom = Dom4jUtil.parse(stream);
generateOutputLeafXml(response,request,finalURL,proxy,style);
String endPath = "";
if(startPath != null)
{
endPath = path.substring(startPath.length());
}
path = startPath + leafUrl + endPath;
}
extendDiretoryDocument(request, path, proxyKey, server, startPath + leafUrl, directoryDocument);
Dom4jUtil.write(directoryDocument,"d:/out.xml");
styleDirectory(request, response);
}
}
catch (FileNotFoundException e)
153,15 → 178,178
logger.warn("url not found for server:" + server + " and path:" + path);
response.sendError(404);
}
}
 
 
public static String FTP_FILE_PREFIX = "FTP_";
 
public static void addAttribute(Element element, String name, String value)
{
element.addAttribute(name, value);
}
 
 
private static void generateOutputLeafXml(HttpServletResponse response,HttpServletRequest request, String finalURL,Proxy proxy, boolean style) throws IOException, DocumentException
protected static void extendDiretoryDocument(HttpServletRequest request, String path, String serverStr, String server, String startPath, Document directoryDocument)
throws ServletException, IOException
{
if(style)
try
{
Map<String,Object> parameters = new HashMap<String,Object>();
String user = ConfigProperties.getProperty(serverStr + ".user");
String pass = ConfigProperties.getProperty(serverStr + ".pass");
 
if (path != null)
{
 
FtpServer ftpServer = FtpServer.getServer(server, user, pass);
FTPClient client = ftpServer.getClient();
 
Element actualNode = (Element) request.getAttribute("actualNode");
 
if(startPath.equals("/"))
startPath = "";
if (path.equals(startPath))
{
client.changeWorkingDirectory(path);
FTPFile[] files = client.listFiles();
List<IFile> iFiles = FtpFile.init(files, server, path);
//root
for (IFile iFile : iFiles)
{
Element iFileElem = actualNode.addElement("leaf");
addAttribute(iFileElem, "id", FTP_FILE_PREFIX + "0_" + iFile.getName());
addAttribute(iFileElem, "idPrefixSize","" + (FTP_FILE_PREFIX + "0_").length());
addAttribute(iFileElem, "label", iFile.getName());
addAttribute(iFileElem, "visualization", "filesystem");
addAttribute(iFileElem, "size", "" + iFile.getSize());
addAttribute(iFileElem, "lastModification", "" + iFile.getLastUpdate().toString());
if (iFile.getType() == FileType.DIRECTORY)
{
addAttribute(iFileElem, "ftpDirectory", "true");
}
else
{
addAttribute(iFileElem, "ftpDirectory", "false");
addAttribute(iFileElem, "absolute", "true");
addAttribute(iFileElem, "url", iFile.getCompleteUrl());
}
}
}
else
{
 
String pathAux = path.substring(startPath.length());
String[] pathFragments;
if(path.startsWith("/"))
pathFragments = pathAux.substring(1).split("/");
else
pathFragments = pathAux.split("/");
 
 
client.changeWorkingDirectory(startPath);
FTPFile[] files = client.listFiles();
List<IFile> iFiles = FtpFile.init(files, server, path);
Element goDeepElement = null;
String actualId = null;
for (IFile iFile : iFiles)
{
Element iFileElem = actualNode.addElement("node");
 
addAttribute(iFileElem, "id", FTP_FILE_PREFIX + "0_" + iFile.getName());
addAttribute(iFileElem, "idPrefixSize","" + (FTP_FILE_PREFIX + "0_").length());
 
addAttribute(iFileElem, "label", iFile.getName());
addAttribute(iFileElem, "visualization", "filesystem");
addAttribute(iFileElem, "size", "" + iFile.getSize());
addAttribute(iFileElem, "lastModification", "" + iFile.getLastUpdate().toString());
if (iFile.getType() == FileType.DIRECTORY)
{
addAttribute(iFileElem, "ftpDirectory", "true");
}
else
{
addAttribute(iFileElem, "ftpDirectory", "false");
addAttribute(iFileElem, "absolute", "true");
addAttribute(iFileElem, "url", iFile.getCompleteUrl());
}
 
if (iFile.getName().equals(pathFragments[0]))
{
actualId = FTP_FILE_PREFIX + "0_" + iFile.getName();
goDeepElement = iFileElem;
}
}
 
 
 
String startPathAux = startPath;
for (int i = 0; i < pathFragments.length; i++)
{
Element nextGoDeepElement = null;
String d = pathFragments[i];
startPathAux = startPathAux + "/" + d;
client.changeWorkingDirectory(startPathAux);
files = client.listFiles();
iFiles = FtpFile.init(files, server, path);
 
for (IFile iFile : iFiles)
{
Element iFileElem;
 
if(i == pathFragments.length - 1)
iFileElem = goDeepElement.addElement("leaf");
else
iFileElem = goDeepElement.addElement("node");
 
addAttribute(iFileElem, "id", FTP_FILE_PREFIX + (i+1) + "_" + iFile.getName());
addAttribute(iFileElem, "idPrefixSize","" + (FTP_FILE_PREFIX + (i+1) + "_").length());
addAttribute(iFileElem, "label", iFile.getName());
addAttribute(iFileElem, "visualization", "filesystem");
addAttribute(iFileElem, "size", "" + iFile.getSize());
addAttribute(iFileElem, "lastModification", "" + iFile.getLastUpdate().toString());
if (iFile.getType() == FileType.DIRECTORY)
{
addAttribute(iFileElem, "ftpDirectory", "true");
}
else
{
addAttribute(iFileElem, "extension", iFile.getExtension());
addAttribute(iFileElem, "ftpDirectory", "false");
addAttribute(iFileElem, "absolute", "true");
addAttribute(iFileElem, "url", iFile.getCompleteUrl());
}
 
if (i < pathFragments.length - 1 && iFile.getName().equals(pathFragments[i + 1]))
{
nextGoDeepElement = iFileElem;
actualId = FTP_FILE_PREFIX + (i+1) + "_" + iFile.getName();
}
}
goDeepElement = nextGoDeepElement;
}
request.setAttribute("ACTUAL_REMOTE_CHILD",actualId);
}
client.quit();
client.disconnect();
}
else
{
throw new FileNotFoundException("url not found for server:" + server + " and path:" + path);
}
}
catch (Throwable e)
{
logger.error(e, e);
}
}
 
 
private static void generateOutputLeafXml(HttpServletResponse response, HttpServletRequest request, String finalURL, Proxy proxy, boolean style) throws IOException, DocumentException
{
if (style)
{
Map<String, Object> parameters = new HashMap<String, Object>();
// OutputFormat outputFormat = new OutputFormat();
// outputFormat.setSuppressDeclaration(true);
// outputFormat.setEncoding("UTF-8");
169,24 → 357,24
// Dom4jUtil.write(dom,writer, outputFormat);
// org.w3c.dom.Document d = new org.dom4j.io.DOMWriter().write(dom);
// parameters.put("body",dom.selectSingleNode("/"));
parameters.put("includeXML",finalURL);
styleDirectory(request,response,parameters,null);
parameters.put("includeXML", finalURL);
styleDirectory(request, response, parameters, null);
}
else
{
InputStream stream = openStream(finalURL,proxy);
InputStream stream = openStream(finalURL, proxy);
Document dom = Dom4jUtil.parse(stream);
Dom4jUtil.write(dom,response.getWriter());
Dom4jUtil.write(dom, response.getWriter());
}
}
 
private static void generateOutputLeaf(HttpServletResponse response,HttpServletRequest request, String content, boolean style) throws IOException
private static void generateOutputLeaf(HttpServletResponse response, HttpServletRequest request, String content, boolean style) throws IOException
{
if(style)
if (style)
{
// Map<String,Object> parameters = new HashMap<String,Object>();
// parameters.put("body",content);
styleDirectory(request,response,new HashMap<String,Object>(),content);
styleDirectory(request, response, new HashMap<String, Object>(), content);
}
else
{
196,35 → 384,56
 
private static void styleDirectory(HttpServletRequest request, HttpServletResponse response) throws IOException
{
styleDirectory(request,response,new HashMap<String,Object>(),null);
styleDirectory(request, response, new HashMap<String, Object>(), null);
}
 
private static void styleDirectory(HttpServletRequest request, HttpServletResponse response, Map<String,Object> parameters, String bodyContent) throws IOException
// private static String normalizeXmlId(String id)
// {
// StringBuilder strBuilder = new StringBuilder();
// strBuilder.append('_');
// for(int i = 0; i < id.length();i++)
// {
// char c = id.charAt(i);
// if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))
// {
// strBuilder.append(c);
// }
// else
// {
// strBuilder.append('.');
// }
// }
// return strBuilder.toString();
// }
 
private static void styleDirectory(HttpServletRequest request, HttpServletResponse response, Map<String, Object> parameters, String bodyContent) throws IOException
{
String stylesheet = (String) request.getAttribute("stylesheet");
Document directoryDocument = (Document) request.getAttribute("directoryDocument");
String actualNodeId = (String) request.getAttribute("actualNodeId");
String actualRemoteNodeId = (String) request.getAttribute("ACTUAL_REMOTE_CHILD");
UserSession userSession = UserSessionProxy.loadUserSessionFromRequest(request);
 
parameters.put("contextPath",request.getContextPath());
if(userSession.getUsername() != null)
parameters.put("username",userSession.getUsername());
if(userSession.getName() != null)
parameters.put("name",userSession.getName());
if(userSession.getUser() != null)
parameters.put("roles",userSession.getUser().getRoles());
parameters.put("ACTUAL",actualNodeId);
parameters.put("contextPath", request.getContextPath());
if (userSession.getUsername() != null)
parameters.put("username", userSession.getUsername());
if (userSession.getName() != null)
parameters.put("name", userSession.getName());
if (userSession.getUser() != null)
parameters.put("roles", userSession.getUser().getRoles());
parameters.put("ACTUAL", actualNodeId);
parameters.put("ACTUAL_REMOTE_CHILD", actualRemoteNodeId);
 
try
{
String html = Dom4jUtil.styleDocument(directoryDocument,stylesheet,parameters);
if(bodyContent != null)
html = html.replace("@@BODY_CONTENT@@",bodyContent);
String html = Dom4jUtil.styleDocument(directoryDocument, stylesheet, parameters);
if (bodyContent != null)
html = html.replace("@@BODY_CONTENT@@", bodyContent);
response.getWriter().write(html);
}
catch (Exception e)
{
logger.error(e,e);
logger.error(e, e);
response.sendError(500);
}
}
/impl/src/java/pt/estgp/estgweb/web/DirLayoutController.java
13,8 → 13,7
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.*;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
41,7 → 40,13
 
private static final Logger logger = Logger.getLogger(DirLayoutController.class);
 
public static Map<String, String> namespaces = new HashMap<String, String>();
 
static
{
namespaces.put("d", "http://www.estgp.pt/baco/directory/");
}
 
private static enum DirectoryNodeType
{
node,
104,15 → 109,14
String directory = request.getParameter("directory");
String path = request.getParameter("path");
 
 
try
{
Document directoryDocument = Dom4jUtil.parseSourceFile("/pt/estgp/estgweb/directories/" + directory + ".xml");
Document directoryDocument = Dom4jUtil.parseSourceFileFromCache("/pt/estgp/estgweb/directories/" + directory + ".xml");
 
if (path.startsWith("/"))
path = path.substring(1);
String[] ids = path.split("/");
Map<String, String> namespaces = new HashMap<String, String>();
 
DirectoryNodeType directoryNodeType = null;
String actualNodeId = null;
Element actualNode = null;
121,7 → 125,7
for (String id : ids)
{
XPath idXpath = directoryDocument.createXPath("//*[@id='" + id + "']");
namespaces.put("d", "http://www.estgp.pt/baco/directory/");
 
idXpath.setNamespaceURIs(namespaces);
Element idElem = (Element) idXpath.selectSingleNode(directoryDocument);
if (idElem == null)
173,7 → 177,7
}
String externalFile = buildExternalFile(stopName, ids);
 
putInRequestCommonAttributes(request, actualNodeId, directoryDocument);
putInRequestCommonAttributes(request,actualNode, actualNodeId, directoryDocument);
 
Attribute layoutStrAtt = directoryDocument.getRootElement().attribute("layout");
Attribute layoutRootStrAtt = directoryDocument.getRootElement().attribute("layoutRoot");
213,7 → 217,7
boolean layoutDo = true;
if (layout != null && layout.length() > 0) layoutDo = Boolean.parseBoolean(layout);
if (!layoutDo) layoutChoosed = "layoutEmpty";
putProxyAttributes(request, proxy, externalFile,xml);
putProxyAttributes(request, proxy, externalFile,xml,url);
request.setAttribute("label", label);
request.setAttribute("style", style);
request.setAttribute("xml", xml);
249,19 → 253,23
return (actualNode.attribute(name) != null ? actualNode.attribute(name).getValue() : null);
}
 
private void putProxyAttributes(HttpServletRequest request, String proxy, String externalFile, String xml)
private void putProxyAttributes(HttpServletRequest request, String proxy, String externalFile, String xml, String url)
{
String server = ConfigProperties.getProperty("server." + proxy);
String proxyHost = ConfigProperties.getProperty(proxy + ".proxy.host");
String proxyPort = ConfigProperties.getProperty(proxy + ".proxy.port");
String confStartPath = ConfigProperties.getProperty("server." + proxy + ".start.path");
 
 
request.setAttribute("leaf.url", url);
request.setAttribute("server", server);
request.setAttribute("proxyKey", proxy);
request.setAttribute("proxy.host", proxyHost);
request.setAttribute("proxy.port", proxyPort);
if (confStartPath != null)
externalFile = confStartPath + externalFile;
request.setAttribute("path", externalFile);
request.setAttribute("startPath", confStartPath);
 
if(xml != null && xml.equals("true"))
{
280,10 → 288,11
return;
}
}
request.setAttribute("useOutputStream", "true");
if(!server.startsWith("ftp://"))
request.setAttribute("useOutputStream", "true");
}
 
private void putInRequestCommonAttributes(HttpServletRequest request, String actualNameId, Document directoryDocument)
private void putInRequestCommonAttributes(HttpServletRequest request,Element actualNode, String actualNameId, Document directoryDocument)
{
/**
* Attributes used in Nodes and Leafs
301,6 → 310,7
request.setAttribute("stylesheet", "/pt/estgp/estgweb/directories/" + styleChoosed);
request.setAttribute("directoryDocument", directoryDocument);
request.setAttribute("actualNodeId", actualNameId);
request.setAttribute("actualNode", actualNode);
request.setAttribute("targetRole", targetRoleChoosed);
}
 
335,9 → 345,9
return null;
}
 
Namespace dirNamespace = new Namespace("d", "http://www.estgp.pt/baco/directory/");
QName nodeDir = new QName("node", dirNamespace);
QName leafDir = new QName("leaf", dirNamespace);
public static Namespace dirNamespace = new Namespace("d", "http://www.estgp.pt/baco/directory/");
public static QName nodeDir = new QName("node", dirNamespace);
public static QName leafDir = new QName("leaf", dirNamespace);
 
private boolean pruneDocument(Element startElem, Map namespaces, UserSession userSession)
{
503,165 → 513,6
}
 
 
protected void processRequestFtp(HttpServletRequest request, String path, String serverStr, String server, String startPath)
throws ServletException, IOException
{
try
{
String user = ConfigProperties.getProperty(serverStr + ".user");
String pass = ConfigProperties.getProperty(serverStr + ".pass");
 
if (path != null)
{
 
DirLayoutController.FtpServer ftpServer = getServer(server, user, pass);
FTPClient client = ftpServer.getClient();
client.changeWorkingDirectory(path);
FTPFile[] files = client.listFiles();
List<IFile> iFiles = new ArrayList<IFile>();
for (FTPFile ftpFile : files)
{
IFile iFile;
if (path.endsWith("/"))
iFile = new FtpFile(ftpFile, server + URIUtil.encodePath(path + ftpFile.getName(), "ISO-8859-1"), path);
else
iFile = new FtpFile(ftpFile, server + URIUtil.encodePath(path + "/" + ftpFile.getName(), "ISO-8859-1"), path);
iFiles.add(iFile);
}
List<NavPlace> navPlaces = FtpFile.getNavPlaces(path, startPath);
request.setAttribute("NavPlaces", navPlaces);
request.setAttribute("files", iFiles);
client.quit();
client.disconnect();
}
else
{
throw new FileNotFoundException("url not found for server:" + server + " and path:" + path);
}
}
catch (Throwable e)
{
logger.error(e, e);
}
}
 
private static HashMap<String, FtpServer> servers = new HashMap<String, DirLayoutController.FtpServer>();
 
/**
* Add a ftpServer to Cache
*
* @param urlStr to parse
* @param user username
* @param pass password
* @return ftpServer
*/
private static synchronized DirLayoutController.FtpServer addServer(String urlStr, String user, String pass)
{
try
{
URL url = new URL(urlStr);
String host = url.getHost();
int port = url.getPort();
if (port <= 0)
port = 21;
logger.info("Connecting to " + host + "in port:" + port);
DirLayoutController.FtpServer ftpServer = new DirLayoutController.FtpServer(host, port, user, pass);
servers.put(urlStr, ftpServer);
return ftpServer;
}
catch (MalformedURLException e)
{
logger.error(e, e);
}
catch (IOException e)
{
logger.error(e, e);
}
return null;
}
 
private static DirLayoutController.FtpServer getServer(String urlStr, String user, String pass)
{
DirLayoutController.FtpServer ftpServer = servers.get(urlStr);
if (ftpServer == null)
ftpServer = addServer(urlStr, user, pass);
return ftpServer;
}
 
public static class FtpServer
{
String host = null;
int port = 21;
String username = null;
String password = null;
 
 
public FtpServer(String host, int port)
{
this.host = host;
if (port > 0)
this.port = port;
}
 
public FtpServer(String host, int port, String username, String password)
{
this.host = host;
this.port = port;
this.username = username;
this.password = password;
}
 
public FTPClient getClient() throws IOException
{
FTPClient ftp = new FTPClient();
ftp.connect(host, port);
if (username != null)
ftp.user(username);
if (password != null)
ftp.pass(password);
return ftp;
}
 
public String getHost()
{
return host;
}
 
public void setHost(String host)
{
this.host = host;
}
 
public int getPort()
{
return port;
}
 
public void setPort(int port)
{
this.port = port;
}
 
public String getUsername()
{
return username;
}
 
public void setUsername(String username)
{
this.username = username;
}
 
public String getPassword()
{
return password;
}
 
public void setPassword(String password)
{
this.password = password;
}
}
 
 
}
/impl/src/java/pt/estgp/estgweb/web/FtpServer.java
New file
0,0 → 1,138
package pt.estgp.estgweb.web;
 
import org.apache.commons.net.ftp.FTPClient;
import org.apache.log4j.Logger;
 
import java.util.HashMap;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
 
/**
* @author Jorge
* @date 18/Jan/2009
* @time 18:35:11
*/
public class FtpServer
{
private static final Logger logger = Logger.getLogger(FtpServer.class);
 
 
private static HashMap<String, FtpServer> servers = new HashMap<String, FtpServer>();
 
 
 
 
String host = null;
int port = 21;
String username = null;
String password = null;
 
 
public FtpServer(String host, int port)
{
this.host = host;
if (port > 0)
this.port = port;
}
 
public FtpServer(String host, int port, String username, String password)
{
this.host = host;
this.port = port;
this.username = username;
this.password = password;
}
 
public FTPClient getClient() throws IOException
{
FTPClient ftp = new FTPClient();
ftp.connect(host, port);
if (username != null)
ftp.user(username);
if (password != null)
ftp.pass(password);
return ftp;
}
 
public String getHost()
{
return host;
}
 
public void setHost(String host)
{
this.host = host;
}
 
public int getPort()
{
return port;
}
 
public void setPort(int port)
{
this.port = port;
}
 
public String getUsername()
{
return username;
}
 
public void setUsername(String username)
{
this.username = username;
}
 
public String getPassword()
{
return password;
}
 
public void setPassword(String password)
{
this.password = password;
}
 
public static FtpServer getServer(String urlStr, String user, String pass)
{
FtpServer ftpServer = servers.get(urlStr);
if (ftpServer == null)
ftpServer = addServer(urlStr, user, pass);
return ftpServer;
}
 
/**
* Add a ftpServer to Cache
*
* @param urlStr to parse
* @param user username
* @param pass password
* @return ftpServer
*/
private static synchronized FtpServer addServer(String urlStr, String user, String pass)
{
try
{
URL url = new URL(urlStr);
String host = url.getHost();
int port = url.getPort();
if (port <= 0)
port = 21;
logger.info("Connecting to " + host + "in port:" + port);
FtpServer ftpServer = new FtpServer(host, port, user, pass);
servers.put(urlStr, ftpServer);
return ftpServer;
}
catch (MalformedURLException e)
{
logger.error(e, e);
}
catch (IOException e)
{
logger.error(e, e);
}
return null;
}
}
/impl/src/java/pt/estgp/estgweb/web/LayoutController.java
122,7 → 122,7
if (path != null)
{
 
FtpServer ftpServer = getServer(server, user, pass);
FtpServer ftpServer = FtpServer.getServer(server, user, pass);
FTPClient client = ftpServer.getClient();
client.changeWorkingDirectory(path);
FTPFile[] files = client.listFiles();
151,124 → 151,4
logger.error(e, e);
}
}
 
private static HashMap<String, FtpServer> servers = new HashMap<String, FtpServer>();
 
/**
* Add a ftpServer to Cache
*
* @param urlStr to parse
* @param user username
* @param pass password
* @return ftpServer
*/
private static synchronized FtpServer addServer(String urlStr, String user, String pass)
{
try
{
URL url = new URL(urlStr);
String host = url.getHost();
int port = url.getPort();
if (port <= 0)
port = 21;
logger.info("Connecting to " + host + "in port:" + port);
FtpServer ftpServer = new FtpServer(host, port, user, pass);
servers.put(urlStr, ftpServer);
return ftpServer;
}
catch (MalformedURLException e)
{
logger.error(e, e);
}
catch (IOException e)
{
logger.error(e, e);
}
return null;
}
 
private static FtpServer getServer(String urlStr, String user, String pass)
{
FtpServer ftpServer = servers.get(urlStr);
if (ftpServer == null)
ftpServer = addServer(urlStr, user, pass);
return ftpServer;
}
 
public static class FtpServer
{
String host = null;
int port = 21;
String username = null;
String password = null;
 
 
public FtpServer(String host, int port)
{
this.host = host;
if (port > 0)
this.port = port;
}
 
public FtpServer(String host, int port, String username, String password)
{
this.host = host;
this.port = port;
this.username = username;
this.password = password;
}
 
public FTPClient getClient() throws IOException
{
FTPClient ftp = new FTPClient();
ftp.connect(host, port);
if (username != null)
ftp.user(username);
if (password != null)
ftp.pass(password);
return ftp;
}
 
public String getHost()
{
return host;
}
 
public void setHost(String host)
{
this.host = host;
}
 
public int getPort()
{
return port;
}
 
public void setPort(int port)
{
this.port = port;
}
 
public String getUsername()
{
return username;
}
 
public void setUsername(String username)
{
this.username = username;
}
 
public String getPassword()
{
return password;
}
 
public void setPassword(String password)
{
this.password = password;
}
}
 
 
}
/impl/src/java/pt/estgp/estgweb/web/UserSessionProxy.java
56,6 → 56,7
IServiceManager sm = ServiceManager.getInstance();
Object[] args = new Object[]{RequestUtils.getRequester(request, response)};
UserSession userSession = (UserSession) sm.execute(RequestUtils.getRequester(request, response),"LoadUserSession",args);
userSession.setRequest(request);
request.setAttribute(Globals.USER_SESSION_KEY,userSession);
return userSession;
}
/impl/src/java/pt/estgp/estgweb/web/filters/UserSessionFilter.java
76,8 → 76,6
}
}
 
 
String path =((HttpServletRequest)request).getServletPath();
if(((HttpServletRequest)request).getServletPath().indexOf("errorNoCookies.do")>=0 || !hrequest.isRequestedSessionIdFromCookie())
chain.doFilter(request,response);
try
/impl/src/doc/Programas0809.doc
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+ application/octet-stream
/impl/src/web/css/style.css
209,13 → 209,13
text-align:left;
}
 
#content a
#content a, .files a
/*, .content a:visited*/
{
color: #4d4d4d;
}
 
#content a:hover {
#content a:hover, .files a:hover {
color: #8EC73F
}
 
/impl/src/web/layout/navigationTop.jsp
21,15 → 21,16
<li class="submenu"><a href="#">Apresentação</a>
<div class="shadow ">
<ul class="menu">
<li><a href="#">Mensagem do Presidente</a></li>
<li><a href="<%=request.getContextPath()%>/proxy/layout4/estgp/public/portal/estgMensagemPresidente.html">Mensagem do Presidente</a></li>
<li><a href="#">A ESTG e a sua missão</a></li>
<li><a href="#">História</a></li>
<li><a href="#">Localização</a></li>
<li><a href="#">Factos e números</a></li>
<li><a href="<%=request.getContextPath()%>/proxy/layout4/estgp/public/portal/estgComoChegarEstg.html">Localização</a></li>
<li><a href="<%=request.getContextPath()%>/proxy/estgFuturosAlunosPortalMenu/estgp/public/portal/estgNumeros.html">Factos e números</a></li>
<li><a href="#">A ESTG em Fotografias</a></li>
</ul>
</div>
</li>
<li class="submenu"><a href="<%=request.getContextPath()%>/proxy/layout4/estgp/public/portal/contactosContactosGeraisEstg.html">Contactos</a></li>
<li class="submenu"><a href="#"><bean:message key="organization"/> </a>
 
<div class="shadow">
/impl/src/web/public/search/searchResults.jsp
1,6 → 1,4
<%@ page import="pt.estgp.estgweb.services.common.*" %>
<%@ page import="pt.estgp.estgweb.web.Globals" %>
<%@ page import="jomm.utils.ConfigProperties" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
181,6 → 179,26
</logic:notEqual>
)
</logic:notEmpty>
<logic:notEmpty name="result" property="subTitlesGroup">
(
<%
String subTitleSeparator = "";
%>
<logic:iterate id="subTitleLabel" name="result" property="subTitlesGroup.labels">
<%=subTitleSeparator%>
<logic:equal value="true" name="subTitleLabel" property="key">
<bean:message key="${subTitleLabel.label}"/>
</logic:equal>
<logic:notEqual value="true" name="subTitleLabel" property="key">
${subTitleLabel.label}
</logic:notEqual>
 
<%
subTitleSeparator = ", ";
%>
</logic:iterate>
)
</logic:notEmpty>
</h2>
 
<p>${result.bestFragments} ...</p>