public class HBaseUtil
extends java.lang.Object
Constructor and Description |
---|
HBaseUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
buildPath(java.util.Stack<java.lang.String> pathStack)
Given the stack of objects containing our target object, build a url path string.
|
static void |
closeHBaseAdmin(org.apache.hadoop.hbase.client.Admin admin) |
static void |
closeHTable(org.apache.hadoop.hbase.client.Table table)
Closes the provided
Table . |
static void |
closeScanner(org.apache.hadoop.hbase.client.ResultScanner scanner)
Close the provided
ResultScanner . |
static void |
commitToHbaseAndExternalSearch(java.lang.String ticket,
java.lang.String objectId,
java.util.Map<java.lang.String,java.lang.Object> properties)
Commits to Hbase and external search
|
static java.lang.Object[] |
convertBytesToArray(byte[] byteArray,
java.lang.String propertyType)
Converts a byte array from HBase into an Object array.
|
static boolean[] |
convertBytesToBooleanArray(byte[] byteArray) |
static java.util.Date[] |
convertBytesToDateArray(byte[] byteArray) |
static double[] |
convertBytesToDoubleArray(byte[] byteArray) |
static int[] |
convertBytesToIntArray(byte[] byteArray) |
static java.lang.String[] |
convertBytesToStringArray(byte[] byteArray) |
static java.util.Map<java.lang.String,java.lang.Object> |
convertEopsToPropertyMap(EnhancedObjectProperty[] newProps)
Converts the newProps into a map of properties that match the Java Type of the OpenContentObject properties map.
|
static byte[] |
convertToByteArray(java.util.List<java.lang.Object> list,
java.lang.String propertyType)
Overloaded version of
convertToByteArray(Object[], String) for handling lists. |
static byte[] |
convertToByteArray(java.lang.Object[] array,
java.lang.String propertyType)
Converts an array of any type into an array of bytes.
|
static EnhancedObjectProperty |
createEOPFromHBaseCell(java.lang.String repoName,
byte[] cellValue) |
static java.lang.String |
createRootFolder(java.lang.String ticket)
Creates the root folder in the repository (ONLY CALL THIS DURING THE "LET THERE BE LIGHT" initiation of HBase 1x.
|
static void |
deleteObjects(java.lang.String[] objectsToDelete) |
static void |
deletePropertiesHBase(java.lang.String objectId,
java.util.List<java.lang.String> properties)
Deletes passed in columns in hbase
|
static void |
externalSearchCommit(java.lang.String ticket,
java.io.InputStream contentStream,
java.lang.String objectId,
java.util.Map<java.lang.String,java.lang.Object[]> metadataNew)
Given a metadata object, index document and commit changes.
|
static EnhancedObjectContent |
getContent(java.lang.String ticket,
org.apache.hadoop.hbase.client.Result hbaseResult,
java.lang.String[] fileExtensions)
Given a hbaseResult from a get request, populate a new EnhancedObjectContent and return it
This method assumes that the hbaseResult that is passed in got both the P and C column families
|
static byte[] |
getContentFromResult(org.apache.hadoop.hbase.client.Result hbaseResult,
java.lang.String mimeType) |
static java.lang.String |
getFirstLifecycleState(java.lang.String ticket,
java.lang.String objectType) |
static java.lang.String |
getIdByPathOrId(java.lang.String ticket,
java.lang.String pathOrId)
This method fetches an id value based on a provided variable that can be either a path to an object or an objectId.
|
static java.lang.String |
getPathToObject(java.lang.String ticket,
java.lang.String rootId,
java.lang.String targetId)
Iterative dfs method to traverse the hbase rel_contains folder tree to find the path to the target object id.
|
static EnhancedCompleteObject |
getProperties(java.lang.String ticket,
org.apache.hadoop.hbase.client.Result hbaseResult)
Given a hbaseResult from a get request, populate a new EnhancedCompleteObject and return it
NOTE: This call does NOT deal with the 'content' column family.
|
static java.util.Map<java.lang.String,java.lang.Object[]> |
getPropertiesMap(java.lang.String objectId) |
static java.lang.String[] |
getRelatedChildIds(java.lang.String parentId,
java.lang.String relationName)
Returns an array of ids of the children of an object
|
static java.lang.String |
getRootFolderId(java.lang.String ticket)
Gets the "root" folder's ID from external search.
|
static org.apache.hadoop.hbase.client.Table |
getTable(java.lang.String tableName,
java.lang.String[] colFamilies)
looks for table with tableName, if it exists it returns it otherwise it creates it
|
static void |
hbaseCommit(java.lang.String objectId,
java.lang.String tableName,
HBaseConfig config,
org.apache.hadoop.hbase.client.Put put)
Given a put object, open an hbase table, make the update, and close the table.
|
static java.util.List<EnhancedObjectProperty> |
mergeProperties(java.util.List<EnhancedObjectProperty> existingProps,
EnhancedObjectProperty[] propsToAdd,
boolean hasBeenMajorVersioned,
boolean isControlledDoc)
Puts the new properties that are passed in onto the eop.
|
static void |
removeAllRelations(java.lang.String ticket,
java.lang.String objectId) |
static void |
removeProperties(java.lang.String ticket,
java.lang.String objectId,
java.util.List<java.lang.String> propsToRemove)
Removes properties without updating modified date/modifier.
|
static void |
setContent(java.lang.String ticket,
java.lang.String objectId,
java.io.InputStream is,
java.lang.String mimeType)
Sets content (native or rendition) in Hbase and external search and updates modified date
|
static void |
setNativeContent(java.lang.String ticket,
java.lang.String objectId,
byte[] content,
java.lang.String mimeType,
org.apache.hadoop.hbase.client.Put put,
java.util.Map<java.lang.String,java.lang.Object[]> metadata) |
static void |
setOCObjectProperties(java.lang.String objectId,
OpenContentObject oco,
org.apache.hadoop.hbase.client.Put put,
java.util.Map<java.lang.String,java.lang.Object[]> metadata) |
static void |
setProperties(java.lang.String objectId,
EnhancedCompleteObject object,
org.apache.hadoop.hbase.client.Put put,
java.util.Map<java.lang.String,java.lang.Object[]> metadata,
boolean newVersion,
boolean majorVersion,
java.lang.String objectType)
Iterates through the properties on the object, determines their type, and adds them to the HBase put request and external search metadata.
|
static void |
transformContent(java.lang.String ticket,
java.lang.String objectId,
HBaseConfig config,
byte[] content,
java.lang.String mimeType)
Given in InputStream, set the appropriate content on the hbase and external search data objects.
|
static void |
updateHbaseProperties(java.lang.String objectId,
java.util.Map<java.lang.String,java.lang.Object[]> properties)
Makes a request to hbase to update the list of properties provided
|
static void |
updateModifiedProperties(java.lang.String ticket,
org.apache.hadoop.hbase.client.Put put,
java.util.Map<java.lang.String,java.lang.Object[]> metadata)
Handle the additional properties that refreshed in setProperties.
|
static void |
updateProperties(java.lang.String ticket,
java.lang.String objectId,
java.util.Map<java.lang.String,java.lang.Object[]> properties)
Updated properties in external search and hbase.
|
public static void closeHTable(org.apache.hadoop.hbase.client.Table table)
Table
. All exceptions thrown attempting to close the table
are swallowed and logged. This method is null-safe.table
- The Table
object to attempt to close. Can be null.public static void closeScanner(org.apache.hadoop.hbase.client.ResultScanner scanner)
ResultScanner
. All exceptions thrown are swallowed and logged and the method is null-safe.scanner
- public static void closeHBaseAdmin(org.apache.hadoop.hbase.client.Admin admin)
public static byte[] convertToByteArray(java.lang.Object[] array, java.lang.String propertyType)
Object[]
- array to turn into bytesString
- propertyTypepublic static byte[] convertToByteArray(java.util.List<java.lang.Object> list, java.lang.String propertyType)
convertToByteArray(Object[], String)
for handling lists. It just converts to an array and passes the array into the corresponding "covert to byte array" method.list
- propertyType
- public static java.lang.Object[] convertBytesToArray(byte[] byteArray, java.lang.String propertyType)
byte[]
- byteArrayString
- propertyTypepublic static java.lang.String[] convertBytesToStringArray(byte[] byteArray)
public static int[] convertBytesToIntArray(byte[] byteArray)
public static double[] convertBytesToDoubleArray(byte[] byteArray)
public static boolean[] convertBytesToBooleanArray(byte[] byteArray)
public static java.util.Date[] convertBytesToDateArray(byte[] byteArray)
public static void hbaseCommit(java.lang.String objectId, java.lang.String tableName, HBaseConfig config, org.apache.hadoop.hbase.client.Put put)
objectId
- config
- put
- public static void externalSearchCommit(java.lang.String ticket, java.io.InputStream contentStream, java.lang.String objectId, java.util.Map<java.lang.String,java.lang.Object[]> metadataNew) throws java.io.UnsupportedEncodingException
objectId
- name
- config
- metadata
- java.io.UnsupportedEncodingException
public static java.lang.String getRootFolderId(java.lang.String ticket)
ticket
- public static java.lang.String createRootFolder(java.lang.String ticket)
ticket
- public static void setContent(java.lang.String ticket, java.lang.String objectId, java.io.InputStream is, java.lang.String mimeType) throws java.io.IOException
ticket
- object
- idis
- - input streammimeType
- java.io.IOException
- for the conversion from InputStream to byte[]public static void setProperties(java.lang.String objectId, EnhancedCompleteObject object, org.apache.hadoop.hbase.client.Put put, java.util.Map<java.lang.String,java.lang.Object[]> metadata, boolean newVersion, boolean majorVersion, java.lang.String objectType)
object
- the object that is being created or updated in HBaseput
- HBase put request (will be updated)metadata
- map of properties used when indexing external search document (will be updated)public static EnhancedObjectContent getContent(java.lang.String ticket, org.apache.hadoop.hbase.client.Result hbaseResult, java.lang.String[] fileExtensions)
ticket
- hbaseResult
- - P and C column families must be populatedpublic static byte[] getContentFromResult(org.apache.hadoop.hbase.client.Result hbaseResult, java.lang.String mimeType)
public static java.util.Map<java.lang.String,java.lang.Object[]> getPropertiesMap(java.lang.String objectId)
public static EnhancedCompleteObject getProperties(java.lang.String ticket, org.apache.hadoop.hbase.client.Result hbaseResult)
ticket
- hbaseResult
- public static void updateModifiedProperties(java.lang.String ticket, org.apache.hadoop.hbase.client.Put put, java.util.Map<java.lang.String,java.lang.Object[]> metadata)
objectType
- put
- metadata
- public static void transformContent(java.lang.String ticket, java.lang.String objectId, HBaseConfig config, byte[] content, java.lang.String mimeType)
ticket
- objectId
- config
- content
- mimeType
- mimeType of the source (native) contentpublic static void setNativeContent(java.lang.String ticket, java.lang.String objectId, byte[] content, java.lang.String mimeType, org.apache.hadoop.hbase.client.Put put, java.util.Map<java.lang.String,java.lang.Object[]> metadata)
public static void setOCObjectProperties(java.lang.String objectId, OpenContentObject oco, org.apache.hadoop.hbase.client.Put put, java.util.Map<java.lang.String,java.lang.Object[]> metadata)
public static EnhancedObjectProperty createEOPFromHBaseCell(java.lang.String repoName, byte[] cellValue)
public static java.lang.String getPathToObject(java.lang.String ticket, java.lang.String rootId, java.lang.String targetId)
ticket
- rootId
- id of root foldertargetId
- id of requested objectpublic static java.lang.String buildPath(java.util.Stack<java.lang.String> pathStack)
pathStack
- stack generated by our dfs path finding method. Top of stack contains target and bottom contains rootrootId
- id of root folderpublic static java.lang.String getIdByPathOrId(java.lang.String ticket, java.lang.String pathOrId)
ticket
- the OC ticket for validationpathOrId
- the path or id for which to find the objectIdpublic static java.lang.String getFirstLifecycleState(java.lang.String ticket, java.lang.String objectType)
public static void deleteObjects(java.lang.String[] objectsToDelete)
public static void removeAllRelations(java.lang.String ticket, java.lang.String objectId)
public static java.util.List<EnhancedObjectProperty> mergeProperties(java.util.List<EnhancedObjectProperty> existingProps, EnhancedObjectProperty[] propsToAdd, boolean hasBeenMajorVersioned, boolean isControlledDoc)
newProps
- properties that are going to be updated/added to/overwritteneops
- List of properties to add/write to the eco.hasBeenMajorVersioned
- boolean that tells whether or not a document has been major versioned beforeisControlledDoc
- boolean that tells whether or not a document is a controlled documentpublic static void removeProperties(java.lang.String ticket, java.lang.String objectId, java.util.List<java.lang.String> propsToRemove)
ticket
- objectId
- propsToRemove
- public static void deletePropertiesHBase(java.lang.String objectId, java.util.List<java.lang.String> properties)
objectId
- properties
- public static java.util.Map<java.lang.String,java.lang.Object> convertEopsToPropertyMap(EnhancedObjectProperty[] newProps)
newProps
- List of eops to be put into the mappublic static void updateProperties(java.lang.String ticket, java.lang.String objectId, java.util.Map<java.lang.String,java.lang.Object[]> properties)
ticket
- objectId
- properties
- public static void updateHbaseProperties(java.lang.String objectId, java.util.Map<java.lang.String,java.lang.Object[]> properties)
objectId
- properties
- public static java.lang.String[] getRelatedChildIds(java.lang.String parentId, java.lang.String relationName)
parentId
- relationName
- public static void commitToHbaseAndExternalSearch(java.lang.String ticket, java.lang.String objectId, java.util.Map<java.lang.String,java.lang.Object> properties)
ticket
- objectId
- object id to commit toproperties.
- The properties to be update. NOTE: assumes that the properties map is repoName to valuepublic static org.apache.hadoop.hbase.client.Table getTable(java.lang.String tableName, java.lang.String[] colFamilies)
tableName
- - name of the table to get or createcolFamilies
- - array of Strings denoting the column familes to create the table with