This commit is contained in:
Shinsuke Sugaya 2014-01-21 23:13:30 +09:00
parent e8094bbda2
commit cf1b75621c
13 changed files with 43 additions and 49 deletions

View file

@ -21,20 +21,17 @@ import java.io.Serializable;
import javax.annotation.Resource;
import jp.sf.fess.dict.DictionaryFile;
import jp.sf.fess.dict.DictionaryItem;
import jp.sf.fess.dict.DictionaryManager;
import jp.sf.fess.form.admin.DictForm;
import jp.sf.fess.helper.SystemHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
public class DictAction implements Serializable {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(DictAction.class);
@Resource
@ActionForm
protected DictForm dictForm;
@ -45,7 +42,7 @@ public class DictAction implements Serializable {
@Resource
protected SystemHelper systemHelper;
public DictionaryFile[] dictFiles;
public DictionaryFile<? extends DictionaryItem>[] dictFiles;
public String getHelpLink() {
return systemHelper.getHelpLink("dict");

View file

@ -22,6 +22,7 @@ import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@ -82,7 +83,7 @@ public class LogAction implements Serializable {
.getBytes(Constants.UTF_8)), Constants.UTF_8);
} catch (final UnsupportedEncodingException e1) {
fileName = new String(Base64.decodeBase64(logForm.logFileName
.getBytes()));
.getBytes()), Charset.defaultCharset());
}
final File logFile = new File(parentDir, fileName);
if (logFile.isFile()) {
@ -154,7 +155,8 @@ public class LogAction implements Serializable {
Constants.UTF_8)), "UTF-8"));
} catch (final UnsupportedEncodingException e) {
map.put("logFileName",
new String(Base64.encodeBase64(file.getName().getBytes())));
new String(Base64.encodeBase64(file.getName().getBytes()),
Charset.defaultCharset()));
}
map.put("lastModified", new Date(file.lastModified()));
return map;

View file

@ -37,6 +37,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelibs.sastruts.core.annotation.Token;
import org.codelibs.sastruts.core.exception.SSCActionMessagesException;
import org.seasar.framework.beans.util.Beans;
import org.seasar.framework.util.StringUtil;
import org.seasar.struts.annotation.ActionForm;
@ -227,10 +228,11 @@ public class SynonymAction {
throw e;
} catch (final CrudMessageException e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
throw new SSCActionMessagesException(e, e.getMessageId(),
e.getArgs());
} catch (final Exception e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(
throw new SSCActionMessagesException(e,
"errors.crud_failed_to_create_crud_table");
}
}
@ -249,10 +251,11 @@ public class SynonymAction {
throw e;
} catch (final CrudMessageException e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
throw new SSCActionMessagesException(e, e.getMessageId(),
e.getArgs());
} catch (final Exception e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(
throw new SSCActionMessagesException(e,
"errors.crud_failed_to_update_crud_table");
}
}
@ -287,10 +290,11 @@ public class SynonymAction {
throw e;
} catch (final CrudMessageException e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
throw new SSCActionMessagesException(e, e.getMessageId(),
e.getArgs());
} catch (final Exception e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(
throw new SSCActionMessagesException(e,
"errors.crud_failed_to_delete_crud_table");
}
}

View file

@ -16,7 +16,7 @@
package jp.sf.fess.crypto;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -35,14 +35,14 @@ public class FessCipher {
private static final Logger logger = LoggerFactory
.getLogger(FessCipher.class);
protected static final String UTF_8 = "UTF-8";
protected static final Charset UTF_8 = Charset.forName("UTF-8");
public String algorithm = "Blowfish";
@Binding(bindingType = BindingType.MUST)
public String key;
public String charsetName = UTF_8;
public Charset charset = UTF_8;
protected Queue<Cipher> encryptoQueue = new ConcurrentLinkedQueue<Cipher>();
@ -63,13 +63,8 @@ public class FessCipher {
}
public String encryptoText(final String text) {
try {
return new String(Base64.encodeBase64(encrypto(text
.getBytes(charsetName))), UTF_8);
} catch (final UnsupportedEncodingException e) {
throw new FessSystemException("Could not encrypto a text by "
+ charsetName + ".", e);
}
return new String(
Base64.encodeBase64(encrypto(text.getBytes(charset))), UTF_8);
}
public byte[] decrypto(final byte[] data) {
@ -87,14 +82,8 @@ public class FessCipher {
}
public String decryptoText(final String text) {
try {
return new String(
decrypto(Base64.decodeBase64(text.getBytes(UTF_8))),
charsetName);
} catch (final UnsupportedEncodingException e) {
throw new FessSystemException("Could not decrypto a text by "
+ charsetName + ".", e);
}
return new String(decrypto(Base64.decodeBase64(text.getBytes(UTF_8))),
charset);
}
protected Cipher pollEncryptoCipher() {
@ -103,8 +92,8 @@ public class FessCipher {
if (logger.isInfoEnabled()) {
logger.info("Initializing a cipher for an encryption.");
}
final SecretKeySpec sksSpec = new SecretKeySpec(key.getBytes(),
algorithm);
final SecretKeySpec sksSpec = new SecretKeySpec(
key.getBytes(UTF_8), algorithm);
try {
cipher = Cipher.getInstance(algorithm);
cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, sksSpec);
@ -126,8 +115,8 @@ public class FessCipher {
if (logger.isInfoEnabled()) {
logger.info("Initializing a cipher for an decryption.");
}
final SecretKeySpec sksSpec = new SecretKeySpec(key.getBytes(),
algorithm);
final SecretKeySpec sksSpec = new SecretKeySpec(
key.getBytes(UTF_8), algorithm);
try {
cipher = Cipher.getInstance(algorithm);
cipher.init(javax.crypto.Cipher.DECRYPT_MODE, sksSpec);

View file

@ -238,7 +238,7 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
}
private String unescape(final String s) {
if (s.indexOf("\\") >= 0) {
if (s.indexOf('\\') >= 0) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
final char ch = s.charAt(i);

View file

@ -237,7 +237,7 @@ public class Crawler implements Serializable {
int exitCode;
try {
exitCode = process(options);
} catch (final Throwable t) {
} catch (final Throwable t) { // NOPMD
logger.error("Crawler does not work correctly.", t);
exitCode = Constants.EXIT_FAIL;
} finally {

View file

@ -36,10 +36,12 @@ public class WebApiFilter implements Filter {
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
// nothing
}
@Override
public void destroy() {
// nothing
}
@Override

View file

@ -139,7 +139,7 @@ public class CrawlingConfigHelper implements Serializable {
.getComponent("systemHelper");
final Object configIdObj = doc.get(systemHelper.configIdField);
if (configIdObj == null) {
throw new FessSystemException("Invalid configId: " + configIdObj);
throw new FessSystemException("configId is null.");
}
final String configId = configIdObj.toString();
if (configId.length() < 2) {
@ -258,6 +258,7 @@ public class CrawlingConfigHelper implements Serializable {
case CHROME:
case FIREFOX:
case OTHER:
default:
response.setHeader(
"Content-Disposition",
"attachment; filename=\"=?utf-8?B?"

View file

@ -138,8 +138,7 @@ public class CrawlJob {
if (sessionId == null) { // create session id
final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
final String sessionId = sdf.format(new Date());
sessionId(sessionId);
sessionId = sdf.format(new Date());
}
resultBuf.append("Session Id: ").append(sessionId).append("\n");
resultBuf.append("Web Config Id:");

View file

@ -99,10 +99,10 @@ public class TriggeredJob implements Job {
jobLog.setScriptResult(ret.toString());
}
jobLog.setJobStatus(Constants.OK);
} catch (final Throwable e) {
logger.error("Failed to execute " + jobId + ": " + script, e);
} catch (final Throwable t) { // NOPMD
logger.error("Failed to execute " + jobId + ": " + script, t);
jobLog.setJobStatus(Constants.FAIL);
jobLog.setScriptResult(systemHelper.abbreviateLongText(e
jobLog.setScriptResult(systemHelper.abbreviateLongText(t
.getLocalizedMessage()));
} finally {
jobHelper.finishJobExecutoer(id);

View file

@ -19,6 +19,7 @@ package jp.sf.fess.screenshot.impl;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -85,8 +86,8 @@ public class CommandGenerator implements ScreenShotGenerator {
final StringBuilder buf = new StringBuilder(50);
buf.append(RandomStringUtils.randomNumeric(directoryNameLength));
buf.append('/');
buf.append(Base64Util.encode(Integer.toString(url.hashCode())
.getBytes()));
buf.append(Base64Util.encode(Integer.toString(url.hashCode()).getBytes(
Charset.defaultCharset())));
buf.append('.');
buf.append(imageExtention);
return buf.toString();
@ -153,7 +154,7 @@ public class CommandGenerator implements ScreenShotGenerator {
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(
p.getInputStream()));
p.getInputStream(), Charset.defaultCharset()));
while ((line = br.readLine()) != null) {
if (logger.isDebugEnabled()) {
logger.debug(line);

View file

@ -24,8 +24,7 @@ import jp.sf.fess.Constants;
import org.seasar.framework.beans.util.Copy;
public class FessCopy extends Copy {
public FessCopy(final Object src, final Object dest)
throws NullPointerException {
public FessCopy(final Object src, final Object dest) {
super(src, dest);
}

View file

@ -20,7 +20,7 @@ import jp.sf.fess.WebApiException;
import org.seasar.struts.util.RequestUtil;
public class WebApiUtil {
public final class WebApiUtil {
private static final String WEB_API_EXCEPTION = "webApiException";