id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
136,100 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java | PlainChangesLogImpl.getLastChildrenStates | public Collection<ItemState> getLastChildrenStates(ItemData rootData, boolean forNodes)
{
Map<String, ItemState> children =
forNodes ? lastChildNodeStates.get(rootData.getIdentifier()) : lastChildPropertyStates.get(rootData
.getIdentifier());
return children == null ? new ArrayList<ItemState>() : children.values();
} | java | public Collection<ItemState> getLastChildrenStates(ItemData rootData, boolean forNodes)
{
Map<String, ItemState> children =
forNodes ? lastChildNodeStates.get(rootData.getIdentifier()) : lastChildPropertyStates.get(rootData
.getIdentifier());
return children == null ? new ArrayList<ItemState>() : children.values();
} | [
"public",
"Collection",
"<",
"ItemState",
">",
"getLastChildrenStates",
"(",
"ItemData",
"rootData",
",",
"boolean",
"forNodes",
")",
"{",
"Map",
"<",
"String",
",",
"ItemState",
">",
"children",
"=",
"forNodes",
"?",
"lastChildNodeStates",
".",
"get",
"(",
"r... | Collect last in ChangesLog order item child changes.
@param rootData
- a item root of the changes scan
@param forNodes
retrieves nodes' ItemStates is true, or properties' otherwise
@return child items states | [
"Collect",
"last",
"in",
"ChangesLog",
"order",
"item",
"child",
"changes",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java#L627-L634 |
136,101 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java | PlainChangesLogImpl.getLastState | public ItemState getLastState(ItemData item, boolean forNode)
{
Map<String, ItemState> children =
forNode ? lastChildNodeStates.get(item.getParentIdentifier()) : lastChildPropertyStates.get(item
.getParentIdentifier());
return children == null ? null : children.get(item.getIdentifier());
} | java | public ItemState getLastState(ItemData item, boolean forNode)
{
Map<String, ItemState> children =
forNode ? lastChildNodeStates.get(item.getParentIdentifier()) : lastChildPropertyStates.get(item
.getParentIdentifier());
return children == null ? null : children.get(item.getIdentifier());
} | [
"public",
"ItemState",
"getLastState",
"(",
"ItemData",
"item",
",",
"boolean",
"forNode",
")",
"{",
"Map",
"<",
"String",
",",
"ItemState",
">",
"children",
"=",
"forNode",
"?",
"lastChildNodeStates",
".",
"get",
"(",
"item",
".",
"getParentIdentifier",
"(",
... | Return the last item state from ChangesLog.
@param item
an item data the last state which need to be taken
@param forNode
retrieves nodes' ItemStates is true, or properties' otherwise
@return the last item state | [
"Return",
"the",
"last",
"item",
"state",
"from",
"ChangesLog",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java#L645-L652 |
136,102 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java | PlainChangesLogImpl.getChildrenChanges | public List<ItemState> getChildrenChanges(String rootIdentifier, boolean forNodes)
{
List<ItemState> children =
forNodes ? childNodeStates.get(rootIdentifier) : childPropertyStates.get(rootIdentifier);
return children == null ? new ArrayList<ItemState>() : children;
} | java | public List<ItemState> getChildrenChanges(String rootIdentifier, boolean forNodes)
{
List<ItemState> children =
forNodes ? childNodeStates.get(rootIdentifier) : childPropertyStates.get(rootIdentifier);
return children == null ? new ArrayList<ItemState>() : children;
} | [
"public",
"List",
"<",
"ItemState",
">",
"getChildrenChanges",
"(",
"String",
"rootIdentifier",
",",
"boolean",
"forNodes",
")",
"{",
"List",
"<",
"ItemState",
">",
"children",
"=",
"forNodes",
"?",
"childNodeStates",
".",
"get",
"(",
"rootIdentifier",
")",
":... | Collect changes of all item direct childs. Including the item itself.
@param rootIdentifier root identifier
@param forNodes must be returned nodes or properties
@return Collect changes of all item direct childs | [
"Collect",
"changes",
"of",
"all",
"item",
"direct",
"childs",
".",
"Including",
"the",
"item",
"itself",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java#L659-L665 |
136,103 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java | PlainChangesLogImpl.getItemState | public ItemState getItemState(String itemIdentifier, int state)
{
return index.get(new IDStateBasedKey(itemIdentifier, state));
} | java | public ItemState getItemState(String itemIdentifier, int state)
{
return index.get(new IDStateBasedKey(itemIdentifier, state));
} | [
"public",
"ItemState",
"getItemState",
"(",
"String",
"itemIdentifier",
",",
"int",
"state",
")",
"{",
"return",
"index",
".",
"get",
"(",
"new",
"IDStateBasedKey",
"(",
"itemIdentifier",
",",
"state",
")",
")",
";",
"}"
] | Get ItemState by identifier and state.
NOTE: Uses index HashMap.
@param itemIdentifier
@param state
@return | [
"Get",
"ItemState",
"by",
"identifier",
"and",
"state",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java#L676-L679 |
136,104 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java | PlainChangesLogImpl.getItemState | public ItemState getItemState(NodeData parentData, QPathEntry name, ItemType itemType) throws IllegalPathException
{
if (itemType != ItemType.UNKNOWN)
{
return index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, itemType));
}
else
{
ItemState state = index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, ItemType.NODE));
if (state == null)
{
state = index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, ItemType.PROPERTY));
}
return state;
}
} | java | public ItemState getItemState(NodeData parentData, QPathEntry name, ItemType itemType) throws IllegalPathException
{
if (itemType != ItemType.UNKNOWN)
{
return index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, itemType));
}
else
{
ItemState state = index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, ItemType.NODE));
if (state == null)
{
state = index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, ItemType.PROPERTY));
}
return state;
}
} | [
"public",
"ItemState",
"getItemState",
"(",
"NodeData",
"parentData",
",",
"QPathEntry",
"name",
",",
"ItemType",
"itemType",
")",
"throws",
"IllegalPathException",
"{",
"if",
"(",
"itemType",
"!=",
"ItemType",
".",
"UNKNOWN",
")",
"{",
"return",
"index",
".",
... | Get ItemState by parent and item name.
@param parentData
parent
@param name
item name
@param itemType
item type
@return
@throws IllegalPathException | [
"Get",
"ItemState",
"by",
"parent",
"and",
"item",
"name",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java#L716-L731 |
136,105 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java | PlainChangesLogImpl.getItemStates | public List<ItemState> getItemStates(String itemIdentifier)
{
List<ItemState> states = new ArrayList<ItemState>();
List<ItemState> currentStates = getAllStates();
for (int i = 0, length = currentStates.size(); i < length; i++)
{
ItemState state = currentStates.get(i);
if (state.getData().getIdentifier().equals(itemIdentifier))
{
states.add(state);
}
}
return states;
} | java | public List<ItemState> getItemStates(String itemIdentifier)
{
List<ItemState> states = new ArrayList<ItemState>();
List<ItemState> currentStates = getAllStates();
for (int i = 0, length = currentStates.size(); i < length; i++)
{
ItemState state = currentStates.get(i);
if (state.getData().getIdentifier().equals(itemIdentifier))
{
states.add(state);
}
}
return states;
} | [
"public",
"List",
"<",
"ItemState",
">",
"getItemStates",
"(",
"String",
"itemIdentifier",
")",
"{",
"List",
"<",
"ItemState",
">",
"states",
"=",
"new",
"ArrayList",
"<",
"ItemState",
">",
"(",
")",
";",
"List",
"<",
"ItemState",
">",
"currentStates",
"="... | Gets items by identifier.
@param itemIdentifier
@return | [
"Gets",
"items",
"by",
"identifier",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java#L765-L778 |
136,106 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java | PlainChangesLogImpl.findItemState | public ItemState findItemState(String id, Boolean isPersisted, int... states) throws IllegalPathException
{
List<ItemState> allStates = getAllStates();
// search from the end for state
for (int i = allStates.size() - 1; i >= 0; i--)
{
ItemState istate = allStates.get(i);
boolean byState = false;
if (states != null)
{
for (int state : states)
{
if (istate.getState() == state)
{
byState = true;
break;
}
}
}
else
{
byState = true;
}
if (byState && (isPersisted != null ? istate.isPersisted() == isPersisted : true)
&& istate.getData().getIdentifier().equals(id))
{
return istate;
}
}
return null;
} | java | public ItemState findItemState(String id, Boolean isPersisted, int... states) throws IllegalPathException
{
List<ItemState> allStates = getAllStates();
// search from the end for state
for (int i = allStates.size() - 1; i >= 0; i--)
{
ItemState istate = allStates.get(i);
boolean byState = false;
if (states != null)
{
for (int state : states)
{
if (istate.getState() == state)
{
byState = true;
break;
}
}
}
else
{
byState = true;
}
if (byState && (isPersisted != null ? istate.isPersisted() == isPersisted : true)
&& istate.getData().getIdentifier().equals(id))
{
return istate;
}
}
return null;
} | [
"public",
"ItemState",
"findItemState",
"(",
"String",
"id",
",",
"Boolean",
"isPersisted",
",",
"int",
"...",
"states",
")",
"throws",
"IllegalPathException",
"{",
"List",
"<",
"ItemState",
">",
"allStates",
"=",
"getAllStates",
"(",
")",
";",
"// search from t... | Search for an item state of item with given id and filter parameters.
@param id
- item id
@param states
- filter only the given list states (ORed), or all if it's null
@param isPersisted
- filter only persisted/not persisted, or all if it's null
@return - filtered {@link ItemState}
@throws IllegalPathException | [
"Search",
"for",
"an",
"item",
"state",
"of",
"item",
"with",
"given",
"id",
"and",
"filter",
"parameters",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java#L830-L860 |
136,107 | exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/CollectionResource.java | CollectionResource.checkIfFile | private String checkIfFile(Node node)
{
return ResourceUtil.isFile(node) ? Boolean.TRUE.toString() : Boolean.FALSE.toString();
} | java | private String checkIfFile(Node node)
{
return ResourceUtil.isFile(node) ? Boolean.TRUE.toString() : Boolean.FALSE.toString();
} | [
"private",
"String",
"checkIfFile",
"(",
"Node",
"node",
")",
"{",
"return",
"ResourceUtil",
".",
"isFile",
"(",
"node",
")",
"?",
"Boolean",
".",
"TRUE",
".",
"toString",
"(",
")",
":",
"Boolean",
".",
"FALSE",
".",
"toString",
"(",
")",
";",
"}"
] | Checks if node is file or folder. | [
"Checks",
"if",
"node",
"is",
"file",
"or",
"folder",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/CollectionResource.java#L538-L541 |
136,108 | exoplatform/jcr | exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionImpl.java | ManagedSessionImpl.onConnectionClosed | private void onConnectionClosed()
{
ConnectionEvent evt = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
for (ConnectionEventListener listener : listeners)
{
try
{
listener.connectionClosed(evt);
}
catch (Exception e1)
{
LOG.warn("An error occurs while notifying the listener " + listener, e1);
}
}
} | java | private void onConnectionClosed()
{
ConnectionEvent evt = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
for (ConnectionEventListener listener : listeners)
{
try
{
listener.connectionClosed(evt);
}
catch (Exception e1)
{
LOG.warn("An error occurs while notifying the listener " + listener, e1);
}
}
} | [
"private",
"void",
"onConnectionClosed",
"(",
")",
"{",
"ConnectionEvent",
"evt",
"=",
"new",
"ConnectionEvent",
"(",
"this",
",",
"ConnectionEvent",
".",
"CONNECTION_CLOSED",
")",
";",
"for",
"(",
"ConnectionEventListener",
"listener",
":",
"listeners",
")",
"{",... | Broadcasts the connection closed event | [
"Broadcasts",
"the",
"connection",
"closed",
"event"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionImpl.java#L190-L204 |
136,109 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDefinitionAccessProvider.java | NodeTypeDefinitionAccessProvider.readPropertyDefinitions | public PropertyDefinitionData[] readPropertyDefinitions(NodeData nodeData) throws NodeTypeReadException,
RepositoryException
{
List<PropertyDefinitionData> propertyDefinitionDataList;
List<NodeData> childDefinitions = dataManager.getChildNodesData(nodeData);
InternalQName name = null;
if (childDefinitions.size() > 0)
name = readMandatoryName(nodeData, null, Constants.JCR_NODETYPENAME);
else
return new PropertyDefinitionData[0];
propertyDefinitionDataList = new ArrayList<PropertyDefinitionData>();
for (NodeData childDefinition : childDefinitions)
{
if (Constants.NT_PROPERTYDEFINITION.equals(childDefinition.getPrimaryTypeName()))
{
propertyDefinitionDataList.add(propertyDefinitionAccessProvider.read(childDefinition, name));
}
}
return propertyDefinitionDataList.toArray(new PropertyDefinitionData[propertyDefinitionDataList.size()]);
} | java | public PropertyDefinitionData[] readPropertyDefinitions(NodeData nodeData) throws NodeTypeReadException,
RepositoryException
{
List<PropertyDefinitionData> propertyDefinitionDataList;
List<NodeData> childDefinitions = dataManager.getChildNodesData(nodeData);
InternalQName name = null;
if (childDefinitions.size() > 0)
name = readMandatoryName(nodeData, null, Constants.JCR_NODETYPENAME);
else
return new PropertyDefinitionData[0];
propertyDefinitionDataList = new ArrayList<PropertyDefinitionData>();
for (NodeData childDefinition : childDefinitions)
{
if (Constants.NT_PROPERTYDEFINITION.equals(childDefinition.getPrimaryTypeName()))
{
propertyDefinitionDataList.add(propertyDefinitionAccessProvider.read(childDefinition, name));
}
}
return propertyDefinitionDataList.toArray(new PropertyDefinitionData[propertyDefinitionDataList.size()]);
} | [
"public",
"PropertyDefinitionData",
"[",
"]",
"readPropertyDefinitions",
"(",
"NodeData",
"nodeData",
")",
"throws",
"NodeTypeReadException",
",",
"RepositoryException",
"{",
"List",
"<",
"PropertyDefinitionData",
">",
"propertyDefinitionDataList",
";",
"List",
"<",
"Node... | Read PropertyDefinitionData of node type.
@param nodeData
@return
@throws RepositoryException
@throws NodeTypeReadException
@throws RepositoryException | [
"Read",
"PropertyDefinitionData",
"of",
"node",
"type",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDefinitionAccessProvider.java#L155-L178 |
136,110 | exoplatform/jcr | exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryChainLogPathHelper.java | RepositoryChainLogPathHelper.getPath | public static String getPath(String relativePath, String backupDirCanonicalPath) throws MalformedURLException
{
String path = "file:" + backupDirCanonicalPath + "/" + relativePath;
URL urlPath = new URL(resolveFileURL(path));
return urlPath.getFile();
} | java | public static String getPath(String relativePath, String backupDirCanonicalPath) throws MalformedURLException
{
String path = "file:" + backupDirCanonicalPath + "/" + relativePath;
URL urlPath = new URL(resolveFileURL(path));
return urlPath.getFile();
} | [
"public",
"static",
"String",
"getPath",
"(",
"String",
"relativePath",
",",
"String",
"backupDirCanonicalPath",
")",
"throws",
"MalformedURLException",
"{",
"String",
"path",
"=",
"\"file:\"",
"+",
"backupDirCanonicalPath",
"+",
"\"/\"",
"+",
"relativePath",
";",
"... | Will be returned absolute path.
@param relativePath
String, relative path.
@param backupDirCanonicalPath
String, path to backup dir
@return String
Will be returned absolute path.
@throws MalformedURLException | [
"Will",
"be",
"returned",
"absolute",
"path",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryChainLogPathHelper.java#L68-L75 |
136,111 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AbstractInconsistencyRepair.java | AbstractInconsistencyRepair.rollback | protected void rollback(WorkspaceStorageConnection conn)
{
try
{
if (conn != null)
{
conn.rollback();
}
}
catch (IllegalStateException e)
{
LOG.error("Can not rollback connection", e);
}
catch (RepositoryException e)
{
LOG.error("Can not rollback connection", e);
}
} | java | protected void rollback(WorkspaceStorageConnection conn)
{
try
{
if (conn != null)
{
conn.rollback();
}
}
catch (IllegalStateException e)
{
LOG.error("Can not rollback connection", e);
}
catch (RepositoryException e)
{
LOG.error("Can not rollback connection", e);
}
} | [
"protected",
"void",
"rollback",
"(",
"WorkspaceStorageConnection",
"conn",
")",
"{",
"try",
"{",
"if",
"(",
"conn",
"!=",
"null",
")",
"{",
"conn",
".",
"rollback",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"LOG",
... | Rollback data. | [
"Rollback",
"data",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AbstractInconsistencyRepair.java#L94-L111 |
136,112 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java | JDBCWorkspaceDataContainer.cleanupSwapDirectory | private void cleanupSwapDirectory()
{
PrivilegedAction<Void> action = new PrivilegedAction<Void>()
{
public Void run()
{
File[] files = containerConfig.spoolConfig.tempDirectory.listFiles();
if (files != null && files.length > 0)
{
LOG.info("Some files have been found in the swap directory and will be deleted");
for (int i = 0; i < files.length; i++)
{
File file = files[i];
// We don't use the file cleaner in case the deletion failed to ensure
// that the file won't be deleted while it is currently re-used
file.delete();
}
}
return null;
}
};
SecurityHelper.doPrivilegedAction(action);
} | java | private void cleanupSwapDirectory()
{
PrivilegedAction<Void> action = new PrivilegedAction<Void>()
{
public Void run()
{
File[] files = containerConfig.spoolConfig.tempDirectory.listFiles();
if (files != null && files.length > 0)
{
LOG.info("Some files have been found in the swap directory and will be deleted");
for (int i = 0; i < files.length; i++)
{
File file = files[i];
// We don't use the file cleaner in case the deletion failed to ensure
// that the file won't be deleted while it is currently re-used
file.delete();
}
}
return null;
}
};
SecurityHelper.doPrivilegedAction(action);
} | [
"private",
"void",
"cleanupSwapDirectory",
"(",
")",
"{",
"PrivilegedAction",
"<",
"Void",
">",
"action",
"=",
"new",
"PrivilegedAction",
"<",
"Void",
">",
"(",
")",
"{",
"public",
"Void",
"run",
"(",
")",
"{",
"File",
"[",
"]",
"files",
"=",
"containerC... | Deletes all the files from the swap directory | [
"Deletes",
"all",
"the",
"files",
"from",
"the",
"swap",
"directory"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java#L338-L360 |
136,113 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java | JDBCWorkspaceDataContainer.checkIntegrity | protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig)
throws RepositoryConfigurationException
{
DatabaseStructureType dbType = DBInitializerHelper.getDatabaseType(wsConfig);
for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries())
{
if (wsEntry.getName().equals(wsConfig.getName())
|| !wsEntry.getContainer().getType().equals(wsConfig.getContainer().getType())
|| !wsEntry.getContainer().getType().equals(this.getClass().getName()))
{
continue;
}
if (!DBInitializerHelper.getDatabaseType(wsEntry).equals(dbType))
{
throw new RepositoryConfigurationException("All workspaces must be of same DB type. But "
+ wsEntry.getName() + "=" + DBInitializerHelper.getDatabaseType(wsEntry) + " and " + wsConfig.getName()
+ "=" + dbType);
}
// source name
String wsSourceName = null;
String newWsSourceName = null;
try
{
wsSourceName = wsEntry.getContainer().getParameterValue("sourceName");
newWsSourceName = wsConfig.getContainer().getParameterValue("sourceName");
}
catch (RepositoryConfigurationException e)
{
if (LOG.isTraceEnabled())
{
LOG.trace("An exception occurred: " + e.getMessage());
}
}
if (wsSourceName != null && newWsSourceName != null)
{
if (dbType.isShareSameDatasource())
{
if (!wsSourceName.equals(newWsSourceName))
{
throw new RepositoryConfigurationException("SourceName must be equals in " + dbType
+ "-database repository." + " Check " + wsEntry.getName() + " and " + wsConfig.getName());
}
}
else
{
if (wsSourceName.equals(newWsSourceName))
{
throw new RepositoryConfigurationException("SourceName " + wsSourceName + " already in use in "
+ wsEntry.getName() + ". SourceName must be different in " + dbType
+ "-database structure type. Check configuration for " + wsConfig.getName());
}
}
continue;
}
}
} | java | protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig)
throws RepositoryConfigurationException
{
DatabaseStructureType dbType = DBInitializerHelper.getDatabaseType(wsConfig);
for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries())
{
if (wsEntry.getName().equals(wsConfig.getName())
|| !wsEntry.getContainer().getType().equals(wsConfig.getContainer().getType())
|| !wsEntry.getContainer().getType().equals(this.getClass().getName()))
{
continue;
}
if (!DBInitializerHelper.getDatabaseType(wsEntry).equals(dbType))
{
throw new RepositoryConfigurationException("All workspaces must be of same DB type. But "
+ wsEntry.getName() + "=" + DBInitializerHelper.getDatabaseType(wsEntry) + " and " + wsConfig.getName()
+ "=" + dbType);
}
// source name
String wsSourceName = null;
String newWsSourceName = null;
try
{
wsSourceName = wsEntry.getContainer().getParameterValue("sourceName");
newWsSourceName = wsConfig.getContainer().getParameterValue("sourceName");
}
catch (RepositoryConfigurationException e)
{
if (LOG.isTraceEnabled())
{
LOG.trace("An exception occurred: " + e.getMessage());
}
}
if (wsSourceName != null && newWsSourceName != null)
{
if (dbType.isShareSameDatasource())
{
if (!wsSourceName.equals(newWsSourceName))
{
throw new RepositoryConfigurationException("SourceName must be equals in " + dbType
+ "-database repository." + " Check " + wsEntry.getName() + " and " + wsConfig.getName());
}
}
else
{
if (wsSourceName.equals(newWsSourceName))
{
throw new RepositoryConfigurationException("SourceName " + wsSourceName + " already in use in "
+ wsEntry.getName() + ". SourceName must be different in " + dbType
+ "-database structure type. Check configuration for " + wsConfig.getName());
}
}
continue;
}
}
} | [
"protected",
"void",
"checkIntegrity",
"(",
"WorkspaceEntry",
"wsConfig",
",",
"RepositoryEntry",
"repConfig",
")",
"throws",
"RepositoryConfigurationException",
"{",
"DatabaseStructureType",
"dbType",
"=",
"DBInitializerHelper",
".",
"getDatabaseType",
"(",
"wsConfig",
")"... | Checks if DataSources used in right manner.
@param wsConfig
Workspace configuration
@param repConfig
Repository configuration
@throws RepositoryConfigurationException
in case of configuration errors | [
"Checks",
"if",
"DataSources",
"used",
"in",
"right",
"manner",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java#L402-L462 |
136,114 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java | JDBCWorkspaceDataContainer.validateDialect | private String validateDialect(String confParam)
{
for (String dbType : DBConstants.DB_DIALECTS)
{
if (confParam.equals(dbType))
{
return dbType;
}
}
return DBConstants.DB_DIALECT_AUTO; // by default
} | java | private String validateDialect(String confParam)
{
for (String dbType : DBConstants.DB_DIALECTS)
{
if (confParam.equals(dbType))
{
return dbType;
}
}
return DBConstants.DB_DIALECT_AUTO; // by default
} | [
"private",
"String",
"validateDialect",
"(",
"String",
"confParam",
")",
"{",
"for",
"(",
"String",
"dbType",
":",
"DBConstants",
".",
"DB_DIALECTS",
")",
"{",
"if",
"(",
"confParam",
".",
"equals",
"(",
"dbType",
")",
")",
"{",
"return",
"dbType",
";",
... | Validate dialect.
@param confParam
String, dialect from configuration.
@return String
return dialect. By default return DB_DIALECT_GENERIC. | [
"Validate",
"dialect",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java#L1233-L1244 |
136,115 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/infinispan/ISPNQuotaPersister.java | ISPNQuotaPersister.composeWorkspaceUniqueName | private String composeWorkspaceUniqueName(String repositoryName, String workspaceName)
{
StringBuilder builder = new StringBuilder();
builder.append(repositoryName);
builder.append('/');
builder.append(workspaceName);
builder.append('/');
return builder.toString();
} | java | private String composeWorkspaceUniqueName(String repositoryName, String workspaceName)
{
StringBuilder builder = new StringBuilder();
builder.append(repositoryName);
builder.append('/');
builder.append(workspaceName);
builder.append('/');
return builder.toString();
} | [
"private",
"String",
"composeWorkspaceUniqueName",
"(",
"String",
"repositoryName",
",",
"String",
"workspaceName",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"repositoryName",
")",
";",
"builde... | Compose unique workspace name in global JCR instance. | [
"Compose",
"unique",
"workspace",
"name",
"in",
"global",
"JCR",
"instance",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/infinispan/ISPNQuotaPersister.java#L523-L532 |
136,116 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryCreationSynchronizer.java | RepositoryCreationSynchronizer.waitForCoordinator | private void waitForCoordinator()
{
LOG.info("Waiting to be released by the coordinator");
try
{
lock.await();
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
} | java | private void waitForCoordinator()
{
LOG.info("Waiting to be released by the coordinator");
try
{
lock.await();
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
} | [
"private",
"void",
"waitForCoordinator",
"(",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Waiting to be released by the coordinator\"",
")",
";",
"try",
"{",
"lock",
".",
"await",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
"... | Make the current node wait until being released by the coordinator | [
"Make",
"the",
"current",
"node",
"wait",
"until",
"being",
"released",
"by",
"the",
"coordinator"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryCreationSynchronizer.java#L275-L286 |
136,117 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java | ISPNCacheFactory.configureCacheStore | public static void configureCacheStore(MappedParametrizedObjectEntry parameterEntry,
String dataSourceParamName, String dataColumnParamName, String idColumnParamName, String timeColumnParamName, String dialectParamName)
throws RepositoryException
{
String dataSourceName = parameterEntry.getParameterValue(dataSourceParamName, null);
String dialect = parameterEntry.getParameterValue(dialectParamName, DBConstants.DB_DIALECT_AUTO).toUpperCase();
// if data source is defined, then inject correct data-types.
// Also it cans be not defined and nothing should be injected
// (i.e. no cache loader is used (possibly pattern is changed, to used another cache loader))
DataSource dataSource;
try
{
dataSource = (DataSource)new InitialContext().lookup(dataSourceName);
}
catch (NamingException e)
{
throw new RepositoryException(e.getMessage(), e);
}
String blobType;
String charType;
String timeStampType;
try
{
blobType = JDBCUtils.getAppropriateBlobType(dataSource);
if (dialect.startsWith(DBConstants.DB_DIALECT_MYSQL) && dialect.endsWith("-UTF8"))
{
charType = "VARCHAR(255)";
}
else
{
charType = JDBCUtils.getAppropriateCharType(dataSource);
}
timeStampType = JDBCUtils.getAppropriateTimestamp(dataSource);
}
catch (SQLException e)
{
throw new RepositoryException(e.getMessage(), e);
}
// set parameters if not defined
// if parameter is missing in configuration, then
// getParameterValue(INFINISPAN_JDBC_CL_DATA_COLUMN, INFINISPAN_JDBC_CL_AUTO)
// will return INFINISPAN_JDBC_CL_AUTO. If parameter is present in configuration and
//equals to "auto", then it should be replaced
// with correct value for given database
if (parameterEntry.getParameterValue(dataColumnParamName, "auto").equalsIgnoreCase("auto"))
{
parameterEntry.putParameterValue(dataColumnParamName, blobType);
}
if (parameterEntry.getParameterValue(idColumnParamName, "auto").equalsIgnoreCase("auto"))
{
parameterEntry.putParameterValue(idColumnParamName, charType);
}
if (parameterEntry.getParameterValue(timeColumnParamName, "auto").equalsIgnoreCase("auto"))
{
parameterEntry.putParameterValue(timeColumnParamName, timeStampType);
}
} | java | public static void configureCacheStore(MappedParametrizedObjectEntry parameterEntry,
String dataSourceParamName, String dataColumnParamName, String idColumnParamName, String timeColumnParamName, String dialectParamName)
throws RepositoryException
{
String dataSourceName = parameterEntry.getParameterValue(dataSourceParamName, null);
String dialect = parameterEntry.getParameterValue(dialectParamName, DBConstants.DB_DIALECT_AUTO).toUpperCase();
// if data source is defined, then inject correct data-types.
// Also it cans be not defined and nothing should be injected
// (i.e. no cache loader is used (possibly pattern is changed, to used another cache loader))
DataSource dataSource;
try
{
dataSource = (DataSource)new InitialContext().lookup(dataSourceName);
}
catch (NamingException e)
{
throw new RepositoryException(e.getMessage(), e);
}
String blobType;
String charType;
String timeStampType;
try
{
blobType = JDBCUtils.getAppropriateBlobType(dataSource);
if (dialect.startsWith(DBConstants.DB_DIALECT_MYSQL) && dialect.endsWith("-UTF8"))
{
charType = "VARCHAR(255)";
}
else
{
charType = JDBCUtils.getAppropriateCharType(dataSource);
}
timeStampType = JDBCUtils.getAppropriateTimestamp(dataSource);
}
catch (SQLException e)
{
throw new RepositoryException(e.getMessage(), e);
}
// set parameters if not defined
// if parameter is missing in configuration, then
// getParameterValue(INFINISPAN_JDBC_CL_DATA_COLUMN, INFINISPAN_JDBC_CL_AUTO)
// will return INFINISPAN_JDBC_CL_AUTO. If parameter is present in configuration and
//equals to "auto", then it should be replaced
// with correct value for given database
if (parameterEntry.getParameterValue(dataColumnParamName, "auto").equalsIgnoreCase("auto"))
{
parameterEntry.putParameterValue(dataColumnParamName, blobType);
}
if (parameterEntry.getParameterValue(idColumnParamName, "auto").equalsIgnoreCase("auto"))
{
parameterEntry.putParameterValue(idColumnParamName, charType);
}
if (parameterEntry.getParameterValue(timeColumnParamName, "auto").equalsIgnoreCase("auto"))
{
parameterEntry.putParameterValue(timeColumnParamName, timeStampType);
}
} | [
"public",
"static",
"void",
"configureCacheStore",
"(",
"MappedParametrizedObjectEntry",
"parameterEntry",
",",
"String",
"dataSourceParamName",
",",
"String",
"dataColumnParamName",
",",
"String",
"idColumnParamName",
",",
"String",
"timeColumnParamName",
",",
"String",
"d... | If a cache store is used, then fills-in column types. If column type configured from jcr-configuration file,
then nothing is overridden. Parameters are injected into the given parameterEntry. | [
"If",
"a",
"cache",
"store",
"is",
"used",
"then",
"fills",
"-",
"in",
"column",
"types",
".",
"If",
"column",
"type",
"configured",
"from",
"jcr",
"-",
"configuration",
"file",
"then",
"nothing",
"is",
"overridden",
".",
"Parameters",
"are",
"injected",
"... | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java#L323-L385 |
136,118 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/CacheKey.java | CacheKey.getGroup | @Group
public final String getGroup()
{
if (fullGroupName != null)
{
return fullGroupName;
}
StringBuilder sb = new StringBuilder();
if (ownerId != null)
{
sb.append(ownerId).append('-');
}
return fullGroupName = sb.append(group == null ? id : group).toString();
} | java | @Group
public final String getGroup()
{
if (fullGroupName != null)
{
return fullGroupName;
}
StringBuilder sb = new StringBuilder();
if (ownerId != null)
{
sb.append(ownerId).append('-');
}
return fullGroupName = sb.append(group == null ? id : group).toString();
} | [
"@",
"Group",
"public",
"final",
"String",
"getGroup",
"(",
")",
"{",
"if",
"(",
"fullGroupName",
"!=",
"null",
")",
"{",
"return",
"fullGroupName",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"ownerId",
"!=",
... | This method is used for the grouping when its enabled. It will return
the value of the group if it has been explicitly set otherwise it will
return the value of the fullId
@return the group | [
"This",
"method",
"is",
"used",
"for",
"the",
"grouping",
"when",
"its",
"enabled",
".",
"It",
"will",
"return",
"the",
"value",
"of",
"the",
"group",
"if",
"it",
"has",
"been",
"explicitly",
"set",
"otherwise",
"it",
"will",
"return",
"the",
"value",
"o... | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/CacheKey.java#L127-L140 |
136,119 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/BaseQuotaManager.java | BaseQuotaManager.getGlobalDataSizeDirectly | public long getGlobalDataSizeDirectly() throws QuotaManagerException
{
long size = 0;
for (RepositoryQuotaManager rqm : rQuotaManagers.values())
{
size += rqm.getRepositoryDataSizeDirectly();
}
return size;
} | java | public long getGlobalDataSizeDirectly() throws QuotaManagerException
{
long size = 0;
for (RepositoryQuotaManager rqm : rQuotaManagers.values())
{
size += rqm.getRepositoryDataSizeDirectly();
}
return size;
} | [
"public",
"long",
"getGlobalDataSizeDirectly",
"(",
")",
"throws",
"QuotaManagerException",
"{",
"long",
"size",
"=",
"0",
";",
"for",
"(",
"RepositoryQuotaManager",
"rqm",
":",
"rQuotaManagers",
".",
"values",
"(",
")",
")",
"{",
"size",
"+=",
"rqm",
".",
"... | Calculates the global size by summing sized of all repositories. | [
"Calculates",
"the",
"global",
"size",
"by",
"summing",
"sized",
"of",
"all",
"repositories",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/BaseQuotaManager.java#L377-L386 |
136,120 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/xpath/XPathQueryBuilder.java | XPathQueryBuilder.createPathQueryNode | private PathQueryNode createPathQueryNode(SimpleNode node) {
root.setLocationNode(factory.createPathQueryNode(root));
node.childrenAccept(this, root.getLocationNode());
return root.getLocationNode();
} | java | private PathQueryNode createPathQueryNode(SimpleNode node) {
root.setLocationNode(factory.createPathQueryNode(root));
node.childrenAccept(this, root.getLocationNode());
return root.getLocationNode();
} | [
"private",
"PathQueryNode",
"createPathQueryNode",
"(",
"SimpleNode",
"node",
")",
"{",
"root",
".",
"setLocationNode",
"(",
"factory",
".",
"createPathQueryNode",
"(",
"root",
")",
")",
";",
"node",
".",
"childrenAccept",
"(",
"this",
",",
"root",
".",
"getLo... | Creates the primary path query node.
@param node xpath node representing the root of the parsed tree.
@return the path qurey node | [
"Creates",
"the",
"primary",
"path",
"query",
"node",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/xpath/XPathQueryBuilder.java#L752-L756 |
136,121 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/JCRDateFormat.java | JCRDateFormat.parse | public static Calendar parse(String dateString) throws ValueFormatException
{
try
{
return ISO8601.parseEx(dateString);
}
catch (ParseException e)
{
throw new ValueFormatException("Can not parse date from [" + dateString + "]", e);
}
catch (NumberFormatException e)
{
throw new ValueFormatException("Can not parse date from [" + dateString + "]", e);
}
} | java | public static Calendar parse(String dateString) throws ValueFormatException
{
try
{
return ISO8601.parseEx(dateString);
}
catch (ParseException e)
{
throw new ValueFormatException("Can not parse date from [" + dateString + "]", e);
}
catch (NumberFormatException e)
{
throw new ValueFormatException("Can not parse date from [" + dateString + "]", e);
}
} | [
"public",
"static",
"Calendar",
"parse",
"(",
"String",
"dateString",
")",
"throws",
"ValueFormatException",
"{",
"try",
"{",
"return",
"ISO8601",
".",
"parseEx",
"(",
"dateString",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"throw",
"new"... | Parse string using possible formats list.
@param dateString
- date string
@return - calendar
@throws ValueFormatException | [
"Parse",
"string",
"using",
"possible",
"formats",
"list",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/JCRDateFormat.java#L116-L130 |
136,122 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/BloomFilter.java | BloomFilter.createHash | public static long createHash(byte[] data) {
long h = 0;
byte[] res;
synchronized (digestFunction) {
res = digestFunction.digest(data);
}
for (int i = 0; i < 4; i++) {
h <<= 8;
h |= ((int) res[i]) & 0xFF;
}
return h;
} | java | public static long createHash(byte[] data) {
long h = 0;
byte[] res;
synchronized (digestFunction) {
res = digestFunction.digest(data);
}
for (int i = 0; i < 4; i++) {
h <<= 8;
h |= ((int) res[i]) & 0xFF;
}
return h;
} | [
"public",
"static",
"long",
"createHash",
"(",
"byte",
"[",
"]",
"data",
")",
"{",
"long",
"h",
"=",
"0",
";",
"byte",
"[",
"]",
"res",
";",
"synchronized",
"(",
"digestFunction",
")",
"{",
"res",
"=",
"digestFunction",
".",
"digest",
"(",
"data",
")... | Generates a digest based on the contents of an array of bytes.
@param data specifies input data.
@return digest as long. | [
"Generates",
"a",
"digest",
"based",
"on",
"the",
"contents",
"of",
"an",
"array",
"of",
"bytes",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/BloomFilter.java#L148-L161 |
136,123 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBBackup.java | DBBackup.backup | public static void backup(File storageDir, Connection jdbcConn, Map<String, String> scripts) throws BackupException
{
Exception exc = null;
ZipObjectWriter contentWriter = null;
ZipObjectWriter contentLenWriter = null;
try
{
contentWriter =
new ZipObjectWriter(PrivilegedFileHelper.zipOutputStream(new File(storageDir, CONTENT_ZIP_FILE)));
contentLenWriter =
new ZipObjectWriter(PrivilegedFileHelper.zipOutputStream(new File(storageDir, CONTENT_LEN_ZIP_FILE)));
for (Entry<String, String> entry : scripts.entrySet())
{
dumpTable(jdbcConn, entry.getKey(), entry.getValue(), storageDir, contentWriter, contentLenWriter);
}
}
catch (IOException e)
{
exc = e;
throw new BackupException(e);
}
catch (SQLException e)
{
exc = e;
throw new BackupException("SQL Exception: " + JDBCUtils.getFullMessage(e), e);
}
finally
{
if (jdbcConn != null)
{
try
{
jdbcConn.close();
}
catch (SQLException e)
{
if (exc != null)
{
LOG.error("Can't close connection", e);
throw new BackupException(exc);
}
else
{
throw new BackupException(e);
}
}
}
try
{
if (contentWriter != null)
{
contentWriter.close();
}
if (contentLenWriter != null)
{
contentLenWriter.close();
}
}
catch (IOException e)
{
if (exc != null)
{
LOG.error("Can't close zip", e);
throw new BackupException(exc);
}
else
{
throw new BackupException(e);
}
}
}
} | java | public static void backup(File storageDir, Connection jdbcConn, Map<String, String> scripts) throws BackupException
{
Exception exc = null;
ZipObjectWriter contentWriter = null;
ZipObjectWriter contentLenWriter = null;
try
{
contentWriter =
new ZipObjectWriter(PrivilegedFileHelper.zipOutputStream(new File(storageDir, CONTENT_ZIP_FILE)));
contentLenWriter =
new ZipObjectWriter(PrivilegedFileHelper.zipOutputStream(new File(storageDir, CONTENT_LEN_ZIP_FILE)));
for (Entry<String, String> entry : scripts.entrySet())
{
dumpTable(jdbcConn, entry.getKey(), entry.getValue(), storageDir, contentWriter, contentLenWriter);
}
}
catch (IOException e)
{
exc = e;
throw new BackupException(e);
}
catch (SQLException e)
{
exc = e;
throw new BackupException("SQL Exception: " + JDBCUtils.getFullMessage(e), e);
}
finally
{
if (jdbcConn != null)
{
try
{
jdbcConn.close();
}
catch (SQLException e)
{
if (exc != null)
{
LOG.error("Can't close connection", e);
throw new BackupException(exc);
}
else
{
throw new BackupException(e);
}
}
}
try
{
if (contentWriter != null)
{
contentWriter.close();
}
if (contentLenWriter != null)
{
contentLenWriter.close();
}
}
catch (IOException e)
{
if (exc != null)
{
LOG.error("Can't close zip", e);
throw new BackupException(exc);
}
else
{
throw new BackupException(e);
}
}
}
} | [
"public",
"static",
"void",
"backup",
"(",
"File",
"storageDir",
",",
"Connection",
"jdbcConn",
",",
"Map",
"<",
"String",
",",
"String",
">",
"scripts",
")",
"throws",
"BackupException",
"{",
"Exception",
"exc",
"=",
"null",
";",
"ZipObjectWriter",
"contentWr... | Backup tables.
@param storageDir
the directory to store data
@param jdbcConn
the connection to database
@param scripts
map which contains table name and respective SQL query to get data
@throws BackupException
if any exception occurred | [
"Backup",
"tables",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBBackup.java#L116-L193 |
136,124 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBBackup.java | DBBackup.dumpTable | private static void dumpTable(Connection jdbcConn, String tableName, String script, File storageDir,
ZipObjectWriter contentWriter, ZipObjectWriter contentLenWriter) throws IOException, SQLException
{
SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
Statement stmt = null;
ResultSet rs = null;
try
{
contentWriter.putNextEntry(new ZipEntry(tableName));
contentLenWriter.putNextEntry(new ZipEntry(tableName));
stmt = jdbcConn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(FETCH_SIZE);
rs = stmt.executeQuery(script);
ResultSetMetaData metaData = rs.getMetaData();
int columnCount = metaData.getColumnCount();
int[] columnType = new int[columnCount];
contentWriter.writeInt(columnCount);
for (int i = 0; i < columnCount; i++)
{
columnType[i] = metaData.getColumnType(i + 1);
contentWriter.writeInt(columnType[i]);
contentWriter.writeString(metaData.getColumnName(i + 1));
}
byte[] tmpBuff = new byte[2048];
// Now we can output the actual data
while (rs.next())
{
for (int i = 0; i < columnCount; i++)
{
InputStream value;
if (columnType[i] == Types.VARBINARY || columnType[i] == Types.LONGVARBINARY
|| columnType[i] == Types.BLOB || columnType[i] == Types.BINARY || columnType[i] == Types.OTHER)
{
value = rs.getBinaryStream(i + 1);
}
else
{
String str = rs.getString(i + 1);
value = str == null ? null : new ByteArrayInputStream(str.getBytes(Constants.DEFAULT_ENCODING));
}
if (value == null)
{
contentLenWriter.writeLong(-1);
}
else
{
long len = 0;
int read = 0;
while ((read = value.read(tmpBuff)) >= 0)
{
contentWriter.write(tmpBuff, 0, read);
len += read;
}
contentLenWriter.writeLong(len);
}
}
}
contentWriter.closeEntry();
contentLenWriter.closeEntry();
}
finally
{
if (rs != null)
{
rs.close();
}
if (stmt != null)
{
stmt.close();
}
}
} | java | private static void dumpTable(Connection jdbcConn, String tableName, String script, File storageDir,
ZipObjectWriter contentWriter, ZipObjectWriter contentLenWriter) throws IOException, SQLException
{
SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
Statement stmt = null;
ResultSet rs = null;
try
{
contentWriter.putNextEntry(new ZipEntry(tableName));
contentLenWriter.putNextEntry(new ZipEntry(tableName));
stmt = jdbcConn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(FETCH_SIZE);
rs = stmt.executeQuery(script);
ResultSetMetaData metaData = rs.getMetaData();
int columnCount = metaData.getColumnCount();
int[] columnType = new int[columnCount];
contentWriter.writeInt(columnCount);
for (int i = 0; i < columnCount; i++)
{
columnType[i] = metaData.getColumnType(i + 1);
contentWriter.writeInt(columnType[i]);
contentWriter.writeString(metaData.getColumnName(i + 1));
}
byte[] tmpBuff = new byte[2048];
// Now we can output the actual data
while (rs.next())
{
for (int i = 0; i < columnCount; i++)
{
InputStream value;
if (columnType[i] == Types.VARBINARY || columnType[i] == Types.LONGVARBINARY
|| columnType[i] == Types.BLOB || columnType[i] == Types.BINARY || columnType[i] == Types.OTHER)
{
value = rs.getBinaryStream(i + 1);
}
else
{
String str = rs.getString(i + 1);
value = str == null ? null : new ByteArrayInputStream(str.getBytes(Constants.DEFAULT_ENCODING));
}
if (value == null)
{
contentLenWriter.writeLong(-1);
}
else
{
long len = 0;
int read = 0;
while ((read = value.read(tmpBuff)) >= 0)
{
contentWriter.write(tmpBuff, 0, read);
len += read;
}
contentLenWriter.writeLong(len);
}
}
}
contentWriter.closeEntry();
contentLenWriter.closeEntry();
}
finally
{
if (rs != null)
{
rs.close();
}
if (stmt != null)
{
stmt.close();
}
}
} | [
"private",
"static",
"void",
"dumpTable",
"(",
"Connection",
"jdbcConn",
",",
"String",
"tableName",
",",
"String",
"script",
",",
"File",
"storageDir",
",",
"ZipObjectWriter",
"contentWriter",
",",
"ZipObjectWriter",
"contentLenWriter",
")",
"throws",
"IOException",
... | Dump table.
@throws IOException
@throws SQLException | [
"Dump",
"table",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBBackup.java#L201-L286 |
136,125 | exoplatform/jcr | exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java | BackupManagerImpl.startBackup | BackupChain startBackup(BackupConfig config, BackupJobListener jobListener) throws BackupOperationException,
BackupConfigurationException, RepositoryException, RepositoryConfigurationException
{
validateBackupConfig(config);
Calendar startTime = Calendar.getInstance();
File dir =
FileNameProducer.generateBackupSetDir(config.getRepository(), config.getWorkspace(), config.getBackupDir()
.getPath(), startTime);
PrivilegedFileHelper.mkdirs(dir);
config.setBackupDir(dir);
BackupChain bchain =
new BackupChainImpl(config, logsDirectory, repoService, fullBackupType, incrementalBackupType, IdGenerator
.generate(), logsDirectory, startTime);
bchain.addListener(messagesListener);
bchain.addListener(jobListener);
currentBackups.add(bchain);
bchain.startBackup();
return bchain;
} | java | BackupChain startBackup(BackupConfig config, BackupJobListener jobListener) throws BackupOperationException,
BackupConfigurationException, RepositoryException, RepositoryConfigurationException
{
validateBackupConfig(config);
Calendar startTime = Calendar.getInstance();
File dir =
FileNameProducer.generateBackupSetDir(config.getRepository(), config.getWorkspace(), config.getBackupDir()
.getPath(), startTime);
PrivilegedFileHelper.mkdirs(dir);
config.setBackupDir(dir);
BackupChain bchain =
new BackupChainImpl(config, logsDirectory, repoService, fullBackupType, incrementalBackupType, IdGenerator
.generate(), logsDirectory, startTime);
bchain.addListener(messagesListener);
bchain.addListener(jobListener);
currentBackups.add(bchain);
bchain.startBackup();
return bchain;
} | [
"BackupChain",
"startBackup",
"(",
"BackupConfig",
"config",
",",
"BackupJobListener",
"jobListener",
")",
"throws",
"BackupOperationException",
",",
"BackupConfigurationException",
",",
"RepositoryException",
",",
"RepositoryConfigurationException",
"{",
"validateBackupConfig",
... | Internally used for call with job listener from scheduler.
@param config
@param jobListener
@return
@throws BackupOperationException
@throws BackupConfigurationException
@throws RepositoryException
@throws RepositoryConfigurationException | [
"Internally",
"used",
"for",
"call",
"with",
"job",
"listener",
"from",
"scheduler",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java#L764-L787 |
136,126 | exoplatform/jcr | exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java | BackupManagerImpl.validateBackupConfig | private void validateBackupConfig(RepositoryBackupConfig config) throws BackupConfigurationException
{
if (config.getIncrementalJobPeriod() < 0)
{
throw new BackupConfigurationException("The parameter 'incremental job period' can not be negative.");
}
if (config.getIncrementalJobNumber() < 0)
{
throw new BackupConfigurationException("The parameter 'incremental job number' can not be negative.");
}
if (config.getIncrementalJobPeriod() == 0 && config.getBackupType() == BackupManager.FULL_AND_INCREMENTAL)
{
config.setIncrementalJobPeriod(defaultIncrementalJobPeriod);
}
} | java | private void validateBackupConfig(RepositoryBackupConfig config) throws BackupConfigurationException
{
if (config.getIncrementalJobPeriod() < 0)
{
throw new BackupConfigurationException("The parameter 'incremental job period' can not be negative.");
}
if (config.getIncrementalJobNumber() < 0)
{
throw new BackupConfigurationException("The parameter 'incremental job number' can not be negative.");
}
if (config.getIncrementalJobPeriod() == 0 && config.getBackupType() == BackupManager.FULL_AND_INCREMENTAL)
{
config.setIncrementalJobPeriod(defaultIncrementalJobPeriod);
}
} | [
"private",
"void",
"validateBackupConfig",
"(",
"RepositoryBackupConfig",
"config",
")",
"throws",
"BackupConfigurationException",
"{",
"if",
"(",
"config",
".",
"getIncrementalJobPeriod",
"(",
")",
"<",
"0",
")",
"{",
"throw",
"new",
"BackupConfigurationException",
"... | Initialize backup chain to workspace backup.
@param config
@return
@throws BackupOperationException
@throws BackupConfigurationException
@throws RepositoryException
@throws RepositoryConfigurationException | [
"Initialize",
"backup",
"chain",
"to",
"workspace",
"backup",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java#L799-L815 |
136,127 | exoplatform/jcr | exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java | BackupManagerImpl.readParamsFromFile | private void readParamsFromFile()
{
PropertiesParam pps = initParams.getPropertiesParam(BACKUP_PROPERTIES);
backupDir = pps.getProperty(BACKUP_DIR);
// full backup type can be not defined. Using default.
fullBackupType =
pps.getProperty(FULL_BACKUP_TYPE) == null ? DEFAULT_VALUE_FULL_BACKUP_TYPE : pps.getProperty(FULL_BACKUP_TYPE);
// incremental backup can be not configured. Using default values.
defIncrPeriod =
pps.getProperty(DEFAULT_INCREMENTAL_JOB_PERIOD) == null ? DEFAULT_VALUE_INCREMENTAL_JOB_PERIOD : pps
.getProperty(DEFAULT_INCREMENTAL_JOB_PERIOD);
incrementalBackupType =
pps.getProperty(INCREMENTAL_BACKUP_TYPE) == null ? DEFAULT_VALUE_INCREMENTAL_BACKUP_TYPE : pps
.getProperty(INCREMENTAL_BACKUP_TYPE);
LOG.info("Backup dir from configuration file: " + backupDir);
LOG.info("Full backup type from configuration file: " + fullBackupType);
LOG.info("(Experimental) Incremental backup type from configuration file: " + incrementalBackupType);
LOG.info("(Experimental) Default incremental job period from configuration file: " + defIncrPeriod);
checkParams();
} | java | private void readParamsFromFile()
{
PropertiesParam pps = initParams.getPropertiesParam(BACKUP_PROPERTIES);
backupDir = pps.getProperty(BACKUP_DIR);
// full backup type can be not defined. Using default.
fullBackupType =
pps.getProperty(FULL_BACKUP_TYPE) == null ? DEFAULT_VALUE_FULL_BACKUP_TYPE : pps.getProperty(FULL_BACKUP_TYPE);
// incremental backup can be not configured. Using default values.
defIncrPeriod =
pps.getProperty(DEFAULT_INCREMENTAL_JOB_PERIOD) == null ? DEFAULT_VALUE_INCREMENTAL_JOB_PERIOD : pps
.getProperty(DEFAULT_INCREMENTAL_JOB_PERIOD);
incrementalBackupType =
pps.getProperty(INCREMENTAL_BACKUP_TYPE) == null ? DEFAULT_VALUE_INCREMENTAL_BACKUP_TYPE : pps
.getProperty(INCREMENTAL_BACKUP_TYPE);
LOG.info("Backup dir from configuration file: " + backupDir);
LOG.info("Full backup type from configuration file: " + fullBackupType);
LOG.info("(Experimental) Incremental backup type from configuration file: " + incrementalBackupType);
LOG.info("(Experimental) Default incremental job period from configuration file: " + defIncrPeriod);
checkParams();
} | [
"private",
"void",
"readParamsFromFile",
"(",
")",
"{",
"PropertiesParam",
"pps",
"=",
"initParams",
".",
"getPropertiesParam",
"(",
"BACKUP_PROPERTIES",
")",
";",
"backupDir",
"=",
"pps",
".",
"getProperty",
"(",
"BACKUP_DIR",
")",
";",
"// full backup type can be ... | Get parameters which passed from the file.
@throws RepositoryConfigurationException | [
"Get",
"parameters",
"which",
"passed",
"from",
"the",
"file",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java#L1059-L1081 |
136,128 | exoplatform/jcr | exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java | RepositoryBackupChainLog.endLog | public synchronized void endLog()
{
if (!finalized)
{
finishedTime = Calendar.getInstance();
finalized = true;
logWriter.writeEndLog();
//copy backup chain log file in into Backupset files itself for portability (e.g. on another server)
try
{
InputStream in = PrivilegedFileHelper.fileInputStream(log);
File dest = new File(config.getBackupDir() + File.separator + log.getName());
if (!PrivilegedFileHelper.exists(dest))
{
OutputStream out = PrivilegedFileHelper.fileOutputStream(dest);
byte[] buf = new byte[(int) (PrivilegedFileHelper.length(log))];
in.read(buf);
String sConfig = new String(buf, Constants.DEFAULT_ENCODING);
sConfig = sConfig.replaceAll("<backup-dir>.+</backup-dir>", "<backup-dir>.</backup-dir>");
out.write(sConfig.getBytes(Constants.DEFAULT_ENCODING));
in.close();
out.close();
}
}
catch (PatternSyntaxException e)
{
logger.error("Can't write log", e);
}
catch (FileNotFoundException e)
{
logger.error("Can't write log", e);
}
catch (IOException e)
{
logger.error("Can't write log", e);
}
}
} | java | public synchronized void endLog()
{
if (!finalized)
{
finishedTime = Calendar.getInstance();
finalized = true;
logWriter.writeEndLog();
//copy backup chain log file in into Backupset files itself for portability (e.g. on another server)
try
{
InputStream in = PrivilegedFileHelper.fileInputStream(log);
File dest = new File(config.getBackupDir() + File.separator + log.getName());
if (!PrivilegedFileHelper.exists(dest))
{
OutputStream out = PrivilegedFileHelper.fileOutputStream(dest);
byte[] buf = new byte[(int) (PrivilegedFileHelper.length(log))];
in.read(buf);
String sConfig = new String(buf, Constants.DEFAULT_ENCODING);
sConfig = sConfig.replaceAll("<backup-dir>.+</backup-dir>", "<backup-dir>.</backup-dir>");
out.write(sConfig.getBytes(Constants.DEFAULT_ENCODING));
in.close();
out.close();
}
}
catch (PatternSyntaxException e)
{
logger.error("Can't write log", e);
}
catch (FileNotFoundException e)
{
logger.error("Can't write log", e);
}
catch (IOException e)
{
logger.error("Can't write log", e);
}
}
} | [
"public",
"synchronized",
"void",
"endLog",
"(",
")",
"{",
"if",
"(",
"!",
"finalized",
")",
"{",
"finishedTime",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"finalized",
"=",
"true",
";",
"logWriter",
".",
"writeEndLog",
"(",
")",
";",
"//copy b... | Finalize log. | [
"Finalize",
"log",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java#L754-L797 |
136,129 | exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/DeleteCommand.java | DeleteCommand.delete | public Response delete(Session session, String path, String lockTokenHeader)
{
try
{
if (lockTokenHeader == null)
{
lockTokenHeader = "";
}
Item item = session.getItem(path);
if (item.isNode())
{
Node node = (Node)item;
if (node.isLocked())
{
String nodeLockToken = node.getLock().getLockToken();
if ((nodeLockToken == null) || (!nodeLockToken.equals(lockTokenHeader)))
{
return Response.status(HTTPStatus.LOCKED).entity("The " + path + " item is locked. ").type(
MediaType.TEXT_PLAIN).build();
}
}
}
item.remove();
session.save();
return Response.status(HTTPStatus.NO_CONTENT).build();
}
catch (PathNotFoundException exc)
{
return Response.status(HTTPStatus.NOT_FOUND).entity(exc.getMessage()).build();
}
catch (RepositoryException exc)
{
return Response.status(HTTPStatus.FORBIDDEN).entity(exc.getMessage()).build();
}
} | java | public Response delete(Session session, String path, String lockTokenHeader)
{
try
{
if (lockTokenHeader == null)
{
lockTokenHeader = "";
}
Item item = session.getItem(path);
if (item.isNode())
{
Node node = (Node)item;
if (node.isLocked())
{
String nodeLockToken = node.getLock().getLockToken();
if ((nodeLockToken == null) || (!nodeLockToken.equals(lockTokenHeader)))
{
return Response.status(HTTPStatus.LOCKED).entity("The " + path + " item is locked. ").type(
MediaType.TEXT_PLAIN).build();
}
}
}
item.remove();
session.save();
return Response.status(HTTPStatus.NO_CONTENT).build();
}
catch (PathNotFoundException exc)
{
return Response.status(HTTPStatus.NOT_FOUND).entity(exc.getMessage()).build();
}
catch (RepositoryException exc)
{
return Response.status(HTTPStatus.FORBIDDEN).entity(exc.getMessage()).build();
}
} | [
"public",
"Response",
"delete",
"(",
"Session",
"session",
",",
"String",
"path",
",",
"String",
"lockTokenHeader",
")",
"{",
"try",
"{",
"if",
"(",
"lockTokenHeader",
"==",
"null",
")",
"{",
"lockTokenHeader",
"=",
"\"\"",
";",
"}",
"Item",
"item",
"=",
... | Webdav Delete method implementation.
@param session current session
@param path file path
@param lockTokenHeader lock tokens
@return the instance of javax.ws.rs.core.Response | [
"Webdav",
"Delete",
"method",
"implementation",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/DeleteCommand.java#L49-L88 |
136,130 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/StreamValueData.java | StreamValueData.spoolInputStream | protected void spoolInputStream()
{
if (spoolFile != null || data != null) // already spooled
{
return;
}
byte[] buffer = new byte[0];
byte[] tmpBuff = new byte[2048];
int read = 0;
int len = 0;
SpoolFile sf = null;
OutputStream sfout = null;
try
{
while ((read = stream.read(tmpBuff)) >= 0)
{
if (sfout != null)
{
// spool to temp file
sfout.write(tmpBuff, 0, read);
len += read;
}
else if (len + read > spoolConfig.maxBufferSize)
{
// threshold for keeping data in memory exceeded,
// if have a fileCleaner create temp file and spool buffer contents.
sf = SpoolFile.createTempFile("jcrvd", null, spoolConfig.tempDirectory);
sf.acquire(this);
sfout = PrivilegedFileHelper.fileOutputStream(sf);
sfout.write(buffer, 0, len);
sfout.write(tmpBuff, 0, read);
buffer = null;
len += read;
}
else
{
// reallocate new buffer and spool old buffer contents
byte[] newBuffer = new byte[len + read];
System.arraycopy(buffer, 0, newBuffer, 0, len);
System.arraycopy(tmpBuff, 0, newBuffer, len, read);
buffer = newBuffer;
len += read;
}
}
if (sf != null)
{
// spooled to file
this.spoolFile = sf;
this.data = null;
}
else
{
// ...bytes
this.spoolFile = null;
this.data = buffer;
}
}
catch (IOException e)
{
if (sf != null)
{
try
{
sf.release(this);
spoolConfig.fileCleaner.addFile(sf);
}
catch (FileNotFoundException ex)
{
if (LOG.isDebugEnabled())
{
LOG.debug("Could not remove temporary file : " + sf.getAbsolutePath());
}
}
}
throw new IllegalStateException("Error of spooling to temp file from " + stream, e);
}
finally
{
try
{
if (sfout != null)
{
sfout.close();
}
}
catch (IOException e)
{
LOG.error("Error of spool output close.", e);
}
this.stream = null;
}
} | java | protected void spoolInputStream()
{
if (spoolFile != null || data != null) // already spooled
{
return;
}
byte[] buffer = new byte[0];
byte[] tmpBuff = new byte[2048];
int read = 0;
int len = 0;
SpoolFile sf = null;
OutputStream sfout = null;
try
{
while ((read = stream.read(tmpBuff)) >= 0)
{
if (sfout != null)
{
// spool to temp file
sfout.write(tmpBuff, 0, read);
len += read;
}
else if (len + read > spoolConfig.maxBufferSize)
{
// threshold for keeping data in memory exceeded,
// if have a fileCleaner create temp file and spool buffer contents.
sf = SpoolFile.createTempFile("jcrvd", null, spoolConfig.tempDirectory);
sf.acquire(this);
sfout = PrivilegedFileHelper.fileOutputStream(sf);
sfout.write(buffer, 0, len);
sfout.write(tmpBuff, 0, read);
buffer = null;
len += read;
}
else
{
// reallocate new buffer and spool old buffer contents
byte[] newBuffer = new byte[len + read];
System.arraycopy(buffer, 0, newBuffer, 0, len);
System.arraycopy(tmpBuff, 0, newBuffer, len, read);
buffer = newBuffer;
len += read;
}
}
if (sf != null)
{
// spooled to file
this.spoolFile = sf;
this.data = null;
}
else
{
// ...bytes
this.spoolFile = null;
this.data = buffer;
}
}
catch (IOException e)
{
if (sf != null)
{
try
{
sf.release(this);
spoolConfig.fileCleaner.addFile(sf);
}
catch (FileNotFoundException ex)
{
if (LOG.isDebugEnabled())
{
LOG.debug("Could not remove temporary file : " + sf.getAbsolutePath());
}
}
}
throw new IllegalStateException("Error of spooling to temp file from " + stream, e);
}
finally
{
try
{
if (sfout != null)
{
sfout.close();
}
}
catch (IOException e)
{
LOG.error("Error of spool output close.", e);
}
this.stream = null;
}
} | [
"protected",
"void",
"spoolInputStream",
"(",
")",
"{",
"if",
"(",
"spoolFile",
"!=",
"null",
"||",
"data",
"!=",
"null",
")",
"// already spooled",
"{",
"return",
";",
"}",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"0",
"]",
";",
"byte",
... | Spool ValueData temp InputStream to a temp File. | [
"Spool",
"ValueData",
"temp",
"InputStream",
"to",
"a",
"temp",
"File",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/StreamValueData.java#L248-L346 |
136,131 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/StreamValueData.java | StreamValueData.removeSpoolFile | private void removeSpoolFile() throws IOException
{
if (spoolFile != null)
{
if (spoolFile instanceof SpoolFile)
{
(spoolFile).release(this);
}
if (PrivilegedFileHelper.exists(spoolFile))
{
if (!PrivilegedFileHelper.delete(spoolFile))
{
spoolConfig.fileCleaner.addFile(spoolFile);
if (LOG.isDebugEnabled())
{
LOG.debug("Could not remove file. Add to fileCleaner "
+ PrivilegedFileHelper.getAbsolutePath(spoolFile));
}
}
}
}
} | java | private void removeSpoolFile() throws IOException
{
if (spoolFile != null)
{
if (spoolFile instanceof SpoolFile)
{
(spoolFile).release(this);
}
if (PrivilegedFileHelper.exists(spoolFile))
{
if (!PrivilegedFileHelper.delete(spoolFile))
{
spoolConfig.fileCleaner.addFile(spoolFile);
if (LOG.isDebugEnabled())
{
LOG.debug("Could not remove file. Add to fileCleaner "
+ PrivilegedFileHelper.getAbsolutePath(spoolFile));
}
}
}
}
} | [
"private",
"void",
"removeSpoolFile",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"spoolFile",
"!=",
"null",
")",
"{",
"if",
"(",
"spoolFile",
"instanceof",
"SpoolFile",
")",
"{",
"(",
"spoolFile",
")",
".",
"release",
"(",
"this",
")",
";",
"}",
... | Delete current spool file.
@throws IOException
if error | [
"Delete",
"current",
"spool",
"file",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/StreamValueData.java#L399-L422 |
136,132 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeValue.java | NodeTypeValue.validateNodeType | public boolean validateNodeType()
{
boolean hasValidated = false;
if (primaryItemName != null)
{
if (primaryItemName.length() <= 0)
{
primaryItemName = null;
hasValidated = true;
}
}
if (declaredSupertypeNames == null)
{
declaredSupertypeNames = new ArrayList<String>();
hasValidated = true;
}
else
{
int prevSize = declaredSupertypeNames.size();
fixStringsList(declaredSupertypeNames);
hasValidated = prevSize != declaredSupertypeNames.size();
}
if (declaredPropertyDefinitionValues == null)
{
declaredPropertyDefinitionValues = new ArrayList<PropertyDefinitionValue>();
hasValidated = true;
}
else
{
int prevSize = declaredPropertyDefinitionValues.size();
fixPropertyDefinitionValuesList(declaredPropertyDefinitionValues);
hasValidated = prevSize != declaredPropertyDefinitionValues.size();
}
if (declaredChildNodeDefinitionValues == null)
{
declaredChildNodeDefinitionValues = new ArrayList<NodeDefinitionValue>();
hasValidated = true;
}
else
{
int prevSize = declaredChildNodeDefinitionValues.size();
fixNodeDefinitionValuesList(declaredChildNodeDefinitionValues);
hasValidated = prevSize != declaredChildNodeDefinitionValues.size();
}
return hasValidated;
} | java | public boolean validateNodeType()
{
boolean hasValidated = false;
if (primaryItemName != null)
{
if (primaryItemName.length() <= 0)
{
primaryItemName = null;
hasValidated = true;
}
}
if (declaredSupertypeNames == null)
{
declaredSupertypeNames = new ArrayList<String>();
hasValidated = true;
}
else
{
int prevSize = declaredSupertypeNames.size();
fixStringsList(declaredSupertypeNames);
hasValidated = prevSize != declaredSupertypeNames.size();
}
if (declaredPropertyDefinitionValues == null)
{
declaredPropertyDefinitionValues = new ArrayList<PropertyDefinitionValue>();
hasValidated = true;
}
else
{
int prevSize = declaredPropertyDefinitionValues.size();
fixPropertyDefinitionValuesList(declaredPropertyDefinitionValues);
hasValidated = prevSize != declaredPropertyDefinitionValues.size();
}
if (declaredChildNodeDefinitionValues == null)
{
declaredChildNodeDefinitionValues = new ArrayList<NodeDefinitionValue>();
hasValidated = true;
}
else
{
int prevSize = declaredChildNodeDefinitionValues.size();
fixNodeDefinitionValuesList(declaredChildNodeDefinitionValues);
hasValidated = prevSize != declaredChildNodeDefinitionValues.size();
}
return hasValidated;
} | [
"public",
"boolean",
"validateNodeType",
"(",
")",
"{",
"boolean",
"hasValidated",
"=",
"false",
";",
"if",
"(",
"primaryItemName",
"!=",
"null",
")",
"{",
"if",
"(",
"primaryItemName",
".",
"length",
"(",
")",
"<=",
"0",
")",
"{",
"primaryItemName",
"=",
... | validateNodeType, method checks the value bean for each valid filed | [
"validateNodeType",
"method",
"checks",
"the",
"value",
"bean",
"for",
"each",
"valid",
"filed"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeValue.java#L172-L223 |
136,133 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java | PropertyImpl.getValueArray | public Value[] getValueArray() throws RepositoryException
{
Value[] values = new Value[propertyData.getValues().size()];
for (int i = 0; i < values.length; i++)
{
values[i] = valueFactory.loadValue(propertyData.getValues().get(i), propertyData.getType());
}
return values;
} | java | public Value[] getValueArray() throws RepositoryException
{
Value[] values = new Value[propertyData.getValues().size()];
for (int i = 0; i < values.length; i++)
{
values[i] = valueFactory.loadValue(propertyData.getValues().get(i), propertyData.getType());
}
return values;
} | [
"public",
"Value",
"[",
"]",
"getValueArray",
"(",
")",
"throws",
"RepositoryException",
"{",
"Value",
"[",
"]",
"values",
"=",
"new",
"Value",
"[",
"propertyData",
".",
"getValues",
"(",
")",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
... | Copies property values into array.
@return array of property values
@throws RepositoryException
if any Exception is occurred | [
"Copies",
"property",
"values",
"into",
"array",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java#L556-L564 |
136,134 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java | PropertyImpl.dump | public String dump()
{
StringBuilder vals = new StringBuilder("Property ");
try
{
vals = new StringBuilder(getPath()).append(" values: ");
for (int i = 0; i < getValueArray().length; i++)
{
vals.append(ValueDataUtil.getString(((BaseValue)getValueArray()[i]).getInternalData())).append(";");
}
}
catch (Exception e)
{
LOG.error(e.getLocalizedMessage(), e);
}
return vals.toString();
} | java | public String dump()
{
StringBuilder vals = new StringBuilder("Property ");
try
{
vals = new StringBuilder(getPath()).append(" values: ");
for (int i = 0; i < getValueArray().length; i++)
{
vals.append(ValueDataUtil.getString(((BaseValue)getValueArray()[i]).getInternalData())).append(";");
}
}
catch (Exception e)
{
LOG.error(e.getLocalizedMessage(), e);
}
return vals.toString();
} | [
"public",
"String",
"dump",
"(",
")",
"{",
"StringBuilder",
"vals",
"=",
"new",
"StringBuilder",
"(",
"\"Property \"",
")",
";",
"try",
"{",
"vals",
"=",
"new",
"StringBuilder",
"(",
"getPath",
"(",
")",
")",
".",
"append",
"(",
"\" values: \"",
")",
";"... | Get info about property values.
@return string with property values | [
"Get",
"info",
"about",
"property",
"values",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java#L571-L587 |
136,135 | exoplatform/jcr | exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/GroupImpl.java | GroupImpl.setParentId | public void setParentId(String parentId)
{
this.parentId = (parentId == null || parentId.equals("") ? null : parentId);
setGroupName(groupName);
} | java | public void setParentId(String parentId)
{
this.parentId = (parentId == null || parentId.equals("") ? null : parentId);
setGroupName(groupName);
} | [
"public",
"void",
"setParentId",
"(",
"String",
"parentId",
")",
"{",
"this",
".",
"parentId",
"=",
"(",
"parentId",
"==",
"null",
"||",
"parentId",
".",
"equals",
"(",
"\"\"",
")",
"?",
"null",
":",
"parentId",
")",
";",
"setGroupName",
"(",
"groupName"... | Sets new parenId and refresh groupId. | [
"Sets",
"new",
"parenId",
"and",
"refresh",
"groupId",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/GroupImpl.java#L147-L151 |
136,136 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScoreNodeIteratorImpl.java | ScoreNodeIteratorImpl.skip | public void skip(long n) throws IllegalArgumentException, NoSuchElementException
{
if (n < 0)
{
throw new IllegalArgumentException("skip(" + n + ")");
}
for (long i = 0; i < n; i++)
{
next();
}
} | java | public void skip(long n) throws IllegalArgumentException, NoSuchElementException
{
if (n < 0)
{
throw new IllegalArgumentException("skip(" + n + ")");
}
for (long i = 0; i < n; i++)
{
next();
}
} | [
"public",
"void",
"skip",
"(",
"long",
"n",
")",
"throws",
"IllegalArgumentException",
",",
"NoSuchElementException",
"{",
"if",
"(",
"n",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"skip(\"",
"+",
"n",
"+",
"\")\"",
")",
";",
"... | Skips the given number of elements.
@param n number of elements to skip
@throws IllegalArgumentException if n is negative
@throws NoSuchElementException if skipped past the last element | [
"Skips",
"the",
"given",
"number",
"of",
"elements",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScoreNodeIteratorImpl.java#L86-L97 |
136,137 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java | DirectoryHelper.listFiles | public static List<File> listFiles(File srcPath) throws IOException
{
List<File> result = new ArrayList<File>();
if (!srcPath.isDirectory())
{
throw new IOException(srcPath.getAbsolutePath() + " is a directory");
}
for (File subFile : srcPath.listFiles())
{
result.add(subFile);
if (subFile.isDirectory())
{
result.addAll(listFiles(subFile));
}
}
return result;
} | java | public static List<File> listFiles(File srcPath) throws IOException
{
List<File> result = new ArrayList<File>();
if (!srcPath.isDirectory())
{
throw new IOException(srcPath.getAbsolutePath() + " is a directory");
}
for (File subFile : srcPath.listFiles())
{
result.add(subFile);
if (subFile.isDirectory())
{
result.addAll(listFiles(subFile));
}
}
return result;
} | [
"public",
"static",
"List",
"<",
"File",
">",
"listFiles",
"(",
"File",
"srcPath",
")",
"throws",
"IOException",
"{",
"List",
"<",
"File",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"File",
">",
"(",
")",
";",
"if",
"(",
"!",
"srcPath",
".",
"isDir... | Returns the files list of whole directory including its sub directories.
@param srcPath
source path
@return List
@throws IOException
if any exception occurred | [
"Returns",
"the",
"files",
"list",
"of",
"whole",
"directory",
"including",
"its",
"sub",
"directories",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java#L65-L84 |
136,138 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java | DirectoryHelper.copyDirectory | public static void copyDirectory(File srcPath, File dstPath) throws IOException
{
if (srcPath.isDirectory())
{
if (!dstPath.exists())
{
dstPath.mkdirs();
}
String files[] = srcPath.list();
for (int i = 0; i < files.length; i++)
{
copyDirectory(new File(srcPath, files[i]), new File(dstPath, files[i]));
}
}
else
{
InputStream in = null;
OutputStream out = null;
try
{
in = new FileInputStream(srcPath);
out = new FileOutputStream(dstPath);
transfer(in, out);
}
finally
{
if (in != null)
{
in.close();
}
if (out != null)
{
out.flush();
out.close();
}
}
}
} | java | public static void copyDirectory(File srcPath, File dstPath) throws IOException
{
if (srcPath.isDirectory())
{
if (!dstPath.exists())
{
dstPath.mkdirs();
}
String files[] = srcPath.list();
for (int i = 0; i < files.length; i++)
{
copyDirectory(new File(srcPath, files[i]), new File(dstPath, files[i]));
}
}
else
{
InputStream in = null;
OutputStream out = null;
try
{
in = new FileInputStream(srcPath);
out = new FileOutputStream(dstPath);
transfer(in, out);
}
finally
{
if (in != null)
{
in.close();
}
if (out != null)
{
out.flush();
out.close();
}
}
}
} | [
"public",
"static",
"void",
"copyDirectory",
"(",
"File",
"srcPath",
",",
"File",
"dstPath",
")",
"throws",
"IOException",
"{",
"if",
"(",
"srcPath",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"!",
"dstPath",
".",
"exists",
"(",
")",
")",
"{",
... | Copy directory.
@param srcPath
source path
@param dstPath
destination path
@throws IOException
if any exception occurred | [
"Copy",
"directory",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java#L96-L137 |
136,139 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java | DirectoryHelper.removeDirectory | public static void removeDirectory(File dir) throws IOException
{
if (dir.isDirectory())
{
for (File subFile : dir.listFiles())
{
removeDirectory(subFile);
}
if (!dir.delete())
{
throw new IOException("Can't remove folder : " + dir.getCanonicalPath());
}
}
else
{
if (!dir.delete())
{
throw new IOException("Can't remove file : " + dir.getCanonicalPath());
}
}
} | java | public static void removeDirectory(File dir) throws IOException
{
if (dir.isDirectory())
{
for (File subFile : dir.listFiles())
{
removeDirectory(subFile);
}
if (!dir.delete())
{
throw new IOException("Can't remove folder : " + dir.getCanonicalPath());
}
}
else
{
if (!dir.delete())
{
throw new IOException("Can't remove file : " + dir.getCanonicalPath());
}
}
} | [
"public",
"static",
"void",
"removeDirectory",
"(",
"File",
"dir",
")",
"throws",
"IOException",
"{",
"if",
"(",
"dir",
".",
"isDirectory",
"(",
")",
")",
"{",
"for",
"(",
"File",
"subFile",
":",
"dir",
".",
"listFiles",
"(",
")",
")",
"{",
"removeDire... | Remove directory.
@param dir
directory to remove
@throws IOException
if any exception occurred | [
"Remove",
"directory",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java#L147-L168 |
136,140 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java | DirectoryHelper.compressDirectory | private static void compressDirectory(String relativePath, File srcPath, ZipOutputStream zip) throws IOException
{
if (srcPath.isDirectory())
{
zip.putNextEntry(new ZipEntry(relativePath + "/" + srcPath.getName() + "/"));
zip.closeEntry();
String files[] = srcPath.list();
for (int i = 0; i < files.length; i++)
{
compressDirectory(relativePath + "/" + srcPath.getName(), new File(srcPath, files[i]), zip);
}
}
else
{
InputStream in = new FileInputStream(srcPath);
try
{
zip.putNextEntry(new ZipEntry(relativePath + "/" + srcPath.getName()));
transfer(in, zip);
zip.closeEntry();
}
finally
{
if (in != null)
{
in.close();
}
}
}
} | java | private static void compressDirectory(String relativePath, File srcPath, ZipOutputStream zip) throws IOException
{
if (srcPath.isDirectory())
{
zip.putNextEntry(new ZipEntry(relativePath + "/" + srcPath.getName() + "/"));
zip.closeEntry();
String files[] = srcPath.list();
for (int i = 0; i < files.length; i++)
{
compressDirectory(relativePath + "/" + srcPath.getName(), new File(srcPath, files[i]), zip);
}
}
else
{
InputStream in = new FileInputStream(srcPath);
try
{
zip.putNextEntry(new ZipEntry(relativePath + "/" + srcPath.getName()));
transfer(in, zip);
zip.closeEntry();
}
finally
{
if (in != null)
{
in.close();
}
}
}
} | [
"private",
"static",
"void",
"compressDirectory",
"(",
"String",
"relativePath",
",",
"File",
"srcPath",
",",
"ZipOutputStream",
"zip",
")",
"throws",
"IOException",
"{",
"if",
"(",
"srcPath",
".",
"isDirectory",
"(",
")",
")",
"{",
"zip",
".",
"putNextEntry",... | Compress files and directories. | [
"Compress",
"files",
"and",
"directories",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java#L220-L252 |
136,141 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java | DirectoryHelper.deleteDstAndRename | public static void deleteDstAndRename(File srcFile, File dstFile) throws IOException
{
if (dstFile.exists())
{
if (!dstFile.delete())
{
throw new IOException("Cannot delete " + dstFile);
}
}
renameFile(srcFile, dstFile);
} | java | public static void deleteDstAndRename(File srcFile, File dstFile) throws IOException
{
if (dstFile.exists())
{
if (!dstFile.delete())
{
throw new IOException("Cannot delete " + dstFile);
}
}
renameFile(srcFile, dstFile);
} | [
"public",
"static",
"void",
"deleteDstAndRename",
"(",
"File",
"srcFile",
",",
"File",
"dstFile",
")",
"throws",
"IOException",
"{",
"if",
"(",
"dstFile",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"dstFile",
".",
"delete",
"(",
")",
")",
"{",
... | Rename file. Trying to remove destination first.
If file can't be renamed in standard way the coping
data will be used instead.
@param srcFile
source file
@param dstFile
destination file
@throws IOException
if any exception occurred | [
"Rename",
"file",
".",
"Trying",
"to",
"remove",
"destination",
"first",
".",
"If",
"file",
"can",
"t",
"be",
"renamed",
"in",
"standard",
"way",
"the",
"coping",
"data",
"will",
"be",
"used",
"instead",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java#L384-L395 |
136,142 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java | DirectoryHelper.renameFile | public static void renameFile(File srcFile, File dstFile) throws IOException
{
// Rename the srcFile file to the new one. Unfortunately, the renameTo()
// method does not work reliably under some JVMs. Therefore, if the
// rename fails, we manually rename by copying the srcFile file to the new one
if (!srcFile.renameTo(dstFile))
{
InputStream in = null;
OutputStream out = null;
try
{
in = new FileInputStream(srcFile);
out = new FileOutputStream(dstFile);
transfer(in, out);
}
catch (IOException ioe)
{
IOException newExc = new IOException("Cannot rename " + srcFile + " to " + dstFile);
newExc.initCause(ioe);
throw newExc;
}
finally
{
if (in != null)
{
in.close();
}
if (out != null)
{
out.close();
}
}
// delete the srcFile file.
srcFile.delete();
}
} | java | public static void renameFile(File srcFile, File dstFile) throws IOException
{
// Rename the srcFile file to the new one. Unfortunately, the renameTo()
// method does not work reliably under some JVMs. Therefore, if the
// rename fails, we manually rename by copying the srcFile file to the new one
if (!srcFile.renameTo(dstFile))
{
InputStream in = null;
OutputStream out = null;
try
{
in = new FileInputStream(srcFile);
out = new FileOutputStream(dstFile);
transfer(in, out);
}
catch (IOException ioe)
{
IOException newExc = new IOException("Cannot rename " + srcFile + " to " + dstFile);
newExc.initCause(ioe);
throw newExc;
}
finally
{
if (in != null)
{
in.close();
}
if (out != null)
{
out.close();
}
}
// delete the srcFile file.
srcFile.delete();
}
} | [
"public",
"static",
"void",
"renameFile",
"(",
"File",
"srcFile",
",",
"File",
"dstFile",
")",
"throws",
"IOException",
"{",
"// Rename the srcFile file to the new one. Unfortunately, the renameTo()\r",
"// method does not work reliably under some JVMs. Therefore, if the\r",
"// ren... | Rename file. If file can't be renamed in standard way the coping
data will be used instead.
@param srcFile
source file
@param dstFile
destination file
@throws IOException
if any exception occurred | [
"Rename",
"file",
".",
"If",
"file",
"can",
"t",
"be",
"renamed",
"in",
"standard",
"way",
"the",
"coping",
"data",
"will",
"be",
"used",
"instead",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java#L408-L446 |
136,143 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java | DirectoryHelper.getSize | public static long getSize(File dir)
{
long size = 0;
for (File file : dir.listFiles())
{
if (file.isFile())
{
size += file.length();
}
else
{
size += getSize(file);
}
}
return size;
} | java | public static long getSize(File dir)
{
long size = 0;
for (File file : dir.listFiles())
{
if (file.isFile())
{
size += file.length();
}
else
{
size += getSize(file);
}
}
return size;
} | [
"public",
"static",
"long",
"getSize",
"(",
"File",
"dir",
")",
"{",
"long",
"size",
"=",
"0",
";",
"for",
"(",
"File",
"file",
":",
"dir",
".",
"listFiles",
"(",
")",
")",
"{",
"if",
"(",
"file",
".",
"isFile",
"(",
")",
")",
"{",
"size",
"+="... | Returns the size of directory including all subfolders. | [
"Returns",
"the",
"size",
"of",
"directory",
"including",
"all",
"subfolders",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java#L451-L467 |
136,144 | exoplatform/jcr | exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobWorkspaceRestore.java | JobWorkspaceRestore.removeWorkspace | protected void removeWorkspace(ManageableRepository mr, String workspaceName) throws RepositoryException
{
boolean isExists = false;
for (String wsName : mr.getWorkspaceNames())
if (workspaceName.equals(wsName))
{
isExists = true;
break;
}
if (isExists)
{
if (!mr.canRemoveWorkspace(workspaceName))
{
WorkspaceContainerFacade wc = mr.getWorkspaceContainer(workspaceName);
SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
sessionRegistry.closeSessions(workspaceName);
}
mr.removeWorkspace(workspaceName);
}
} | java | protected void removeWorkspace(ManageableRepository mr, String workspaceName) throws RepositoryException
{
boolean isExists = false;
for (String wsName : mr.getWorkspaceNames())
if (workspaceName.equals(wsName))
{
isExists = true;
break;
}
if (isExists)
{
if (!mr.canRemoveWorkspace(workspaceName))
{
WorkspaceContainerFacade wc = mr.getWorkspaceContainer(workspaceName);
SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
sessionRegistry.closeSessions(workspaceName);
}
mr.removeWorkspace(workspaceName);
}
} | [
"protected",
"void",
"removeWorkspace",
"(",
"ManageableRepository",
"mr",
",",
"String",
"workspaceName",
")",
"throws",
"RepositoryException",
"{",
"boolean",
"isExists",
"=",
"false",
";",
"for",
"(",
"String",
"wsName",
":",
"mr",
".",
"getWorkspaceNames",
"("... | Remove workspace.
@param mr
ManageableRepository, the manageable repository
@param workspaceName
String, the workspace name
@throws RepositoryException
will be generated the RepositoryException | [
"Remove",
"workspace",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobWorkspaceRestore.java#L248-L270 |
136,145 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/NodeRemover.java | NodeRemover.removeChildrenItems | private void removeChildrenItems(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException, IllegalNameException,
IllegalStateException, UnsupportedOperationException, InvalidItemStateException, RepositoryException
{
String parentId = resultSet.getString(DBConstants.COLUMN_ID);
String selectStatement = "select * from " + iTable + " where I_CLASS = 1 and PARENT_ID = '" + parentId + "'";
String deleteStatement = "delete from " + iTable + " where I_CLASS = 1 and PARENT_ID = '" + parentId + "'";
// traversing down to the bottom of the tree
PreparedStatement statement = conn.getJdbcConnection().prepareStatement(selectStatement);
ResultSet selResult = statement.executeQuery();
try
{
while (selResult.next())
{
removeChildrenItems(conn, selResult);
}
}
finally
{
JDBCUtils.freeResources(selResult, statement, null);
}
// remove properties
NodeData node = createNodeData(resultSet);
for (PropertyData prop : conn.getChildPropertiesData(node))
{
conn.delete(prop, new SimpleChangedSizeHandler());
}
// remove nodes
statement = conn.getJdbcConnection().prepareStatement(deleteStatement);
try
{
statement.execute();
}
finally
{
JDBCUtils.freeResources(null, statement, null);
}
} | java | private void removeChildrenItems(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException, IllegalNameException,
IllegalStateException, UnsupportedOperationException, InvalidItemStateException, RepositoryException
{
String parentId = resultSet.getString(DBConstants.COLUMN_ID);
String selectStatement = "select * from " + iTable + " where I_CLASS = 1 and PARENT_ID = '" + parentId + "'";
String deleteStatement = "delete from " + iTable + " where I_CLASS = 1 and PARENT_ID = '" + parentId + "'";
// traversing down to the bottom of the tree
PreparedStatement statement = conn.getJdbcConnection().prepareStatement(selectStatement);
ResultSet selResult = statement.executeQuery();
try
{
while (selResult.next())
{
removeChildrenItems(conn, selResult);
}
}
finally
{
JDBCUtils.freeResources(selResult, statement, null);
}
// remove properties
NodeData node = createNodeData(resultSet);
for (PropertyData prop : conn.getChildPropertiesData(node))
{
conn.delete(prop, new SimpleChangedSizeHandler());
}
// remove nodes
statement = conn.getJdbcConnection().prepareStatement(deleteStatement);
try
{
statement.execute();
}
finally
{
JDBCUtils.freeResources(null, statement, null);
}
} | [
"private",
"void",
"removeChildrenItems",
"(",
"JDBCStorageConnection",
"conn",
",",
"ResultSet",
"resultSet",
")",
"throws",
"SQLException",
",",
"IllegalNameException",
",",
"IllegalStateException",
",",
"UnsupportedOperationException",
",",
"InvalidItemStateException",
","... | Removes all children items. | [
"Removes",
"all",
"children",
"items",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/NodeRemover.java#L152-L191 |
136,146 | exoplatform/jcr | exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestUpdateListener.java | GroovyScript2RestUpdateListener.loadScript | private void loadScript(Node node) throws Exception
{
ResourceId key = new NodeScriptKey(repository.getConfiguration().getName(), workspaceName, node);
ObjectFactory<AbstractResourceDescriptor> resource =
groovyScript2RestLoader.groovyPublisher.unpublishResource(key);
if (resource != null)
{
groovyScript2RestLoader.groovyPublisher.publishPerRequest(node.getProperty("jcr:data").getStream(), key,
resource.getObjectModel().getProperties());
}
else
{
groovyScript2RestLoader.groovyPublisher.publishPerRequest(node.getProperty("jcr:data").getStream(), key, null);
}
} | java | private void loadScript(Node node) throws Exception
{
ResourceId key = new NodeScriptKey(repository.getConfiguration().getName(), workspaceName, node);
ObjectFactory<AbstractResourceDescriptor> resource =
groovyScript2RestLoader.groovyPublisher.unpublishResource(key);
if (resource != null)
{
groovyScript2RestLoader.groovyPublisher.publishPerRequest(node.getProperty("jcr:data").getStream(), key,
resource.getObjectModel().getProperties());
}
else
{
groovyScript2RestLoader.groovyPublisher.publishPerRequest(node.getProperty("jcr:data").getStream(), key, null);
}
} | [
"private",
"void",
"loadScript",
"(",
"Node",
"node",
")",
"throws",
"Exception",
"{",
"ResourceId",
"key",
"=",
"new",
"NodeScriptKey",
"(",
"repository",
".",
"getConfiguration",
"(",
")",
".",
"getName",
"(",
")",
",",
"workspaceName",
",",
"node",
")",
... | Load script form supplied node.
@param node JCR node
@throws Exception if any error occurs | [
"Load",
"script",
"form",
"supplied",
"node",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestUpdateListener.java#L121-L135 |
136,147 | exoplatform/jcr | exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestUpdateListener.java | GroovyScript2RestUpdateListener.unloadScript | private void unloadScript(String path) throws Exception
{
ResourceId key = new NodeScriptKey(repository.getConfiguration().getName(), workspaceName, path);
groovyScript2RestLoader.groovyPublisher.unpublishResource(key);
} | java | private void unloadScript(String path) throws Exception
{
ResourceId key = new NodeScriptKey(repository.getConfiguration().getName(), workspaceName, path);
groovyScript2RestLoader.groovyPublisher.unpublishResource(key);
} | [
"private",
"void",
"unloadScript",
"(",
"String",
"path",
")",
"throws",
"Exception",
"{",
"ResourceId",
"key",
"=",
"new",
"NodeScriptKey",
"(",
"repository",
".",
"getConfiguration",
"(",
")",
".",
"getName",
"(",
")",
",",
"workspaceName",
",",
"path",
")... | Unload script.
@param path unified JCR node path
@throws Exception if any error occurs | [
"Unload",
"script",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestUpdateListener.java#L143-L147 |
136,148 | exoplatform/jcr | exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionFactory.java | ManagedSessionFactory.getContainer | private ExoContainer getContainer() throws ResourceException
{
ExoContainer container = ExoContainerContext.getCurrentContainer();
if (container instanceof RootContainer)
{
String portalContainerName =
portalContainer == null ? PortalContainer.DEFAULT_PORTAL_CONTAINER_NAME : portalContainer;
container = RootContainer.getInstance().getPortalContainer(portalContainerName);
if (container == null)
{
throw new ResourceException("The eXo container is null, because the current container is a RootContainer "
+ "and there is no PortalContainer with the name '" + portalContainerName + "'.");
}
}
else if (container == null)
{
throw new ResourceException("The eXo container is null, because the current container is null.");
}
return container;
} | java | private ExoContainer getContainer() throws ResourceException
{
ExoContainer container = ExoContainerContext.getCurrentContainer();
if (container instanceof RootContainer)
{
String portalContainerName =
portalContainer == null ? PortalContainer.DEFAULT_PORTAL_CONTAINER_NAME : portalContainer;
container = RootContainer.getInstance().getPortalContainer(portalContainerName);
if (container == null)
{
throw new ResourceException("The eXo container is null, because the current container is a RootContainer "
+ "and there is no PortalContainer with the name '" + portalContainerName + "'.");
}
}
else if (container == null)
{
throw new ResourceException("The eXo container is null, because the current container is null.");
}
return container;
} | [
"private",
"ExoContainer",
"getContainer",
"(",
")",
"throws",
"ResourceException",
"{",
"ExoContainer",
"container",
"=",
"ExoContainerContext",
".",
"getCurrentContainer",
"(",
")",
";",
"if",
"(",
"container",
"instanceof",
"RootContainer",
")",
"{",
"String",
"p... | Gets the container from the current context | [
"Gets",
"the",
"container",
"from",
"the",
"current",
"context"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionFactory.java#L224-L243 |
136,149 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/ValueDataUtil.java | ValueDataUtil.readValueData | public static ValueDataWrapper readValueData(String cid, int type, int orderNumber, int version,
final InputStream content, SpoolConfig spoolConfig) throws IOException
{
ValueDataWrapper vdDataWrapper = new ValueDataWrapper();
byte[] buffer = new byte[0];
byte[] spoolBuffer = new byte[ValueFileIOHelper.IOBUFFER_SIZE];
int read;
int len = 0;
OutputStream out = null;
SwapFile swapFile = null;
try
{
// stream from database
if (content != null)
{
while ((read = content.read(spoolBuffer)) >= 0)
{
if (out != null)
{
// spool to temp file
out.write(spoolBuffer, 0, read);
}
else if (len + read > spoolConfig.maxBufferSize)
{
// threshold for keeping data in memory exceeded;
// create temp file and spool buffer contents
swapFile = SwapFile.get(spoolConfig.tempDirectory, cid + orderNumber + "." + version,spoolConfig.fileCleaner);
if (swapFile.isSpooled())
{
// break, value already spooled
buffer = null;
break;
}
out = PrivilegedFileHelper.fileOutputStream(swapFile);
out.write(buffer, 0, len);
out.write(spoolBuffer, 0, read);
buffer = null;
}
else
{
// reallocate new buffer and spool old buffer contents
byte[] newBuffer = new byte[len + read];
System.arraycopy(buffer, 0, newBuffer, 0, len);
System.arraycopy(spoolBuffer, 0, newBuffer, len, read);
buffer = newBuffer;
}
len += read;
}
}
}
finally
{
if (out != null)
{
out.close();
swapFile.spoolDone();
}
}
vdDataWrapper.size = len;
if (swapFile != null)
{
vdDataWrapper.value = new CleanableFilePersistedValueData(orderNumber, swapFile, spoolConfig);
}
else
{
vdDataWrapper.value = createValueData(type, orderNumber, buffer);
}
return vdDataWrapper;
} | java | public static ValueDataWrapper readValueData(String cid, int type, int orderNumber, int version,
final InputStream content, SpoolConfig spoolConfig) throws IOException
{
ValueDataWrapper vdDataWrapper = new ValueDataWrapper();
byte[] buffer = new byte[0];
byte[] spoolBuffer = new byte[ValueFileIOHelper.IOBUFFER_SIZE];
int read;
int len = 0;
OutputStream out = null;
SwapFile swapFile = null;
try
{
// stream from database
if (content != null)
{
while ((read = content.read(spoolBuffer)) >= 0)
{
if (out != null)
{
// spool to temp file
out.write(spoolBuffer, 0, read);
}
else if (len + read > spoolConfig.maxBufferSize)
{
// threshold for keeping data in memory exceeded;
// create temp file and spool buffer contents
swapFile = SwapFile.get(spoolConfig.tempDirectory, cid + orderNumber + "." + version,spoolConfig.fileCleaner);
if (swapFile.isSpooled())
{
// break, value already spooled
buffer = null;
break;
}
out = PrivilegedFileHelper.fileOutputStream(swapFile);
out.write(buffer, 0, len);
out.write(spoolBuffer, 0, read);
buffer = null;
}
else
{
// reallocate new buffer and spool old buffer contents
byte[] newBuffer = new byte[len + read];
System.arraycopy(buffer, 0, newBuffer, 0, len);
System.arraycopy(spoolBuffer, 0, newBuffer, len, read);
buffer = newBuffer;
}
len += read;
}
}
}
finally
{
if (out != null)
{
out.close();
swapFile.spoolDone();
}
}
vdDataWrapper.size = len;
if (swapFile != null)
{
vdDataWrapper.value = new CleanableFilePersistedValueData(orderNumber, swapFile, spoolConfig);
}
else
{
vdDataWrapper.value = createValueData(type, orderNumber, buffer);
}
return vdDataWrapper;
} | [
"public",
"static",
"ValueDataWrapper",
"readValueData",
"(",
"String",
"cid",
",",
"int",
"type",
",",
"int",
"orderNumber",
",",
"int",
"version",
",",
"final",
"InputStream",
"content",
",",
"SpoolConfig",
"spoolConfig",
")",
"throws",
"IOException",
"{",
"Va... | Read value data from stream.
@param cid
property identifier
@param type
property type, {@link PropertyType}
@param orderNumber
value data order number
@param version
property persisted version
@param content
value data represented in stream
@param spoolConfig
contains threshold for spooling
@return PersistedValueData
@throws IOException
if any error is occurred | [
"Read",
"value",
"data",
"from",
"stream",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/ValueDataUtil.java#L83-L157 |
136,150 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/ValueDataUtil.java | ValueDataUtil.readValueData | public static ValueDataWrapper readValueData(int type, int orderNumber, File file, SpoolConfig spoolConfig)
throws IOException
{
ValueDataWrapper vdDataWrapper = new ValueDataWrapper();
long fileSize = file.length();
vdDataWrapper.size = fileSize;
if (fileSize > spoolConfig.maxBufferSize)
{
vdDataWrapper.value = new FilePersistedValueData(orderNumber, file, spoolConfig);
}
else
{
// JCR-2463 In case the file was renamed to be removed/changed,
// but the transaction wasn't rollbacked cleanly
file = fixFileName(file);
FileInputStream is = new FileInputStream(file);
try
{
byte[] data = new byte[(int)fileSize];
byte[] buff =
new byte[ValueFileIOHelper.IOBUFFER_SIZE > fileSize ? ValueFileIOHelper.IOBUFFER_SIZE : (int)fileSize];
int rpos = 0;
int read;
while ((read = is.read(buff)) >= 0)
{
System.arraycopy(buff, 0, data, rpos, read);
rpos += read;
}
vdDataWrapper.value = createValueData(type, orderNumber, data);
}
finally
{
is.close();
}
}
return vdDataWrapper;
} | java | public static ValueDataWrapper readValueData(int type, int orderNumber, File file, SpoolConfig spoolConfig)
throws IOException
{
ValueDataWrapper vdDataWrapper = new ValueDataWrapper();
long fileSize = file.length();
vdDataWrapper.size = fileSize;
if (fileSize > spoolConfig.maxBufferSize)
{
vdDataWrapper.value = new FilePersistedValueData(orderNumber, file, spoolConfig);
}
else
{
// JCR-2463 In case the file was renamed to be removed/changed,
// but the transaction wasn't rollbacked cleanly
file = fixFileName(file);
FileInputStream is = new FileInputStream(file);
try
{
byte[] data = new byte[(int)fileSize];
byte[] buff =
new byte[ValueFileIOHelper.IOBUFFER_SIZE > fileSize ? ValueFileIOHelper.IOBUFFER_SIZE : (int)fileSize];
int rpos = 0;
int read;
while ((read = is.read(buff)) >= 0)
{
System.arraycopy(buff, 0, data, rpos, read);
rpos += read;
}
vdDataWrapper.value = createValueData(type, orderNumber, data);
}
finally
{
is.close();
}
}
return vdDataWrapper;
} | [
"public",
"static",
"ValueDataWrapper",
"readValueData",
"(",
"int",
"type",
",",
"int",
"orderNumber",
",",
"File",
"file",
",",
"SpoolConfig",
"spoolConfig",
")",
"throws",
"IOException",
"{",
"ValueDataWrapper",
"vdDataWrapper",
"=",
"new",
"ValueDataWrapper",
"(... | Read value data from file.
@param type
property type, {@link PropertyType}
@param file
File
@param orderNumber
value data order number
@param spoolConfig
contains threshold for spooling
@return PersistedValueData
@throws IOException
if any error is occurred | [
"Read",
"value",
"data",
"from",
"file",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/ValueDataUtil.java#L174-L216 |
136,151 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/ValueDataUtil.java | ValueDataUtil.createValueData | public static PersistedValueData createValueData(int type, int orderNumber, byte[] data) throws IOException
{
switch (type)
{
case PropertyType.BINARY :
case PropertyType.UNDEFINED :
return new ByteArrayPersistedValueData(orderNumber, data);
case PropertyType.BOOLEAN :
return new BooleanPersistedValueData(orderNumber, Boolean.valueOf(getString(data)));
case PropertyType.DATE :
try
{
return new CalendarPersistedValueData(orderNumber, JCRDateFormat.parse(getString(data)));
}
catch (ValueFormatException e)
{
throw new IOException("Can't create Calendar value", e);
}
case PropertyType.DOUBLE :
return new DoublePersistedValueData(orderNumber, Double.valueOf(getString(data)));
case PropertyType.LONG :
return new LongPersistedValueData(orderNumber, Long.valueOf(getString(data)));
case PropertyType.NAME :
try
{
return new NamePersistedValueData(orderNumber, InternalQName.parse(getString(data)));
}
catch (IllegalNameException e)
{
throw new IOException(e.getMessage(), e);
}
case PropertyType.PATH :
try
{
return new PathPersistedValueData(orderNumber, QPath.parse(getString(data)));
}
catch (IllegalPathException e)
{
throw new IOException(e.getMessage(), e);
}
case PropertyType.REFERENCE :
return new ReferencePersistedValueData(orderNumber, new Identifier(data));
case PropertyType.STRING :
return new StringPersistedValueData(orderNumber, getString(data));
case ExtendedPropertyType.PERMISSION :
return new PermissionPersistedValueData(orderNumber, AccessControlEntry.parse(getString(data)));
default :
throw new IllegalStateException("Unknown property type " + type);
}
} | java | public static PersistedValueData createValueData(int type, int orderNumber, byte[] data) throws IOException
{
switch (type)
{
case PropertyType.BINARY :
case PropertyType.UNDEFINED :
return new ByteArrayPersistedValueData(orderNumber, data);
case PropertyType.BOOLEAN :
return new BooleanPersistedValueData(orderNumber, Boolean.valueOf(getString(data)));
case PropertyType.DATE :
try
{
return new CalendarPersistedValueData(orderNumber, JCRDateFormat.parse(getString(data)));
}
catch (ValueFormatException e)
{
throw new IOException("Can't create Calendar value", e);
}
case PropertyType.DOUBLE :
return new DoublePersistedValueData(orderNumber, Double.valueOf(getString(data)));
case PropertyType.LONG :
return new LongPersistedValueData(orderNumber, Long.valueOf(getString(data)));
case PropertyType.NAME :
try
{
return new NamePersistedValueData(orderNumber, InternalQName.parse(getString(data)));
}
catch (IllegalNameException e)
{
throw new IOException(e.getMessage(), e);
}
case PropertyType.PATH :
try
{
return new PathPersistedValueData(orderNumber, QPath.parse(getString(data)));
}
catch (IllegalPathException e)
{
throw new IOException(e.getMessage(), e);
}
case PropertyType.REFERENCE :
return new ReferencePersistedValueData(orderNumber, new Identifier(data));
case PropertyType.STRING :
return new StringPersistedValueData(orderNumber, getString(data));
case ExtendedPropertyType.PERMISSION :
return new PermissionPersistedValueData(orderNumber, AccessControlEntry.parse(getString(data)));
default :
throw new IllegalStateException("Unknown property type " + type);
}
} | [
"public",
"static",
"PersistedValueData",
"createValueData",
"(",
"int",
"type",
",",
"int",
"orderNumber",
",",
"byte",
"[",
"]",
"data",
")",
"throws",
"IOException",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"PropertyType",
".",
"BINARY",
":",
"case",... | Creates value data depending on its type. It avoids storing unnecessary bytes in memory
every time.
@param type
property data type, can be either {@link PropertyType} or {@link ExtendedPropertyType}
@param orderNumber
value data order number
@param data
value data represented in array of bytes | [
"Creates",
"value",
"data",
"depending",
"on",
"its",
"type",
".",
"It",
"avoids",
"storing",
"unnecessary",
"bytes",
"in",
"memory",
"every",
"time",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/ValueDataUtil.java#L243-L302 |
136,152 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java | JDBCValueContentAddressStorageImpl.isRecordAlreadyExistsException | private boolean isRecordAlreadyExistsException(SQLException e)
{
// Search in UPPER case
// MySQL 5.0.x - com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
// Duplicate entry '4f684b34c0a800030018c34f99165791-0' for key 1
// HSQLDB 8.x - java.sql.SQLException: Violation of unique constraint $$: duplicate value(s) for
// column(s) $$:
// JCR_VCAS_PK in statement [INSERT INTO JCR_VCAS (PROPERTY_ID, ORDER_NUM, CAS_ID)
// VALUES(?,?,?)] String H2_PK_CONSTRAINT_DETECT_PATTERN = "(.*JdbcSQLException.*violation.*PRIMARY_KEY_.*)";
// PostgreSQL 8.2.x - org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
// constraint "jcr_vcas_pk"
// Oracle 9i x64 (on Fedora 7) - java.sql.SQLException: ORA-00001: unique constraint
// (EXOADMIN.JCR_VCAS_PK) violated
// H2 - org.h2.jdbc.JdbcSQLException: Unique index or primary key violation:
// "PRIMARY_KEY_4 ON PUBLIC.JCR_VCAS_TEST(PROPERTY_ID, ORDER_NUM)";
//
String err = e.toString();
if (dialect.startsWith(DBConstants.DB_DIALECT_MYSQL))
{
// for MySQL will search
return MYSQL_PK_CONSTRAINT_DETECT.matcher(err).find();
}
else if (err.toLowerCase().toUpperCase().indexOf(sqlConstraintPK.toLowerCase().toUpperCase()) >= 0)
{
// most of supported dbs prints PK name in exception
return true;
}
else if (dialect.startsWith(DBConstants.DB_DIALECT_DB2))
{
return DB2_PK_CONSTRAINT_DETECT.matcher(err).find();
}
else if (dialect.startsWith(DBConstants.DB_DIALECT_H2))
{
return H2_PK_CONSTRAINT_DETECT.matcher(err).find();
}
// NOTICE! As an additional check we may ask the database for property currently processed in
// VCAS
// and tell true if the property already exists only.
return false;
} | java | private boolean isRecordAlreadyExistsException(SQLException e)
{
// Search in UPPER case
// MySQL 5.0.x - com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
// Duplicate entry '4f684b34c0a800030018c34f99165791-0' for key 1
// HSQLDB 8.x - java.sql.SQLException: Violation of unique constraint $$: duplicate value(s) for
// column(s) $$:
// JCR_VCAS_PK in statement [INSERT INTO JCR_VCAS (PROPERTY_ID, ORDER_NUM, CAS_ID)
// VALUES(?,?,?)] String H2_PK_CONSTRAINT_DETECT_PATTERN = "(.*JdbcSQLException.*violation.*PRIMARY_KEY_.*)";
// PostgreSQL 8.2.x - org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
// constraint "jcr_vcas_pk"
// Oracle 9i x64 (on Fedora 7) - java.sql.SQLException: ORA-00001: unique constraint
// (EXOADMIN.JCR_VCAS_PK) violated
// H2 - org.h2.jdbc.JdbcSQLException: Unique index or primary key violation:
// "PRIMARY_KEY_4 ON PUBLIC.JCR_VCAS_TEST(PROPERTY_ID, ORDER_NUM)";
//
String err = e.toString();
if (dialect.startsWith(DBConstants.DB_DIALECT_MYSQL))
{
// for MySQL will search
return MYSQL_PK_CONSTRAINT_DETECT.matcher(err).find();
}
else if (err.toLowerCase().toUpperCase().indexOf(sqlConstraintPK.toLowerCase().toUpperCase()) >= 0)
{
// most of supported dbs prints PK name in exception
return true;
}
else if (dialect.startsWith(DBConstants.DB_DIALECT_DB2))
{
return DB2_PK_CONSTRAINT_DETECT.matcher(err).find();
}
else if (dialect.startsWith(DBConstants.DB_DIALECT_H2))
{
return H2_PK_CONSTRAINT_DETECT.matcher(err).find();
}
// NOTICE! As an additional check we may ask the database for property currently processed in
// VCAS
// and tell true if the property already exists only.
return false;
} | [
"private",
"boolean",
"isRecordAlreadyExistsException",
"(",
"SQLException",
"e",
")",
"{",
"// Search in UPPER case\r",
"// MySQL 5.0.x - com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:\r",
"// Duplicate entry '4f684b34c0a800030018c34f99165791-0' for key 1\r",
"// HSQLDB... | Tell is it a RecordAlreadyExistsException.
@param e
SQLException
@return boolean | [
"Tell",
"is",
"it",
"a",
"RecordAlreadyExistsException",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java#L338-L379 |
136,153 | exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/FileResource.java | FileResource.isTextContent | public boolean isTextContent()
{
try
{
return dataProperty().getType() != PropertyType.BINARY;
}
catch (RepositoryException exc)
{
LOG.error(exc.getMessage(), exc);
return false;
}
} | java | public boolean isTextContent()
{
try
{
return dataProperty().getType() != PropertyType.BINARY;
}
catch (RepositoryException exc)
{
LOG.error(exc.getMessage(), exc);
return false;
}
} | [
"public",
"boolean",
"isTextContent",
"(",
")",
"{",
"try",
"{",
"return",
"dataProperty",
"(",
")",
".",
"getType",
"(",
")",
"!=",
"PropertyType",
".",
"BINARY",
";",
"}",
"catch",
"(",
"RepositoryException",
"exc",
")",
"{",
"LOG",
".",
"error",
"(",
... | if the content of node is text.
@return true if the content of node is text false if not | [
"if",
"the",
"content",
"of",
"node",
"is",
"text",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/FileResource.java#L394-L405 |
136,154 | exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/WebDavNamespaceContext.java | WebDavNamespaceContext.createQName | public QName createQName(String strName)
{
String[] parts = strName.split(":");
if (parts.length > 1)
return new QName(getNamespaceURI(parts[0]), parts[1], parts[0]);
else
return new QName(parts[0]);
} | java | public QName createQName(String strName)
{
String[] parts = strName.split(":");
if (parts.length > 1)
return new QName(getNamespaceURI(parts[0]), parts[1], parts[0]);
else
return new QName(parts[0]);
} | [
"public",
"QName",
"createQName",
"(",
"String",
"strName",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"strName",
".",
"split",
"(",
"\":\"",
")",
";",
"if",
"(",
"parts",
".",
"length",
">",
"1",
")",
"return",
"new",
"QName",
"(",
"getNamespaceURI",... | Converts String into QName.
@param strName string name
@return new QName | [
"Converts",
"String",
"into",
"QName",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/WebDavNamespaceContext.java#L86-L93 |
136,155 | exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/WebDavNamespaceContext.java | WebDavNamespaceContext.getNamespaceURI | public String getNamespaceURI(String prefix)
{
String uri = null;
try
{
uri = namespaceRegistry.getURI(prefix);
}
catch (NamespaceException exc)
{
uri = namespaces.get(prefix);
}
catch (RepositoryException exc)
{
log.error(exc.getMessage(), exc);
}
return uri;
} | java | public String getNamespaceURI(String prefix)
{
String uri = null;
try
{
uri = namespaceRegistry.getURI(prefix);
}
catch (NamespaceException exc)
{
uri = namespaces.get(prefix);
}
catch (RepositoryException exc)
{
log.error(exc.getMessage(), exc);
}
return uri;
} | [
"public",
"String",
"getNamespaceURI",
"(",
"String",
"prefix",
")",
"{",
"String",
"uri",
"=",
"null",
";",
"try",
"{",
"uri",
"=",
"namespaceRegistry",
".",
"getURI",
"(",
"prefix",
")",
";",
"}",
"catch",
"(",
"NamespaceException",
"exc",
")",
"{",
"u... | Returns namespace URI.
@see javax.xml.namespace.NamespaceContext#getNamespaceURI(String)
@param prefix namespace prefix
@return namespace URI | [
"Returns",
"namespace",
"URI",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/WebDavNamespaceContext.java#L112-L128 |
136,156 | exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/WebDavNamespaceContext.java | WebDavNamespaceContext.getPrefix | public String getPrefix(String namespaceURI)
{
String prefix = null;
try
{
prefix = namespaceRegistry.getPrefix(namespaceURI);
}
catch (NamespaceException exc)
{
prefix = prefixes.get(namespaceURI);
}
catch (RepositoryException exc)
{
log.error(exc.getMessage(), exc);
}
return prefix;
} | java | public String getPrefix(String namespaceURI)
{
String prefix = null;
try
{
prefix = namespaceRegistry.getPrefix(namespaceURI);
}
catch (NamespaceException exc)
{
prefix = prefixes.get(namespaceURI);
}
catch (RepositoryException exc)
{
log.error(exc.getMessage(), exc);
}
return prefix;
} | [
"public",
"String",
"getPrefix",
"(",
"String",
"namespaceURI",
")",
"{",
"String",
"prefix",
"=",
"null",
";",
"try",
"{",
"prefix",
"=",
"namespaceRegistry",
".",
"getPrefix",
"(",
"namespaceURI",
")",
";",
"}",
"catch",
"(",
"NamespaceException",
"exc",
"... | Returns namespace prefix.
@see javax.xml.namespace.NamespaceContext#getPrefix(String)
@param namespaceURI namespace URI
@return namespace prefix | [
"Returns",
"namespace",
"prefix",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/WebDavNamespaceContext.java#L136-L153 |
136,157 | exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/WebDavNamespaceContext.java | WebDavNamespaceContext.getPrefixes | public Iterator<String> getPrefixes(String namespaceURI)
{
List<String> list = new ArrayList<String>();
list.add(getPrefix(namespaceURI));
return list.iterator();
} | java | public Iterator<String> getPrefixes(String namespaceURI)
{
List<String> list = new ArrayList<String>();
list.add(getPrefix(namespaceURI));
return list.iterator();
} | [
"public",
"Iterator",
"<",
"String",
">",
"getPrefixes",
"(",
"String",
"namespaceURI",
")",
"{",
"List",
"<",
"String",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"list",
".",
"add",
"(",
"getPrefix",
"(",
"namespaceURI",
... | Returns the list of registered for this URI namespace prefixes.
@see javax.xml.namespace.NamespaceContext#getPrefixes(String)
@param namespaceURI namespace URI
@return list of registered for prefixes | [
"Returns",
"the",
"list",
"of",
"registered",
"for",
"this",
"URI",
"namespace",
"prefixes",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/WebDavNamespaceContext.java#L161-L166 |
136,158 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PropertiesSynonymProvider.java | PropertiesSynonymProvider.getSynonyms | private static Map<String, String[]> getSynonyms(InputStream config) throws IOException
{
try
{
Map<String, String[]> synonyms = new HashMap<String, String[]>();
Properties props = new Properties();
props.load(config);
Iterator<Map.Entry<Object, Object>> it = props.entrySet().iterator();
while (it.hasNext())
{
Map.Entry<Object, Object> e = it.next();
String key = (String)e.getKey();
String value = (String)e.getValue();
addSynonym(key, value, synonyms);
addSynonym(value, key, synonyms);
}
return synonyms;
}
catch (Exception e)
{
throw Util.createIOException(e);
}
} | java | private static Map<String, String[]> getSynonyms(InputStream config) throws IOException
{
try
{
Map<String, String[]> synonyms = new HashMap<String, String[]>();
Properties props = new Properties();
props.load(config);
Iterator<Map.Entry<Object, Object>> it = props.entrySet().iterator();
while (it.hasNext())
{
Map.Entry<Object, Object> e = it.next();
String key = (String)e.getKey();
String value = (String)e.getValue();
addSynonym(key, value, synonyms);
addSynonym(value, key, synonyms);
}
return synonyms;
}
catch (Exception e)
{
throw Util.createIOException(e);
}
} | [
"private",
"static",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"getSynonyms",
"(",
"InputStream",
"config",
")",
"throws",
"IOException",
"{",
"try",
"{",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"synonyms",
"=",
"new",
"HashMap",
... | Reads the synonym properties file and returns the contents as a synonym
Map.
@param config the synonym properties file.
@return a Map containing the synonyms.
@throws IOException if an error occurs while reading from the file system
resource. | [
"Reads",
"the",
"synonym",
"properties",
"file",
"and",
"returns",
"the",
"contents",
"as",
"a",
"synonym",
"Map",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PropertiesSynonymProvider.java#L145-L167 |
136,159 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PropertiesSynonymProvider.java | PropertiesSynonymProvider.addSynonym | private static void addSynonym(String term, String synonym, Map<String, String[]> synonyms)
{
term = term.toLowerCase();
String[] syns = synonyms.get(term);
if (syns == null)
{
syns = new String[]{synonym};
}
else
{
String[] tmp = new String[syns.length + 1];
System.arraycopy(syns, 0, tmp, 0, syns.length);
tmp[syns.length] = synonym;
syns = tmp;
}
synonyms.put(term, syns);
} | java | private static void addSynonym(String term, String synonym, Map<String, String[]> synonyms)
{
term = term.toLowerCase();
String[] syns = synonyms.get(term);
if (syns == null)
{
syns = new String[]{synonym};
}
else
{
String[] tmp = new String[syns.length + 1];
System.arraycopy(syns, 0, tmp, 0, syns.length);
tmp[syns.length] = synonym;
syns = tmp;
}
synonyms.put(term, syns);
} | [
"private",
"static",
"void",
"addSynonym",
"(",
"String",
"term",
",",
"String",
"synonym",
",",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"synonyms",
")",
"{",
"term",
"=",
"term",
".",
"toLowerCase",
"(",
")",
";",
"String",
"[",
"]",
"sy... | Adds a synonym definition to the map.
@param term the term
@param synonym synonym for <code>term</code>.
@param synonyms the Map containing the synonyms. | [
"Adds",
"a",
"synonym",
"definition",
"to",
"the",
"map",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PropertiesSynonymProvider.java#L176-L192 |
136,160 | exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/UnCheckOutCommand.java | UnCheckOutCommand.uncheckout | public Response uncheckout(Session session, String path)
{
try
{
Node node = session.getRootNode().getNode(TextUtil.relativizePath(path));
Version restoreVersion = node.getBaseVersion();
node.restore(restoreVersion, true);
return Response.ok().header(HttpHeaders.CACHE_CONTROL, "no-cache").build();
}
catch (UnsupportedRepositoryOperationException exc)
{
return Response.status(HTTPStatus.CONFLICT).entity(exc.getMessage()).build();
}
catch (LockException exc)
{
return Response.status(HTTPStatus.LOCKED).entity(exc.getMessage()).build();
}
catch (PathNotFoundException exc)
{
return Response.status(HTTPStatus.NOT_FOUND).entity(exc.getMessage()).build();
}
catch (RepositoryException exc)
{
LOG.error(exc.getMessage(), exc);
return Response.serverError().entity(exc.getMessage()).build();
}
} | java | public Response uncheckout(Session session, String path)
{
try
{
Node node = session.getRootNode().getNode(TextUtil.relativizePath(path));
Version restoreVersion = node.getBaseVersion();
node.restore(restoreVersion, true);
return Response.ok().header(HttpHeaders.CACHE_CONTROL, "no-cache").build();
}
catch (UnsupportedRepositoryOperationException exc)
{
return Response.status(HTTPStatus.CONFLICT).entity(exc.getMessage()).build();
}
catch (LockException exc)
{
return Response.status(HTTPStatus.LOCKED).entity(exc.getMessage()).build();
}
catch (PathNotFoundException exc)
{
return Response.status(HTTPStatus.NOT_FOUND).entity(exc.getMessage()).build();
}
catch (RepositoryException exc)
{
LOG.error(exc.getMessage(), exc);
return Response.serverError().entity(exc.getMessage()).build();
}
} | [
"public",
"Response",
"uncheckout",
"(",
"Session",
"session",
",",
"String",
"path",
")",
"{",
"try",
"{",
"Node",
"node",
"=",
"session",
".",
"getRootNode",
"(",
")",
".",
"getNode",
"(",
"TextUtil",
".",
"relativizePath",
"(",
"path",
")",
")",
";",
... | Webdav Uncheckout method implementation.
@param session current session
@param path resource path
@return the instance of javax.ws.rs.core.Response | [
"Webdav",
"Uncheckout",
"method",
"implementation",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/UnCheckOutCommand.java#L58-L92 |
136,161 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java | JDBCConfigurationPersister.isDbInitialized | protected boolean isDbInitialized(final Connection con)
{
return SecurityHelper.doPrivilegedAction(new PrivilegedAction<Boolean>()
{
public Boolean run()
{
return JDBCUtils.tableExists(configTableName, con);
}
});
} | java | protected boolean isDbInitialized(final Connection con)
{
return SecurityHelper.doPrivilegedAction(new PrivilegedAction<Boolean>()
{
public Boolean run()
{
return JDBCUtils.tableExists(configTableName, con);
}
});
} | [
"protected",
"boolean",
"isDbInitialized",
"(",
"final",
"Connection",
"con",
")",
"{",
"return",
"SecurityHelper",
".",
"doPrivilegedAction",
"(",
"new",
"PrivilegedAction",
"<",
"Boolean",
">",
"(",
")",
"{",
"public",
"Boolean",
"run",
"(",
")",
"{",
"retur... | Check if config table already exists
@param con | [
"Check",
"if",
"config",
"table",
"already",
"exists"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java#L224-L234 |
136,162 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/ValueDataResourceHolder.java | ValueDataResourceHolder.aquire | public boolean aquire(final Object resource, final ValueLockSupport lockHolder) throws InterruptedException,
IOException
{
final Thread myThread = Thread.currentThread();
final VDResource res = resources.get(resource);
if (res != null)
{
if (res.addUserLock(myThread, lockHolder))
// resource locked in this thread (by me)
return false;
synchronized (res.lock)
{
// resource locked, wait for unlock
res.lock.wait();
// new record with existing lock (to respect Object.notify())
resources.put(resource, new VDResource(myThread, res.lock, lockHolder));
}
}
else
resources.put(resource, new VDResource(myThread, new Object(), lockHolder));
return true;
} | java | public boolean aquire(final Object resource, final ValueLockSupport lockHolder) throws InterruptedException,
IOException
{
final Thread myThread = Thread.currentThread();
final VDResource res = resources.get(resource);
if (res != null)
{
if (res.addUserLock(myThread, lockHolder))
// resource locked in this thread (by me)
return false;
synchronized (res.lock)
{
// resource locked, wait for unlock
res.lock.wait();
// new record with existing lock (to respect Object.notify())
resources.put(resource, new VDResource(myThread, res.lock, lockHolder));
}
}
else
resources.put(resource, new VDResource(myThread, new Object(), lockHolder));
return true;
} | [
"public",
"boolean",
"aquire",
"(",
"final",
"Object",
"resource",
",",
"final",
"ValueLockSupport",
"lockHolder",
")",
"throws",
"InterruptedException",
",",
"IOException",
"{",
"final",
"Thread",
"myThread",
"=",
"Thread",
".",
"currentThread",
"(",
")",
";",
... | Aquire ValueData resource.
@param resource
Object
@param lockHolder
ValueLockSupport
@throws InterruptedException
if resource lock is interrupted
@return boolean, false - if the resource reaquired by the same user (Thread), true otherwise
@throws IOException
if lock error occurs | [
"Aquire",
"ValueData",
"resource",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/ValueDataResourceHolder.java#L152-L175 |
136,163 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/ValueDataResourceHolder.java | ValueDataResourceHolder.release | public boolean release(final Object resource) throws IOException
{
final Thread myThread = Thread.currentThread();
final VDResource res = resources.get(resource);
if (res != null)
{
if (res.removeUserLock(myThread))
{
synchronized (res.lock)
{
// unlock holder
res.lockSupport.unlock();
// locked by this thread (by me)
// ...Wakes up a single thread that is waiting on this object's monitor
res.lock.notify();
// resources will be reputed with new VDResource in aquire() of another Thread
resources.remove(resource);
}
return true;
}
}
return false;
} | java | public boolean release(final Object resource) throws IOException
{
final Thread myThread = Thread.currentThread();
final VDResource res = resources.get(resource);
if (res != null)
{
if (res.removeUserLock(myThread))
{
synchronized (res.lock)
{
// unlock holder
res.lockSupport.unlock();
// locked by this thread (by me)
// ...Wakes up a single thread that is waiting on this object's monitor
res.lock.notify();
// resources will be reputed with new VDResource in aquire() of another Thread
resources.remove(resource);
}
return true;
}
}
return false;
} | [
"public",
"boolean",
"release",
"(",
"final",
"Object",
"resource",
")",
"throws",
"IOException",
"{",
"final",
"Thread",
"myThread",
"=",
"Thread",
".",
"currentThread",
"(",
")",
";",
"final",
"VDResource",
"res",
"=",
"resources",
".",
"get",
"(",
"resour... | Release resource.
@param resource
Object
@return boolean, true - if resource is released, false - if the resource still in use.
@throws IOException
if unlock error occurs | [
"Release",
"resource",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/ValueDataResourceHolder.java#L186-L210 |
136,164 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NodeDataIndexing.java | NodeDataIndexing.getProperty | public PropertyData getProperty(String name)
{
return properties == null ? null : properties.get(name);
} | java | public PropertyData getProperty(String name)
{
return properties == null ? null : properties.get(name);
} | [
"public",
"PropertyData",
"getProperty",
"(",
"String",
"name",
")",
"{",
"return",
"properties",
"==",
"null",
"?",
"null",
":",
"properties",
".",
"get",
"(",
"name",
")",
";",
"}"
] | Property data.
@return PropertyData | [
"Property",
"data",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NodeDataIndexing.java#L75-L78 |
136,165 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedPropertyDataReader.java | PersistedPropertyDataReader.read | public PersistedPropertyData read(ObjectReader in) throws UnknownClassIdException, IOException
{
// read id
int key;
if ((key = in.readInt()) != SerializationConstants.PERSISTED_PROPERTY_DATA)
{
throw new UnknownClassIdException("There is unexpected class [" + key + "]");
}
QPath qpath;
try
{
String sQPath = in.readString();
qpath = QPath.parse(sQPath);
}
catch (final IllegalPathException e)
{
throw new IOException("Deserialization error. " + e)
{
/**
* {@inheritDoc}
*/
@Override
public Throwable getCause()
{
return e;
}
};
}
String identifier = in.readString();
String parentIdentifier = null;
if (in.readByte() == SerializationConstants.NOT_NULL_DATA)
{
parentIdentifier = in.readString();
}
int persistedVersion = in.readInt();
// --------------
int type = in.readInt();
boolean multiValued = in.readBoolean();
PersistedSize persistedSizeHandler = new SimplePersistedSize(in.readLong());
PersistedPropertyData prop;
if (in.readByte() == SerializationConstants.NOT_NULL_DATA)
{
int listSize = in.readInt();
List<ValueData> values = new ArrayList<ValueData>();
PersistedValueDataReader rdr = new PersistedValueDataReader(holder, spoolConfig);
for (int i = 0; i < listSize; i++)
{
values.add(rdr.read(in, type));
}
prop =
new PersistedPropertyData(identifier, qpath, parentIdentifier, persistedVersion, type, multiValued, values,
persistedSizeHandler);
}
else
{
prop =
new PersistedPropertyData(identifier, qpath, parentIdentifier, persistedVersion, type, multiValued, null,
persistedSizeHandler);
}
return prop;
} | java | public PersistedPropertyData read(ObjectReader in) throws UnknownClassIdException, IOException
{
// read id
int key;
if ((key = in.readInt()) != SerializationConstants.PERSISTED_PROPERTY_DATA)
{
throw new UnknownClassIdException("There is unexpected class [" + key + "]");
}
QPath qpath;
try
{
String sQPath = in.readString();
qpath = QPath.parse(sQPath);
}
catch (final IllegalPathException e)
{
throw new IOException("Deserialization error. " + e)
{
/**
* {@inheritDoc}
*/
@Override
public Throwable getCause()
{
return e;
}
};
}
String identifier = in.readString();
String parentIdentifier = null;
if (in.readByte() == SerializationConstants.NOT_NULL_DATA)
{
parentIdentifier = in.readString();
}
int persistedVersion = in.readInt();
// --------------
int type = in.readInt();
boolean multiValued = in.readBoolean();
PersistedSize persistedSizeHandler = new SimplePersistedSize(in.readLong());
PersistedPropertyData prop;
if (in.readByte() == SerializationConstants.NOT_NULL_DATA)
{
int listSize = in.readInt();
List<ValueData> values = new ArrayList<ValueData>();
PersistedValueDataReader rdr = new PersistedValueDataReader(holder, spoolConfig);
for (int i = 0; i < listSize; i++)
{
values.add(rdr.read(in, type));
}
prop =
new PersistedPropertyData(identifier, qpath, parentIdentifier, persistedVersion, type, multiValued, values,
persistedSizeHandler);
}
else
{
prop =
new PersistedPropertyData(identifier, qpath, parentIdentifier, persistedVersion, type, multiValued, null,
persistedSizeHandler);
}
return prop;
} | [
"public",
"PersistedPropertyData",
"read",
"(",
"ObjectReader",
"in",
")",
"throws",
"UnknownClassIdException",
",",
"IOException",
"{",
"// read id",
"int",
"key",
";",
"if",
"(",
"(",
"key",
"=",
"in",
".",
"readInt",
"(",
")",
")",
"!=",
"SerializationConst... | Read and set PersistedPropertyData object data.
@param in ObjectReader.
@return PersistedPropertyData object.
@throws UnknownClassIdException If read Class ID is not expected or do not
exist.
@throws IOException If an I/O error has occurred. | [
"Read",
"and",
"set",
"PersistedPropertyData",
"object",
"data",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedPropertyDataReader.java#L67-L138 |
136,166 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java | AbstractIndex.addDocuments | void addDocuments(final Document[] docs) throws IOException
{
final IndexWriter writer = getIndexWriter();
IOException ioExc = null;
try
{
for (Document doc : docs)
{
try
{
writer.addDocument(doc);
}
catch (Throwable e) //NOSONAR
{
if (ioExc == null)
{
if (e instanceof IOException)
{
ioExc = (IOException)e;
}
else
{
ioExc = Util.createIOException(e);
}
}
log.warn("Exception while inverting document", e);
}
}
}
finally
{
invalidateSharedReader();
}
if (ioExc != null)
{
throw ioExc;
}
} | java | void addDocuments(final Document[] docs) throws IOException
{
final IndexWriter writer = getIndexWriter();
IOException ioExc = null;
try
{
for (Document doc : docs)
{
try
{
writer.addDocument(doc);
}
catch (Throwable e) //NOSONAR
{
if (ioExc == null)
{
if (e instanceof IOException)
{
ioExc = (IOException)e;
}
else
{
ioExc = Util.createIOException(e);
}
}
log.warn("Exception while inverting document", e);
}
}
}
finally
{
invalidateSharedReader();
}
if (ioExc != null)
{
throw ioExc;
}
} | [
"void",
"addDocuments",
"(",
"final",
"Document",
"[",
"]",
"docs",
")",
"throws",
"IOException",
"{",
"final",
"IndexWriter",
"writer",
"=",
"getIndexWriter",
"(",
")",
";",
"IOException",
"ioExc",
"=",
"null",
";",
"try",
"{",
"for",
"(",
"Document",
"do... | Adds documents to this index and invalidates the shared reader.
@param docs the documents to add.
@throws IOException if an error occurs while writing to the index. | [
"Adds",
"documents",
"to",
"this",
"index",
"and",
"invalidates",
"the",
"shared",
"reader",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java#L171-L211 |
136,167 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java | AbstractIndex.close | synchronized void close()
{
releaseWriterAndReaders();
if (directory != null)
{
try
{
directory.close();
}
catch (IOException e)
{
directory = null;
}
}
} | java | synchronized void close()
{
releaseWriterAndReaders();
if (directory != null)
{
try
{
directory.close();
}
catch (IOException e)
{
directory = null;
}
}
} | [
"synchronized",
"void",
"close",
"(",
")",
"{",
"releaseWriterAndReaders",
"(",
")",
";",
"if",
"(",
"directory",
"!=",
"null",
")",
"{",
"try",
"{",
"directory",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"directory"... | Closes this index, releasing all held resources. | [
"Closes",
"this",
"index",
"releasing",
"all",
"held",
"resources",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java#L420-L434 |
136,168 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java | AbstractIndex.releaseWriterAndReaders | protected void releaseWriterAndReaders()
{
if (indexWriter != null)
{
try
{
indexWriter.close();
}
catch (IOException e)
{
log.warn("Exception closing index writer: " + e.toString());
}
indexWriter = null;
}
if (indexReader != null)
{
try
{
indexReader.close();
}
catch (IOException e)
{
log.warn("Exception closing index reader: " + e.toString());
}
indexReader = null;
}
if (readOnlyReader != null)
{
try
{
readOnlyReader.release();
}
catch (IOException e)
{
log.warn("Exception closing index reader: " + e.toString());
}
readOnlyReader = null;
}
if (sharedReader != null)
{
try
{
sharedReader.release();
}
catch (IOException e)
{
log.warn("Exception closing index reader: " + e.toString());
}
sharedReader = null;
}
} | java | protected void releaseWriterAndReaders()
{
if (indexWriter != null)
{
try
{
indexWriter.close();
}
catch (IOException e)
{
log.warn("Exception closing index writer: " + e.toString());
}
indexWriter = null;
}
if (indexReader != null)
{
try
{
indexReader.close();
}
catch (IOException e)
{
log.warn("Exception closing index reader: " + e.toString());
}
indexReader = null;
}
if (readOnlyReader != null)
{
try
{
readOnlyReader.release();
}
catch (IOException e)
{
log.warn("Exception closing index reader: " + e.toString());
}
readOnlyReader = null;
}
if (sharedReader != null)
{
try
{
sharedReader.release();
}
catch (IOException e)
{
log.warn("Exception closing index reader: " + e.toString());
}
sharedReader = null;
}
} | [
"protected",
"void",
"releaseWriterAndReaders",
"(",
")",
"{",
"if",
"(",
"indexWriter",
"!=",
"null",
")",
"{",
"try",
"{",
"indexWriter",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"Except... | Releases all potentially held index writer and readers. | [
"Releases",
"all",
"potentially",
"held",
"index",
"writer",
"and",
"readers",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java#L439-L489 |
136,169 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java | AbstractIndex.invalidateSharedReader | protected synchronized void invalidateSharedReader() throws IOException
{
// also close the read-only reader
if (readOnlyReader != null)
{
readOnlyReader.release();
readOnlyReader = null;
}
// invalidate shared reader
if (sharedReader != null)
{
sharedReader.release();
sharedReader = null;
}
} | java | protected synchronized void invalidateSharedReader() throws IOException
{
// also close the read-only reader
if (readOnlyReader != null)
{
readOnlyReader.release();
readOnlyReader = null;
}
// invalidate shared reader
if (sharedReader != null)
{
sharedReader.release();
sharedReader = null;
}
} | [
"protected",
"synchronized",
"void",
"invalidateSharedReader",
"(",
")",
"throws",
"IOException",
"{",
"// also close the read-only reader",
"if",
"(",
"readOnlyReader",
"!=",
"null",
")",
"{",
"readOnlyReader",
".",
"release",
"(",
")",
";",
"readOnlyReader",
"=",
... | Closes the shared reader.
@throws IOException if an error occurs while closing the reader. | [
"Closes",
"the",
"shared",
"reader",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java#L511-L525 |
136,170 | exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchRequestEntity.java | SearchRequestEntity.getQueryLanguage | public String getQueryLanguage() throws UnsupportedQueryException
{
if (body.getChild(0).getName().getNamespaceURI().equals("DAV:")
&& body.getChild(0).getName().getLocalPart().equals("sql"))
{
return "sql";
}
else if (body.getChild(0).getName().getNamespaceURI().equals("DAV:")
&& body.getChild(0).getName().getLocalPart().equals("xpath"))
{
return "xpath";
}
throw new UnsupportedOperationException();
} | java | public String getQueryLanguage() throws UnsupportedQueryException
{
if (body.getChild(0).getName().getNamespaceURI().equals("DAV:")
&& body.getChild(0).getName().getLocalPart().equals("sql"))
{
return "sql";
}
else if (body.getChild(0).getName().getNamespaceURI().equals("DAV:")
&& body.getChild(0).getName().getLocalPart().equals("xpath"))
{
return "xpath";
}
throw new UnsupportedOperationException();
} | [
"public",
"String",
"getQueryLanguage",
"(",
")",
"throws",
"UnsupportedQueryException",
"{",
"if",
"(",
"body",
".",
"getChild",
"(",
"0",
")",
".",
"getName",
"(",
")",
".",
"getNamespaceURI",
"(",
")",
".",
"equals",
"(",
"\"DAV:\"",
")",
"&&",
"body",
... | Get query language.
@return query language
@throws UnsupportedQueryException {@link UnsupportedQueryException} | [
"Get",
"query",
"language",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchRequestEntity.java#L53-L67 |
136,171 | exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchRequestEntity.java | SearchRequestEntity.getQuery | public String getQuery() throws UnsupportedQueryException
{
if (body.getChild(0).getName().getNamespaceURI().equals("DAV:")
&& body.getChild(0).getName().getLocalPart().equals("sql"))
{
return body.getChild(0).getValue();
}
else if (body.getChild(0).getName().getNamespaceURI().equals("DAV:")
&& body.getChild(0).getName().getLocalPart().equals("xpath"))
{
return body.getChild(0).getValue();
}
throw new UnsupportedQueryException();
} | java | public String getQuery() throws UnsupportedQueryException
{
if (body.getChild(0).getName().getNamespaceURI().equals("DAV:")
&& body.getChild(0).getName().getLocalPart().equals("sql"))
{
return body.getChild(0).getValue();
}
else if (body.getChild(0).getName().getNamespaceURI().equals("DAV:")
&& body.getChild(0).getName().getLocalPart().equals("xpath"))
{
return body.getChild(0).getValue();
}
throw new UnsupportedQueryException();
} | [
"public",
"String",
"getQuery",
"(",
")",
"throws",
"UnsupportedQueryException",
"{",
"if",
"(",
"body",
".",
"getChild",
"(",
"0",
")",
".",
"getName",
"(",
")",
".",
"getNamespaceURI",
"(",
")",
".",
"equals",
"(",
"\"DAV:\"",
")",
"&&",
"body",
".",
... | Get query.
@return query qury body.
@throws UnsupportedQueryException {@link UnsupportedQueryException} | [
"Get",
"query",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchRequestEntity.java#L75-L89 |
136,172 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerIoModeHandler.java | IndexerIoModeHandler.setMode | public synchronized void setMode(IndexerIoMode mode)
{
if (this.mode != mode)
{
log.info("Indexer io mode=" + mode);
this.mode = mode;
for (IndexerIoModeListener listener : listeners)
{
listener.onChangeMode(mode);
}
}
} | java | public synchronized void setMode(IndexerIoMode mode)
{
if (this.mode != mode)
{
log.info("Indexer io mode=" + mode);
this.mode = mode;
for (IndexerIoModeListener listener : listeners)
{
listener.onChangeMode(mode);
}
}
} | [
"public",
"synchronized",
"void",
"setMode",
"(",
"IndexerIoMode",
"mode",
")",
"{",
"if",
"(",
"this",
".",
"mode",
"!=",
"mode",
")",
"{",
"log",
".",
"info",
"(",
"\"Indexer io mode=\"",
"+",
"mode",
")",
";",
"this",
".",
"mode",
"=",
"mode",
";",
... | Changes the current mode of the indexer. If the value has changes all the listeners
will be notified | [
"Changes",
"the",
"current",
"mode",
"of",
"the",
"indexer",
".",
"If",
"the",
"value",
"has",
"changes",
"all",
"the",
"listeners",
"will",
"be",
"notified"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerIoModeHandler.java#L72-L83 |
136,173 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java | IndexInfos.read | public void read() throws IOException
{
SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
{
public Object run() throws Exception
{
// Known issue for NFS bases on ext3. Need to refresh directory to read actual data.
dir.listAll();
names.clear();
indexes.clear();
if (dir.fileExists(name))
{
// clear current lists
InputStream in = new IndexInputStream(dir.openInput(name));
DataInputStream di = null;
try
{
di = new DataInputStream(in);
counter = di.readInt();
for (int i = di.readInt(); i > 0; i--)
{
String indexName = di.readUTF();
indexes.add(indexName);
names.add(indexName);
}
}
finally
{
if (di != null)
di.close();
in.close();
}
}
return null;
}
});
} | java | public void read() throws IOException
{
SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
{
public Object run() throws Exception
{
// Known issue for NFS bases on ext3. Need to refresh directory to read actual data.
dir.listAll();
names.clear();
indexes.clear();
if (dir.fileExists(name))
{
// clear current lists
InputStream in = new IndexInputStream(dir.openInput(name));
DataInputStream di = null;
try
{
di = new DataInputStream(in);
counter = di.readInt();
for (int i = di.readInt(); i > 0; i--)
{
String indexName = di.readUTF();
indexes.add(indexName);
names.add(indexName);
}
}
finally
{
if (di != null)
di.close();
in.close();
}
}
return null;
}
});
} | [
"public",
"void",
"read",
"(",
")",
"throws",
"IOException",
"{",
"SecurityHelper",
".",
"doPrivilegedIOExceptionAction",
"(",
"new",
"PrivilegedExceptionAction",
"<",
"Object",
">",
"(",
")",
"{",
"public",
"Object",
"run",
"(",
")",
"throws",
"Exception",
"{",... | Reads the index infos. Before reading it checks if file exists
@throws IOException if an error occurs. | [
"Reads",
"the",
"index",
"infos",
".",
"Before",
"reading",
"it",
"checks",
"if",
"file",
"exists"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java#L118-L155 |
136,174 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java | IndexInfos.write | public void write() throws IOException
{
SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
{
public Object run() throws Exception
{
// do not write if not dirty
if (!dirty)
{
return null;
}
OutputStream out = new IndexOutputStream(dir.createOutput(name + ".new"));
DataOutputStream dataOut = null;
try
{
dataOut = new DataOutputStream(out);
dataOut.writeInt(counter);
dataOut.writeInt(indexes.size());
for (int i = 0; i < indexes.size(); i++)
{
dataOut.writeUTF(getName(i));
}
}
finally
{
if (dataOut != null)
dataOut.close();
out.close();
}
// delete old
if (dir.fileExists(name))
{
dir.deleteFile(name);
}
rename(name + ".new", name);
dirty = false;
return null;
}
});
} | java | public void write() throws IOException
{
SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
{
public Object run() throws Exception
{
// do not write if not dirty
if (!dirty)
{
return null;
}
OutputStream out = new IndexOutputStream(dir.createOutput(name + ".new"));
DataOutputStream dataOut = null;
try
{
dataOut = new DataOutputStream(out);
dataOut.writeInt(counter);
dataOut.writeInt(indexes.size());
for (int i = 0; i < indexes.size(); i++)
{
dataOut.writeUTF(getName(i));
}
}
finally
{
if (dataOut != null)
dataOut.close();
out.close();
}
// delete old
if (dir.fileExists(name))
{
dir.deleteFile(name);
}
rename(name + ".new", name);
dirty = false;
return null;
}
});
} | [
"public",
"void",
"write",
"(",
")",
"throws",
"IOException",
"{",
"SecurityHelper",
".",
"doPrivilegedIOExceptionAction",
"(",
"new",
"PrivilegedExceptionAction",
"<",
"Object",
">",
"(",
")",
"{",
"public",
"Object",
"run",
"(",
")",
"throws",
"Exception",
"{"... | Writes the index infos to disk if they are dirty.
@throws IOException if an error occurs. | [
"Writes",
"the",
"index",
"infos",
"to",
"disk",
"if",
"they",
"are",
"dirty",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java#L162-L202 |
136,175 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java | IndexInfos.rename | private void rename(String from, String to) throws IOException
{
IndexOutputStream out = null;
IndexInputStream in = null;
try
{
out = new IndexOutputStream(dir.createOutput(to));
in = new IndexInputStream(dir.openInput(from));
DirectoryHelper.transfer(in, out);
}
finally
{
if (in != null)
{
in.close();
}
if (out != null)
{
out.flush();
out.close();
}
}
try
{
// delete old one
if (dir.fileExists(from))
{
dir.deleteFile(from);
}
}
catch (IOException e)
{
// do noting. Will be removed later
if (LOG.isTraceEnabled())
{
LOG.trace("Can't deleted file: " + e.getMessage());
}
}
} | java | private void rename(String from, String to) throws IOException
{
IndexOutputStream out = null;
IndexInputStream in = null;
try
{
out = new IndexOutputStream(dir.createOutput(to));
in = new IndexInputStream(dir.openInput(from));
DirectoryHelper.transfer(in, out);
}
finally
{
if (in != null)
{
in.close();
}
if (out != null)
{
out.flush();
out.close();
}
}
try
{
// delete old one
if (dir.fileExists(from))
{
dir.deleteFile(from);
}
}
catch (IOException e)
{
// do noting. Will be removed later
if (LOG.isTraceEnabled())
{
LOG.trace("Can't deleted file: " + e.getMessage());
}
}
} | [
"private",
"void",
"rename",
"(",
"String",
"from",
",",
"String",
"to",
")",
"throws",
"IOException",
"{",
"IndexOutputStream",
"out",
"=",
"null",
";",
"IndexInputStream",
"in",
"=",
"null",
";",
"try",
"{",
"out",
"=",
"new",
"IndexOutputStream",
"(",
"... | Renames file by copying.
@param from
@param to
@throws IOException | [
"Renames",
"file",
"by",
"copying",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java#L211-L250 |
136,176 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java | IndexInfos.addName | public void addName(String name)
{
if (names.contains(name))
{
throw new IllegalArgumentException("already contains: " + name);
}
indexes.add(name);
names.add(name);
dirty = true;
} | java | public void addName(String name)
{
if (names.contains(name))
{
throw new IllegalArgumentException("already contains: " + name);
}
indexes.add(name);
names.add(name);
dirty = true;
} | [
"public",
"void",
"addName",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"names",
".",
"contains",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"already contains: \"",
"+",
"name",
")",
";",
"}",
"indexes",
".",
"add",
"... | Adds a name to the index infos.
@param name the name to add. | [
"Adds",
"a",
"name",
"to",
"the",
"index",
"infos",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java#L284-L293 |
136,177 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java | IndexInfos.setNames | protected void setNames(Set<String> names)
{
this.names.clear();
this.indexes.clear();
this.names.addAll(names);
this.indexes.addAll(names);
// new list of indexes if thought to be up to date
dirty = false;
} | java | protected void setNames(Set<String> names)
{
this.names.clear();
this.indexes.clear();
this.names.addAll(names);
this.indexes.addAll(names);
// new list of indexes if thought to be up to date
dirty = false;
} | [
"protected",
"void",
"setNames",
"(",
"Set",
"<",
"String",
">",
"names",
")",
"{",
"this",
".",
"names",
".",
"clear",
"(",
")",
";",
"this",
".",
"indexes",
".",
"clear",
"(",
")",
";",
"this",
".",
"names",
".",
"addAll",
"(",
"names",
")",
";... | Sets new names, clearing existing. It is thought to be used when list of indexes can
be externally changed.
@param names | [
"Sets",
"new",
"names",
"clearing",
"existing",
".",
"It",
"is",
"thought",
"to",
"be",
"used",
"when",
"list",
"of",
"indexes",
"can",
"be",
"externally",
"changed",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java#L354-L362 |
136,178 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessControlList.java | AccessControlList.addPermissions | public void addPermissions(String identity, String[] perm) throws RepositoryException
{
for (String p : perm)
{
accessList.add(new AccessControlEntry(identity, p));
}
} | java | public void addPermissions(String identity, String[] perm) throws RepositoryException
{
for (String p : perm)
{
accessList.add(new AccessControlEntry(identity, p));
}
} | [
"public",
"void",
"addPermissions",
"(",
"String",
"identity",
",",
"String",
"[",
"]",
"perm",
")",
"throws",
"RepositoryException",
"{",
"for",
"(",
"String",
"p",
":",
"perm",
")",
"{",
"accessList",
".",
"add",
"(",
"new",
"AccessControlEntry",
"(",
"i... | Adds a set of permission types to a given identity
@param identity the member identity
@param perm an array of permission types to add | [
"Adds",
"a",
"set",
"of",
"permission",
"types",
"to",
"a",
"given",
"identity"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessControlList.java#L131-L137 |
136,179 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessControlList.java | AccessControlList.removePermissions | public void removePermissions(String identity)
{
for (Iterator<AccessControlEntry> iter = accessList.iterator(); iter.hasNext();)
{
AccessControlEntry a = iter.next();
if (a.getIdentity().equals(identity))
iter.remove();
}
} | java | public void removePermissions(String identity)
{
for (Iterator<AccessControlEntry> iter = accessList.iterator(); iter.hasNext();)
{
AccessControlEntry a = iter.next();
if (a.getIdentity().equals(identity))
iter.remove();
}
} | [
"public",
"void",
"removePermissions",
"(",
"String",
"identity",
")",
"{",
"for",
"(",
"Iterator",
"<",
"AccessControlEntry",
">",
"iter",
"=",
"accessList",
".",
"iterator",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"AccessControlEn... | Removes all the permissions of a given identity
@param identity the member identity | [
"Removes",
"all",
"the",
"permissions",
"of",
"a",
"given",
"identity"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessControlList.java#L142-L150 |
136,180 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessControlList.java | AccessControlList.getPermissionEntries | public List<AccessControlEntry> getPermissionEntries()
{
List<AccessControlEntry> list = new ArrayList<AccessControlEntry>();
for (int i = 0, length = accessList.size(); i < length; i++)
{
AccessControlEntry entry = accessList.get(i);
list.add(new AccessControlEntry(entry.getIdentity(), entry.getPermission()));
}
return list;
} | java | public List<AccessControlEntry> getPermissionEntries()
{
List<AccessControlEntry> list = new ArrayList<AccessControlEntry>();
for (int i = 0, length = accessList.size(); i < length; i++)
{
AccessControlEntry entry = accessList.get(i);
list.add(new AccessControlEntry(entry.getIdentity(), entry.getPermission()));
}
return list;
} | [
"public",
"List",
"<",
"AccessControlEntry",
">",
"getPermissionEntries",
"(",
")",
"{",
"List",
"<",
"AccessControlEntry",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"AccessControlEntry",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"length"... | Gives all the permission entries
@return a safe copy of all the permission entries | [
"Gives",
"all",
"the",
"permission",
"entries"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessControlList.java#L189-L198 |
136,181 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/PathQueryNode.java | PathQueryNode.getPathSteps | public LocationStepQueryNode[] getPathSteps() {
if (operands == null) {
return EMPTY;
} else {
return (LocationStepQueryNode[]) operands.toArray(new LocationStepQueryNode[operands.size()]);
}
} | java | public LocationStepQueryNode[] getPathSteps() {
if (operands == null) {
return EMPTY;
} else {
return (LocationStepQueryNode[]) operands.toArray(new LocationStepQueryNode[operands.size()]);
}
} | [
"public",
"LocationStepQueryNode",
"[",
"]",
"getPathSteps",
"(",
")",
"{",
"if",
"(",
"operands",
"==",
"null",
")",
"{",
"return",
"EMPTY",
";",
"}",
"else",
"{",
"return",
"(",
"LocationStepQueryNode",
"[",
"]",
")",
"operands",
".",
"toArray",
"(",
"... | Returns an array of all currently set location step nodes.
@return an array of all currently set location step nodes. | [
"Returns",
"an",
"array",
"of",
"all",
"currently",
"set",
"location",
"step",
"nodes",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/PathQueryNode.java#L97-L103 |
136,182 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/AbstractDefinitionComparator.java | AbstractDefinitionComparator.isResidualMatch | protected boolean isResidualMatch(InternalQName itemName, T[] recipientDefinition)
{
boolean containsResidual = false;
for (int i = 0; i < recipientDefinition.length; i++)
{
if (itemName.equals(recipientDefinition[i].getName()))
return false;
else if (Constants.JCR_ANY_NAME.equals(recipientDefinition[i].getName()))
containsResidual = true;
}
return containsResidual;
} | java | protected boolean isResidualMatch(InternalQName itemName, T[] recipientDefinition)
{
boolean containsResidual = false;
for (int i = 0; i < recipientDefinition.length; i++)
{
if (itemName.equals(recipientDefinition[i].getName()))
return false;
else if (Constants.JCR_ANY_NAME.equals(recipientDefinition[i].getName()))
containsResidual = true;
}
return containsResidual;
} | [
"protected",
"boolean",
"isResidualMatch",
"(",
"InternalQName",
"itemName",
",",
"T",
"[",
"]",
"recipientDefinition",
")",
"{",
"boolean",
"containsResidual",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"recipientDefinition",
".",
"... | Return true if recipientDefinition contains Constants.JCR_ANY_NAME and
doesn't contain definition with name itemName.
@param itemName
@param recipientDefinition
@return | [
"Return",
"true",
"if",
"recipientDefinition",
"contains",
"Constants",
".",
"JCR_ANY_NAME",
"and",
"doesn",
"t",
"contain",
"definition",
"with",
"name",
"itemName",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/AbstractDefinitionComparator.java#L101-L112 |
136,183 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.createThreadFindNodesCount | private Thread createThreadFindNodesCount(final Reindexable reindexableComponent)
{
return new Thread("Nodes count(" + handler.getContext().getWorkspaceName() + ")")
{
public void run()
{
try
{
if (reindexableComponent != null)
{
Long value = reindexableComponent.getNodesCount();
if (value != null)
{
nodesCount = new AtomicLong(value);
}
}
}
catch (RepositoryException e)
{
LOG.error("Can't calculate nodes count : " + e.getMessage());
}
}
};
} | java | private Thread createThreadFindNodesCount(final Reindexable reindexableComponent)
{
return new Thread("Nodes count(" + handler.getContext().getWorkspaceName() + ")")
{
public void run()
{
try
{
if (reindexableComponent != null)
{
Long value = reindexableComponent.getNodesCount();
if (value != null)
{
nodesCount = new AtomicLong(value);
}
}
}
catch (RepositoryException e)
{
LOG.error("Can't calculate nodes count : " + e.getMessage());
}
}
};
} | [
"private",
"Thread",
"createThreadFindNodesCount",
"(",
"final",
"Reindexable",
"reindexableComponent",
")",
"{",
"return",
"new",
"Thread",
"(",
"\"Nodes count(\"",
"+",
"handler",
".",
"getContext",
"(",
")",
".",
"getWorkspaceName",
"(",
")",
"+",
"\")\"",
")",... | Create thread finding count of nodes. | [
"Create",
"thread",
"finding",
"count",
"of",
"nodes",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L428-L451 |
136,184 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.numDocs | int numDocs() throws IOException
{
if (indexNames.size() == 0)
{
return volatileIndex.getNumDocuments();
}
else
{
CachingMultiIndexReader reader = getIndexReader();
try
{
return reader.numDocs();
}
finally
{
reader.release();
}
}
} | java | int numDocs() throws IOException
{
if (indexNames.size() == 0)
{
return volatileIndex.getNumDocuments();
}
else
{
CachingMultiIndexReader reader = getIndexReader();
try
{
return reader.numDocs();
}
finally
{
reader.release();
}
}
} | [
"int",
"numDocs",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"indexNames",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"volatileIndex",
".",
"getNumDocuments",
"(",
")",
";",
"}",
"else",
"{",
"CachingMultiIndexReader",
"reader",
"=",
"... | Returns the number of documents in this index.
@return the number of documents in this index.
@throws IOException
if an error occurs while reading from the index. | [
"Returns",
"the",
"number",
"of",
"documents",
"in",
"this",
"index",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L460-L478 |
136,185 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.reindex | public void reindex(ItemDataConsumer stateMgr) throws IOException, RepositoryException
{
if (stopped.get())
{
throw new IllegalStateException("Can't invoke reindexing on closed index.");
}
if (online.get())
{
throw new IllegalStateException("Can't invoke reindexing while index still online.");
}
// traverse and index workspace
executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
long count;
// check if we have deal with RDBMS reindexing mechanism
Reindexable rdbmsReindexableComponent =
(Reindexable)handler.getContext().getContainer().getComponent(Reindexable.class);
if (handler.isRDBMSReindexing() && rdbmsReindexableComponent != null
&& rdbmsReindexableComponent.isReindexingSupported())
{
count =
createIndex(rdbmsReindexableComponent.getNodeDataIndexingIterator(handler.getReindexingPageSize()),
indexingTree.getIndexingRoot());
}
else
{
count = createIndex(indexingTree.getIndexingRoot(), stateMgr);
}
executeAndLog(new Commit(getTransactionId()));
LOG.info("Created initial index for {} nodes", new Long(count));
releaseMultiReader();
} | java | public void reindex(ItemDataConsumer stateMgr) throws IOException, RepositoryException
{
if (stopped.get())
{
throw new IllegalStateException("Can't invoke reindexing on closed index.");
}
if (online.get())
{
throw new IllegalStateException("Can't invoke reindexing while index still online.");
}
// traverse and index workspace
executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
long count;
// check if we have deal with RDBMS reindexing mechanism
Reindexable rdbmsReindexableComponent =
(Reindexable)handler.getContext().getContainer().getComponent(Reindexable.class);
if (handler.isRDBMSReindexing() && rdbmsReindexableComponent != null
&& rdbmsReindexableComponent.isReindexingSupported())
{
count =
createIndex(rdbmsReindexableComponent.getNodeDataIndexingIterator(handler.getReindexingPageSize()),
indexingTree.getIndexingRoot());
}
else
{
count = createIndex(indexingTree.getIndexingRoot(), stateMgr);
}
executeAndLog(new Commit(getTransactionId()));
LOG.info("Created initial index for {} nodes", new Long(count));
releaseMultiReader();
} | [
"public",
"void",
"reindex",
"(",
"ItemDataConsumer",
"stateMgr",
")",
"throws",
"IOException",
",",
"RepositoryException",
"{",
"if",
"(",
"stopped",
".",
"get",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Can't invoke reindexing on closed ... | Recreates index by reindexing in runtime.
@param stateMgr
@throws RepositoryException | [
"Recreates",
"index",
"by",
"reindexing",
"in",
"runtime",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L668-L705 |
136,186 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.update | synchronized void update(final Collection<String> remove, final Collection<Document> add) throws IOException
{
if (!online.get())
{
doUpdateOffline(remove, add);
}
else if (modeHandler.getMode() == IndexerIoMode.READ_WRITE && redoLog != null)
{
doUpdateRW(remove, add);
}
else
{
doUpdateRO(remove, add);
}
} | java | synchronized void update(final Collection<String> remove, final Collection<Document> add) throws IOException
{
if (!online.get())
{
doUpdateOffline(remove, add);
}
else if (modeHandler.getMode() == IndexerIoMode.READ_WRITE && redoLog != null)
{
doUpdateRW(remove, add);
}
else
{
doUpdateRO(remove, add);
}
} | [
"synchronized",
"void",
"update",
"(",
"final",
"Collection",
"<",
"String",
">",
"remove",
",",
"final",
"Collection",
"<",
"Document",
">",
"add",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"online",
".",
"get",
"(",
")",
")",
"{",
"doUpdateOff... | Atomically updates the index by removing some documents and adding
others.
@param remove
collection of <code>UUID</code>s that identify documents to
remove
@param add
collection of <code>Document</code>s to add. Some of the
elements in this collection may be <code>null</code>, to
indicate that a node could not be indexed successfully.
@throws IOException
if an error occurs while updating the index. | [
"Atomically",
"updates",
"the",
"index",
"by",
"removing",
"some",
"documents",
"and",
"adding",
"others",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L721-L735 |
136,187 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.doUpdateRW | private void doUpdateRW(final Collection<String> remove, final Collection<Document> add) throws IOException
{
// make sure a reader is available during long updates
if (add.size() > handler.getBufferSize())
{
try
{
releaseMultiReader();
}
catch (IOException e)
{
// do not fail if an exception is thrown here
LOG.warn("unable to prepare index reader " + "for queries during update", e);
}
}
synchronized (updateMonitor)
{
//updateInProgress = true;
indexUpdateMonitor.setUpdateInProgress(true, false);
}
boolean flush = false;
try
{
long transactionId = nextTransactionId++;
executeAndLog(new Start(transactionId));
for (Iterator<String> it = remove.iterator(); it.hasNext();)
{
executeAndLog(new DeleteNode(transactionId, it.next()));
}
for (Iterator<Document> it = add.iterator(); it.hasNext();)
{
Document doc = it.next();
if (doc != null)
{
executeAndLog(new AddNode(transactionId, doc));
// commit volatile index if needed
flush |= checkVolatileCommit();
}
}
executeAndLog(new Commit(transactionId));
// flush whole index when volatile index has been commited.
if (flush)
{
// if we are going to flush, need to set persistent update
synchronized (updateMonitor)
{
indexUpdateMonitor.setUpdateInProgress(true, true);
}
flush();
}
}
finally
{
synchronized (updateMonitor)
{
//updateInProgress = false;
indexUpdateMonitor.setUpdateInProgress(false, flush);
updateMonitor.notifyAll();
releaseMultiReader();
}
}
} | java | private void doUpdateRW(final Collection<String> remove, final Collection<Document> add) throws IOException
{
// make sure a reader is available during long updates
if (add.size() > handler.getBufferSize())
{
try
{
releaseMultiReader();
}
catch (IOException e)
{
// do not fail if an exception is thrown here
LOG.warn("unable to prepare index reader " + "for queries during update", e);
}
}
synchronized (updateMonitor)
{
//updateInProgress = true;
indexUpdateMonitor.setUpdateInProgress(true, false);
}
boolean flush = false;
try
{
long transactionId = nextTransactionId++;
executeAndLog(new Start(transactionId));
for (Iterator<String> it = remove.iterator(); it.hasNext();)
{
executeAndLog(new DeleteNode(transactionId, it.next()));
}
for (Iterator<Document> it = add.iterator(); it.hasNext();)
{
Document doc = it.next();
if (doc != null)
{
executeAndLog(new AddNode(transactionId, doc));
// commit volatile index if needed
flush |= checkVolatileCommit();
}
}
executeAndLog(new Commit(transactionId));
// flush whole index when volatile index has been commited.
if (flush)
{
// if we are going to flush, need to set persistent update
synchronized (updateMonitor)
{
indexUpdateMonitor.setUpdateInProgress(true, true);
}
flush();
}
}
finally
{
synchronized (updateMonitor)
{
//updateInProgress = false;
indexUpdateMonitor.setUpdateInProgress(false, flush);
updateMonitor.notifyAll();
releaseMultiReader();
}
}
} | [
"private",
"void",
"doUpdateRW",
"(",
"final",
"Collection",
"<",
"String",
">",
"remove",
",",
"final",
"Collection",
"<",
"Document",
">",
"add",
")",
"throws",
"IOException",
"{",
"// make sure a reader is available during long updates",
"if",
"(",
"add",
".",
... | For investigation purposes only
@param remove
@param add
@throws IOException | [
"For",
"investigation",
"purposes",
"only"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L913-L978 |
136,188 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.doUpdateOffline | private void doUpdateOffline(final Collection<String> remove, final Collection<Document> add) throws IOException
{
SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
{
public Object run() throws Exception
{
for (Iterator<String> it = remove.iterator(); it.hasNext();)
{
Term idTerm = new Term(FieldNames.UUID, it.next());
offlineIndex.removeDocument(idTerm);
}
for (Iterator<Document> it = add.iterator(); it.hasNext();)
{
Document doc = it.next();
if (doc != null)
{
offlineIndex.addDocuments(new Document[]{doc});
// reset volatile index if needed
if (offlineIndex.getRamSizeInBytes() >= handler.getMaxVolatileIndexSize())
{
offlineIndex.commit();
}
}
}
return null;
}
});
} | java | private void doUpdateOffline(final Collection<String> remove, final Collection<Document> add) throws IOException
{
SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
{
public Object run() throws Exception
{
for (Iterator<String> it = remove.iterator(); it.hasNext();)
{
Term idTerm = new Term(FieldNames.UUID, it.next());
offlineIndex.removeDocument(idTerm);
}
for (Iterator<Document> it = add.iterator(); it.hasNext();)
{
Document doc = it.next();
if (doc != null)
{
offlineIndex.addDocuments(new Document[]{doc});
// reset volatile index if needed
if (offlineIndex.getRamSizeInBytes() >= handler.getMaxVolatileIndexSize())
{
offlineIndex.commit();
}
}
}
return null;
}
});
} | [
"private",
"void",
"doUpdateOffline",
"(",
"final",
"Collection",
"<",
"String",
">",
"remove",
",",
"final",
"Collection",
"<",
"Document",
">",
"add",
")",
"throws",
"IOException",
"{",
"SecurityHelper",
".",
"doPrivilegedIOExceptionAction",
"(",
"new",
"Privile... | Performs indexing while re-indexing is in progress
@param remove
@param add
@throws IOException | [
"Performs",
"indexing",
"while",
"re",
"-",
"indexing",
"is",
"in",
"progress"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L1017-L1045 |
136,189 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.addDocument | void addDocument(Document doc) throws IOException
{
update(Collections.<String> emptyList(), Arrays.asList(new Document[]{doc}));
} | java | void addDocument(Document doc) throws IOException
{
update(Collections.<String> emptyList(), Arrays.asList(new Document[]{doc}));
} | [
"void",
"addDocument",
"(",
"Document",
"doc",
")",
"throws",
"IOException",
"{",
"update",
"(",
"Collections",
".",
"<",
"String",
">",
"emptyList",
"(",
")",
",",
"Arrays",
".",
"asList",
"(",
"new",
"Document",
"[",
"]",
"{",
"doc",
"}",
")",
")",
... | Adds a document to the index.
@param doc
the document to add.
@throws IOException
if an error occurs while adding the document to the index. | [
"Adds",
"a",
"document",
"to",
"the",
"index",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L1055-L1058 |
136,190 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.initMerger | private void initMerger() throws IOException
{
if (merger == null)
{
merger = new IndexMerger(this);
merger.setMaxMergeDocs(handler.getMaxMergeDocs());
merger.setMergeFactor(handler.getMergeFactor());
merger.setMinMergeDocs(handler.getMinMergeDocs());
for (Object index : indexes)
{
merger.indexAdded(((PersistentIndex)index).getName(), ((PersistentIndex)index).getNumDocuments());
}
merger.start();
}
} | java | private void initMerger() throws IOException
{
if (merger == null)
{
merger = new IndexMerger(this);
merger.setMaxMergeDocs(handler.getMaxMergeDocs());
merger.setMergeFactor(handler.getMergeFactor());
merger.setMinMergeDocs(handler.getMinMergeDocs());
for (Object index : indexes)
{
merger.indexAdded(((PersistentIndex)index).getName(), ((PersistentIndex)index).getNumDocuments());
}
merger.start();
}
} | [
"private",
"void",
"initMerger",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"merger",
"==",
"null",
")",
"{",
"merger",
"=",
"new",
"IndexMerger",
"(",
"this",
")",
";",
"merger",
".",
"setMaxMergeDocs",
"(",
"handler",
".",
"getMaxMergeDocs",
"(",... | Initialize IndexMerger. | [
"Initialize",
"IndexMerger",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L1789-L1804 |
136,191 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.scheduleFlushTask | private void scheduleFlushTask()
{
// cancel task
if (flushTask != null)
{
flushTask.cancel();
}
// clear canceled tasks
FLUSH_TIMER.purge();
// new flush task, cause canceled can't be re-used
flushTask = new TimerTask()
{
@Override
public void run()
{
// check if volatile index should be flushed
checkFlush();
}
};
FLUSH_TIMER.schedule(flushTask, 0, 1000);
lastFlushTime = System.currentTimeMillis();
lastFileSystemFlushTime = System.currentTimeMillis();
} | java | private void scheduleFlushTask()
{
// cancel task
if (flushTask != null)
{
flushTask.cancel();
}
// clear canceled tasks
FLUSH_TIMER.purge();
// new flush task, cause canceled can't be re-used
flushTask = new TimerTask()
{
@Override
public void run()
{
// check if volatile index should be flushed
checkFlush();
}
};
FLUSH_TIMER.schedule(flushTask, 0, 1000);
lastFlushTime = System.currentTimeMillis();
lastFileSystemFlushTime = System.currentTimeMillis();
} | [
"private",
"void",
"scheduleFlushTask",
"(",
")",
"{",
"// cancel task",
"if",
"(",
"flushTask",
"!=",
"null",
")",
"{",
"flushTask",
".",
"cancel",
"(",
")",
";",
"}",
"// clear canceled tasks",
"FLUSH_TIMER",
".",
"purge",
"(",
")",
";",
"// new flush task, ... | Cancel flush task and add new one | [
"Cancel",
"flush",
"task",
"and",
"add",
"new",
"one"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L1830-L1852 |
136,192 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.resetVolatileIndex | private void resetVolatileIndex() throws IOException
{
volatileIndex = new VolatileIndex(handler.getTextAnalyzer(), handler.getSimilarity());
volatileIndex.setUseCompoundFile(handler.getUseCompoundFile());
volatileIndex.setMaxFieldLength(handler.getMaxFieldLength());
volatileIndex.setBufferSize(handler.getBufferSize());
} | java | private void resetVolatileIndex() throws IOException
{
volatileIndex = new VolatileIndex(handler.getTextAnalyzer(), handler.getSimilarity());
volatileIndex.setUseCompoundFile(handler.getUseCompoundFile());
volatileIndex.setMaxFieldLength(handler.getMaxFieldLength());
volatileIndex.setBufferSize(handler.getBufferSize());
} | [
"private",
"void",
"resetVolatileIndex",
"(",
")",
"throws",
"IOException",
"{",
"volatileIndex",
"=",
"new",
"VolatileIndex",
"(",
"handler",
".",
"getTextAnalyzer",
"(",
")",
",",
"handler",
".",
"getSimilarity",
"(",
")",
")",
";",
"volatileIndex",
".",
"se... | Resets the volatile index to a new instance. | [
"Resets",
"the",
"volatile",
"index",
"to",
"a",
"new",
"instance",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L1857-L1863 |
136,193 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.commitVolatileIndex | private void commitVolatileIndex() throws IOException
{
// check if volatile index contains documents at all
if (volatileIndex.getNumDocuments() > 0)
{
long time = 0;
if (LOG.isDebugEnabled())
{
time = System.currentTimeMillis();
}
// create index
CreateIndex create = new CreateIndex(getTransactionId(), null);
executeAndLog(create);
// commit volatile index
executeAndLog(new VolatileCommit(getTransactionId(), create.getIndexName()));
// add new index
AddIndex add = new AddIndex(getTransactionId(), create.getIndexName());
executeAndLog(add);
// create new volatile index
resetVolatileIndex();
if (LOG.isDebugEnabled())
{
time = System.currentTimeMillis() - time;
LOG.debug("Committed in-memory index in " + time + "ms.");
}
}
} | java | private void commitVolatileIndex() throws IOException
{
// check if volatile index contains documents at all
if (volatileIndex.getNumDocuments() > 0)
{
long time = 0;
if (LOG.isDebugEnabled())
{
time = System.currentTimeMillis();
}
// create index
CreateIndex create = new CreateIndex(getTransactionId(), null);
executeAndLog(create);
// commit volatile index
executeAndLog(new VolatileCommit(getTransactionId(), create.getIndexName()));
// add new index
AddIndex add = new AddIndex(getTransactionId(), create.getIndexName());
executeAndLog(add);
// create new volatile index
resetVolatileIndex();
if (LOG.isDebugEnabled())
{
time = System.currentTimeMillis() - time;
LOG.debug("Committed in-memory index in " + time + "ms.");
}
}
} | [
"private",
"void",
"commitVolatileIndex",
"(",
")",
"throws",
"IOException",
"{",
"// check if volatile index contains documents at all",
"if",
"(",
"volatileIndex",
".",
"getNumDocuments",
"(",
")",
">",
"0",
")",
"{",
"long",
"time",
"=",
"0",
";",
"if",
"(",
... | Commits the volatile index to a persistent index. The new persistent
index is added to the list of indexes but not written to disk. When this
method returns a new volatile index has been created.
@throws IOException
if an error occurs while writing the volatile index to disk. | [
"Commits",
"the",
"volatile",
"index",
"to",
"a",
"persistent",
"index",
".",
"The",
"new",
"persistent",
"index",
"is",
"added",
"to",
"the",
"list",
"of",
"indexes",
"but",
"not",
"written",
"to",
"disk",
".",
"When",
"this",
"method",
"returns",
"a",
... | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L1928-L1960 |
136,194 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.removeDeletable | private void removeDeletable()
{
String fileName = "deletable";
try
{
if (indexDir.fileExists(fileName))
{
indexDir.deleteFile(fileName);
}
}
catch (IOException e)
{
LOG.warn("Unable to remove file 'deletable'.", e);
}
} | java | private void removeDeletable()
{
String fileName = "deletable";
try
{
if (indexDir.fileExists(fileName))
{
indexDir.deleteFile(fileName);
}
}
catch (IOException e)
{
LOG.warn("Unable to remove file 'deletable'.", e);
}
} | [
"private",
"void",
"removeDeletable",
"(",
")",
"{",
"String",
"fileName",
"=",
"\"deletable\"",
";",
"try",
"{",
"if",
"(",
"indexDir",
".",
"fileExists",
"(",
"fileName",
")",
")",
"{",
"indexDir",
".",
"deleteFile",
"(",
"fileName",
")",
";",
"}",
"}"... | Removes the deletable file if it exists. The file is not used anymore in
Jackrabbit versions >= 1.5. | [
"Removes",
"the",
"deletable",
"file",
"if",
"it",
"exists",
".",
"The",
"file",
"is",
"not",
"used",
"anymore",
"in",
"Jackrabbit",
"versions",
">",
"=",
"1",
".",
"5",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L2249-L2263 |
136,195 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.setReadOnly | protected void setReadOnly()
{
// try to stop merger in safe way
if (merger != null)
{
merger.dispose();
merger = null;
}
if (flushTask != null)
{
flushTask.cancel();
}
FLUSH_TIMER.purge();
this.redoLog = null;
} | java | protected void setReadOnly()
{
// try to stop merger in safe way
if (merger != null)
{
merger.dispose();
merger = null;
}
if (flushTask != null)
{
flushTask.cancel();
}
FLUSH_TIMER.purge();
this.redoLog = null;
} | [
"protected",
"void",
"setReadOnly",
"(",
")",
"{",
"// try to stop merger in safe way",
"if",
"(",
"merger",
"!=",
"null",
")",
"{",
"merger",
".",
"dispose",
"(",
")",
";",
"merger",
"=",
"null",
";",
"}",
"if",
"(",
"flushTask",
"!=",
"null",
")",
"{",... | Sets mode to READ_ONLY, discarding flush task | [
"Sets",
"mode",
"to",
"READ_ONLY",
"discarding",
"flush",
"task"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L3379-L3394 |
136,196 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.setReadWrite | protected void setReadWrite() throws IOException
{
// Release all the current threads
synchronized (updateMonitor)
{
indexUpdateMonitor.setUpdateInProgress(false, true);
updateMonitor.notifyAll();
releaseMultiReader();
}
this.redoLog = new RedoLog(indexDir);
redoLogApplied = redoLog.hasEntries();
// run recovery
Recovery.run(this, redoLog);
// enqueue unused segments for deletion
enqueueUnusedSegments();
attemptDelete();
// now that we are ready, start index merger
initMerger();
if (redoLogApplied)
{
// wait for the index merge to finish pending jobs
try
{
merger.waitUntilIdle();
}
catch (InterruptedException e)
{
// move on
}
flush();
}
if (indexNames.size() > 0)
{
scheduleFlushTask();
}
} | java | protected void setReadWrite() throws IOException
{
// Release all the current threads
synchronized (updateMonitor)
{
indexUpdateMonitor.setUpdateInProgress(false, true);
updateMonitor.notifyAll();
releaseMultiReader();
}
this.redoLog = new RedoLog(indexDir);
redoLogApplied = redoLog.hasEntries();
// run recovery
Recovery.run(this, redoLog);
// enqueue unused segments for deletion
enqueueUnusedSegments();
attemptDelete();
// now that we are ready, start index merger
initMerger();
if (redoLogApplied)
{
// wait for the index merge to finish pending jobs
try
{
merger.waitUntilIdle();
}
catch (InterruptedException e)
{
// move on
}
flush();
}
if (indexNames.size() > 0)
{
scheduleFlushTask();
}
} | [
"protected",
"void",
"setReadWrite",
"(",
")",
"throws",
"IOException",
"{",
"// Release all the current threads",
"synchronized",
"(",
"updateMonitor",
")",
"{",
"indexUpdateMonitor",
".",
"setUpdateInProgress",
"(",
"false",
",",
"true",
")",
";",
"updateMonitor",
"... | Sets mode to READ_WRITE, initiating recovery process
@throws IOException | [
"Sets",
"mode",
"to",
"READ_WRITE",
"initiating",
"recovery",
"process"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L3401-L3442 |
136,197 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.refreshIndexList | public void refreshIndexList() throws IOException
{
synchronized (updateMonitor)
{
// release reader if any
releaseMultiReader();
// prepare added/removed sets
Set<String> newList = new HashSet<String>(indexNames.getNames());
// remove removed indexes
Iterator<PersistentIndex> iterator = indexes.iterator();
while (iterator.hasNext())
{
PersistentIndex index = iterator.next();
String name = index.getName();
// if current index not in new list, close it, cause it is deleted.
if (!newList.contains(name))
{
index.close();
iterator.remove();
}
else
{
// remove from list, cause this segment of index still present and indexes list contains
// PersistentIndex instance related to this index..
newList.remove(name);
// Release everything to make sure that we see the
// latest changes
index.releaseWriterAndReaders();
}
}
// now newList contains ONLY new, added indexes, deleted indexes, are removed from list.
for (String name : newList)
{
// only open if it still exists
// it is possible that indexNames still contains a name for
// an index that has been deleted, but indexNames has not been
// written to disk.
if (!directoryManager.hasDirectory(name))
{
LOG.debug("index does not exist anymore: " + name);
// move on to next index
continue;
}
PersistentIndex index =
new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager,
modeHandler);
index.setMaxFieldLength(handler.getMaxFieldLength());
index.setUseCompoundFile(handler.getUseCompoundFile());
index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
indexes.add(index);
}
// Reset the volatile index to be exactly like the master
resetVolatileIndex();
}
} | java | public void refreshIndexList() throws IOException
{
synchronized (updateMonitor)
{
// release reader if any
releaseMultiReader();
// prepare added/removed sets
Set<String> newList = new HashSet<String>(indexNames.getNames());
// remove removed indexes
Iterator<PersistentIndex> iterator = indexes.iterator();
while (iterator.hasNext())
{
PersistentIndex index = iterator.next();
String name = index.getName();
// if current index not in new list, close it, cause it is deleted.
if (!newList.contains(name))
{
index.close();
iterator.remove();
}
else
{
// remove from list, cause this segment of index still present and indexes list contains
// PersistentIndex instance related to this index..
newList.remove(name);
// Release everything to make sure that we see the
// latest changes
index.releaseWriterAndReaders();
}
}
// now newList contains ONLY new, added indexes, deleted indexes, are removed from list.
for (String name : newList)
{
// only open if it still exists
// it is possible that indexNames still contains a name for
// an index that has been deleted, but indexNames has not been
// written to disk.
if (!directoryManager.hasDirectory(name))
{
LOG.debug("index does not exist anymore: " + name);
// move on to next index
continue;
}
PersistentIndex index =
new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager,
modeHandler);
index.setMaxFieldLength(handler.getMaxFieldLength());
index.setUseCompoundFile(handler.getUseCompoundFile());
index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
indexes.add(index);
}
// Reset the volatile index to be exactly like the master
resetVolatileIndex();
}
} | [
"public",
"void",
"refreshIndexList",
"(",
")",
"throws",
"IOException",
"{",
"synchronized",
"(",
"updateMonitor",
")",
"{",
"// release reader if any",
"releaseMultiReader",
"(",
")",
";",
"// prepare added/removed sets",
"Set",
"<",
"String",
">",
"newList",
"=",
... | Refresh list of indexes. Used to be called asynchronously when list changes. New, actual list is read from
IndexInfos.
@throws IOException | [
"Refresh",
"list",
"of",
"indexes",
".",
"Used",
"to",
"be",
"called",
"asynchronously",
"when",
"list",
"changes",
".",
"New",
"actual",
"list",
"is",
"read",
"from",
"IndexInfos",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L3449-L3504 |
136,198 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.setOnline | public synchronized void setOnline(boolean isOnline, boolean dropStaleIndexes, boolean initMerger) throws IOException
{
// if mode really changed
if (online.get() != isOnline)
{
// switching to ONLINE
if (isOnline)
{
LOG.info("Setting index ONLINE ({})", handler.getContext().getWorkspacePath(true));
if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
{
offlineIndex.commit(true);
online.set(true);
// cleaning stale indexes
for (PersistentIndex staleIndex : staleIndexes)
{
deleteIndex(staleIndex);
}
//invoking offline index
invokeOfflineIndex();
staleIndexes.clear();
if(initMerger)
{
initMerger();
}
}
else
{
online.set(true);
staleIndexes.clear();
}
}
// switching to OFFLINE
else
{
LOG.info("Setting index OFFLINE ({})", handler.getContext().getWorkspacePath(true));
if (initMerger && merger != null)
{
merger.dispose();
merger = null;
}
offlineIndex =
new OfflinePersistentIndex(handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager,
modeHandler);
if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
{
flush();
}
releaseMultiReader();
if (dropStaleIndexes)
{
staleIndexes.addAll(indexes);
}
online.set(false);
}
}
else if (!online.get())
{
throw new IOException("Index is already in OFFLINE mode.");
}
} | java | public synchronized void setOnline(boolean isOnline, boolean dropStaleIndexes, boolean initMerger) throws IOException
{
// if mode really changed
if (online.get() != isOnline)
{
// switching to ONLINE
if (isOnline)
{
LOG.info("Setting index ONLINE ({})", handler.getContext().getWorkspacePath(true));
if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
{
offlineIndex.commit(true);
online.set(true);
// cleaning stale indexes
for (PersistentIndex staleIndex : staleIndexes)
{
deleteIndex(staleIndex);
}
//invoking offline index
invokeOfflineIndex();
staleIndexes.clear();
if(initMerger)
{
initMerger();
}
}
else
{
online.set(true);
staleIndexes.clear();
}
}
// switching to OFFLINE
else
{
LOG.info("Setting index OFFLINE ({})", handler.getContext().getWorkspacePath(true));
if (initMerger && merger != null)
{
merger.dispose();
merger = null;
}
offlineIndex =
new OfflinePersistentIndex(handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager,
modeHandler);
if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
{
flush();
}
releaseMultiReader();
if (dropStaleIndexes)
{
staleIndexes.addAll(indexes);
}
online.set(false);
}
}
else if (!online.get())
{
throw new IOException("Index is already in OFFLINE mode.");
}
} | [
"public",
"synchronized",
"void",
"setOnline",
"(",
"boolean",
"isOnline",
",",
"boolean",
"dropStaleIndexes",
",",
"boolean",
"initMerger",
")",
"throws",
"IOException",
"{",
"// if mode really changed",
"if",
"(",
"online",
".",
"get",
"(",
")",
"!=",
"isOnline"... | Switches index mode
@param isOnline
@throws IOException | [
"Switches",
"index",
"mode"
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L3559-L3620 |
136,199 | exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java | MultiIndex.recoveryIndexFromCoordinator | private boolean recoveryIndexFromCoordinator() throws IOException
{
File indexDirectory = new File(handler.getContext().getIndexDirectory());
try
{
IndexRecovery indexRecovery = handler.getContext().getIndexRecovery();
// check if index not ready
if (!indexRecovery.checkIndexReady())
{
return false;
}
//Switch index offline
indexRecovery.setIndexOffline();
for (String filePath : indexRecovery.getIndexList())
{
File indexFile = new File(indexDirectory, filePath);
if (!PrivilegedFileHelper.exists(indexFile.getParentFile()))
{
PrivilegedFileHelper.mkdirs(indexFile.getParentFile());
}
// transfer file
InputStream in = indexRecovery.getIndexFile(filePath);
OutputStream out = PrivilegedFileHelper.fileOutputStream(indexFile);
try
{
DirectoryHelper.transfer(in, out);
}
finally
{
DirectoryHelper.safeClose(in);
DirectoryHelper.safeClose(out);
}
}
//Switch index online
indexRecovery.setIndexOnline();
return true;
}
catch (RepositoryException e)
{
LOG.error("Cannot retrieve the indexes from the coordinator, the indexes will then be created from indexing",
e);
}
catch (IOException e)
{
LOG.error("Cannot retrieve the indexes from the coordinator, the indexes will then be created from indexing",
e);
}
LOG.info("Clean up index directory " + indexDirectory.getAbsolutePath());
DirectoryHelper.removeDirectory(indexDirectory);
return false;
} | java | private boolean recoveryIndexFromCoordinator() throws IOException
{
File indexDirectory = new File(handler.getContext().getIndexDirectory());
try
{
IndexRecovery indexRecovery = handler.getContext().getIndexRecovery();
// check if index not ready
if (!indexRecovery.checkIndexReady())
{
return false;
}
//Switch index offline
indexRecovery.setIndexOffline();
for (String filePath : indexRecovery.getIndexList())
{
File indexFile = new File(indexDirectory, filePath);
if (!PrivilegedFileHelper.exists(indexFile.getParentFile()))
{
PrivilegedFileHelper.mkdirs(indexFile.getParentFile());
}
// transfer file
InputStream in = indexRecovery.getIndexFile(filePath);
OutputStream out = PrivilegedFileHelper.fileOutputStream(indexFile);
try
{
DirectoryHelper.transfer(in, out);
}
finally
{
DirectoryHelper.safeClose(in);
DirectoryHelper.safeClose(out);
}
}
//Switch index online
indexRecovery.setIndexOnline();
return true;
}
catch (RepositoryException e)
{
LOG.error("Cannot retrieve the indexes from the coordinator, the indexes will then be created from indexing",
e);
}
catch (IOException e)
{
LOG.error("Cannot retrieve the indexes from the coordinator, the indexes will then be created from indexing",
e);
}
LOG.info("Clean up index directory " + indexDirectory.getAbsolutePath());
DirectoryHelper.removeDirectory(indexDirectory);
return false;
} | [
"private",
"boolean",
"recoveryIndexFromCoordinator",
"(",
")",
"throws",
"IOException",
"{",
"File",
"indexDirectory",
"=",
"new",
"File",
"(",
"handler",
".",
"getContext",
"(",
")",
".",
"getIndexDirectory",
"(",
")",
")",
";",
"try",
"{",
"IndexRecovery",
... | Retrieves index from other node.
@throws IOException if can't clean up directory after retrieving being failed | [
"Retrieves",
"index",
"from",
"other",
"node",
"."
] | 3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2 | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java#L3872-L3928 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.