Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 379 → Rev 380

/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/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
11,7 → 11,7
<!--<xsl:param name="ACTUAL">pagina_a1.2.1</xsl:param>-->
<!--<xsl:param name="ACTUAL">ficha_trabalhoIncluido</xsl:param>-->
<xsl:param name="ACTUAL">ionline</xsl:param>
<xsl:param name="ACTUAL_REMOTE_CHILD"></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="/">
382,7 → 382,7
</td>
<td class="contentPortal">
<xsl:choose>
<xsl:when test="not(./d:leaf)">
<xsl:when test="not(./d:*[@ftpDirectory])">
<xsl:apply-templates select="." mode="bodyContent"/>
</xsl:when>
<xsl:otherwise>
401,12 → 401,9
</table>
</xsl:template>
<xsl:template match="d:node" mode="remoteChildsContent">
<xsl:template match="d:*" mode="remoteChildsContent">
<xsl:apply-templates select="." mode="topNavRemote"/>
 
</xsl:template>
<xsl:template match="d:leaf" mode="remoteChildsContent">
<xsl:apply-templates select="." mode="topNavRemote"/>
<div class="files">
<table cellpadding="0" cellspacing="0">
<tr>
420,38 → 417,64
Tamanho
</th>
</tr>
<xsl:apply-templates select="./d:leaf[@d:ftpDirectory='true']" mode="ftpLine"/>
<xsl:apply-templates select="./d:leaf[@d:ftpDirectory='false']" mode="ftpLine"/>
<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="./@d:ftpDirectory='true'">
<tr>
<td colspan="3">
<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:value-of select="@d:label"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="." mode="link"/>
</td>
</tr>
</xsl:when>
<xsl:otherwise>
<tr>
<tr class="file">
<td>
<xsl:value-of select="./@d:label"/>
<xsl:apply-templates select="." mode="mime"/><xsl:text> </xsl:text>
<xsl:apply-templates select="." mode="link"/>
</td>
<td>
<xsl:value-of select="./@d:lastModification"/>
<xsl:value-of select="./@lastModification"/>
</td>
<td>
<xsl:value-of select="./@d:size"/>
<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;'))"/>
466,6 → 489,7
===========================================================
-->
 
<xsl:template match="d:leaf" mode="topNav">
<div id="topnav">
<ul>
509,8 → 533,7
<div id="topnav">
<ul>
<li class="navPlace">
raiz
</li>
<xsl:value-of select="@label"/></li>
</ul>
</div>
</xsl:template>
547,15 → 570,22
</li>
</xsl:template>
<xsl:template match="d:leaf" mode="navBackRemote">
<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="navBack"/>
<xsl:apply-templates select=".." mode="navBackRemote"/>
<li class="navPlace">
&gt;
<xsl:apply-templates select="." mode="link"/>
569,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">
598,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);
/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/web/DirWebProxy.java
149,7 → 149,17
else
{
Document directoryDocument = (Document) request.getAttribute("directoryDocument");
if(leafUrl != null && leafUrl.length() > 0)
{
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);
}
}
175,7 → 185,7
 
public static void addAttribute(Element element, String name, String value)
{
element.addAttribute(new QName(name, DirLayoutController.dirNamespace), value);
element.addAttribute(name, value);
}
 
 
205,8 → 215,10
//root
for (IFile iFile : iFiles)
{
Element iFileElem = actualNode.addElement(DirLayoutController.leafDir);
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());
227,17 → 239,25
{
 
String pathAux = path.substring(startPath.length());
String[] pathFragments = pathAux.split("/");
String[] pathFragments;
if(path.startsWith("/"))
pathFragments = pathAux.substring(1).split("/");
else
pathFragments = pathAux.split("/");
 
client.changeWorkingDirectory(startPath);
 
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(DirLayoutController.nodeDir);
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());
254,29 → 274,36
}
 
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];
String startPathAux = startPath + "/" + d;
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(DirLayoutController.leafDir);
iFileElem = goDeepElement.addElement("leaf");
else
iFileElem = goDeepElement.addElement(DirLayoutController.nodeDir);
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());
287,17 → 314,21
}
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",pathFragments[pathFragments.length - 1]);
request.setAttribute("ACTUAL_REMOTE_CHILD",actualId);
}
client.quit();
client.disconnect();
313,49 → 344,7
}
}
 
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)
{
 
FtpServer 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 void generateOutputLeafXml(HttpServletResponse response, HttpServletRequest request, String finalURL, Proxy proxy, boolean style) throws IOException, DocumentException
{
if (style)
398,6 → 387,25
styleDirectory(request, response, new HashMap<String, Object>(), null);
}
 
// 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");
/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
}