diff --git a/source/java/org/alfresco/repo/domain/contentdata/AbstractContentDataDAOImpl.java b/source/java/org/alfresco/repo/domain/contentdata/AbstractContentDataDAOImpl.java index 824642e306..a18a0143ab 100644 --- a/source/java/org/alfresco/repo/domain/contentdata/AbstractContentDataDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/contentdata/AbstractContentDataDAOImpl.java @@ -191,16 +191,16 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO { throw new IllegalArgumentException("Cannot look up ContentData by null ID."); } - Pair pair = contentUrlCache.getByValue(contentUrl); - if(pair != null) - { - contentUrlCache.updateValue(pair.getFirst(), contentUrl); - } - else - { - pair = contentUrlCache.getOrCreateByValue(contentUrl); - contentUrlCache.updateValue(pair.getFirst(), contentUrl); - } + Pair pair = contentUrlCache.getByValue(contentUrl); + if(pair != null) + { + contentUrlCache.updateValue(pair.getFirst(), contentUrl); + } + else + { + pair = contentUrlCache.getOrCreateByValue(contentUrl); + contentUrlCache.updateValue(pair.getFirst(), contentUrl); + } } @Override @@ -212,8 +212,8 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO } ContentUrlEntity entity = new ContentUrlEntity(); entity.setContentUrl(contentUrl); - Pair pair = contentUrlCache.getByValue(entity); - return (pair == null ? null : pair.getSecond()); + Pair pair = contentUrlCache.getByValue(entity); + return (pair == null ? null : pair.getSecond()); } @Override @@ -223,8 +223,8 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO { throw new IllegalArgumentException("Cannot look up ContentData by null ID."); } - Pair pair = contentUrlCache.getByKey(contentUrlId); - return (pair == null ? null : pair.getSecond()); + Pair pair = contentUrlCache.getByKey(contentUrlId); + return (pair == null ? null : pair.getSecond()); } public void cacheContentDataForNodes(Set nodeIds) @@ -334,21 +334,21 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO @Override public Pair findByValue(ContentUrlEntity entity) { - String contentUrl = entity.getContentUrl(); - ContentUrlEntity ret = getContentUrlEntity(contentUrl); - return (ret != null ? new Pair(ret.getId(), ret) : null); + String contentUrl = entity.getContentUrl(); + ContentUrlEntity ret = getContentUrlEntity(contentUrl); + return (ret != null ? new Pair(ret.getId(), ret) : null); } public Pair createValue(ContentUrlEntity value) { - ContentUrlEntity contentUrlEntity = createContentUrlEntity(value.getContentUrl(), value.getSize(), value.getContentUrlKey()); + ContentUrlEntity contentUrlEntity = createContentUrlEntity(value.getContentUrl(), value.getSize(), value.getContentUrlKey()); // Done return new Pair(contentUrlEntity.getId(), contentUrlEntity); } public Pair findByKey(Long id) { - ContentUrlEntity contentUrlEntity = getContentUrlEntity(id); + ContentUrlEntity contentUrlEntity = getContentUrlEntity(id); if (contentUrlEntity == null) { return null; @@ -371,7 +371,7 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO @Override public int deleteByKey(Long id) { - return deleteContentUrlEntity(id); + return deleteContentUrlEntity(id); } } @@ -381,18 +381,18 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO private ContentData makeContentData(ContentDataEntity contentDataEntity) { // Decode content URL - Long contentUrlId = contentDataEntity.getContentUrlId(); - String contentUrl = null; - if(contentUrlId != null) - { - Pair entityPair = contentUrlCache.getByKey(contentUrlId); - if (entityPair == null) - { - throw new DataIntegrityViolationException("No ContentUrl value exists for ID " + contentUrlId); - } - ContentUrlEntity contentUrlEntity = entityPair.getSecond(); - contentUrl = contentUrlEntity.getContentUrl(); - } + Long contentUrlId = contentDataEntity.getContentUrlId(); + String contentUrl = null; + if(contentUrlId != null) + { + Pair entityPair = contentUrlCache.getByKey(contentUrlId); + if (entityPair == null) + { + throw new DataIntegrityViolationException("No ContentUrl value exists for ID " + contentUrlId); + } + ContentUrlEntity contentUrlEntity = entityPair.getSecond(); + contentUrl = contentUrlEntity.getContentUrl(); + } long size = contentDataEntity.getSize() == null ? 0L : contentDataEntity.getSize().longValue(); @@ -437,11 +437,11 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO long size = contentData.getSize(); if (contentUrl != null) { - ContentUrlEntity contentUrlEntity = new ContentUrlEntity(); - contentUrlEntity.setContentUrl(contentUrl); - contentUrlEntity.setSize(size); - Pair pair = contentUrlCache.getOrCreateByValue(contentUrlEntity); - contentUrlId = pair.getFirst(); + ContentUrlEntity contentUrlEntity = new ContentUrlEntity(); + contentUrlEntity.setContentUrl(contentUrl); + contentUrlEntity.setSize(size); + Pair pair = contentUrlCache.getOrCreateByValue(contentUrlEntity); + contentUrlId = pair.getFirst(); } // Resolve the mimetype @@ -482,12 +482,12 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO ContentUrlEntity contentUrlEntity = null; if(oldContentUrlId != null) { - Pair entityPair = contentUrlCache.getByKey(oldContentUrlId); - if (entityPair == null) - { - throw new DataIntegrityViolationException("No ContentUrl value exists for ID " + oldContentUrlId); - } - contentUrlEntity = entityPair.getSecond(); + Pair entityPair = contentUrlCache.getByKey(oldContentUrlId); + if (entityPair == null) + { + throw new DataIntegrityViolationException("No ContentUrl value exists for ID " + oldContentUrlId); + } + contentUrlEntity = entityPair.getSecond(); } String oldContentUrl = (contentUrlEntity != null ? contentUrlEntity.getContentUrl() : null); @@ -501,15 +501,15 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO } if (newContentUrl != null) { - if(contentUrlEntity == null) - { - contentUrlEntity = new ContentUrlEntity(); - contentUrlEntity.setContentUrl(newContentUrl); - } - Pair pair = contentUrlCache.getOrCreateByValue(contentUrlEntity); - Long newContentUrlId = pair.getFirst(); - contentUrlEntity.setId(newContentUrlId); - contentDataEntity.setContentUrlId(newContentUrlId); + if(contentUrlEntity == null) + { + contentUrlEntity = new ContentUrlEntity(); + contentUrlEntity.setContentUrl(newContentUrl); + } + Pair pair = contentUrlCache.getOrCreateByValue(contentUrlEntity); + Long newContentUrlId = pair.getFirst(); + contentUrlEntity.setId(newContentUrlId); + contentDataEntity.setContentUrlId(newContentUrlId); } else { diff --git a/source/java/org/alfresco/repo/domain/contentdata/ContentDataEntity.java b/source/java/org/alfresco/repo/domain/contentdata/ContentDataEntity.java index 49936178b8..b103cec416 100644 --- a/source/java/org/alfresco/repo/domain/contentdata/ContentDataEntity.java +++ b/source/java/org/alfresco/repo/domain/contentdata/ContentDataEntity.java @@ -45,7 +45,7 @@ public class ContentDataEntity { } - @Override + @Override public int hashCode() { return (id == null ? 0 : id.hashCode()); @@ -69,7 +69,7 @@ public class ContentDataEntity } } - @Override + @Override public String toString() { StringBuilder sb = new StringBuilder(512); diff --git a/source/java/org/alfresco/repo/domain/contentdata/ContentUrlEntity.java b/source/java/org/alfresco/repo/domain/contentdata/ContentUrlEntity.java index 87b91c34d3..fba9a7033b 100644 --- a/source/java/org/alfresco/repo/domain/contentdata/ContentUrlEntity.java +++ b/source/java/org/alfresco/repo/domain/contentdata/ContentUrlEntity.java @@ -36,10 +36,10 @@ import org.alfresco.util.Pair; public class ContentUrlEntity implements Serializable { /** - * - */ - private static final long serialVersionUID = -7697859151521433536L; - public static final Long CONST_LONG_ZERO = new Long(0L); + * + */ + private static final long serialVersionUID = -7697859151521433536L; + public static final Long CONST_LONG_ZERO = new Long(0L); public static final String EMPTY_URL = "empty"; private Long id; @@ -124,29 +124,29 @@ public class ContentUrlEntity implements Serializable public ContentUrlKeyEntity getContentUrlKey() { - return contentUrlKey; - } + return contentUrlKey; + } - public static ContentUrlEntity setContentUrlKey(ContentUrlEntity existing, ContentUrlKeyEntity contentUrlKey) - { - ContentUrlEntity ret = new ContentUrlEntity(); - ret.setContentUrl(existing == null ? null : existing.getContentUrl()); - ret.setContentUrlShort(existing == null ? null : existing.getContentUrlShort()); - ret.setContentUrlCrc(existing == null ? null : existing.getContentUrlCrc()); - ret.setContentUrlKey(contentUrlKey); - ret.setOrphanTime(existing == null ? null : existing.getOrphanTime()); - ret.setSize(existing == null ? null : existing.getSize()); - ret.setId(existing == null ? null : existing.getId()); + public static ContentUrlEntity setContentUrlKey(ContentUrlEntity existing, ContentUrlKeyEntity contentUrlKey) + { + ContentUrlEntity ret = new ContentUrlEntity(); + ret.setContentUrl(existing == null ? null : existing.getContentUrl()); + ret.setContentUrlShort(existing == null ? null : existing.getContentUrlShort()); + ret.setContentUrlCrc(existing == null ? null : existing.getContentUrlCrc()); + ret.setContentUrlKey(contentUrlKey); + ret.setOrphanTime(existing == null ? null : existing.getOrphanTime()); + ret.setSize(existing == null ? null : existing.getSize()); + ret.setId(existing == null ? null : existing.getId()); // done return ret; - } + } - public void setContentUrlKey(ContentUrlKeyEntity contentUrlKey) - { - this.contentUrlKey = contentUrlKey; - } + public void setContentUrlKey(ContentUrlKeyEntity contentUrlKey) + { + this.contentUrlKey = contentUrlKey; + } - public Long getId() + public Long getId() { return id; } diff --git a/source/java/org/alfresco/repo/domain/contentdata/ContentUrlKeyEntity.java b/source/java/org/alfresco/repo/domain/contentdata/ContentUrlKeyEntity.java index e844a29fde..64421f0d57 100644 --- a/source/java/org/alfresco/repo/domain/contentdata/ContentUrlKeyEntity.java +++ b/source/java/org/alfresco/repo/domain/contentdata/ContentUrlKeyEntity.java @@ -32,11 +32,11 @@ import org.apache.commons.codec.DecoderException; */ public class ContentUrlKeyEntity implements Serializable { - private static final long serialVersionUID = -6594309522849585169L; + private static final long serialVersionUID = -6594309522849585169L; - private Long id; - private Long contentUrlId; - private byte[] encryptedKeyAsBytes; + private Long id; + private Long contentUrlId; + private byte[] encryptedKeyAsBytes; private Integer keySize; private String algorithm; private String masterKeystoreId; @@ -49,121 +49,121 @@ public class ContentUrlKeyEntity implements Serializable public ContentUrlKey getContentUrlKey() throws DecoderException { - ContentUrlKey contentUrlKey = new ContentUrlKey(); - contentUrlKey.setAlgorithm(algorithm); - contentUrlKey.setKeySize(keySize); - contentUrlKey.setEncryptedKeyBytes(ByteBuffer.wrap(encryptedKeyAsBytes)); - contentUrlKey.setMasterKeyAlias(masterKeyAlias); - contentUrlKey.setMasterKeystoreId(masterKeystoreId); - contentUrlKey.setUnencryptedFileSize(unencryptedFileSize); - return contentUrlKey; + ContentUrlKey contentUrlKey = new ContentUrlKey(); + contentUrlKey.setAlgorithm(algorithm); + contentUrlKey.setKeySize(keySize); + contentUrlKey.setEncryptedKeyBytes(ByteBuffer.wrap(encryptedKeyAsBytes)); + contentUrlKey.setMasterKeyAlias(masterKeyAlias); + contentUrlKey.setMasterKeystoreId(masterKeystoreId); + contentUrlKey.setUnencryptedFileSize(unencryptedFileSize); + return contentUrlKey; } - public Long getContentUrlId() + public Long getContentUrlId() { - return contentUrlId; - } - - public void setContentUrlId(Long contentUrlId) - { - this.contentUrlId = contentUrlId; - } - - public void setEncryptedKeyAsBytes(byte[] encryptedKeyAsBytes) - { - this.encryptedKeyAsBytes = encryptedKeyAsBytes; - } - - public byte[] getEncryptedKeyAsBytes() - { - return encryptedKeyAsBytes; - } - - public void updateEncryptedKey(EncryptedKey encryptedKey) - { - byte[] encryptedKeyAsBytes = new byte[encryptedKey.getByteBuffer().remaining()]; - encryptedKey.getByteBuffer().get(encryptedKeyAsBytes); - this.encryptedKeyAsBytes = encryptedKeyAsBytes; - setKeySize(encryptedKeyAsBytes.length*8); - setAlgorithm(encryptedKey.getAlgorithm()); - setMasterKeyAlias(encryptedKey.getMasterKeyAlias()); - setMasterKeystoreId(encryptedKey.getMasterKeystoreId()); + return contentUrlId; } - public Long getId() - { - return id; - } + public void setContentUrlId(Long contentUrlId) + { + this.contentUrlId = contentUrlId; + } - public void setId(Long id) - { - this.id = id; - } - - public EncryptedKey getEncryptedKey() throws DecoderException - { - EncryptedKey encryptedKey = new EncryptedKey(getMasterKeystoreId(), getMasterKeyAlias(), - getAlgorithm(), ByteBuffer.wrap(this.encryptedKeyAsBytes)); - return encryptedKey; - } + public void setEncryptedKeyAsBytes(byte[] encryptedKeyAsBytes) + { + this.encryptedKeyAsBytes = encryptedKeyAsBytes; + } - public Long getUnencryptedFileSize() - { - return unencryptedFileSize; - } + public byte[] getEncryptedKeyAsBytes() + { + return encryptedKeyAsBytes; + } - public void setUnencryptedFileSize(Long unencryptedFileSize) - { - this.unencryptedFileSize = unencryptedFileSize; - } + public void updateEncryptedKey(EncryptedKey encryptedKey) + { + byte[] encryptedKeyAsBytes = new byte[encryptedKey.getByteBuffer().remaining()]; + encryptedKey.getByteBuffer().get(encryptedKeyAsBytes); + this.encryptedKeyAsBytes = encryptedKeyAsBytes; + setKeySize(encryptedKeyAsBytes.length*8); + setAlgorithm(encryptedKey.getAlgorithm()); + setMasterKeyAlias(encryptedKey.getMasterKeyAlias()); + setMasterKeystoreId(encryptedKey.getMasterKeystoreId()); + } - public void setKeySize(Integer keySize) - { - this.keySize = keySize; - } + public Long getId() + { + return id; + } - public Integer getKeySize() - { - return keySize; - } + public void setId(Long id) + { + this.id = id; + } + + public EncryptedKey getEncryptedKey() throws DecoderException + { + EncryptedKey encryptedKey = new EncryptedKey(getMasterKeystoreId(), getMasterKeyAlias(), + getAlgorithm(), ByteBuffer.wrap(this.encryptedKeyAsBytes)); + return encryptedKey; + } - public String getAlgorithm() - { - return algorithm; - } + public Long getUnencryptedFileSize() + { + return unencryptedFileSize; + } - public void setAlgorithm(String algorithm) - { - this.algorithm = algorithm; - } + public void setUnencryptedFileSize(Long unencryptedFileSize) + { + this.unencryptedFileSize = unencryptedFileSize; + } - public String getMasterKeystoreId() - { - return masterKeystoreId; - } + public void setKeySize(Integer keySize) + { + this.keySize = keySize; + } - public void setMasterKeystoreId(String masterKeystoreId) - { - this.masterKeystoreId = masterKeystoreId; - } + public Integer getKeySize() + { + return keySize; + } - public String getMasterKeyAlias() - { - return masterKeyAlias; - } + public String getAlgorithm() + { + return algorithm; + } - public void setMasterKeyAlias(String masterKeyAlias) - { - this.masterKeyAlias = masterKeyAlias; - } + public void setAlgorithm(String algorithm) + { + this.algorithm = algorithm; + } - @Override - public String toString() - { - return "ContentUrlKeyEntity [id=" + id + ", encryptedKeyAsBytes=" - + encryptedKeyAsBytes+ ", keySize=" + keySize + ", algorithm=" - + algorithm + ", masterKeystoreId=" + masterKeystoreId - + ", masterKeyAlias=" + masterKeyAlias - + ", unencryptedFileSize=" + unencryptedFileSize + "]"; - } + public String getMasterKeystoreId() + { + return masterKeystoreId; + } + + public void setMasterKeystoreId(String masterKeystoreId) + { + this.masterKeystoreId = masterKeystoreId; + } + + public String getMasterKeyAlias() + { + return masterKeyAlias; + } + + public void setMasterKeyAlias(String masterKeyAlias) + { + this.masterKeyAlias = masterKeyAlias; + } + + @Override + public String toString() + { + return "ContentUrlKeyEntity [id=" + id + ", encryptedKeyAsBytes=" + + encryptedKeyAsBytes+ ", keySize=" + keySize + ", algorithm=" + + algorithm + ", masterKeystoreId=" + masterKeystoreId + + ", masterKeyAlias=" + masterKeyAlias + + ", unencryptedFileSize=" + unencryptedFileSize + "]"; + } } diff --git a/source/java/org/alfresco/repo/domain/contentdata/EncryptedKey.java b/source/java/org/alfresco/repo/domain/contentdata/EncryptedKey.java index 9c409e7b04..4565c102cb 100644 --- a/source/java/org/alfresco/repo/domain/contentdata/EncryptedKey.java +++ b/source/java/org/alfresco/repo/domain/contentdata/EncryptedKey.java @@ -5,51 +5,51 @@ import java.nio.ByteBuffer; public class EncryptedKey implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private String masterKeystoreId; - private String masterKeyAlias; - private final String algorithm; - private final ByteBuffer encryptedKeyBytes; - - public EncryptedKey(String masterKeystoreId, String masterKeyAlias, String algorithm, ByteBuffer encryptedKeyBytes) - { - this.masterKeyAlias = masterKeyAlias; - this.masterKeystoreId = masterKeystoreId; - this.algorithm = algorithm; - this.encryptedKeyBytes = encryptedKeyBytes.asReadOnlyBuffer(); - } + private String masterKeystoreId; + private String masterKeyAlias; + private final String algorithm; + private final ByteBuffer encryptedKeyBytes; + + public EncryptedKey(String masterKeystoreId, String masterKeyAlias, String algorithm, ByteBuffer encryptedKeyBytes) + { + this.masterKeyAlias = masterKeyAlias; + this.masterKeystoreId = masterKeystoreId; + this.algorithm = algorithm; + this.encryptedKeyBytes = encryptedKeyBytes.asReadOnlyBuffer(); + } - public String getMasterKeystoreId() - { - return masterKeystoreId; - } + public String getMasterKeystoreId() + { + return masterKeystoreId; + } - public String getMasterKeyAlias() - { - return masterKeyAlias; - } + public String getMasterKeyAlias() + { + return masterKeyAlias; + } - public ByteBuffer getEncryptedKeyBytes() - { - return encryptedKeyBytes; - } + public ByteBuffer getEncryptedKeyBytes() + { + return encryptedKeyBytes; + } - public String getAlgorithm() - { - return this.algorithm; - } - - public ByteBuffer getByteBuffer() - { - return this.encryptedKeyBytes.asReadOnlyBuffer(); - } + public String getAlgorithm() + { + return this.algorithm; + } + + public ByteBuffer getByteBuffer() + { + return this.encryptedKeyBytes.asReadOnlyBuffer(); + } - public int keySize() - { - byte[] eKey = new byte[getByteBuffer().remaining()]; - getByteBuffer().get(eKey); - return eKey.length * 8; - } + public int keySize() + { + byte[] eKey = new byte[getByteBuffer().remaining()]; + getByteBuffer().get(eKey); + return eKey.length * 8; + } } diff --git a/source/java/org/alfresco/repo/domain/contentdata/SymmetricKeyCount.java b/source/java/org/alfresco/repo/domain/contentdata/SymmetricKeyCount.java index 4308a92bcf..6344494627 100644 --- a/source/java/org/alfresco/repo/domain/contentdata/SymmetricKeyCount.java +++ b/source/java/org/alfresco/repo/domain/contentdata/SymmetricKeyCount.java @@ -16,39 +16,39 @@ import java.io.Serializable; */ public class SymmetricKeyCount implements Serializable { - private static final long serialVersionUID = -7823962733045613866L; + private static final long serialVersionUID = -7823962733045613866L; - private String masterKeyAlias; - private int count; + private String masterKeyAlias; + private int count; - public SymmetricKeyCount() - { - } + public SymmetricKeyCount() + { + } - public String getMasterKeyAlias() - { - return masterKeyAlias; - } + public String getMasterKeyAlias() + { + return masterKeyAlias; + } - public void setMasterKeyAlias(String masterKeyAlias) - { - this.masterKeyAlias = masterKeyAlias; - } + public void setMasterKeyAlias(String masterKeyAlias) + { + this.masterKeyAlias = masterKeyAlias; + } - public int getCount() - { - return count; - } + public int getCount() + { + return count; + } - public void setCount(int count) - { - this.count = count; - } + public void setCount(int count) + { + this.count = count; + } - @Override - public String toString() - { - return "SymmetricKeyCount [masterKeyAlias=" + masterKeyAlias - + ", count=" + count + "]"; - } + @Override + public String toString() + { + return "SymmetricKeyCount [masterKeyAlias=" + masterKeyAlias + + ", count=" + count + "]"; + } }