summaryrefslogtreecommitdiffstats
path: root/base/common/src/com
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2012-07-09 15:12:11 -0400
committerAde Lee <alee@redhat.com>2012-07-12 16:42:18 -0400
commit15ac6d2b8e83a73ac1f62ab0da0d6a85717f28fd (patch)
treef3bd2a816e816ad565f13ce90816a7fd7fb32454 /base/common/src/com
parent9e4e40b80de0ba47702392b9ad6ccecf67496db7 (diff)
downloadpki-15ac6d2b8e83a73ac1f62ab0da0d6a85717f28fd.tar.gz
pki-15ac6d2b8e83a73ac1f62ab0da0d6a85717f28fd.tar.xz
pki-15ac6d2b8e83a73ac1f62ab0da0d6a85717f28fd.zip
NO_HASHCODE_OVERRIDDEN
Diffstat (limited to 'base/common/src/com')
-rw-r--r--base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java54
-rw-r--r--base/common/src/com/netscape/certsrv/util/StatsEvent.java2
-rw-r--r--base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java6
-rw-r--r--base/common/src/com/netscape/cms/servlet/base/CMSStartServlet.java4
-rw-r--r--base/common/src/com/netscape/cmscore/apps/CMSEngine.java9
-rw-r--r--base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java4
-rw-r--r--base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java3
-rw-r--r--base/common/src/com/netscape/cmscore/request/RequestRepository.java2
-rw-r--r--base/common/src/com/netscape/cmscore/security/PWsdrCache.java10
9 files changed, 57 insertions, 37 deletions
diff --git a/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java b/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
index 63480478f..087110a0f 100644
--- a/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
+++ b/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
@@ -129,29 +129,41 @@ public class MetaAttributeDef {
return newDef;
}
- /**
- * Compares this attribute definition with another, for equality.
- * <P>
- *
- * @return true iff names, valueClasses and object identifiers
- * are identical.
- */
- public boolean equals(Object other) {
- if (other == this)
- return true;
-
- if (other instanceof MetaAttributeDef) {
- MetaAttributeDef otherDef = (MetaAttributeDef) other;
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((mName == null) ? 0 : mName.hashCode());
+ result = prime * result + ((mOid == null) ? 0 : mOid.hashCode());
+ result = prime * result + ((mValueClass == null) ? 0 : mValueClass.hashCode());
+ return result;
+ }
- if ((mOid != null && otherDef.mOid != null &&
- !mOid.equals(otherDef.mOid)) ||
- (mOid == null && otherDef.mOid != null) ||
- !mName.equals(otherDef.mName) ||
- !mValueClass.equals(otherDef.mValueClass)) {
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MetaAttributeDef other = (MetaAttributeDef) obj;
+ if (mName == null) {
+ if (other.mName != null)
return false;
- }
- }
- return false;
+ } else if (!mName.equals(other.mName))
+ return false;
+ if (mOid == null) {
+ if (other.mOid != null)
+ return false;
+ } else if (!mOid.equals(other.mOid))
+ return false;
+ if (mValueClass == null) {
+ if (other.mValueClass != null)
+ return false;
+ } else if (!mValueClass.equals(other.mValueClass))
+ return false;
+ return true;
}
/**
diff --git a/base/common/src/com/netscape/certsrv/util/StatsEvent.java b/base/common/src/com/netscape/certsrv/util/StatsEvent.java
index 4137aa3b2..07bbf9547 100644
--- a/base/common/src/com/netscape/certsrv/util/StatsEvent.java
+++ b/base/common/src/com/netscape/certsrv/util/StatsEvent.java
@@ -116,7 +116,7 @@ public class StatsEvent {
long a = getTimeTakenSqSum();
long b = (-2 * getAvg() * getTimeTaken());
long c = getAvg() * getAvg() * getNoOfOperations();
- return (long) Math.sqrt((a + b + c) / getNoOfOperations());
+ return (long) Math.sqrt(((double) (a + b + c)) / getNoOfOperations());
}
}
diff --git a/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java b/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
index 6a1d528ac..c48aa2db4 100644
--- a/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
+++ b/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
@@ -366,8 +366,9 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
destName = baseName + ".der";
destFile = new File(destName);
- if (destFile.exists())
+ if (destFile.exists()) {
destFile.delete();
+ }
renameFile = new File(tempFile);
renameFile.renameTo(destFile);
@@ -402,8 +403,9 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
destName = baseName + ".b64";
destFile = new File(destName);
- if (destFile.exists())
+ if (destFile.exists()) {
destFile.delete();
+ }
renameFile = new File(tempFile);
renameFile.renameTo(destFile);
}
diff --git a/base/common/src/com/netscape/cms/servlet/base/CMSStartServlet.java b/base/common/src/com/netscape/cms/servlet/base/CMSStartServlet.java
index 6f9f43d3a..a8a4008b7 100644
--- a/base/common/src/com/netscape/cms/servlet/base/CMSStartServlet.java
+++ b/base/common/src/com/netscape/cms/servlet/base/CMSStartServlet.java
@@ -75,7 +75,9 @@ public class CMSStartServlet extends HttpServlet {
// Remove the original file if and only if
// the backup copy was successful.
if (f.exists()) {
- f1.delete();
+ if (!f1.delete()) {
+ CMS.debug("CMSStartServlet: init: Cannot delete file : " + old_path);
+ }
// Make certain that the new file has
// the correct permissions.
diff --git a/base/common/src/com/netscape/cmscore/apps/CMSEngine.java b/base/common/src/com/netscape/cmscore/apps/CMSEngine.java
index 13a8bb6bf..84afb8474 100644
--- a/base/common/src/com/netscape/cmscore/apps/CMSEngine.java
+++ b/base/common/src/com/netscape/cmscore/apps/CMSEngine.java
@@ -657,12 +657,11 @@ public class CMSEngine implements ICMSEngine {
try {
/* if the file is not there, create one */
File f = new File(path);
- if (!f.exists()) {
- f.createNewFile();
- }
- } catch (Exception e) {
+ f.createNewFile();
+ } catch (IOException e) {
+ CMS.debug("Cannot create file: " + path + " ." + e.toString());
+ throw new EBaseException("Cannot create file: " + path + " ." + e.toString());
}
-
return new FileConfigStore(path);
}
diff --git a/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java b/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
index 45807d6e9..1ec3c009a 100644
--- a/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
@@ -173,7 +173,9 @@ public class ProfileSubsystem implements IProfileSubsystem {
mConfig.removeSubStore(id);
File file1 = new File(configPath);
- file1.delete();
+ if (!file1.delete()) {
+ CMS.debug("ProfileSubsystem: deleteProfile: Cannot delete the configuration file : " + configPath);
+ }
mProfileIds.removeElement(id);
mProfiles.remove(id);
mProfileClassIds.remove(id);
diff --git a/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java b/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java
index 0576bcf58..86debf3da 100644
--- a/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java
+++ b/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java
@@ -423,13 +423,12 @@ public class PKIJNDIRealm extends JNDIRealm {
String right = expBlock[1];
if (left != null) {
- left.trim();
+ left = left.trim();
} else {
return allowed;
}
//Massage the right hand side of this expression to be a legal string value.
if (right != null) {
- right.trim();
right = right.replace("\"", "");
right = right.trim();
} else {
diff --git a/base/common/src/com/netscape/cmscore/request/RequestRepository.java b/base/common/src/com/netscape/cmscore/request/RequestRepository.java
index ed18c7048..31edc31b0 100644
--- a/base/common/src/com/netscape/cmscore/request/RequestRepository.java
+++ b/base/common/src/com/netscape/cmscore/request/RequestRepository.java
@@ -174,7 +174,7 @@ class RequestRepository
}
}
- if (obj != null || (obj instanceof RepositoryRecord)) {
+ if (obj != null && (obj instanceof RepositoryRecord)) {
record = (RepositoryRecord) obj;
status = record.getPublishingStatus();
} else {
diff --git a/base/common/src/com/netscape/cmscore/security/PWsdrCache.java b/base/common/src/com/netscape/cmscore/security/PWsdrCache.java
index 810605d41..e9c7af8e5 100644
--- a/base/common/src/com/netscape/cmscore/security/PWsdrCache.java
+++ b/base/common/src/com/netscape/cmscore/security/PWsdrCache.java
@@ -382,7 +382,9 @@ public class PWsdrCache {
if (tmpPWcache.exists()) {
// it wasn't removed?
- tmpPWcache.delete();
+ if (!tmpPWcache.delete()) {
+ debug("Could not delete the existing " + mPWcachedb + ".tmp file.");
+ }
tmpPWcache = new File(mPWcachedb + ".tmp");
}
outstream = new FileOutputStream(mPWcachedb + ".tmp");
@@ -417,10 +419,12 @@ public class PWsdrCache {
origFile.getCanonicalPath());
} catch (IOException e) {
CMS.debug("Unable to change file permissions on "
- + origFile.toString());
+ + origFile.toString());
}
}
- tmpPWcache.delete();
+ if (!tmpPWcache.delete()) {
+ debug("Could not delete the existing " + mPWcachedb + ".tmp file.");
+ }
debug("operation completed for " + mPWcachedb);
}
} catch (Exception exx) {