exo-jcr SVN: r2267 - jcr/branches/1.14.x.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-04-12 08:47:24 -0400 (Mon, 12 Apr 2010)
New Revision: 2267
Modified:
jcr/branches/1.14.x/pom.xml
Log:
EXOJCR-604 dock-style dependency version changed to 1
Modified: jcr/branches/1.14.x/pom.xml
===================================================================
--- jcr/branches/1.14.x/pom.xml 2010-04-12 07:34:10 UTC (rev 2266)
+++ jcr/branches/1.14.x/pom.xml 2010-04-12 12:47:24 UTC (rev 2267)
@@ -42,7 +42,7 @@
<org.exoplatform.kernel.version>2.2.1-GA-SNAPSHOT</org.exoplatform.kernel.version>
<org.exoplatform.core.version>2.4.0-Beta01-SNAPSHOT</org.exoplatform.core.version>
<org.exoplatform.ws.version>2.1.1-GA-SNAPSHOT</org.exoplatform.ws.version>
- <org.exoplatform.doc-style.version>2</org.exoplatform.doc-style.version>
+ <org.exoplatform.doc-style.version>1</org.exoplatform.doc-style.version>
</properties>
<dependencyManagement>
<dependencies>
14 years, 1 month
exo-jcr SVN: r2266 - in jcr/trunk: exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command and 3 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-04-12 03:34:10 -0400 (Mon, 12 Apr 2010)
New Revision: 2266
Modified:
jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/FtpTextUtils.java
jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdMkd.java
jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdStor.java
jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfig.java
jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfigImpl.java
jcr/trunk/exo.jcr.component.ftp/src/main/resources/conf/jcr-ftp-configuration.xml
jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/MKDTest.java
jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/STORTest.java
Log:
EXOJCR-634 : The "replace forbidden chars" mechanism was implemented.
By default "replace forbidden chars" mechanism is enabled.
By default the forbidden chars is ':', '[', ']', '*', ''', '"', '|'.
By default the forbidden chars will be replaced to '_'.
How to configuration in ftp config when need change defaults config :
<value-param>
<name>replace-forbidden-chars</name>
<value>true</value>
</value-param>
<value-param>
<name>forbidden-chars</name>
<value>:[]*'"|</value>
</value-param>
<value-param>
<name>replace-char</name>
<value>_</value>
</value-param>
Modified: jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/FtpTextUtils.java
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/FtpTextUtils.java 2010-04-12 07:14:47 UTC (rev 2265)
+++ jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/FtpTextUtils.java 2010-04-12 07:34:10 UTC (rev 2266)
@@ -73,4 +73,31 @@
return result;
}
+ public static String replaceForbiddenChars(String strVal, String forbiddenChars, char replaceChar)
+ {
+ char[] result = new char[strVal.length()];
+
+ for (int i = 0; i < strVal.length(); i++)
+ {
+ boolean replaced = false;
+
+ for (int j = 0; j < forbiddenChars.length(); j++)
+ {
+ if (strVal.charAt(i) == forbiddenChars.charAt(j))
+ {
+ result[i] = replaceChar;
+ replaced = true;
+ break;
+ }
+ }
+
+ if (!replaced)
+ {
+ result[i] = strVal.charAt(i);
+ }
+ }
+
+ return new String(result);
+ }
+
}
Modified: jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdMkd.java
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdMkd.java 2010-04-12 07:14:47 UTC (rev 2265)
+++ jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdMkd.java 2010-04-12 07:34:10 UTC (rev 2266)
@@ -19,6 +19,8 @@
package org.exoplatform.services.ftp.command;
import org.exoplatform.services.ftp.FtpConst;
+import org.exoplatform.services.ftp.FtpTextUtils;
+import org.exoplatform.services.ftp.config.FtpConfig;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -62,6 +64,9 @@
reply(String.format(FtpConst.Replyes.REPLY_550, srcPath));
return;
}
+
+ FtpConfig ftpConfig = clientSession().getFtpServer().getConfiguration();
+ boolean replaceForbiddenChars =ftpConfig.isReplaceForbiddenChars();
try
{
@@ -73,6 +78,11 @@
{
String curPathName = newPath.get(i);
+ if (replaceForbiddenChars)
+ {
+ curPathName = FtpTextUtils.replaceForbiddenChars(curPathName, ftpConfig.getForbiddenChars(), ftpConfig.getReplaceChar());
+ }
+
if (parentNode.hasNode(curPathName))
{
parentNode = parentNode.getNode(curPathName);
Modified: jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdStor.java
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdStor.java 2010-04-12 07:14:47 UTC (rev 2265)
+++ jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdStor.java 2010-04-12 07:34:10 UTC (rev 2266)
@@ -20,6 +20,7 @@
import org.exoplatform.commons.utils.MimeTypeResolver;
import org.exoplatform.services.ftp.FtpConst;
+import org.exoplatform.services.ftp.FtpTextUtils;
import org.exoplatform.services.ftp.config.FtpConfig;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
@@ -88,6 +89,16 @@
try
{
ArrayList<String> newPath = clientSession().getFullPath(fileName);
+
+ FtpConfig ftpConfig = clientSession().getFtpServer().getConfiguration();
+ if (ftpConfig.isReplaceForbiddenChars())
+ {
+ String fName = newPath.get(newPath.size()-1);
+ String newfName = FtpTextUtils.replaceForbiddenChars(fName, ftpConfig.getForbiddenChars(), ftpConfig.getReplaceChar());
+
+ fileName = fileName.substring(0, fileName.indexOf(fName)) + newfName;
+ }
+
Session curSession = clientSession().getSession(newPath.get(0));
Node resourceNode = getExistedFileNode(curSession, fileName);
Modified: jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfig.java
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfig.java 2010-04-12 07:14:47 UTC (rev 2265)
+++ jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfig.java 2010-04-12 07:34:10 UTC (rev 2266)
@@ -61,4 +61,9 @@
PortalContainer getPortalContainer();
+ boolean isReplaceForbiddenChars();
+
+ String getForbiddenChars();
+
+ char getReplaceChar();
}
Modified: jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfigImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfigImpl.java 2010-04-12 07:14:47 UTC (rev 2265)
+++ jcr/trunk/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfigImpl.java 2010-04-12 07:34:10 UTC (rev 2266)
@@ -91,11 +91,58 @@
* "download-speed-limit".
*/
public static final String INIT_PARAM_DOWNLOAD_SPEED_LIMIT = "download-speed-limit";
+
+ /**
+ * replace-forbidden-chars
+ */
+ public static final String INIT_PARAM_REPLACE_FORBIDDEN_CHARS = "replace-forbidden-chars";
+
+ /**
+ * forbidden-chars
+ */
+ public static final String INIT_PARAM_FORBIDDEN_CHARS = "forbidden-chars";
+
+ /**
+ * replace-char
+ */
+ public static final String INIT_PARAM_REPLACE_CHAR = "replace-char";
/**
* "timeout".
*/
public static final String INIT_PARAM_TIME_OUT = "timeout";
+
+ /**
+ * According JCR specification JSR-170 .
+ * See 4.6 Path Syntax:
+ * Any Unicode character except: '/', ':', '[', ']', '*', ''', '"', '|'
+ */
+ public static final String DEFAULT_JCR_FORBIDDEN_CHARS = ":[]*'\"|";
+
+ /**
+ * The all forbidden chars will replaced '_' by default.
+ */
+ public static final char DEFAULT_REPLACE_CHAR = '_';
+
+ /**
+ * The replace forbidden chars is enable by default.
+ */
+ public static final boolean DEFAULT_REPLACE_FORBIDDEN_CHARS = true;
+
+ /**
+ * Forbidden chars.
+ */
+ public String _forbiddenChars = DEFAULT_JCR_FORBIDDEN_CHARS;
+
+ /**
+ * Replace char.
+ */
+ public char _replaceChar = DEFAULT_REPLACE_CHAR;
+
+ /**
+ * Replace forbidden chars.
+ */
+ public boolean _replaceForbiddenChars = DEFAULT_REPLACE_FORBIDDEN_CHARS;
/**
* Command port.
@@ -264,7 +311,25 @@
_needTimeOut = true;
_timeOutValue = new Integer(pTimeOut.getValue());
}
+
+ ValueParam pReplaceForbiddenChars = params.getValueParam(INIT_PARAM_REPLACE_FORBIDDEN_CHARS);
+ if (pReplaceForbiddenChars != null)
+ {
+ _replaceForbiddenChars = new Boolean(pReplaceForbiddenChars.getValue());
+ }
+ ValueParam pForbiddenChars = params.getValueParam(INIT_PARAM_FORBIDDEN_CHARS);
+ if (pForbiddenChars != null)
+ {
+ _forbiddenChars = pForbiddenChars.getValue();
+ }
+
+ ValueParam pReplaceChar = params.getValueParam(INIT_PARAM_REPLACE_CHAR);
+ if (pReplaceChar != null)
+ {
+ _replaceChar = pReplaceChar.getValue().charAt(0);
+ }
+
ExoContainer container = context.getContainer();
if (container instanceof PortalContainer)
{
@@ -300,6 +365,10 @@
{
log.debug(INIT_PARAM_TIME_OUT + ".value = " + _timeOutValue);
}
+
+ log.debug(INIT_PARAM_REPLACE_FORBIDDEN_CHARS + " = " + _replaceForbiddenChars);
+ log.debug(INIT_PARAM_FORBIDDEN_CHARS + " = " + _forbiddenChars);
+ log.debug(INIT_PARAM_REPLACE_CHAR + " = " + _replaceChar);
}
}
@@ -383,5 +452,20 @@
{
return _portalContainer;
}
+
+ public String getForbiddenChars()
+ {
+ return _forbiddenChars;
+ }
+
+ public char getReplaceChar()
+ {
+ return _replaceChar;
+ }
+
+ public boolean isReplaceForbiddenChars()
+ {
+ return _replaceForbiddenChars;
+ }
}
Modified: jcr/trunk/exo.jcr.component.ftp/src/main/resources/conf/jcr-ftp-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ftp/src/main/resources/conf/jcr-ftp-configuration.xml 2010-04-12 07:14:47 UTC (rev 2265)
+++ jcr/trunk/exo.jcr.component.ftp/src/main/resources/conf/jcr-ftp-configuration.xml 2010-04-12 07:34:10 UTC (rev 2266)
@@ -79,6 +79,25 @@
<!-- <name>timeout</name>-->
<!-- <value>60</value>-->
<!-- </value-param>-->
+
+ <!-- That is default configuration to mechanism "replace-forbidden-chars"
+ We will uncoment when we need changed default configuration.
+ -->
+ <!--value-param>
+ <name>replace-forbidden-chars</name>
+ <value>true</value>
+ </value-param>
+
+ <value-param>
+ <name>forbidden-chars</name>
+ <value>:[]*'"|</value>
+ </value-param>
+
+ <value-param>
+ <name>replace-char</name>
+ <value>_</value>
+ </value-param -->
+
</init-params>
</component>
</configuration>
\ No newline at end of file
Modified: jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/MKDTest.java
===================================================================
--- jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/MKDTest.java 2010-04-12 07:14:47 UTC (rev 2265)
+++ jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/MKDTest.java 2010-04-12 07:34:10 UTC (rev 2266)
@@ -89,5 +89,38 @@
client.close();
log.info("Complete.\r\n");
}
+
+ public void testForbiddenCharsMKD() throws Exception {
+ log.info("Test...");
+ FtpClientSession client = FtpTestConfig.getTestFtpClient();
+ client.connect();
+
+ {
+ CmdUser cmdUser = new CmdUser(FtpTestConfig.USER_ID);
+ assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(cmdUser));
+ }
+
+ {
+ CmdPass cmdPass = new CmdPass(FtpTestConfig.USER_PASS);
+ assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(cmdPass));
+ }
+
+ {
+ CmdCwd cmdCwd = new CmdCwd("production");
+ assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(cmdCwd));
+
+ String folderName = "test_folder_123" + ":[]*'\"|" + "123";
+
+ CmdMkd cmdMkd = new CmdMkd(folderName);
+ assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdMkd));
+
+ CmdRmd cmdRmd = new CmdRmd("test_folder_123" + "_______" + "123");
+ assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(cmdRmd));
+ }
+
+ client.close();
+ log.info("Complete.\r\n");
+ }
+
}
Modified: jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/STORTest.java
===================================================================
--- jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/STORTest.java 2010-04-12 07:14:47 UTC (rev 2265)
+++ jcr/trunk/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/STORTest.java 2010-04-12 07:34:10 UTC (rev 2266)
@@ -120,5 +120,42 @@
client.close();
log.info("Complete.\r\n");
}
+
+ public void testForbiddenChars_STOR() throws Exception {
+ log.info("Test...");
+ FtpClientSession client = FtpTestConfig.getTestFtpClient();
+ client.connect();
+
+ byte[] fileContent = "THIS FILE CONTENT".getBytes();
+
+ // login
+ {
+ assertEquals(FtpConst.Replyes.REPLY_331,
+ client.executeCommand(new CmdUser(FtpTestConfig.USER_ID)));
+ assertEquals(FtpConst.Replyes.REPLY_230,
+ client.executeCommand(new CmdPass(FtpTestConfig.USER_PASS)));
+ }
+
+ String fileName = "test_stor_file_" + ":[]*'\"|" + ".txt";
+
+ // desired reply - 125 Data connection already open; Transfer starting
+ // 226 Transfer complete
+ {
+ assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("production")));
+ assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));
+
+ CmdStor cmdStor = new CmdStor(fileName);
+ cmdStor.setFileContent(fileContent);
+ assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(cmdStor));
+ }
+
+ {
+ assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdDele("test_stor_file_" + "_______" + ".txt")));
+ }
+
+ client.close();
+ log.info("Complete.\r\n");
+ }
+
}
14 years, 1 month
exo-jcr SVN: r2265 - jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-04-12 03:14:47 -0400 (Mon, 12 Apr 2010)
New Revision: 2265
Modified:
jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdSize.java
Log:
EXOJCR-633 : Add fix to CmdSize in JCR 1.14.x
Modified: jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdSize.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdSize.java 2010-04-12 07:10:56 UTC (rev 2264)
+++ jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdSize.java 2010-04-12 07:14:47 UTC (rev 2265)
@@ -55,8 +55,15 @@
}
String resName = params[1];
-
+
ArrayList<String> newPath = clientSession().getFullPath(resName);
+
+ if (newPath.size() == 0)
+ {
+ reply(String.format(FtpConst.Replyes.REPLY_550_SIZE, resName));
+ return;
+ }
+
String repoPath = clientSession().getRepoPath(newPath);
try
{
14 years, 1 month
exo-jcr SVN: r2264 - jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/resources/conf.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-04-12 03:10:56 -0400 (Mon, 12 Apr 2010)
New Revision: 2264
Modified:
jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/resources/conf/jcr-ftp-configuration.xml
Log:
EXOJCR-634 : Add configuration of 'replace forbidden chars' was added to conf/portal
Modified: jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/resources/conf/jcr-ftp-configuration.xml
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/resources/conf/jcr-ftp-configuration.xml 2010-04-12 06:45:08 UTC (rev 2263)
+++ jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/resources/conf/jcr-ftp-configuration.xml 2010-04-12 07:10:56 UTC (rev 2264)
@@ -79,6 +79,25 @@
<!-- <name>timeout</name>-->
<!-- <value>60</value>-->
<!-- </value-param>-->
+
+ <!-- That is default configuration to mechanism "replace-forbidden-chars"
+ We will uncoment when we need changed default configuration.
+ -->
+ <!--value-param>
+ <name>replace-forbidden-chars</name>
+ <value>true</value>
+ </value-param>
+
+ <value-param>
+ <name>forbidden-chars</name>
+ <value>:[]*'"|</value>
+ </value-param>
+
+ <value-param>
+ <name>replace-char</name>
+ <value>_</value>
+ </value-param -->
+
</init-params>
</component>
</configuration>
\ No newline at end of file
14 years, 1 month
exo-jcr SVN: r2263 - jcr/trunk/exo.jcr.component.core/src/main/javacc/sql.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-04-12 02:45:08 -0400 (Mon, 12 Apr 2010)
New Revision: 2263
Modified:
jcr/trunk/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt
Log:
EXOJCR-498: TokenMgrError is wrapped by ParseException with new message.
Modified: jcr/trunk/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt 2010-04-09 15:21:21 UTC (rev 2262)
+++ jcr/trunk/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt 2010-04-12 06:45:08 UTC (rev 2263)
@@ -75,6 +75,30 @@
// this.resolver = resolver;
// }
+ void handleTokenMgrError(TokenMgrError e) throws ParseException{
+ if (e.errorCode == e.LEXICAL_ERROR)
+ {
+ StringBuffer sb = new StringBuffer();
+ try
+ {
+ char c;
+ while ((c = token_source.input_stream.readChar()) != ' ')
+ {
+ sb.append(c);
+ }
+ }
+ catch (java.io.IOException ioe)
+ {
+ // probably EOF occurs, but any way, do not report this exceptions
+ }
+
+ throw new ParseException("Unknown Query Construction : \"" + sb.toString() + "\". " + e.getMessage());
+ }
+ else
+ {
+ throw e;
+ }
+ }
}
PARSER_END(JCRSQLParser)
@@ -269,11 +293,18 @@
ASTQuery Query() :
{}
{
+ try{
+
<SELECT>
SelectList()
TableExpression()
[ OrderByClause() ]
<EOF>
+
+ }catch(TokenMgrError e){
+ handleTokenMgrError(e);
+ }
+
{ return jjtThis; }
}
14 years, 1 month
exo-jcr SVN: r2262 - in ws/trunk/exo.ws.rest.core/src: test/java/org/exoplatform/services/rest/impl and 1 other directory.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-04-09 11:21:21 -0400 (Fri, 09 Apr 2010)
New Revision: 2262
Added:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/DefaultExceptionMapper.java
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java
Log:
EXOJCR-645: create default exception mapper
Added: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/DefaultExceptionMapper.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/DefaultExceptionMapper.java (rev 0)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/DefaultExceptionMapper.java 2010-04-09 15:21:21 UTC (rev 2262)
@@ -0,0 +1,47 @@
+/**
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.rest.impl;
+
+import org.exoplatform.services.rest.ExtHttpHeaders;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+/**
+ * Transform {@link java.lang.Exception} to JAX-RS response.
+ *
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id$
+ */
+public class DefaultExceptionMapper implements ExceptionMapper<Exception>
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public Response toResponse(Exception exception)
+ {
+ String message = exception.getMessage();
+ return Response.status(500).entity(message == null ? exception.getClass().getName() : message).type(
+ MediaType.TEXT_PLAIN).header(ExtHttpHeaders.JAXRS_BODY_PROVIDED, "Error-Message").build();
+ }
+
+}
Property changes on: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/DefaultExceptionMapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java 2010-04-09 14:25:13 UTC (rev 2261)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java 2010-04-09 15:21:21 UTC (rev 2262)
@@ -86,7 +86,7 @@
/**
* Providers instance.
- *
+ *
* @see Providers
*/
private static AtomicReference<ProviderBinder> ainst = new AtomicReference<ProviderBinder>();
@@ -182,6 +182,8 @@
// JAXB context
addContextResolver(JAXBContextResolver.class, null, ComponentLifecycleScope.CONTAINER);
+ addExceptionMapper(new DefaultExceptionMapper());
+
}
/**
@@ -235,7 +237,7 @@
/**
* Add per-request ContextResolver.
- *
+ *
* @param clazz class of implementation ContextResolver
*/
@SuppressWarnings("unchecked")
@@ -253,7 +255,7 @@
/**
* Add singleton ContextResolver.
- *
+ *
* @param instance ContextResolver instance
*/
@SuppressWarnings("unchecked")
@@ -272,7 +274,7 @@
/**
* Add per-request ExceptionMapper.
- *
+ *
* @param clazz class of implementation ExceptionMapper
*/
@SuppressWarnings("unchecked")
@@ -290,7 +292,7 @@
/**
* Add singleton ExceptionMapper.
- *
+ *
* @param instance ExceptionMapper instance
*/
@SuppressWarnings("unchecked")
@@ -309,7 +311,7 @@
/**
* Add per-request MessageBodyReader.
- *
+ *
* @param clazz class of implementation MessageBodyReader
*/
@SuppressWarnings("unchecked")
@@ -327,7 +329,7 @@
/**
* Add singleton MessageBodyReader.
- *
+ *
* @param instance MessageBodyReader instance
*/
@SuppressWarnings("unchecked")
@@ -346,7 +348,7 @@
/**
* Add per-request MessageBodyWriter.
- *
+ *
* @param clazz class of implementation MessageBodyWriter
*/
@SuppressWarnings("unchecked")
@@ -364,7 +366,7 @@
/**
* Add singleton MessageBodyWriter.
- *
+ *
* @param instance MessageBodyWriter instance
*/
@SuppressWarnings("unchecked")
@@ -383,7 +385,7 @@
/**
* Get list of most acceptable writer's media type for specified type.
- *
+ *
* @param type type
* @param genericType generic type
* @param annotations annotations
@@ -401,7 +403,9 @@
{
MessageBodyWriter writer = (MessageBodyWriter)pf.getInstance(ApplicationContextImpl.getCurrent());
if (writer.isWriteable(type, genericType, annotations, MediaTypeHelper.DEFAULT_TYPE))
+ {
l.add(mime);
+ }
}
}
@@ -419,14 +423,20 @@
if (pm != null)
{
if (mediaType == null)
+ {
return _getContextResolver(pm, contextType, MediaTypeHelper.DEFAULT_TYPE);
+ }
resolver = _getContextResolver(pm, contextType, mediaType);
if (resolver == null)
+ {
resolver =
_getContextResolver(pm, contextType, new MediaType(mediaType.getType(), MediaType.MEDIA_TYPE_WILDCARD));
+ }
if (resolver == null)
+ {
resolver = _getContextResolver(pm, contextType, MediaTypeHelper.DEFAULT_TYPE);
+ }
}
return resolver;
}
@@ -439,7 +449,9 @@
{
ObjectFactory pf = exceptionMappers.get(type);
if (pf != null)
+ {
return (ExceptionMapper<T>)pf.getInstance(ApplicationContextImpl.getCurrent());
+ }
return null;
}
@@ -450,15 +462,21 @@
MediaType mediaType)
{
if (mediaType == null)
+ {
return _getMessageBodyReader(type, genericType, annotations, MediaTypeHelper.DEFAULT_TYPE);
+ }
MessageBodyReader<T> reader = _getMessageBodyReader(type, genericType, annotations, mediaType);
if (reader == null)
+ {
reader =
_getMessageBodyReader(type, genericType, annotations, new MediaType(mediaType.getType(),
MediaType.MEDIA_TYPE_WILDCARD));
+ }
if (reader == null)
+ {
reader = _getMessageBodyReader(type, genericType, annotations, MediaTypeHelper.DEFAULT_TYPE);
+ }
return reader;
}
@@ -470,21 +488,27 @@
MediaType mediaType)
{
if (mediaType == null)
+ {
return _getMessageBodyWriter(type, genericType, annotations, MediaTypeHelper.DEFAULT_TYPE);
+ }
MessageBodyWriter<T> writer = _getMessageBodyWriter(type, genericType, annotations, mediaType);
if (writer == null)
+ {
writer =
_getMessageBodyWriter(type, genericType, annotations, new MediaType(mediaType.getType(),
MediaType.MEDIA_TYPE_WILDCARD));
+ }
if (writer == null)
+ {
writer = _getMessageBodyWriter(type, genericType, annotations, MediaTypeHelper.DEFAULT_TYPE);
+ }
return writer;
}
/**
* Add per-request MethodInvokerFilter.
- *
+ *
* @param clazz class of implementation MethodInvokerFilter
*/
public void addMethodInvokerFilter(Class<? extends MethodInvokerFilter> clazz)
@@ -501,7 +525,7 @@
/**
* Add singleton MethodInvokerFilter.
- *
+ *
* @param instance MethodInvokerFilter instance
*/
public void addMethodInvokerFilter(MethodInvokerFilter instance)
@@ -519,7 +543,7 @@
/**
* Add per-request RequestFilter.
- *
+ *
* @param clazz class of implementation RequestFilter
*/
public void addRequestFilter(Class<? extends RequestFilter> clazz)
@@ -536,7 +560,7 @@
/**
* Add singleton RequestFilter.
- *
+ *
* @param instance RequestFilter instance
*/
public void addRequestFilter(RequestFilter instance)
@@ -554,7 +578,7 @@
/**
* Add per-request ResponseFilter.
- *
+ *
* @param clazz class of implementation ResponseFilter
*/
public void addResponseFilter(Class<? extends ResponseFilter> clazz)
@@ -571,7 +595,7 @@
/**
* Add singleton ResponseFilter.
- *
+ *
* @param instance ResponseFilter instance
*/
public void addResponseFilter(ResponseFilter instance)
@@ -639,7 +663,9 @@
{
int len = capturingValues.size();
if (capturingValues.get(len - 1) != null && !"/".equals(capturingValues.get(len - 1)))
+ {
continue; // not matched
+ }
}
else
{
@@ -681,7 +707,7 @@
/**
* Looking for message body reader according to supplied entity class, entity
* generic type, annotations and content type.
- *
+ *
* @param <T> message body reader actual type argument
* @param type entity type
* @param genericType entity generic type
@@ -697,7 +723,9 @@
{
MessageBodyReader reader = (MessageBodyReader)pf.getInstance(ApplicationContextImpl.getCurrent());
if (reader.isReadable(type, genericType, annotations, mediaType))
+ {
return reader;
+ }
}
return null;
}
@@ -705,7 +733,7 @@
/**
* Looking for message body writer according to supplied entity class, entity
* generic type, annotations and content type.
- *
+ *
* @param <T> message body writer actual type argument
* @param type entity type
* @param genericType entity generic type
@@ -721,7 +749,9 @@
{
MessageBodyWriter writer = (MessageBodyWriter)pf.getInstance(ApplicationContextImpl.getCurrent());
if (writer.isWriteable(type, genericType, annotations, mediaType))
+ {
return writer;
+ }
}
return null;
}
@@ -745,7 +775,9 @@
{
Type[] atypes = pt.getActualTypeArguments();
if (atypes.length > 1)
+ {
throw new RuntimeException("Unable strong determine actual type argument, more then one type found.");
+ }
Class<?> aclazz = (Class<?>)atypes[0];
@@ -768,7 +800,9 @@
break;
case SINGLETON :
if (instance == null)
+ {
throw new NullPointerException("ContextResolver instance is null.");
+ }
factory = new SingletonObjectFactory<ProviderDescriptor>(descriptor, instance);
break;
case CONTAINER :
@@ -814,7 +848,9 @@
break;
case SINGLETON :
if (instance == null)
+ {
throw new NullPointerException("MessageBodyReader instance is null.");
+ }
factory = new SingletonObjectFactory<ProviderDescriptor>(descriptor, instance);
break;
case CONTAINER :
@@ -827,7 +863,9 @@
// check is reader for the same Java and media type already exists.
// Let it be under developer's control.
for (MediaType mime : factory.getObjectModel().consumes())
+ {
readProviders.getList(mime).add(factory);
+ }
}
/**
@@ -850,7 +888,9 @@
break;
case SINGLETON :
if (instance == null)
+ {
throw new NullPointerException("MessageBodyWriter instance is null.");
+ }
factory = new SingletonObjectFactory<ProviderDescriptor>(descriptor, instance);
break;
case CONTAINER :
@@ -863,7 +903,9 @@
// check is writer for the same Java and media type already exists.
// Let it be under developer's control.
for (MediaType mime : factory.getObjectModel().produces())
+ {
writeProviders.getList(mime).add(factory);
+ }
}
/**
@@ -885,7 +927,9 @@
{
Type[] atypes = pt.getActualTypeArguments();
if (atypes.length > 1)
+ {
throw new RuntimeException("Unable strong determine actual type argument, more then one type found.");
+ }
Class<? extends Throwable> exc = (Class<? extends Throwable>)atypes[0];
if (exceptionMappers.get(exc) != null)
@@ -905,7 +949,9 @@
break;
case SINGLETON :
if (instance == null)
+ {
throw new NullPointerException("ExceptionMapper instance is null.");
+ }
factory = new SingletonObjectFactory<ProviderDescriptor>(descriptor, instance);
break;
case CONTAINER :
@@ -940,7 +986,9 @@
break;
case SINGLETON :
if (instance == null)
+ {
throw new NullPointerException("RequestFilter instance is null.");
+ }
factory = new SingletonObjectFactory<FilterDescriptor>(descriptor, instance);
break;
case CONTAINER :
@@ -972,7 +1020,9 @@
break;
case SINGLETON :
if (instance == null)
+ {
throw new NullPointerException("ResponseFilter instance is null.");
+ }
factory = new SingletonObjectFactory<FilterDescriptor>(descriptor, instance);
break;
case CONTAINER :
@@ -1004,7 +1054,9 @@
break;
case SINGLETON :
if (instance == null)
+ {
throw new NullPointerException("MethodInvokerFilter instance is null.");
+ }
factory = new SingletonObjectFactory<FilterDescriptor>(descriptor, instance);
break;
case CONTAINER :
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java 2010-04-09 14:25:13 UTC (rev 2261)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java 2010-04-09 15:21:21 UTC (rev 2262)
@@ -18,23 +18,21 @@
*/
package org.exoplatform.services.rest.impl;
+import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.ExtHttpHeaders;
+import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
+
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
-import org.exoplatform.services.rest.AbstractResourceTest;
-import org.exoplatform.services.rest.ExtHttpHeaders;
-import org.exoplatform.services.rest.impl.ContainerResponse;
-import org.exoplatform.services.rest.impl.UnhandledException;
-import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
-
/**
* Created by The eXo Platform SAS. <br/>
* Date: 24 Dec 2009
- *
+ *
* @author <a href="mailto:max.shaposhnik@exoplatform.com">Max Shaposhnik</a>
- * @version $Id: WebApplicationExceptionTest.java
+ * @version $Id: ExceptionsTest
*/
public class ExceptionsTest extends AbstractResourceTest
{
@@ -70,7 +68,7 @@
@Path("3")
public void m3() throws Exception
{
- throw new RuntimeException("Runtime exception");
+ throw new RuntimeException(errorMessage);
}
@GET
@@ -98,7 +96,7 @@
unregistry(resource);
super.tearDown();
}
-
+
public void testErrorResponse() throws Exception
{
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
@@ -112,15 +110,11 @@
public void testUncheckedException() throws Exception
{
ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
- try
- {
- service("GET", "/a/3", "", null, null, writer);
- fail("UnhandledException should be throw by RequstHandlerImpl");
- }
- catch (UnhandledException e)
- {
- // OK
- }
+ ContainerResponse response = service("GET", "/a/3", "", null, null, writer);
+ assertEquals(500, response.getStatus());
+ String entity = new String(writer.getBody());
+ assertEquals(errorMessage, entity);
+ assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
}
public void testWebApplicationExceptionWithCause() throws Exception
14 years, 1 month
exo-jcr SVN: r2261 - in jcr/branches/1.14.x: exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command and 2 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-04-09 10:25:13 -0400 (Fri, 09 Apr 2010)
New Revision: 2261
Modified:
jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/FtpTextUtils.java
jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdMkd.java
jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdStor.java
jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfig.java
jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfigImpl.java
jcr/branches/1.14.x/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/MKDTest.java
jcr/branches/1.14.x/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/STORTest.java
Log:
EXOJCR-634 : The "replace forbidden chars" mechanism was implemented.
By default "replace forbidden chars" mechanism is enabled.
By default the forbidden chars is ':', '[', ']', '*', ''', '"', '|'.
By default the forbidden chars will be replaced to '_'.
How to configuration in ftp config when need change defaults config :
<value-param>
<name>replace-forbidden-chars</name>
<value>true</value>
</value-param>
<value-param>
<name>forbidden-chars</name>
<value>:[]*'"|</value>
</value-param>
<value-param>
<name>replace-char</name>
<value>_</value>
</value-param>
Modified: jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/FtpTextUtils.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/FtpTextUtils.java 2010-04-09 14:16:55 UTC (rev 2260)
+++ jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/FtpTextUtils.java 2010-04-09 14:25:13 UTC (rev 2261)
@@ -73,4 +73,31 @@
return result;
}
+ public static String replaceForbiddenChars(String strVal, String forbiddenChars, char replaceChar)
+ {
+ char[] result = new char[strVal.length()];
+
+ for (int i = 0; i < strVal.length(); i++)
+ {
+ boolean replaced = false;
+
+ for (int j = 0; j < forbiddenChars.length(); j++)
+ {
+ if (strVal.charAt(i) == forbiddenChars.charAt(j))
+ {
+ result[i] = replaceChar;
+ replaced = true;
+ break;
+ }
+ }
+
+ if (!replaced)
+ {
+ result[i] = strVal.charAt(i);
+ }
+ }
+
+ return new String(result);
+ }
+
}
Modified: jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdMkd.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdMkd.java 2010-04-09 14:16:55 UTC (rev 2260)
+++ jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdMkd.java 2010-04-09 14:25:13 UTC (rev 2261)
@@ -19,6 +19,8 @@
package org.exoplatform.services.ftp.command;
import org.exoplatform.services.ftp.FtpConst;
+import org.exoplatform.services.ftp.FtpTextUtils;
+import org.exoplatform.services.ftp.config.FtpConfig;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -62,6 +64,9 @@
reply(String.format(FtpConst.Replyes.REPLY_550, srcPath));
return;
}
+
+ FtpConfig ftpConfig = clientSession().getFtpServer().getConfiguration();
+ boolean replaceForbiddenChars =ftpConfig.isReplaceForbiddenChars();
try
{
@@ -73,6 +78,11 @@
{
String curPathName = newPath.get(i);
+ if (replaceForbiddenChars)
+ {
+ curPathName = FtpTextUtils.replaceForbiddenChars(curPathName, ftpConfig.getForbiddenChars(), ftpConfig.getReplaceChar());
+ }
+
if (parentNode.hasNode(curPathName))
{
parentNode = parentNode.getNode(curPathName);
Modified: jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdStor.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdStor.java 2010-04-09 14:16:55 UTC (rev 2260)
+++ jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/command/CmdStor.java 2010-04-09 14:25:13 UTC (rev 2261)
@@ -20,6 +20,7 @@
import org.exoplatform.commons.utils.MimeTypeResolver;
import org.exoplatform.services.ftp.FtpConst;
+import org.exoplatform.services.ftp.FtpTextUtils;
import org.exoplatform.services.ftp.config.FtpConfig;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
@@ -88,6 +89,16 @@
try
{
ArrayList<String> newPath = clientSession().getFullPath(fileName);
+
+ FtpConfig ftpConfig = clientSession().getFtpServer().getConfiguration();
+ if (ftpConfig.isReplaceForbiddenChars())
+ {
+ String fName = newPath.get(newPath.size()-1);
+ String newfName = FtpTextUtils.replaceForbiddenChars(fName, ftpConfig.getForbiddenChars(), ftpConfig.getReplaceChar());
+
+ fileName = fileName.substring(0, fileName.indexOf(fName)) + newfName;
+ }
+
Session curSession = clientSession().getSession(newPath.get(0));
Node resourceNode = getExistedFileNode(curSession, fileName);
Modified: jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfig.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfig.java 2010-04-09 14:16:55 UTC (rev 2260)
+++ jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfig.java 2010-04-09 14:25:13 UTC (rev 2261)
@@ -61,4 +61,9 @@
PortalContainer getPortalContainer();
+ boolean isReplaceForbiddenChars();
+
+ String getForbiddenChars();
+
+ char getReplaceChar();
}
Modified: jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfigImpl.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfigImpl.java 2010-04-09 14:16:55 UTC (rev 2260)
+++ jcr/branches/1.14.x/exo.jcr.component.ftp/src/main/java/org/exoplatform/services/ftp/config/FtpConfigImpl.java 2010-04-09 14:25:13 UTC (rev 2261)
@@ -91,11 +91,58 @@
* "download-speed-limit".
*/
public static final String INIT_PARAM_DOWNLOAD_SPEED_LIMIT = "download-speed-limit";
+
+ /**
+ * replace-forbidden-chars
+ */
+ public static final String INIT_PARAM_REPLACE_FORBIDDEN_CHARS = "replace-forbidden-chars";
+
+ /**
+ * forbidden-chars
+ */
+ public static final String INIT_PARAM_FORBIDDEN_CHARS = "forbidden-chars";
+
+ /**
+ * replace-char
+ */
+ public static final String INIT_PARAM_REPLACE_CHAR = "replace-char";
/**
* "timeout".
*/
public static final String INIT_PARAM_TIME_OUT = "timeout";
+
+ /**
+ * According JCR specification JSR-170 .
+ * See 4.6 Path Syntax:
+ * Any Unicode character except: '/', ':', '[', ']', '*', ''', '"', '|'
+ */
+ public static final String DEFAULT_JCR_FORBIDDEN_CHARS = ":[]*'\"|";
+
+ /**
+ * The all forbidden chars will replaced '_' by default.
+ */
+ public static final char DEFAULT_REPLACE_CHAR = '_';
+
+ /**
+ * The replace forbidden chars is enable by default.
+ */
+ public static final boolean DEFAULT_REPLACE_FORBIDDEN_CHARS = true;
+
+ /**
+ * Forbidden chars.
+ */
+ public String _forbiddenChars = DEFAULT_JCR_FORBIDDEN_CHARS;
+
+ /**
+ * Replace char.
+ */
+ public char _replaceChar = DEFAULT_REPLACE_CHAR;
+
+ /**
+ * Replace forbidden chars.
+ */
+ public boolean _replaceForbiddenChars = DEFAULT_REPLACE_FORBIDDEN_CHARS;
/**
* Command port.
@@ -264,7 +311,25 @@
_needTimeOut = true;
_timeOutValue = new Integer(pTimeOut.getValue());
}
+
+ ValueParam pReplaceForbiddenChars = params.getValueParam(INIT_PARAM_REPLACE_FORBIDDEN_CHARS);
+ if (pReplaceForbiddenChars != null)
+ {
+ _replaceForbiddenChars = new Boolean(pReplaceForbiddenChars.getValue());
+ }
+ ValueParam pForbiddenChars = params.getValueParam(INIT_PARAM_FORBIDDEN_CHARS);
+ if (pForbiddenChars != null)
+ {
+ _forbiddenChars = pForbiddenChars.getValue();
+ }
+
+ ValueParam pReplaceChar = params.getValueParam(INIT_PARAM_REPLACE_CHAR);
+ if (pReplaceChar != null)
+ {
+ _replaceChar = pReplaceChar.getValue().charAt(0);
+ }
+
ExoContainer container = context.getContainer();
if (container instanceof PortalContainer)
{
@@ -300,6 +365,10 @@
{
log.debug(INIT_PARAM_TIME_OUT + ".value = " + _timeOutValue);
}
+
+ log.debug(INIT_PARAM_REPLACE_FORBIDDEN_CHARS + " = " + _replaceForbiddenChars);
+ log.debug(INIT_PARAM_FORBIDDEN_CHARS + " = " + _forbiddenChars);
+ log.debug(INIT_PARAM_REPLACE_CHAR + " = " + _replaceChar);
}
}
@@ -383,5 +452,20 @@
{
return _portalContainer;
}
+
+ public String getForbiddenChars()
+ {
+ return _forbiddenChars;
+ }
+
+ public char getReplaceChar()
+ {
+ return _replaceChar;
+ }
+
+ public boolean isReplaceForbiddenChars()
+ {
+ return _replaceForbiddenChars;
+ }
}
Modified: jcr/branches/1.14.x/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/MKDTest.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/MKDTest.java 2010-04-09 14:16:55 UTC (rev 2260)
+++ jcr/branches/1.14.x/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/MKDTest.java 2010-04-09 14:25:13 UTC (rev 2261)
@@ -89,5 +89,38 @@
client.close();
log.info("Complete.\r\n");
}
+
+ public void testForbiddenCharsMKD() throws Exception {
+ log.info("Test...");
+ FtpClientSession client = FtpTestConfig.getTestFtpClient();
+ client.connect();
+
+ {
+ CmdUser cmdUser = new CmdUser(FtpTestConfig.USER_ID);
+ assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(cmdUser));
+ }
+
+ {
+ CmdPass cmdPass = new CmdPass(FtpTestConfig.USER_PASS);
+ assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(cmdPass));
+ }
+
+ {
+ CmdCwd cmdCwd = new CmdCwd("production");
+ assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(cmdCwd));
+
+ String folderName = "test_folder_123" + ":[]*'\"|" + "123";
+
+ CmdMkd cmdMkd = new CmdMkd(folderName);
+ assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdMkd));
+
+ CmdRmd cmdRmd = new CmdRmd("test_folder_123" + "_______" + "123");
+ assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(cmdRmd));
+ }
+
+ client.close();
+ log.info("Complete.\r\n");
+ }
+
}
Modified: jcr/branches/1.14.x/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/STORTest.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/STORTest.java 2010-04-09 14:16:55 UTC (rev 2260)
+++ jcr/branches/1.14.x/exo.jcr.framework.ftpclient/src/test/java/org/exoplatform/frameworks/ftpclient/cmdtests/STORTest.java 2010-04-09 14:25:13 UTC (rev 2261)
@@ -120,5 +120,42 @@
client.close();
log.info("Complete.\r\n");
}
+
+ public void testForbiddenChars_STOR() throws Exception {
+ log.info("Test...");
+ FtpClientSession client = FtpTestConfig.getTestFtpClient();
+ client.connect();
+
+ byte[] fileContent = "THIS FILE CONTENT".getBytes();
+
+ // login
+ {
+ assertEquals(FtpConst.Replyes.REPLY_331,
+ client.executeCommand(new CmdUser(FtpTestConfig.USER_ID)));
+ assertEquals(FtpConst.Replyes.REPLY_230,
+ client.executeCommand(new CmdPass(FtpTestConfig.USER_PASS)));
+ }
+
+ String fileName = "test_stor_file_" + ":[]*'\"|" + ".txt";
+
+ // desired reply - 125 Data connection already open; Transfer starting
+ // 226 Transfer complete
+ {
+ assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("production")));
+ assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));
+
+ CmdStor cmdStor = new CmdStor(fileName);
+ cmdStor.setFileContent(fileContent);
+ assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(cmdStor));
+ }
+
+ {
+ assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdDele("test_stor_file_" + "_______" + ".txt")));
+ }
+
+ client.close();
+ log.info("Complete.\r\n");
+ }
+
}
14 years, 1 month
exo-jcr SVN: r2260 - jcr/branches/1.14.x/exo.jcr.component.core.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-04-09 10:16:55 -0400 (Fri, 09 Apr 2010)
New Revision: 2260
Modified:
jcr/branches/1.14.x/exo.jcr.component.core/pom.xml
Log:
EXOJCR-626 H2 Database version updated
Modified: jcr/branches/1.14.x/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.core/pom.xml 2010-04-09 14:04:27 UTC (rev 2259)
+++ jcr/branches/1.14.x/exo.jcr.component.core/pom.xml 2010-04-09 14:16:55 UTC (rev 2260)
@@ -270,9 +270,8 @@
<!-- dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
- <version>1.0.74</version>
- <scope>test</scope>
- </dependency -->
+ <version>1.2.132</version>
+ </dependency-->
<!-- Ingres Database (local repository) -->
<!-- dependency>
<groupId>com.ingres.jdbc</groupId>
14 years, 1 month
exo-jcr SVN: r2259 - jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-04-09 10:04:27 -0400 (Fri, 09 Apr 2010)
New Revision: 2259
Modified:
jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
Log:
EXOJCR-626 Added mechanism to catch H2 Private Key violation esxception "org.h2.jdbc.JdbcSQLException: Unique index or primary key violation"
Modified: jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-04-09 13:49:51 UTC (rev 2258)
+++ jcr/branches/1.14.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-04-09 14:04:27 UTC (rev 2259)
@@ -97,6 +97,18 @@
*/
private static final String DB2_PK_CONSTRAINT_DETECT_PATTERN =
"(.*DB2 SQL error+.*SQLCODE: -803+.*SQLSTATE: 23505+.*%s.*)+?";
+
+ /**
+ * MYSQL_PK_CONSTRAINT_DETECT_PATTERN.
+ */
+ private static final String H2_PK_CONSTRAINT_DETECT_PATTERN =
+ "(.*JdbcSQLException.*violation.*PRIMARY_KEY_.*)";
+
+ /**
+ * H2_PK_CONSTRAINT_DETECT.
+ */
+ private static final Pattern H2_PK_CONSTRAINT_DETECT =
+ Pattern.compile(H2_PK_CONSTRAINT_DETECT_PATTERN, Pattern.CASE_INSENSITIVE);
/**
* DB2_PK_CONSTRAINT_DETECT.
@@ -302,11 +314,14 @@
// HSQLDB 8.x - java.sql.SQLException: Violation of unique constraint $$: duplicate value(s) for
// column(s) $$:
// JCR_VCAS_PK in statement [INSERT INTO JCR_VCAS (PROPERTY_ID, ORDER_NUM, CAS_ID)
- // VALUES(?,?,?)]
+ // VALUES(?,?,?)] String H2_PK_CONSTRAINT_DETECT_PATTERN = "(.*JdbcSQLException.*violation.*PRIMARY_KEY_.*)";
// PostgreSQL 8.2.x - org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
// constraint "jcr_vcas_pk"
// Oracle 9i x64 (on Fedora 7) - java.sql.SQLException: ORA-00001: unique constraint
// (EXOADMIN.JCR_VCAS_PK) violated
+ // H2 - org.h2.jdbc.JdbcSQLException: Unique index or primary key violation:
+ // "PRIMARY_KEY_4 ON PUBLIC.JCR_VCAS_TEST(PROPERTY_ID, ORDER_NUM)";
+ //
String err = e.toString();
if (DBConstants.DB_DIALECT_MYSQL.equalsIgnoreCase(dialect)
|| DBConstants.DB_DIALECT_MYSQL_UTF8.equalsIgnoreCase(dialect))
@@ -323,6 +338,10 @@
{
return DB2_PK_CONSTRAINT_DETECT.matcher(err).find();
}
+ else if (DBConstants.DB_DIALECT_H2.equalsIgnoreCase(dialect))
+ {
+ return H2_PK_CONSTRAINT_DETECT.matcher(err).find();
+ }
// NOTICE! As an additional check we may ask the database for property currently processed in
// VCAS
14 years, 1 month
exo-jcr SVN: r2258 - jcr/branches/1.14.x/exo.jcr.component.core/src/main/javacc/sql.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-04-09 09:49:51 -0400 (Fri, 09 Apr 2010)
New Revision: 2258
Modified:
jcr/branches/1.14.x/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt
Log:
EXOJCR-498: TokenMgrError is wrapped by ParseException with new message.
Modified: jcr/branches/1.14.x/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt
===================================================================
--- jcr/branches/1.14.x/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt 2010-04-09 12:39:05 UTC (rev 2257)
+++ jcr/branches/1.14.x/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt 2010-04-09 13:49:51 UTC (rev 2258)
@@ -75,6 +75,30 @@
// this.resolver = resolver;
// }
+ void handleTokenMgrError(TokenMgrError e) throws ParseException{
+ if (e.errorCode == e.LEXICAL_ERROR)
+ {
+ StringBuffer sb = new StringBuffer();
+ try
+ {
+ char c;
+ while ((c = token_source.input_stream.readChar()) != ' ')
+ {
+ sb.append(c);
+ }
+ }
+ catch (java.io.IOException ioe)
+ {
+ // probably EOF occurs, but any way, do not report this exceptions
+ }
+
+ throw new ParseException("Unknown Query Construction : \"" + sb.toString() + "\". " + e.getMessage());
+ }
+ else
+ {
+ throw e;
+ }
+ }
}
PARSER_END(JCRSQLParser)
@@ -269,11 +293,18 @@
ASTQuery Query() :
{}
{
+ try{
+
<SELECT>
SelectList()
TableExpression()
[ OrderByClause() ]
<EOF>
+
+ }catch(TokenMgrError e){
+ handleTokenMgrError(e);
+ }
+
{ return jjtThis; }
}
14 years, 1 month