[exo-jcr-commits] exo-jcr SVN: r5379 - in jcr/trunk: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Dec 28 10:45:31 EST 2011
Author: andrew.plotnikov
Date: 2011-12-28 10:45:30 -0500 (Wed, 28 Dec 2011)
New Revision: 5379
Modified:
jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLExceptionHandler.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
jcr/trunk/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/cli/GetContextInfoCommand.java
jcr/trunk/exo.jcr.framework.ftpclient/src/main/java/org/exoplatform/frameworks/ftpclient/data/FtpFileInfoImpl.java
Log:
EXOJCR-1687: Fixed new sonar violations in project
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java 2011-12-28 15:33:38 UTC (rev 5378)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/java/org/exoplatform/jcr/backupconsole/BackupClientImpl.java 2011-12-28 15:45:30 UTC (rev 5379)
@@ -307,63 +307,50 @@
if (info.getType() == DetailedInfo.COMPLETED)
{
- String result = "\nThe completed (ready to restore) backup information : \n";
+ StringBuilder result = new StringBuilder("\nThe completed (ready to restore) backup information : \n");
BackupConfigBean configBean = info.getBackupConfig();
- result +=
- ("\t\tbackup id : "
- + info.getBackupId()
- + "\n"
- + "\t\tbackup folder : "
- + configBean.getBackupDir()
- + "\n"
- + "\t\trepository name : "
- + info.getRepositoryName()
- + "\n"
- + (info.getWorkspaceName().equals("") ? "" : "\t\tworkspace name : "
- + info.getWorkspaceName() + "\n")
- + "\t\tbackup type : "
- + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
- : "full only") + "\n" + "\t\tstarted time : " + info.getStartedTime()
- + "\n" + (info.getFinishedTime().equals("") ? "\n" : "\t\tfinished time : "
- + info.getFinishedTime() + "\n\n"));
+ result.append("\t\tbackup id : ").append(info.getBackupId()).append("\n");
+ result.append("\t\tbackup folder : ").append(configBean.getBackupDir()).append("\n");
+ result.append("\t\trepository name : ").append(info.getRepositoryName()).append("\n");
+ result.append(info.getWorkspaceName().equals("") ? "" : "\t\tworkspace name : "
+ + info.getWorkspaceName() + "\n");
+ result.append("\t\tbackup type : ");
+ result.append(configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
+ : "full only");
+ result.append("\n");
+ result.append("\t\tstarted time : ").append(info.getStartedTime()).append("\n");
+ result.append(info.getFinishedTime().equals("") ? "\n" : "\t\tfinished time : "
+ + info.getFinishedTime() + "\n\n");
- return result;
+ return result.toString();
}
else
{
- String result = "\nThe current backup information : \n";
-
+ StringBuilder result = new StringBuilder("\nThe current backup information : \n");
BackupConfigBean configBean = info.getBackupConfig();
- result +=
- ("\t\tbackup id : "
- + info.getBackupId()
- + "\n"
- + "\t\tbackup folder : "
- + configBean.getBackupDir()
- + "\n"
- + "\t\trepository name : "
- + info.getRepositoryName()
- + "\n"
- + (info.getWorkspaceName().equals("") ? "" : "\t\tworkspace name : "
- + info.getWorkspaceName() + "\n")
- + "\t\tbackup type : "
- + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
- : "full only") + "\n" + "\t\tfull backup state : " + (info
- .getWorkspaceName().equals("") ? getRepositoryBackupToFullState(info.getState())
- : getState(info.getState())))
- + "\n"
- + (info.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
- : "\t\tincremental backup state : " + "working" + "\n")
- + "\t\tstarted time : "
- + info.getStartedTime()
- + "\n"
- + (info.getFinishedTime().equals("") ? "\n" : "\t\tfinished time : "
- + info.getFinishedTime() + "\n\n");
-
- return result;
+ result.append("\t\tbackup id : ").append(info.getBackupId()).append("\n");
+ result.append("\t\tbackup folder : ").append(configBean.getBackupDir()).append("\n");
+ result.append("\t\trepository name : ").append(info.getRepositoryName()).append("\n");
+ result.append(info.getWorkspaceName().equals("") ? "" : "\t\tworkspace name : "
+ + info.getWorkspaceName() + "\n");
+ result.append("\t\tbackup type : ");
+ result.append(configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
+ : "full only");
+ result.append("\n");
+ result.append("\t\tfull backup state : ");
+ result.append(info.getWorkspaceName().equals("") ? getRepositoryBackupToFullState(info.getState())
+ : getState(info.getState()));
+ result.append("\n");
+ result.append(info.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
+ : "\t\tincremental backup state : " + "working" + "\n");
+ result.append("\t\tstarted time : ").append(info.getStartedTime()).append("\n");
+ result.append(info.getFinishedTime().equals("") ? "\n" : "\t\tfinished time : "
+ + info.getFinishedTime() + "\n\n");
+
+ return result.toString();
}
}
else
@@ -754,64 +741,58 @@
throw new RuntimeException("Can not get ShortInfoList from responce.", e);
}
- String result = "\nThe current backups information : \n";
+ StringBuilder result = new StringBuilder("\nThe current backups information : \n");
if ((repositoryInfoList.getBackups().size() == 0) && (workspaceInfoList.getBackups().size() == 0))
{
- result += "\tNo active backups.\n\n";
+ result.append("\tNo active backups.\n\n");
}
int count = 1;
for (ShortInfo shortInfo : repositoryInfoList.getBackups())
{
- result += "\t" + count + ") Repository backup with id " + shortInfo.getBackupId() + " :\n";
-
- result +=
- ("\t\trepository name : "
- + shortInfo.getRepositoryName()
- + "\n"
- + "\t\tbackup type : "
- + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
- : "full only") + "\n" + "\t\tfull backups state : "
- + getRepositoryBackupToFullState(shortInfo.getState()))
- + "\n"
- + (shortInfo.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
- : "\t\tincremental backups state : " + "working" + "\n")
- + "\t\tstarted time : "
- + shortInfo.getStartedTime()
- + "\n"
- + (shortInfo.getFinishedTime().equals("") ? "" : "\t\tfinished time : "
- + shortInfo.getFinishedTime() + "\n");
+ result.append("\t").append(count).append(") Repository backup with id ").append(shortInfo.getBackupId())
+ .append(" :\n");
+ result.append("\t\trepository name : ").append(shortInfo.getRepositoryName()).append("\n");
+ result.append("\t\tbackup type : ");
+ result.append(shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
+ : "full only");
+ result.append("\n");
+ result.append("\t\tfull backups state : ")
+ .append(getRepositoryBackupToFullState(shortInfo.getState())).append("\n");
+ result.append(shortInfo.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
+ : "\t\tincremental backups state : " + "working" + "\n");
+ result.append("\t\tstarted time : ").append(shortInfo.getStartedTime()).append("\n");
+ result.append(shortInfo.getFinishedTime().equals("") ? "" : "\t\tfinished time : "
+ + shortInfo.getFinishedTime() + "\n");
+
count++;
}
for (ShortInfo shortInfo : workspaceInfoList.getBackups())
{
- result += "\t" + count + ") Workspace backup with id " + shortInfo.getBackupId() + " :\n";
+ result.append("\t").append(count).append(") Workspace backup with id ").append(shortInfo.getBackupId())
+ .append(" :\n");
- result +=
- ("\t\trepository name : "
- + shortInfo.getRepositoryName()
- + "\n"
- + "\t\tworkspace name : "
- + shortInfo.getWorkspaceName()
- + "\n"
- + "\t\tbackup type : "
- + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
- : "full only") + "\n" + "\t\tfull backup state : " + getState(shortInfo
- .getState()))
- + "\n"
- + (shortInfo.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
- : "\t\tincremental backup state : " + "working" + "\n")
- + "\t\tstarted time : "
- + shortInfo.getStartedTime()
- + "\n"
- + (shortInfo.getFinishedTime().equals("") ? "" : "\t\tfinished time : "
- + shortInfo.getFinishedTime() + "\n");
+ result.append("\t\trepository name : ").append(shortInfo.getRepositoryName()).append("\n");
+ result.append("\t\tworkspace name : ").append(shortInfo.getWorkspaceName()).append("\n");
+
+ result.append("\t\tbackup type : ");
+ result.append(
+ shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental" : "full only")
+ .append("\n");
+
+ result.append("\t\tfull backup state : ").append(getState(shortInfo.getState())).append("\n");
+ result.append(shortInfo.getBackupType() == BackupManager.FULL_BACKUP_ONLY ? ""
+ : "\t\tincremental backup state : " + "working\n");
+ result.append("\t\tstarted time : ").append(shortInfo.getStartedTime()).append("\n");
+ result.append(shortInfo.getFinishedTime().equals("") ? "" : "\t\tfinished time : "
+ + shortInfo.getFinishedTime() + "\n");
+
count++;
}
- return result;
+ return result.toString();
}
else
{
@@ -856,50 +837,50 @@
throw new RuntimeException("Can not get ShortInfoList from responce.", e);
}
- String result = "\nThe completed (ready to restore) backups information : \n";
+ StringBuilder result = new StringBuilder("\nThe completed (ready to restore) backups information : \n");
if ((repositoryInfoList.getBackups().size() == 0) && (workspaceInfoList.getBackups().size() == 0))
{
- result += "\tNo completed backups.\n\n";
+ result.append("\tNo completed backups.\n\n");
}
int count = 1;
for (ShortInfo shortInfo : repositoryInfoList.getBackups())
{
- result += "\t" + count + ") Repository backup with id " + shortInfo.getBackupId() + " :\n";
+ result.append("\t").append(count).append(") Repository backup with id ").append(shortInfo.getBackupId())
+ .append(" :\n");
+ result.append("\t\trepository name : ").append(shortInfo.getRepositoryName()).append("\n");
- result +=
- ("\t\trepository name : "
- + shortInfo.getRepositoryName()
- + "\n"
- + "\t\tbackup type : "
- + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
- : "full only") + "\n" + "\t\tstarted time : "
- + shortInfo.getStartedTime() + "\n" + (shortInfo.getFinishedTime().equals("") ? "\n"
- : "\t\tfinished time : " + shortInfo.getFinishedTime() + "\n"));
+ result.append("\t\tbackup type : ");
+ result.append(
+ shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental" : "full only")
+ .append("\n");
+ result.append("\t\tstarted time : ").append(shortInfo.getStartedTime()).append("\n");
+ result.append(shortInfo.getFinishedTime().equals("") ? "\n"
+ : "\t\tfinished time : " + shortInfo.getFinishedTime() + "\n");
+
count++;
}
for (ShortInfo shortInfo : workspaceInfoList.getBackups())
{
- result += "\t" + count + ") Workspace backup with id " + shortInfo.getBackupId() + " :\n";
+ result.append("\t").append(count).append(") Workspace backup with id ").append(shortInfo.getBackupId())
+ .append(" :\n");
+ result.append("\t\trepository name : ").append(shortInfo.getRepositoryName()).append("\n");
+ result.append("\t\tworkspace name : ").append(shortInfo.getWorkspaceName()).append("\n");
- result +=
- ("\t\trepository name : "
- + shortInfo.getRepositoryName()
- + "\n"
- + "\t\tworkspace name : "
- + shortInfo.getWorkspaceName()
- + "\n"
- + "\t\tbackup type : "
- + (shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
- : "full only") + "\n" + "\t\tstarted time : "
- + shortInfo.getStartedTime() + "\n" + (shortInfo.getFinishedTime().equals("") ? "\n"
- : "\t\tfinished time : " + shortInfo.getFinishedTime() + "\n"));
+ result.append("\t\tbackup type : ");
+ result.append(
+ shortInfo.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental" : "full only")
+ .append("\n");
+ result.append("\t\tstarted time : ").append(shortInfo.getStartedTime()).append("\n");
+ result.append(shortInfo.getFinishedTime().equals("") ? "\n"
+ : "\t\tfinished time : " + shortInfo.getFinishedTime() + "\n");
+
count++;
}
- return result;
+ return result.toString();
}
else
{
@@ -932,30 +913,25 @@
throw new RuntimeException("Can not get DetailedInfo from responce.", e);
}
- String result = "\nThe current restores information : \n";
+ StringBuilder result = new StringBuilder("\nThe current restores information : \n");
- result += "\tWorkspace restore with id " + info.getBackupId() + ":\n";
+ result.append("\tWorkspace restore with id ").append(info.getBackupId()).append(":\n");
BackupConfigBean configBean = info.getBackupConfig();
- result +=
- ("\t\tbackup folder : "
- + configBean.getBackupDir()
- + "\n"
- + "\t\trepository name : "
- + info.getRepositoryName()
- + "\n"
- + "\t\tworkspace name : "
- + info.getWorkspaceName()
- + "\n"
- + "\t\tbackup type : "
- + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
- : "full only") + "\n" + "\t\trestore state : "
- + getRestoreState(info.getState()) + "\n" + "\t\tstarted time : "
- + info.getStartedTime() + "\n" + (info.getFinishedTime().equals("") ? "\n"
- : "\t\tfinished time : " + info.getFinishedTime() + "\n\n"));
+ result.append("\t\tbackup folder : ").append(configBean.getBackupDir()).append("\n");
+ result.append("\t\trepository name : ").append(info.getRepositoryName()).append("\n");
+ result.append("\t\tworkspace name : ").append(info.getWorkspaceName()).append("\n");
+ result.append("\t\tbackup type : ");
+ result.append(
+ configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental" : "full only")
+ .append("\n");
+ result.append("\t\trestore state : ").append(getRestoreState(info.getState())).append("\n");
+ result.append("\t\tstarted time : ").append(info.getStartedTime()).append("\n");
+ result.append(info.getFinishedTime().equals("") ? "\n"
+ : "\t\tfinished time : " + info.getFinishedTime() + "\n\n");
- return result;
+ return result.toString();
}
else
{
@@ -983,27 +959,25 @@
throw new RuntimeException("Can not get DetailedInfo from responce.", e);
}
- String result = "\nThe current restores information : \n";
+ StringBuilder result = new StringBuilder("\nThe current restores information : \n");
- result += "\tRepository restore with id " + info.getBackupId() + ":\n";
+ result.append("\tRepository restore with id ").append(info.getBackupId()).append(":\n");
BackupConfigBean configBean = info.getBackupConfig();
- result +=
- ("\t\tbackup folder : "
- + configBean.getBackupDir()
- + "\n"
- + "\t\trepository name : "
- + info.getRepositoryName()
- + "\n"
- + "\t\tbackup type : "
- + (configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental"
- : "full only") + "\n" + "\t\trestore state : "
- + getRepositoryRestoreState(info.getState()) + "\n" + "\t\tstarted time : "
- + info.getStartedTime() + "\n" + (info.getFinishedTime().equals("") ? "\n"
- : "\t\tfinished time : " + info.getFinishedTime() + "\n\n"));
-
- return result;
+ result.append("\t\tbackup folder : ").append(configBean.getBackupDir()).append("\n");
+ result.append("\t\trepository name : ").append(info.getRepositoryName()).append("\n");
+ result.append("\t\tbackup type : ");
+ result.append(
+ configBean.getBackupType() == BackupManager.FULL_AND_INCREMENTAL ? "full + incremental" : "full only")
+ .append("\n");
+ result.append("\t\trestore state : ").append(getRepositoryRestoreState(info.getState()))
+ .append("\n");
+ result.append("\t\tstarted time : ").append(info.getStartedTime()).append("\n");
+ result.append(info.getFinishedTime().equals("") ? "\n"
+ : "\t\tfinished time : " + info.getFinishedTime() + "\n\n");
+
+ return result.toString();
}
else
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2011-12-28 15:33:38 UTC (rev 5378)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2011-12-28 15:45:30 UTC (rev 5379)
@@ -124,11 +124,9 @@
public String dump()
{
- String d = "\nChanges:";
- d += changesLog.dump();
- d += "\nCache:";
- d += itemsPool.dump();
- return d;
+ StringBuilder d = new StringBuilder("\nChanges:");
+ d.append(changesLog.dump()).append("\nCache:").append(itemsPool.dump());
+ return d.toString();
}
/**
@@ -536,10 +534,10 @@
if (log.isDebugEnabled())
{
start = System.currentTimeMillis();
- String debugPath = "";
+ StringBuilder debugPath = new StringBuilder();
for (QPathEntry rp : relPath)
{
- debugPath += rp.getAsString();
+ debugPath.append(rp.getAsString());
}
log.debug("getItem(" + parent.getQPath().getAsString() + " + " + debugPath + " ) >>>>>");
}
@@ -553,10 +551,10 @@
{
if (log.isDebugEnabled())
{
- String debugPath = "";
+ StringBuilder debugPath = new StringBuilder();
for (QPathEntry rp : relPath)
{
- debugPath += rp.getAsString();
+ debugPath.append(rp.getAsString());
}
log.debug("getItem(" + parent.getQPath().getAsString() + " + " + debugPath + ") --> "
+ (item != null ? item.getPath() : "null") + " <<<<< " + ((System.currentTimeMillis() - start) / 1000d)
@@ -1994,7 +1992,7 @@
PlainChangesLog slog = changesLog.pushLog(item.getQPath());
SessionChangesLog changes = new SessionChangesLog(slog.getAllStates(), session);
- String exceptions = "";
+ StringBuilder exceptions = new StringBuilder();
for (Iterator<ItemImpl> removedIter = invalidated.iterator(); removedIter.hasNext();)
{
@@ -2005,8 +2003,8 @@
if (rstate == null)
{
- exceptions +=
- "Can't find removed item " + removed.getLocation().getAsString(false) + " in changes for rollback.\n";
+ exceptions.append("Can't find removed item ").append(removed.getLocation().getAsString(false))
+ .append(" in changes for rollback.\n");
continue;
}
@@ -2016,9 +2014,8 @@
rstate = changes.findItemState(rstate.getData().getIdentifier(), false, new int[]{ItemState.DELETED});
if (rstate == null)
{
- exceptions +=
- "Can't find removed item (of move operation) " + removed.getLocation().getAsString(false)
- + " in changes for rollback.\n";
+ exceptions.append("Can't find removed item (of move operation) ")
+ .append(removed.getLocation().getAsString(false)).append(" in changes for rollback.\n");
continue;
}
}
@@ -2040,7 +2037,7 @@
removedIter.remove();
}
- if (exceptions.length() > 0 && log.isDebugEnabled())
+ if (exceptions.toString().length() > 0 && log.isDebugEnabled())
{
log.warn(exceptions);
}
@@ -2708,16 +2705,18 @@
String dump()
{
- String str = "Items Pool: \n";
+ StringBuilder str = new StringBuilder("Items Pool: \n");
try
{
for (ItemImpl item : getAll())
{
if (item != null)
{
- str +=
- (item.isNode() ? "Node\t\t" : "Property\t") + "\t" + item.isValid() + "\t" + item.isNew() + "\t"
- + item.getInternalIdentifier() + "\t" + item.getPath() + "\n";
+ str.append(item.isNode() ? "Node\t\t" : "Property\t");
+ str.append("\t").append(item.isValid());
+ str.append("\t").append(item.isNew());
+ str.append("\t").append(item.getInternalIdentifier());
+ str.append("\t").append(item.getPath()).append("\n");
}
}
}
@@ -2726,7 +2725,7 @@
log.error(e.getLocalizedMessage(), e);
}
- return str;
+ return str.toString();
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLExceptionHandler.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLExceptionHandler.java 2011-12-28 15:33:38 UTC (rev 5378)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLExceptionHandler.java 2011-12-28 15:45:30 UTC (rev 5379)
@@ -102,7 +102,9 @@
protected String handleAddException(SQLException e, ItemData item) throws RepositoryException,
InvalidItemStateException
{
- String message = "[" + containerName + "] ADD " + (item.isNode() ? "NODE. " : "PROPERTY. ");
+ StringBuilder message = new StringBuilder("[");
+ message.append(containerName).append("] ADD ").append(item.isNode() ? "NODE. " : "PROPERTY. ");
+
String errMessage = e.getMessage();
String itemInfo =
item.getQPath().getAsString() + ", ID: " + item.getIdentifier() + ", ParentID: " + item.getParentIdentifier()
@@ -114,51 +116,55 @@
String umsg = errMessage.toLowerCase().toUpperCase();
if (umsg.indexOf(conn.JCR_FK_ITEM_PARENT) >= 0)
{
- message += "Parent not found. Item " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.ADDED, e);
+ message.append("Parent not found. Item ").append(itemInfo);
+ throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
}
else if (umsg.indexOf(conn.JCR_PK_ITEM) >= 0)
{
- message += "Item already exists. Condition: ID. " + itemInfo;
+ message.append("Item already exists. Condition: ID. ").append(itemInfo);
// InvalidItemStateException ! - because it's impossible add new item with existed UUID
- throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.ADDED, e);
+ throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
}
else if (umsg.indexOf(conn.JCR_IDX_ITEM_PARENT) >= 0 || umsg.indexOf(conn.JCR_IDX_ITEM_PARENT_NAME) >= 0)
{
- message += "Item already exists. Condition: parent ID, name, index. " + itemInfo;
- throw new ItemExistsException(message, e);
+ message.append("Item already exists. Condition: parent ID, name, index. ").append(itemInfo);
+ throw new ItemExistsException(message.toString(), e);
}
else if (umsg.indexOf(conn.JCR_IDX_ITEM_PARENT_ID) >= 0)
{
- message += "Item already exists. Condition: parent ID and ID. " + itemInfo;
- throw new ItemExistsException(message, e);
+ message.append("Item already exists. Condition: parent ID and ID. ").append(itemInfo);
+ throw new ItemExistsException(message.toString(), e);
}
else if (umsg.indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
{
- message += "Property is not exist but the value is being created. Condition: property ID. " + itemInfo;
- throw new RepositoryException(message, e);
+ message.append("Property is not exist but the value is being created. Condition: property ID. ").append(
+ itemInfo);
+ throw new RepositoryException(message.toString(), e);
}
else if (umsg.indexOf(conn.JCR_IDX_VALUE_PROPERTY) >= 0)
{
- message += "Property already exists. Condition: property ID, order number. " + itemInfo;
- throw new RepositoryException(message, e);
+ message.append("Property already exists. Condition: property ID, order number. ").append(itemInfo);
+ throw new RepositoryException(message.toString(), e);
}
else if (umsg.indexOf(conn.JCR_PK_VALUE) >= 0)
{
- message +=
- "[FATAL] Value already exists with the ValueID. Impossible state, check is ValueID is autoincremented. "
- + itemInfo;
- throw new RepositoryException(message, e);
+ message
+ .append(
+ "[FATAL] Value already exists with the ValueID. Impossible state, check is ValueID is autoincremented. ")
+ .append(itemInfo);
+ throw new RepositoryException(message.toString(), e);
}
else if (umsg.indexOf(conn.JCR_PK_REF) >= 0)
{
- message += "Reference chain already exists. Condition: node ID, property ID, order number. " + itemInfo;
- throw new RepositoryException(message, e);
+ message.append("Reference chain already exists. Condition: node ID, property ID, order number. ").append(
+ itemInfo);
+ throw new RepositoryException(message.toString(), e);
}
else if (umsg.indexOf(conn.JCR_IDX_REF_PROPERTY) >= 0)
{
- message += "Referenceable property value already exists. Condition: property ID, order number. " + itemInfo;
- throw new RepositoryException(message, e);
+ message.append("Referenceable property value already exists. Condition: property ID, order number. ")
+ .append(itemInfo);
+ throw new RepositoryException(message.toString(), e);
}
}
@@ -176,8 +182,8 @@
if (me != null)
{
// item already exists
- message += "Item already exists in storage: " + itemInfo;
- ownException = new JCRItemExistsException(message, me.getIdentifier(), ItemState.ADDED, e);
+ message.append("Item already exists in storage: ").append(itemInfo);
+ ownException = new JCRItemExistsException(message.toString(), me.getIdentifier(), ItemState.ADDED, e);
throw ownException;
}
@@ -186,8 +192,8 @@
ItemType.getItemType(item));
if (me != null)
{
- message += "Item already exists in storage: " + itemInfo;
- ownException = new JCRItemExistsException(message, me.getIdentifier(), ItemState.ADDED, e);
+ message.append("Item already exists in storage: ").append(itemInfo);
+ ownException = new JCRItemExistsException(message.toString(), me.getIdentifier(), ItemState.ADDED, e);
throw ownException;
}
@@ -204,20 +210,20 @@
&& errMessage.indexOf(item.getIdentifier()) >= 0)
{
// it's JCR_PK_ITEM violation
- message += "Item already exists. Condition: ID. " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.ADDED, e);
+ message.append("Item already exists. Condition: ID. ").append(itemInfo);
+ throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
}
// DB2 violation
if (e.getClass().getName().indexOf("SqlIntegrityConstraintViolationException") >= 0
&& errMessage.indexOf("SQLCODE=-803") >= 0)
{
- message += "Item already exists." + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.ADDED, e);
+ message.append("Item already exists.").append(itemInfo);
+ throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
}
- message += "Error of item add. " + itemInfo;
- ownException = new RepositoryException(message, e);
+ message.append("Error of item add. ").append(itemInfo);
+ ownException = new RepositoryException(message.toString(), e);
throw ownException;
}
}
@@ -227,8 +233,8 @@
if (ownException != null)
throw ownException;
}
- message += "Error of item add. " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.ADDED, e);
+ message.append("Error of item add. ").append(itemInfo);
+ throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
}
/**
@@ -247,7 +253,9 @@
protected String handleAddException(IOException e, ItemData item) throws RepositoryException,
InvalidItemStateException
{
- String message = "[" + containerName + "] ADD " + (item.isNode() ? "NODE. " : "PROPERTY. ");
+ StringBuilder message = new StringBuilder("[");
+ message.append(containerName).append("] ADD ").append(item.isNode() ? "NODE. " : "PROPERTY. ");
+
String errMessage = e.getMessage();
String itemInfo =
item.getQPath().getAsString() + ", ID: " + item.getIdentifier() + ", ParentID: " + item.getParentIdentifier()
@@ -267,8 +275,8 @@
if (me != null)
{
// item already exists
- message += "Item already exists in storage: " + itemInfo;
- ownException = new ItemExistsException(message, e);
+ message.append("Item already exists in storage: ").append(itemInfo);
+ ownException = new ItemExistsException(message.toString(), e);
throw ownException;
}
@@ -277,8 +285,8 @@
ItemType.getItemType(item));
if (me != null)
{
- message += "Item already exists in storage: " + itemInfo;
- ownException = new ItemExistsException(message, e);
+ message.append("Item already exists in storage: ").append(itemInfo);
+ ownException = new ItemExistsException(message.toString(), e);
throw ownException;
}
@@ -289,8 +297,8 @@
if (ownException != null)
throw ownException;
}
- message += "Error of item add. " + itemInfo;
- ownException = new RepositoryException(message, e);
+ message.append("Error of item add. ").append(itemInfo);
+ ownException = new RepositoryException(message.toString(), e);
throw ownException;
}
}
@@ -300,8 +308,8 @@
if (ownException != null)
throw ownException;
}
- message += "Error of item add. " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.ADDED, e);
+ message.append("Error of item add. ").append(itemInfo);
+ throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
}
/**
@@ -320,7 +328,9 @@
protected String handleDeleteException(SQLException e, ItemData item) throws RepositoryException,
InvalidItemStateException
{
- String message = "[" + containerName + "] DELETE " + (item.isNode() ? "NODE. " : "PROPERTY. ");
+ StringBuilder message = new StringBuilder("[");
+ message.append(containerName).append("] DELETE ").append(item.isNode() ? "NODE. " : "PROPERTY. ");
+
String errMessage = e.getMessage();
String itemInfo =
item.getQPath().getAsString() + " " + item.getIdentifier()
@@ -332,19 +342,19 @@
String umsg = errMessage.toLowerCase().toUpperCase();
if (umsg.indexOf(conn.JCR_FK_ITEM_PARENT) >= 0)
{
- message += "Can not delete parent till childs exists. Item " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.DELETED, e);
+ message.append("Can not delete parent till childs exists. Item ").append(itemInfo);
+ throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.DELETED, e);
}
else if (umsg.indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
{
- message +=
- "[FATAL] Can not delete property item till it contains values. Condition: property ID. " + itemInfo;
- throw new RepositoryException(message, e);
+ message.append("[FATAL] Can not delete property item till it contains values. Condition: property ID. ")
+ .append(itemInfo);
+ throw new RepositoryException(message.toString(), e);
}
}
- message += "Error of item delete " + itemInfo;
- throw new RepositoryException(message, e);
+ message.append("Error of item delete ").append(itemInfo);
+ throw new RepositoryException(message.toString(), e);
}
/**
@@ -363,7 +373,9 @@
public String handleUpdateException(SQLException e, ItemData item) throws RepositoryException,
InvalidItemStateException
{
- String message = "[" + containerName + "] EDIT " + (item.isNode() ? "NODE. " : "PROPERTY. ");
+ StringBuilder message = new StringBuilder("[");
+ message.append(containerName).append("] EDIT ").append(item.isNode() ? "NODE. " : "PROPERTY. ");
+
String errMessage = e.getMessage();
String itemInfo =
item.getQPath().getAsString() + " " + item.getIdentifier()
@@ -373,13 +385,14 @@
// try detect error by foreign key names
if (errMessage.toLowerCase().toUpperCase().indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
{
- message += "Property is not exists but the value is being created. Condition: property ID. " + itemInfo;
- throw new RepositoryException(message, e);
+ message.append("Property is not exists but the value is being created. Condition: property ID. ").append(
+ itemInfo);
+ throw new RepositoryException(message.toString(), e);
}
else if (errMessage.toLowerCase().toUpperCase().indexOf(conn.JCR_PK_ITEM) >= 0)
{
- message += "Item already exists. Condition: ID. " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.UPDATED, e);
+ message.append("Item already exists. Condition: ID. ").append(itemInfo);
+ throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.UPDATED, e);
}
// try detect integrity violation
@@ -390,8 +403,8 @@
if (me != null)
{
// item already exists
- message += "Item already exists. But update errors. " + itemInfo;
- ownException = new RepositoryException(message, e);
+ message.append("Item already exists. But update errors. ").append(itemInfo);
+ ownException = new RepositoryException(message.toString(), e);
throw ownException;
}
}
@@ -401,8 +414,8 @@
if (ownException != null)
throw ownException;
}
- message += "Error of item update. " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.UPDATED, e);
+ message.append("Error of item update. ").append(itemInfo);
+ throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.UPDATED, e);
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java 2011-12-28 15:33:38 UTC (rev 5378)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java 2011-12-28 15:45:30 UTC (rev 5379)
@@ -85,12 +85,12 @@
protected String buildPathX(String fileName)
{
char[] chs = fileName.toCharArray();
- String path = "";
+ StringBuilder path = new StringBuilder();
for (char ch : chs)
{
- path += File.separator + ch;
+ path.append(File.separator).append(ch);
}
- return path;
+ return path.toString();
}
// best for now, 12.07.07
@@ -98,13 +98,13 @@
{
final int xLength = 8;
char[] chs = fileName.toCharArray();
- String path = "";
+ StringBuilder path = new StringBuilder();
for (int i = 0; i < xLength; i++)
{
- path += File.separator + chs[i];
+ path.append(File.separator).append(chs[i]);
}
- path += fileName.substring(xLength);
- return path;
+ path.append(fileName.substring(xLength));
+ return path.toString();
}
protected String buildPathXX2X4(String fileName)
@@ -113,48 +113,49 @@
final int xLength = 8;
boolean xxBlock = true;
char[] chs = fileName.toCharArray();
- String path = "";
+ StringBuilder path = new StringBuilder();
+
for (int xxi = 0; xxi < xxLength; xxi++)
{
char ch = chs[xxi];
- path += xxBlock ? File.separator + ch : ch;
+ path.append(xxBlock ? File.separator + ch : ch);
xxBlock = !xxBlock;
}
for (int xi = xxLength; xi < xLength; xi++)
{
- path += File.separator + chs[xi];
+ path.append(File.separator).append(chs[xi]);
}
- path += fileName.substring(xLength);
- return path;
+ path.append(fileName.substring(xLength));
+ return path.toString();
}
protected String buildPathXX(String fileName)
{
char[] chs = fileName.toCharArray();
- String path = "";
+ StringBuilder path = new StringBuilder();
boolean block = true;
for (char ch : chs)
{
- path += block ? File.separator + ch : ch;
+ path.append(block ? File.separator + ch : ch);
block = !block;
}
- return path;
+ return path.toString();
}
protected String buildPathXX8(String fileName)
{
final int xxLength = 16; // length / 2 = xx length
char[] chs = fileName.toCharArray();
- String path = "";
+ StringBuilder path = new StringBuilder();
boolean block = true;
for (int i = 0; i < xxLength; i++)
{
char ch = chs[i];
- path += block ? File.separator + ch : ch;
+ path.append(block ? File.separator + ch : ch);
block = !block;
}
- path += fileName.substring(xxLength);
- return path;
+ path.append(fileName.substring(xxLength));
+ return path.toString();
}
private static void mkdirs(File dir)
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2011-12-28 15:33:38 UTC (rev 5378)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2011-12-28 15:45:30 UTC (rev 5379)
@@ -249,48 +249,54 @@
private String makeJobInfo(BackupJob job, Throwable error)
{
- String jobInfo = "";
+ StringBuilder jobInfo = new StringBuilder();
if (job != null)
{
switch (job.getType())
{
- case BackupJob.FULL :
- jobInfo += "FULL BACKUP";
+ case BackupJob.FULL : {
+ jobInfo.append("FULL BACKUP");
break;
- case BackupJob.INCREMENTAL :
- jobInfo += "INCREMENTAL BACKUP";
+ }
+ case BackupJob.INCREMENTAL : {
+ jobInfo.append("INCREMENTAL BACKUP");
break;
+ }
}
- jobInfo += " [";
+ jobInfo.append(" [");
switch (job.getState())
{
- case BackupJob.FINISHED :
- jobInfo += "FINISHED";
+ case BackupJob.FINISHED : {
+ jobInfo.append("FINISHED");
break;
- case BackupJob.STARTING :
- jobInfo += "STARTING";
+ }
+ case BackupJob.STARTING : {
+ jobInfo.append("STARTING");
break;
- case BackupJob.WAITING :
- jobInfo += "WAITING";
+ }
+ case BackupJob.WAITING : {
+ jobInfo.append("WAITING");
break;
- case BackupJob.WORKING :
- jobInfo += "WORKING";
+ }
+ case BackupJob.WORKING : {
+ jobInfo.append("WORKING");
break;
+ }
}
- jobInfo += "]";
+ jobInfo.append("]");
if (error != null)
{
- jobInfo += " Error: " + error.getMessage();
+ jobInfo.append(" Error: ").append(error.getMessage());
}
try
{
- jobInfo += " log: " + job.getStorageURL().getPath();
+ jobInfo.append(" log: ").append(job.getStorageURL().getPath());
}
catch (BackupOperationException e)
{
@@ -298,11 +304,11 @@
}
finally
{
- jobInfo += " ";
+ jobInfo.append(" ");
}
}
- return jobInfo;
+ return jobInfo.toString();
}
public String printStackTrace(Throwable error)
Modified: jcr/trunk/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/cli/GetContextInfoCommand.java
===================================================================
--- jcr/trunk/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/cli/GetContextInfoCommand.java 2011-12-28 15:33:38 UTC (rev 5378)
+++ jcr/trunk/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/cli/GetContextInfoCommand.java 2011-12-28 15:45:30 UTC (rev 5379)
@@ -41,10 +41,10 @@
public boolean perform(CliAppContext ctx)
{
- String output = "";
+ StringBuilder output = new StringBuilder();
try
{
- output = "Context info: \n";
+ output.append("Context info: \n");
Item item = ctx.getCurrentItem();
ItemDefinition itemDefinition;
if (item.isNode())
@@ -55,17 +55,19 @@
{
itemDefinition = ((PropertyImpl)item).getDefinition();
}
- output += "username: " + ctx.getUserName() + "\n";
- output += "workspace: " + ctx.getCurrentWorkspace() + "\n";
- output += "item path: " + item.getPath() + "\n";
- String itemType = item.isNode() ? "Node" : "Property";
- output += "item type: " + itemType + "\n";
- output += "item definitions:\n";
- output += " name: " + itemDefinition.getName() + "\n";
- output += " autocreated:" + itemDefinition.isAutoCreated() + "\n";
- output += " mandatory:" + itemDefinition.isMandatory() + "\n";
- output += " protected:" + itemDefinition.isProtected() + "\n";
- output += " onparentversion:" + itemDefinition.getOnParentVersion() + "\n";
+
+ output.append("username: ").append(ctx.getUserName()).append("\n");
+ output.append("workspace: ").append(ctx.getCurrentWorkspace()).append("\n");
+ output.append("item path: ").append(item.getPath()).append("\n");
+ output.append("item type: ").append(item.isNode() ? "Node" : "Property").append("\n");
+ output.append("item definitions:\n");
+ output.append(" name: ").append(itemDefinition.getName()).append("\n");
+ output.append(" autocreated:").append(itemDefinition.isAutoCreated()).append("\n");
+ output.append(" mandatory:").append(itemDefinition.isMandatory()).append("\n");
+ output.append(" protected:").append(itemDefinition.isProtected()).append("\n");
+ output.append(" onparentversion:").append(itemDefinition.getOnParentVersion()).append("\n");
+
+
if (item.isNode() == false)
{
Property property = (Property)item;
@@ -75,32 +77,33 @@
PropertyDefinition propertyDefinition = (PropertyDefinition)itemDefinition;
if (propertyDefinition.isMultiple() == false)
{
- output += "property value:" + property.getValue().getString() + "\n";
+ output.append("property value:").append(property.getValue().getString()).append("\n");
}
else
{
- output += "property value is multiple" + "\n";
+ output.append("property value is multiple\n");
}
}
else
{
- output += "can't show property value:" + "\n";
+ output.append("can't show property value:\n");
}
}
- output += "parameters:\n";
+ output.append("parameters:\n");
+
Iterator parametersIterator = ctx.getParameters().iterator();
int i = 0;
while (parametersIterator.hasNext())
{
- output += " [" + i + "]" + " : " + (String)parametersIterator.next() + "\n";
+ output.append(" [").append(i).append("] : ").append((String)parametersIterator.next()).append("\n");
i++;
}
}
catch (Exception e)
{
- output = "Can't execute command - " + e.getMessage() + "\n";
+ output.append("Can't execute command - ").append(e.getMessage()).append("\n");
}
- ctx.setOutput(output);
+ ctx.setOutput(output.toString());
return false;
}
}
Modified: jcr/trunk/exo.jcr.framework.ftpclient/src/main/java/org/exoplatform/frameworks/ftpclient/data/FtpFileInfoImpl.java
===================================================================
--- jcr/trunk/exo.jcr.framework.ftpclient/src/main/java/org/exoplatform/frameworks/ftpclient/data/FtpFileInfoImpl.java 2011-12-28 15:33:38 UTC (rev 5378)
+++ jcr/trunk/exo.jcr.framework.ftpclient/src/main/java/org/exoplatform/frameworks/ftpclient/data/FtpFileInfoImpl.java 2011-12-28 15:45:30 UTC (rev 5379)
@@ -111,10 +111,10 @@
{
String fileL = fileLine.substring(0);
- String _date = "";
+ StringBuilder _date = new StringBuilder();
while (fileL.charAt(0) != ' ')
{
- _date += fileL.charAt(0);
+ _date.append(fileL.charAt(0));
fileL = fileL.substring(1);
}
@@ -123,11 +123,11 @@
fileL = fileL.substring(1);
}
- String _time = "";
+ StringBuilder _time = new StringBuilder();
while (fileL.charAt(0) != ' ')
{
- _time += fileL.charAt(0);
+ _time.append(fileL.charAt(0));
fileL = fileL.substring(1);
}
@@ -136,7 +136,7 @@
fileL = fileL.substring(1);
}
- String _size = "";
+ StringBuilder _size = new StringBuilder();
if (fileL.indexOf("<DIR>") == 0)
{
@@ -145,13 +145,13 @@
{
fileL = fileL.substring(1);
}
- _size = "0";
+ _size = new StringBuilder("0");
}
else
{
while (fileL.charAt(0) != ' ')
{
- _size += fileL.charAt(0);
+ _size.append(fileL.charAt(0));
fileL = fileL.substring(1);
}
}
@@ -163,10 +163,10 @@
String _name = fileL;
- this.name = _name;
- this.date = _date;
- this.time = _time;
- this.size = new Long(_size);
+ this.name = _name.toString();
+ this.date = _date.toString();
+ this.time = _time.toString();
+ this.size = new Long(_size.toString());
return false;
}
@@ -217,10 +217,10 @@
fileL = fileL.substring(1);
}
- String _size = "";
+ StringBuilder _size = new StringBuilder();
while (fileL.charAt(0) != ' ')
{
- _size += fileL.charAt(0);
+ _size.append(fileL.charAt(0));
fileL = fileL.substring(1);
}
@@ -229,10 +229,10 @@
fileL = fileL.substring(1);
}
- String _month = "";
+ StringBuilder _month = new StringBuilder();
while (fileL.charAt(0) != ' ')
{
- _month += fileL.charAt(0);
+ _month.append(fileL.charAt(0));
fileL = fileL.substring(1);
}
@@ -241,10 +241,10 @@
fileL = fileL.substring(1);
}
- String _day = "";
+ StringBuilder _day = new StringBuilder();
while (fileL.charAt(0) != ' ')
{
- _day += fileL.charAt(0);
+ _day.append(fileL.charAt(0));
fileL = fileL.substring(1);
}
@@ -253,10 +253,10 @@
fileL = fileL.substring(1);
}
- String _time = "";
+ StringBuilder _time = new StringBuilder();
while (fileL.charAt(0) != ' ')
{
- _time += fileL.charAt(0);
+ _time.append(fileL.charAt(0));
fileL = fileL.substring(1);
}
@@ -269,8 +269,8 @@
this.name = _name;
this.date = _month + " " + _day;
- this.time = _time;
- this.size = new Long(_size);
+ this.time = _time.toString();
+ this.size = new Long(_size.toString());
return false;
}
More information about the exo-jcr-commits
mailing list