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,300
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java
DBInitializerHelper.getRootNodeInitializeScript
public static String getRootNodeInitializeScript(String itemTableName, boolean multiDb) { String singeDbScript = "insert into " + itemTableName + "(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, " + "N_ORDER_NUM) VALUES('" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME + "', '" + Constants.ROOT_PARENT_CONAINER_NAME + "', 0, 0, 0, 0)"; String multiDbScript = "insert into " + itemTableName + "(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, " + "N_ORDER_NUM) VALUES('" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME + "', 0, 0, 0, 0)"; return multiDb ? multiDbScript : singeDbScript; }
java
public static String getRootNodeInitializeScript(String itemTableName, boolean multiDb) { String singeDbScript = "insert into " + itemTableName + "(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, " + "N_ORDER_NUM) VALUES('" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME + "', '" + Constants.ROOT_PARENT_CONAINER_NAME + "', 0, 0, 0, 0)"; String multiDbScript = "insert into " + itemTableName + "(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, " + "N_ORDER_NUM) VALUES('" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME + "', 0, 0, 0, 0)"; return multiDb ? multiDbScript : singeDbScript; }
[ "public", "static", "String", "getRootNodeInitializeScript", "(", "String", "itemTableName", ",", "boolean", "multiDb", ")", "{", "String", "singeDbScript", "=", "\"insert into \"", "+", "itemTableName", "+", "\"(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, \...
Initialization script for root node.
[ "Initialization", "script", "for", "root", "node", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java#L206-L219
136,301
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java
DBInitializerHelper.getObjectScript
public static String getObjectScript(String objectName, boolean multiDb, String dialect, WorkspaceEntry wsEntry) throws RepositoryConfigurationException, IOException { String scripts = prepareScripts(wsEntry, dialect); String sql = null; for (String query : JDBCUtils.splitWithSQLDelimiter(scripts)) { String q = JDBCUtils.cleanWhitespaces(query); if (q.contains(objectName)) { if (sql != null) { throw new RepositoryConfigurationException("Can't find unique script for object creation. Object name: " + objectName); } sql = q; } } if (sql != null) { return sql; } throw new RepositoryConfigurationException("Script for object creation is not found. Object name: " + objectName); }
java
public static String getObjectScript(String objectName, boolean multiDb, String dialect, WorkspaceEntry wsEntry) throws RepositoryConfigurationException, IOException { String scripts = prepareScripts(wsEntry, dialect); String sql = null; for (String query : JDBCUtils.splitWithSQLDelimiter(scripts)) { String q = JDBCUtils.cleanWhitespaces(query); if (q.contains(objectName)) { if (sql != null) { throw new RepositoryConfigurationException("Can't find unique script for object creation. Object name: " + objectName); } sql = q; } } if (sql != null) { return sql; } throw new RepositoryConfigurationException("Script for object creation is not found. Object name: " + objectName); }
[ "public", "static", "String", "getObjectScript", "(", "String", "objectName", ",", "boolean", "multiDb", ",", "String", "dialect", ",", "WorkspaceEntry", "wsEntry", ")", "throws", "RepositoryConfigurationException", ",", "IOException", "{", "String", "scripts", "=", ...
Returns SQL script for create objects such as index, primary of foreign key.
[ "Returns", "SQL", "script", "for", "create", "objects", "such", "as", "index", "primary", "of", "foreign", "key", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java#L303-L330
136,302
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java
DBInitializerHelper.useSequenceForOrderNumber
public static boolean useSequenceForOrderNumber(WorkspaceEntry wsConfig, String dbDialect) throws RepositoryConfigurationException { try { if (wsConfig.getContainer().getParameterValue(JDBCWorkspaceDataContainer.USE_SEQUENCE_FOR_ORDER_NUMBER, JDBCWorkspaceDataContainer.USE_SEQUENCE_AUTO).equalsIgnoreCase(JDBCWorkspaceDataContainer.USE_SEQUENCE_AUTO)) { return JDBCWorkspaceDataContainer.useSequenceDefaultValue(); } else { return wsConfig.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.USE_SEQUENCE_FOR_ORDER_NUMBER); } } catch (RepositoryConfigurationException e) { return JDBCWorkspaceDataContainer.useSequenceDefaultValue(); } }
java
public static boolean useSequenceForOrderNumber(WorkspaceEntry wsConfig, String dbDialect) throws RepositoryConfigurationException { try { if (wsConfig.getContainer().getParameterValue(JDBCWorkspaceDataContainer.USE_SEQUENCE_FOR_ORDER_NUMBER, JDBCWorkspaceDataContainer.USE_SEQUENCE_AUTO).equalsIgnoreCase(JDBCWorkspaceDataContainer.USE_SEQUENCE_AUTO)) { return JDBCWorkspaceDataContainer.useSequenceDefaultValue(); } else { return wsConfig.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.USE_SEQUENCE_FOR_ORDER_NUMBER); } } catch (RepositoryConfigurationException e) { return JDBCWorkspaceDataContainer.useSequenceDefaultValue(); } }
[ "public", "static", "boolean", "useSequenceForOrderNumber", "(", "WorkspaceEntry", "wsConfig", ",", "String", "dbDialect", ")", "throws", "RepositoryConfigurationException", "{", "try", "{", "if", "(", "wsConfig", ".", "getContainer", "(", ")", ".", "getParameterValue...
Use sequence for order number. @param wsConfig The workspace configuration. @return true if the sequence are enable. False otherwise.
[ "Use", "sequence", "for", "order", "number", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java#L395-L412
136,303
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionFactory.java
SessionFactory.createSession
SessionImpl createSession(ConversationState user) throws RepositoryException, LoginException { if (IdentityConstants.SYSTEM.equals(user.getIdentity().getUserId())) { // Need privileges to get system session. SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(JCRRuntimePermissions.CREATE_SYSTEM_SESSION_PERMISSION); } } else if (DynamicIdentity.DYNAMIC.equals(user.getIdentity().getUserId())) { // Need privileges to get Dynamic session. SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(JCRRuntimePermissions.CREATE_DYNAMIC_SESSION_PERMISSION); } } if (SessionReference.isStarted()) { return new TrackedSession(workspaceName, user, container); } else { return new SessionImpl(workspaceName, user, container); } }
java
SessionImpl createSession(ConversationState user) throws RepositoryException, LoginException { if (IdentityConstants.SYSTEM.equals(user.getIdentity().getUserId())) { // Need privileges to get system session. SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(JCRRuntimePermissions.CREATE_SYSTEM_SESSION_PERMISSION); } } else if (DynamicIdentity.DYNAMIC.equals(user.getIdentity().getUserId())) { // Need privileges to get Dynamic session. SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(JCRRuntimePermissions.CREATE_DYNAMIC_SESSION_PERMISSION); } } if (SessionReference.isStarted()) { return new TrackedSession(workspaceName, user, container); } else { return new SessionImpl(workspaceName, user, container); } }
[ "SessionImpl", "createSession", "(", "ConversationState", "user", ")", "throws", "RepositoryException", ",", "LoginException", "{", "if", "(", "IdentityConstants", ".", "SYSTEM", ".", "equals", "(", "user", ".", "getIdentity", "(", ")", ".", "getUserId", "(", ")...
Creates Session object by given Credentials @param credentials @return the SessionImpl corresponding to the given {@link ConversationState} @throws RepositoryException
[ "Creates", "Session", "object", "by", "given", "Credentials" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionFactory.java#L119-L147
136,304
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java
RepositoryServiceConfigurationImpl.retain
@Override public synchronized void retain() throws RepositoryException { try { if (!isRetainable()) throw new RepositoryException("Unsupported configuration place " + configurationService.getURL(param.getValue()) + " If you want to save configuration, start repository from standalone file." + " Or persister-class-name not configured"); OutputStream saveStream = null; if (configurationPersister != null) { saveStream = new ByteArrayOutputStream(); } else { URL filePath = configurationService.getURL(param.getValue()); final File sourceConfig = new File(filePath.toURI()); final File backUp = new File(sourceConfig.getAbsoluteFile() + "." + indexBackupFile++); if (indexBackupFile > maxBackupFiles) { indexBackupFile = 1; } try { SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Void>() { public Void run() throws IOException { DirectoryHelper.deleteDstAndRename(sourceConfig, backUp); return null; } }); } catch (IOException ioe) { throw new RepositoryException("Can't back up configuration on path " + PrivilegedFileHelper.getAbsolutePath(sourceConfig), ioe); } saveStream = PrivilegedFileHelper.fileOutputStream(sourceConfig); } IBindingFactory bfact; try { bfact = SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<IBindingFactory>() { public IBindingFactory run() throws Exception { return BindingDirectory.getFactory(RepositoryServiceConfiguration.class); } }); } catch (PrivilegedActionException pae) { Throwable cause = pae.getCause(); if (cause instanceof JiBXException) { throw (JiBXException)cause; } else if (cause instanceof RuntimeException) { throw (RuntimeException)cause; } else { throw new RuntimeException(cause); } } IMarshallingContext mctx = bfact.createMarshallingContext(); mctx.marshalDocument(this, "ISO-8859-1", null, saveStream); saveStream.close(); // writing configuration in to the persister if (configurationPersister != null) { configurationPersister.write(new ByteArrayInputStream(((ByteArrayOutputStream)saveStream).toByteArray())); } } catch (JiBXException e) { throw new RepositoryException(e); } catch (FileNotFoundException e) { throw new RepositoryException(e); } catch (IOException e) { throw new RepositoryException(e); } catch (RepositoryConfigurationException e) { throw new RepositoryException(e); } catch (Exception e) { throw new RepositoryException(e); } }
java
@Override public synchronized void retain() throws RepositoryException { try { if (!isRetainable()) throw new RepositoryException("Unsupported configuration place " + configurationService.getURL(param.getValue()) + " If you want to save configuration, start repository from standalone file." + " Or persister-class-name not configured"); OutputStream saveStream = null; if (configurationPersister != null) { saveStream = new ByteArrayOutputStream(); } else { URL filePath = configurationService.getURL(param.getValue()); final File sourceConfig = new File(filePath.toURI()); final File backUp = new File(sourceConfig.getAbsoluteFile() + "." + indexBackupFile++); if (indexBackupFile > maxBackupFiles) { indexBackupFile = 1; } try { SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Void>() { public Void run() throws IOException { DirectoryHelper.deleteDstAndRename(sourceConfig, backUp); return null; } }); } catch (IOException ioe) { throw new RepositoryException("Can't back up configuration on path " + PrivilegedFileHelper.getAbsolutePath(sourceConfig), ioe); } saveStream = PrivilegedFileHelper.fileOutputStream(sourceConfig); } IBindingFactory bfact; try { bfact = SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<IBindingFactory>() { public IBindingFactory run() throws Exception { return BindingDirectory.getFactory(RepositoryServiceConfiguration.class); } }); } catch (PrivilegedActionException pae) { Throwable cause = pae.getCause(); if (cause instanceof JiBXException) { throw (JiBXException)cause; } else if (cause instanceof RuntimeException) { throw (RuntimeException)cause; } else { throw new RuntimeException(cause); } } IMarshallingContext mctx = bfact.createMarshallingContext(); mctx.marshalDocument(this, "ISO-8859-1", null, saveStream); saveStream.close(); // writing configuration in to the persister if (configurationPersister != null) { configurationPersister.write(new ByteArrayInputStream(((ByteArrayOutputStream)saveStream).toByteArray())); } } catch (JiBXException e) { throw new RepositoryException(e); } catch (FileNotFoundException e) { throw new RepositoryException(e); } catch (IOException e) { throw new RepositoryException(e); } catch (RepositoryConfigurationException e) { throw new RepositoryException(e); } catch (Exception e) { throw new RepositoryException(e); } }
[ "@", "Override", "public", "synchronized", "void", "retain", "(", ")", "throws", "RepositoryException", "{", "try", "{", "if", "(", "!", "isRetainable", "(", ")", ")", "throw", "new", "RepositoryException", "(", "\"Unsupported configuration place \"", "+", "confi...
Retain configuration of JCR If configurationPersister is configured it write data in to the persister otherwise it try to save configuration in file @throws RepositoryException
[ "Retain", "configuration", "of", "JCR", "If", "configurationPersister", "is", "configured", "it", "write", "data", "in", "to", "the", "persister", "otherwise", "it", "try", "to", "save", "configuration", "in", "file" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java#L166-L273
136,305
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/WorkspaceQuotaRestore.java
WorkspaceQuotaRestore.doRestore
protected void doRestore(File backupFile) throws BackupException { if (!PrivilegedFileHelper.exists(backupFile)) { LOG.warn("Nothing to restore for quotas"); return; } ZipObjectReader in = null; try { in = new ZipObjectReader(PrivilegedFileHelper.zipInputStream(backupFile)); quotaPersister.restoreWorkspaceData(rName, wsName, in); } catch (IOException e) { throw new BackupException(e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.error("Can't close input stream", e); } } } repairDataSize(); }
java
protected void doRestore(File backupFile) throws BackupException { if (!PrivilegedFileHelper.exists(backupFile)) { LOG.warn("Nothing to restore for quotas"); return; } ZipObjectReader in = null; try { in = new ZipObjectReader(PrivilegedFileHelper.zipInputStream(backupFile)); quotaPersister.restoreWorkspaceData(rName, wsName, in); } catch (IOException e) { throw new BackupException(e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.error("Can't close input stream", e); } } } repairDataSize(); }
[ "protected", "void", "doRestore", "(", "File", "backupFile", ")", "throws", "BackupException", "{", "if", "(", "!", "PrivilegedFileHelper", ".", "exists", "(", "backupFile", ")", ")", "{", "LOG", ".", "warn", "(", "\"Nothing to restore for quotas\"", ")", ";", ...
Restores content.
[ "Restores", "content", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/WorkspaceQuotaRestore.java#L186-L220
136,306
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/WorkspaceQuotaRestore.java
WorkspaceQuotaRestore.repairDataSize
private void repairDataSize() { try { long dataSize = quotaPersister.getWorkspaceDataSize(rName, wsName); ChangesItem changesItem = new ChangesItem(); changesItem.updateWorkspaceChangedSize(dataSize); quotaPersister.setWorkspaceDataSize(rName, wsName, 0); // workaround Runnable task = new ApplyPersistedChangesTask(wqm.getContext(), changesItem); task.run(); } catch (UnknownDataSizeException e) { if (LOG.isTraceEnabled()) { LOG.trace(e.getMessage(), e); } } }
java
private void repairDataSize() { try { long dataSize = quotaPersister.getWorkspaceDataSize(rName, wsName); ChangesItem changesItem = new ChangesItem(); changesItem.updateWorkspaceChangedSize(dataSize); quotaPersister.setWorkspaceDataSize(rName, wsName, 0); // workaround Runnable task = new ApplyPersistedChangesTask(wqm.getContext(), changesItem); task.run(); } catch (UnknownDataSizeException e) { if (LOG.isTraceEnabled()) { LOG.trace(e.getMessage(), e); } } }
[ "private", "void", "repairDataSize", "(", ")", "{", "try", "{", "long", "dataSize", "=", "quotaPersister", ".", "getWorkspaceDataSize", "(", "rName", ",", "wsName", ")", ";", "ChangesItem", "changesItem", "=", "new", "ChangesItem", "(", ")", ";", "changesItem"...
After workspace data size being restored, need also to update repository and global data size on respective value.
[ "After", "workspace", "data", "size", "being", "restored", "need", "also", "to", "update", "repository", "and", "global", "data", "size", "on", "respective", "value", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/WorkspaceQuotaRestore.java#L226-L247
136,307
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/WorkspaceQuotaRestore.java
WorkspaceQuotaRestore.doBackup
protected void doBackup(File backupFile) throws BackupException { ZipObjectWriter out = null; try { out = new ZipObjectWriter(PrivilegedFileHelper.zipOutputStream(backupFile)); quotaPersister.backupWorkspaceData(rName, wsName, out); } catch (IOException e) { throw new BackupException(e); } finally { if (out != null) { try { out.close(); } catch (IOException e) { LOG.error("Can't close output stream", e); } } } }
java
protected void doBackup(File backupFile) throws BackupException { ZipObjectWriter out = null; try { out = new ZipObjectWriter(PrivilegedFileHelper.zipOutputStream(backupFile)); quotaPersister.backupWorkspaceData(rName, wsName, out); } catch (IOException e) { throw new BackupException(e); } finally { if (out != null) { try { out.close(); } catch (IOException e) { LOG.error("Can't close output stream", e); } } } }
[ "protected", "void", "doBackup", "(", "File", "backupFile", ")", "throws", "BackupException", "{", "ZipObjectWriter", "out", "=", "null", ";", "try", "{", "out", "=", "new", "ZipObjectWriter", "(", "PrivilegedFileHelper", ".", "zipOutputStream", "(", "backupFile",...
Backups data to define file.
[ "Backups", "data", "to", "define", "file", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/WorkspaceQuotaRestore.java#L252-L278
136,308
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/artifact/ArtifactManagingServiceImpl.java
ArtifactManagingServiceImpl.importResource
private void importResource(Node parentNode, InputStream file_in, String resourceType, ArtifactDescriptor artifact) throws RepositoryException { // Note that artifactBean been initialized within constructor // resourceType can be jar, pom, metadata String filename; if (resourceType.equals("metadata")) { filename = "maven-metadata.xml"; } else { filename = String.format("%s-%s.%s", artifact.getArtifactId(), artifact.getVersionId(), resourceType); } OutputStream fout = null; File tmp_file = null; try { String tmpFilename = getUniqueFilename(filename); tmp_file = File.createTempFile(tmpFilename, null); fout = new FileOutputStream(tmp_file); IOUtils.copy(file_in, fout); fout.flush(); } catch (FileNotFoundException e) { LOG.error("Cannot create .tmp file for storing artifact", e); } catch (IOException e) { LOG.error("IO exception on .tmp file for storing artifact", e); } finally { IOUtils.closeQuietly(file_in); IOUtils.closeQuietly(fout); } writePrimaryContent(parentNode, filename, resourceType, tmp_file); writeChecksum(parentNode, filename, tmp_file, "SHA1"); try { // and collect all garbage : temporary files FileUtils.forceDelete(tmp_file); } catch (IOException e) { LOG.error("Cannot delete tmp file", e); } }
java
private void importResource(Node parentNode, InputStream file_in, String resourceType, ArtifactDescriptor artifact) throws RepositoryException { // Note that artifactBean been initialized within constructor // resourceType can be jar, pom, metadata String filename; if (resourceType.equals("metadata")) { filename = "maven-metadata.xml"; } else { filename = String.format("%s-%s.%s", artifact.getArtifactId(), artifact.getVersionId(), resourceType); } OutputStream fout = null; File tmp_file = null; try { String tmpFilename = getUniqueFilename(filename); tmp_file = File.createTempFile(tmpFilename, null); fout = new FileOutputStream(tmp_file); IOUtils.copy(file_in, fout); fout.flush(); } catch (FileNotFoundException e) { LOG.error("Cannot create .tmp file for storing artifact", e); } catch (IOException e) { LOG.error("IO exception on .tmp file for storing artifact", e); } finally { IOUtils.closeQuietly(file_in); IOUtils.closeQuietly(fout); } writePrimaryContent(parentNode, filename, resourceType, tmp_file); writeChecksum(parentNode, filename, tmp_file, "SHA1"); try { // and collect all garbage : temporary files FileUtils.forceDelete(tmp_file); } catch (IOException e) { LOG.error("Cannot delete tmp file", e); } }
[ "private", "void", "importResource", "(", "Node", "parentNode", ",", "InputStream", "file_in", ",", "String", "resourceType", ",", "ArtifactDescriptor", "artifact", ")", "throws", "RepositoryException", "{", "// Note that artifactBean been initialized within constructor", "//...
this method used for writing to repo jars, poms and their checksums
[ "this", "method", "used", "for", "writing", "to", "repo", "jars", "poms", "and", "their", "checksums" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/artifact/ArtifactManagingServiceImpl.java#L858-L911
136,309
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java
ISPNIndexChangesFilter.createIndexInfos
private IndexInfos createIndexInfos(Boolean system, IndexerIoModeHandler modeHandler, QueryHandlerEntry config, QueryHandler handler) throws RepositoryConfigurationException { try { // read RSYNC configuration RSyncConfiguration rSyncConfiguration = new RSyncConfiguration(config); // rsync configured if (rSyncConfiguration.getRsyncEntryName() != null) { return new RsyncIndexInfos(wsId, cache, system, modeHandler, handler.getContext() .getIndexDirectory(), rSyncConfiguration); } else { return new ISPNIndexInfos(wsId, cache, true, modeHandler); } } catch (RepositoryConfigurationException e) { return new ISPNIndexInfos(wsId, cache, true, modeHandler); } }
java
private IndexInfos createIndexInfos(Boolean system, IndexerIoModeHandler modeHandler, QueryHandlerEntry config, QueryHandler handler) throws RepositoryConfigurationException { try { // read RSYNC configuration RSyncConfiguration rSyncConfiguration = new RSyncConfiguration(config); // rsync configured if (rSyncConfiguration.getRsyncEntryName() != null) { return new RsyncIndexInfos(wsId, cache, system, modeHandler, handler.getContext() .getIndexDirectory(), rSyncConfiguration); } else { return new ISPNIndexInfos(wsId, cache, true, modeHandler); } } catch (RepositoryConfigurationException e) { return new ISPNIndexInfos(wsId, cache, true, modeHandler); } }
[ "private", "IndexInfos", "createIndexInfos", "(", "Boolean", "system", ",", "IndexerIoModeHandler", "modeHandler", ",", "QueryHandlerEntry", "config", ",", "QueryHandler", "handler", ")", "throws", "RepositoryConfigurationException", "{", "try", "{", "// read RSYNC configur...
Factory method for creating corresponding IndexInfos class. RSyncIndexInfos created if RSync configured and ISPNIndexInfos otherwise @param system @param modeHandler @param config @param handler @return @throws RepositoryConfigurationException
[ "Factory", "method", "for", "creating", "corresponding", "IndexInfos", "class", ".", "RSyncIndexInfos", "created", "if", "RSync", "configured", "and", "ISPNIndexInfos", "otherwise" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java#L125-L148
136,310
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java
AbstractCacheableLockManager.getNumLocks
@Managed @ManagedDescription("The number of active locks") public int getNumLocks() { try { return getNumLocks.run(); } catch (LockException e) { if (LOG.isTraceEnabled()) { LOG.trace("An exception occurred: " + e.getMessage()); } } return -1; }
java
@Managed @ManagedDescription("The number of active locks") public int getNumLocks() { try { return getNumLocks.run(); } catch (LockException e) { if (LOG.isTraceEnabled()) { LOG.trace("An exception occurred: " + e.getMessage()); } } return -1; }
[ "@", "Managed", "@", "ManagedDescription", "(", "\"The number of active locks\"", ")", "public", "int", "getNumLocks", "(", ")", "{", "try", "{", "return", "getNumLocks", ".", "run", "(", ")", ";", "}", "catch", "(", "LockException", "e", ")", "{", "if", "...
Returns the number of active locks.
[ "Returns", "the", "number", "of", "active", "locks", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java#L200-L216
136,311
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java
AbstractCacheableLockManager.hasLocks
protected boolean hasLocks() { try { return hasLocks.run(); } catch (LockException e) { if (LOG.isTraceEnabled()) { LOG.trace("An exception occurred: " + e.getMessage()); } } return true; }
java
protected boolean hasLocks() { try { return hasLocks.run(); } catch (LockException e) { if (LOG.isTraceEnabled()) { LOG.trace("An exception occurred: " + e.getMessage()); } } return true; }
[ "protected", "boolean", "hasLocks", "(", ")", "{", "try", "{", "return", "hasLocks", ".", "run", "(", ")", ";", "}", "catch", "(", "LockException", "e", ")", "{", "if", "(", "LOG", ".", "isTraceEnabled", "(", ")", ")", "{", "LOG", ".", "trace", "("...
Indicates if some locks have already been created.
[ "Indicates", "if", "some", "locks", "have", "already", "been", "created", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java#L221-L235
136,312
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java
AbstractCacheableLockManager.isLockLive
public boolean isLockLive(String nodeId) throws LockException { try { return isLockLive.run(nodeId); } catch (LockException e) { if (LOG.isTraceEnabled()) { LOG.trace("An exception occurred: " + e.getMessage()); } } return false; }
java
public boolean isLockLive(String nodeId) throws LockException { try { return isLockLive.run(nodeId); } catch (LockException e) { if (LOG.isTraceEnabled()) { LOG.trace("An exception occurred: " + e.getMessage()); } } return false; }
[ "public", "boolean", "isLockLive", "(", "String", "nodeId", ")", "throws", "LockException", "{", "try", "{", "return", "isLockLive", ".", "run", "(", "nodeId", ")", ";", "}", "catch", "(", "LockException", "e", ")", "{", "if", "(", "LOG", ".", "isTraceEn...
Check is LockManager contains lock. No matter it is in pending or persistent state.
[ "Check", "is", "LockManager", "contains", "lock", ".", "No", "matter", "it", "is", "in", "pending", "or", "persistent", "state", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java#L240-L254
136,313
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java
AbstractCacheableLockManager.getLockDataById
protected LockData getLockDataById(String nodeId) { try { return getLockDataById.run(nodeId); } catch (LockException e) { if (LOG.isTraceEnabled()) { LOG.trace("An exception occurred: " + e.getMessage()); } } return null; }
java
protected LockData getLockDataById(String nodeId) { try { return getLockDataById.run(nodeId); } catch (LockException e) { if (LOG.isTraceEnabled()) { LOG.trace("An exception occurred: " + e.getMessage()); } } return null; }
[ "protected", "LockData", "getLockDataById", "(", "String", "nodeId", ")", "{", "try", "{", "return", "getLockDataById", ".", "run", "(", "nodeId", ")", ";", "}", "catch", "(", "LockException", "e", ")", "{", "if", "(", "LOG", ".", "isTraceEnabled", "(", ...
Returns lock data by node identifier.
[ "Returns", "lock", "data", "by", "node", "identifier", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java#L286-L300
136,314
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java
AbstractCacheableLockManager.getLockList
protected synchronized List<LockData> getLockList() { try { return getLockList.run(); } catch (LockException e) { if (LOG.isTraceEnabled()) { LOG.trace("An exception occurred: " + e.getMessage()); } } return null; }
java
protected synchronized List<LockData> getLockList() { try { return getLockList.run(); } catch (LockException e) { if (LOG.isTraceEnabled()) { LOG.trace("An exception occurred: " + e.getMessage()); } } return null; }
[ "protected", "synchronized", "List", "<", "LockData", ">", "getLockList", "(", ")", "{", "try", "{", "return", "getLockList", ".", "run", "(", ")", ";", "}", "catch", "(", "LockException", "e", ")", "{", "if", "(", "LOG", ".", "isTraceEnabled", "(", ")...
Returns all locks.
[ "Returns", "all", "locks", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java#L305-L319
136,315
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java
AbstractCacheableLockManager.getSessionLockManager
public SessionLockManager getSessionLockManager(String sessionId, SessionDataManager transientManager) { CacheableSessionLockManager sessionManager = new CacheableSessionLockManager(sessionId, this, transientManager); sessionLockManagers.put(sessionId, sessionManager); return sessionManager; }
java
public SessionLockManager getSessionLockManager(String sessionId, SessionDataManager transientManager) { CacheableSessionLockManager sessionManager = new CacheableSessionLockManager(sessionId, this, transientManager); sessionLockManagers.put(sessionId, sessionManager); return sessionManager; }
[ "public", "SessionLockManager", "getSessionLockManager", "(", "String", "sessionId", ",", "SessionDataManager", "transientManager", ")", "{", "CacheableSessionLockManager", "sessionManager", "=", "new", "CacheableSessionLockManager", "(", "sessionId", ",", "this", ",", "tra...
Return new instance of session lock manager.
[ "Return", "new", "instance", "of", "session", "lock", "manager", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java#L336-L341
136,316
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java
AbstractCacheableLockManager.removeExpired
public synchronized void removeExpired() { final List<String> removeLockList = new ArrayList<String>(); for (LockData lock : getLockList()) { if (!lock.isSessionScoped() && lock.getTimeToDeath() < 0) { removeLockList.add(lock.getNodeIdentifier()); } } Collections.sort(removeLockList); for (String rLock : removeLockList) { removeLock(rLock); } }
java
public synchronized void removeExpired() { final List<String> removeLockList = new ArrayList<String>(); for (LockData lock : getLockList()) { if (!lock.isSessionScoped() && lock.getTimeToDeath() < 0) { removeLockList.add(lock.getNodeIdentifier()); } } Collections.sort(removeLockList); for (String rLock : removeLockList) { removeLock(rLock); } }
[ "public", "synchronized", "void", "removeExpired", "(", ")", "{", "final", "List", "<", "String", ">", "removeLockList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "LockData", "lock", ":", "getLockList", "(", ")", ")", "{", ...
Remove expired locks. Used from LockRemover.
[ "Remove", "expired", "locks", ".", "Used", "from", "LockRemover", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java#L526-L544
136,317
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java
AbstractCacheableLockManager.removeLock
protected void removeLock(String nodeIdentifier) { try { NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier); //Skip removing, because that node was removed in other node of cluster. if (nData == null) { return; } PlainChangesLog changesLog = new PlainChangesLogImpl(new ArrayList<ItemState>(), IdentityConstants.SYSTEM, ExtendedEvent.UNLOCK); ItemData lockOwner = copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1), ItemType.PROPERTY)); //Skip removing, because that lock was removed in other node of cluster. if (lockOwner == null) { return; } changesLog.add(ItemState.createDeletedState(lockOwner)); ItemData lockIsDeep = copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1), ItemType.PROPERTY)); //Skip removing, because that lock was removed in other node of cluster. if (lockIsDeep == null) { return; } changesLog.add(ItemState.createDeletedState(lockIsDeep)); // lock probably removed by other thread if (lockOwner == null && lockIsDeep == null) { return; } dataManager.save(new TransactionChangesLog(changesLog)); } catch (JCRInvalidItemStateException e) { //Skip property not found in DB, because that lock property was removed in other node of cluster. if (LOG.isDebugEnabled()) { LOG.debug("The propperty was removed in other node of cluster.", e); } } catch (RepositoryException e) { LOG.error("Error occur during removing lock" + e.getLocalizedMessage(), e); } }
java
protected void removeLock(String nodeIdentifier) { try { NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier); //Skip removing, because that node was removed in other node of cluster. if (nData == null) { return; } PlainChangesLog changesLog = new PlainChangesLogImpl(new ArrayList<ItemState>(), IdentityConstants.SYSTEM, ExtendedEvent.UNLOCK); ItemData lockOwner = copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1), ItemType.PROPERTY)); //Skip removing, because that lock was removed in other node of cluster. if (lockOwner == null) { return; } changesLog.add(ItemState.createDeletedState(lockOwner)); ItemData lockIsDeep = copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1), ItemType.PROPERTY)); //Skip removing, because that lock was removed in other node of cluster. if (lockIsDeep == null) { return; } changesLog.add(ItemState.createDeletedState(lockIsDeep)); // lock probably removed by other thread if (lockOwner == null && lockIsDeep == null) { return; } dataManager.save(new TransactionChangesLog(changesLog)); } catch (JCRInvalidItemStateException e) { //Skip property not found in DB, because that lock property was removed in other node of cluster. if (LOG.isDebugEnabled()) { LOG.debug("The propperty was removed in other node of cluster.", e); } } catch (RepositoryException e) { LOG.error("Error occur during removing lock" + e.getLocalizedMessage(), e); } }
[ "protected", "void", "removeLock", "(", "String", "nodeIdentifier", ")", "{", "try", "{", "NodeData", "nData", "=", "(", "NodeData", ")", "dataManager", ".", "getItemData", "(", "nodeIdentifier", ")", ";", "//Skip removing, because that node was removed in other node of...
Remove lock, used by Lock remover. @param nodeIdentifier String
[ "Remove", "lock", "used", "by", "Lock", "remover", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java#L722-L782
136,318
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java
AbstractCacheableLockManager.removeAll
protected void removeAll() { List<LockData> locks = getLockList(); for (LockData lockData : locks) { removeLock(lockData.getNodeIdentifier()); } }
java
protected void removeAll() { List<LockData> locks = getLockList(); for (LockData lockData : locks) { removeLock(lockData.getNodeIdentifier()); } }
[ "protected", "void", "removeAll", "(", ")", "{", "List", "<", "LockData", ">", "locks", "=", "getLockList", "(", ")", ";", "for", "(", "LockData", "lockData", ":", "locks", ")", "{", "removeLock", "(", "lockData", ".", "getNodeIdentifier", "(", ")", ")",...
Remove all locks.
[ "Remove", "all", "locks", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/AbstractCacheableLockManager.java#L814-L821
136,319
exoplatform/jcr
exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java
PendingChangesLog.getAsByteArray
public static byte[] getAsByteArray(TransactionChangesLog dataChangesLog) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(os); oos.writeObject(dataChangesLog); byte[] bArray = os.toByteArray(); return bArray; }
java
public static byte[] getAsByteArray(TransactionChangesLog dataChangesLog) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(os); oos.writeObject(dataChangesLog); byte[] bArray = os.toByteArray(); return bArray; }
[ "public", "static", "byte", "[", "]", "getAsByteArray", "(", "TransactionChangesLog", "dataChangesLog", ")", "throws", "IOException", "{", "ByteArrayOutputStream", "os", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ObjectOutputStream", "oos", "=", "new", "Ob...
getAsByteArray. Make the array of bytes from ChangesLog. @param dataChangesLog the ChangesLog with data @return byte[] return the serialized ChangesLog @throws IOException will be generated the IOException
[ "getAsByteArray", ".", "Make", "the", "array", "of", "bytes", "from", "ChangesLog", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java#L374-L382
136,320
exoplatform/jcr
exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java
PendingChangesLog.getAsItemDataChangesLog
public static TransactionChangesLog getAsItemDataChangesLog(byte[] byteArray) throws IOException, ClassNotFoundException { ByteArrayInputStream is = new ByteArrayInputStream(byteArray); ObjectInputStream ois = new ObjectInputStream(is); TransactionChangesLog objRead = (TransactionChangesLog)ois.readObject(); return objRead; }
java
public static TransactionChangesLog getAsItemDataChangesLog(byte[] byteArray) throws IOException, ClassNotFoundException { ByteArrayInputStream is = new ByteArrayInputStream(byteArray); ObjectInputStream ois = new ObjectInputStream(is); TransactionChangesLog objRead = (TransactionChangesLog)ois.readObject(); return objRead; }
[ "public", "static", "TransactionChangesLog", "getAsItemDataChangesLog", "(", "byte", "[", "]", "byteArray", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "ByteArrayInputStream", "is", "=", "new", "ByteArrayInputStream", "(", "byteArray", ")", ";", ...
getAsItemDataChangesLog. Make the ChangesLog from array of bytes. @param byteArray the serialized ChangesLog @return TransactionChangesLog return the deserialized ChangesLog @throws IOException will be generated the IOException @throws ClassNotFoundException will be generated the ClassNotFoundException
[ "getAsItemDataChangesLog", ".", "Make", "the", "ChangesLog", "from", "array", "of", "bytes", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java#L395-L403
136,321
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PlainChangesLogReader.java
PlainChangesLogReader.read
public PlainChangesLog read(ObjectReader in) throws UnknownClassIdException, IOException { int key; if ((key = in.readInt()) != SerializationConstants.PLAIN_CHANGES_LOG_IMPL) { throw new UnknownClassIdException("There is unexpected class [" + key + "]"); } int eventType = in.readInt(); String sessionId = in.readString(); List<ItemState> items = new ArrayList<ItemState>(); int listSize = in.readInt(); for (int i = 0; i < listSize; i++) { ItemStateReader isr = new ItemStateReader(holder, spoolConfig); ItemState is = isr.read(in); items.add(is); } return new PlainChangesLogImpl(items, sessionId, eventType); }
java
public PlainChangesLog read(ObjectReader in) throws UnknownClassIdException, IOException { int key; if ((key = in.readInt()) != SerializationConstants.PLAIN_CHANGES_LOG_IMPL) { throw new UnknownClassIdException("There is unexpected class [" + key + "]"); } int eventType = in.readInt(); String sessionId = in.readString(); List<ItemState> items = new ArrayList<ItemState>(); int listSize = in.readInt(); for (int i = 0; i < listSize; i++) { ItemStateReader isr = new ItemStateReader(holder, spoolConfig); ItemState is = isr.read(in); items.add(is); } return new PlainChangesLogImpl(items, sessionId, eventType); }
[ "public", "PlainChangesLog", "read", "(", "ObjectReader", "in", ")", "throws", "UnknownClassIdException", ",", "IOException", "{", "int", "key", ";", "if", "(", "(", "key", "=", "in", ".", "readInt", "(", ")", ")", "!=", "SerializationConstants", ".", "PLAIN...
Read and set PlainChangesLog data. @param in ObjectReader. @return PlainChangesLog 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", "PlainChangesLog", "data", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PlainChangesLogReader.java#L78-L99
136,322
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PlainChangesLogWriter.java
PlainChangesLogWriter.write
public void write(ObjectWriter out, PlainChangesLog pcl) throws IOException { // write id out.writeInt(SerializationConstants.PLAIN_CHANGES_LOG_IMPL); out.writeInt(pcl.getEventType()); out.writeString(pcl.getSessionId()); List<ItemState> list = pcl.getAllStates(); int listSize = list.size(); out.writeInt(listSize); ItemStateWriter wr = new ItemStateWriter(); for (int i = 0; i < listSize; i++) { wr.write(out, list.get(i)); } }
java
public void write(ObjectWriter out, PlainChangesLog pcl) throws IOException { // write id out.writeInt(SerializationConstants.PLAIN_CHANGES_LOG_IMPL); out.writeInt(pcl.getEventType()); out.writeString(pcl.getSessionId()); List<ItemState> list = pcl.getAllStates(); int listSize = list.size(); out.writeInt(listSize); ItemStateWriter wr = new ItemStateWriter(); for (int i = 0; i < listSize; i++) { wr.write(out, list.get(i)); } }
[ "public", "void", "write", "(", "ObjectWriter", "out", ",", "PlainChangesLog", "pcl", ")", "throws", "IOException", "{", "// write id\r", "out", ".", "writeInt", "(", "SerializationConstants", ".", "PLAIN_CHANGES_LOG_IMPL", ")", ";", "out", ".", "writeInt", "(", ...
Write PlainChangesLog data. @param out ObjectWriter @param pcl PlainChangesLog ojbect @throws IOException if any Exception is occurred
[ "Write", "PlainChangesLog", "data", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PlainChangesLogWriter.java#L51-L69
136,323
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/SimpleJCRUserListAccess.java
SimpleJCRUserListAccess.getUsersStorageNode
private ExtendedNode getUsersStorageNode() throws RepositoryException { Session session = service.getStorageSession(); try { return (ExtendedNode)utils.getUsersStorageNode(service.getStorageSession()); } finally { session.logout(); } }
java
private ExtendedNode getUsersStorageNode() throws RepositoryException { Session session = service.getStorageSession(); try { return (ExtendedNode)utils.getUsersStorageNode(service.getStorageSession()); } finally { session.logout(); } }
[ "private", "ExtendedNode", "getUsersStorageNode", "(", ")", "throws", "RepositoryException", "{", "Session", "session", "=", "service", ".", "getStorageSession", "(", ")", ";", "try", "{", "return", "(", "ExtendedNode", ")", "utils", ".", "getUsersStorageNode", "(...
Returns users storage node.
[ "Returns", "users", "storage", "node", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/SimpleJCRUserListAccess.java#L95-L106
136,324
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.closeStatements
protected void closeStatements() { try { if (findItemById != null) { findItemById.close(); } if (findItemByPath != null) { findItemByPath.close(); } if (findItemByName != null) { findItemByName.close(); } if (findChildPropertyByPath != null) { findChildPropertyByPath.close(); } if (findPropertyByName != null) { findPropertyByName.close(); } if (findDescendantNodes != null) { findDescendantNodes.close(); } if (findDescendantProperties != null) { findDescendantProperties.close(); } if (findReferences != null) { findReferences.close(); } if (findValuesByPropertyId != null) { findValuesByPropertyId.close(); } if (findValuesDataByPropertyId != null) { findValuesDataByPropertyId.close(); } if (findNodesByParentId != null) { findNodesByParentId.close(); } if (findLastOrderNumberByParentId != null) { findLastOrderNumberByParentId.close(); } if (findNodesCountByParentId != null) { findNodesCountByParentId.close(); } if (findPropertiesByParentId != null) { findPropertiesByParentId.close(); } if (findMaxPropertyVersions != null) { findMaxPropertyVersions.close(); } if (insertNode != null) { insertNode.close(); } if (insertProperty != null) { insertProperty.close(); } if (insertReference != null) { insertReference.close(); } if (insertValue != null) { insertValue.close(); } if (updateNode != null) { updateNode.close(); } if (updateProperty != null) { updateProperty.close(); } if (deleteItem != null) { deleteItem.close(); } if (deleteReference != null) { deleteReference.close(); } if (deleteValue != null) { deleteValue.close(); } if (renameNode != null) { renameNode.close(); } if (findNodesAndProperties != null) { findNodesAndProperties.close(); } if (findNodesCount != null) { findNodesCount.close(); } if (findWorkspaceDataSize != null) { findWorkspaceDataSize.close(); } if (findNodeDataSize != null) { findNodeDataSize.close(); } if (findNodePropertiesOnValueStorage != null) { findNodePropertiesOnValueStorage.close(); } if (findWorkspacePropertiesOnValueStorage != null) { findWorkspacePropertiesOnValueStorage.close(); } if (findValueStorageDescAndSize != null) { findValueStorageDescAndSize.close(); } } catch (SQLException e) { LOG.error("Can't close the statement: " + e.getMessage()); } }
java
protected void closeStatements() { try { if (findItemById != null) { findItemById.close(); } if (findItemByPath != null) { findItemByPath.close(); } if (findItemByName != null) { findItemByName.close(); } if (findChildPropertyByPath != null) { findChildPropertyByPath.close(); } if (findPropertyByName != null) { findPropertyByName.close(); } if (findDescendantNodes != null) { findDescendantNodes.close(); } if (findDescendantProperties != null) { findDescendantProperties.close(); } if (findReferences != null) { findReferences.close(); } if (findValuesByPropertyId != null) { findValuesByPropertyId.close(); } if (findValuesDataByPropertyId != null) { findValuesDataByPropertyId.close(); } if (findNodesByParentId != null) { findNodesByParentId.close(); } if (findLastOrderNumberByParentId != null) { findLastOrderNumberByParentId.close(); } if (findNodesCountByParentId != null) { findNodesCountByParentId.close(); } if (findPropertiesByParentId != null) { findPropertiesByParentId.close(); } if (findMaxPropertyVersions != null) { findMaxPropertyVersions.close(); } if (insertNode != null) { insertNode.close(); } if (insertProperty != null) { insertProperty.close(); } if (insertReference != null) { insertReference.close(); } if (insertValue != null) { insertValue.close(); } if (updateNode != null) { updateNode.close(); } if (updateProperty != null) { updateProperty.close(); } if (deleteItem != null) { deleteItem.close(); } if (deleteReference != null) { deleteReference.close(); } if (deleteValue != null) { deleteValue.close(); } if (renameNode != null) { renameNode.close(); } if (findNodesAndProperties != null) { findNodesAndProperties.close(); } if (findNodesCount != null) { findNodesCount.close(); } if (findWorkspaceDataSize != null) { findWorkspaceDataSize.close(); } if (findNodeDataSize != null) { findNodeDataSize.close(); } if (findNodePropertiesOnValueStorage != null) { findNodePropertiesOnValueStorage.close(); } if (findWorkspacePropertiesOnValueStorage != null) { findWorkspacePropertiesOnValueStorage.close(); } if (findValueStorageDescAndSize != null) { findValueStorageDescAndSize.close(); } } catch (SQLException e) { LOG.error("Can't close the statement: " + e.getMessage()); } }
[ "protected", "void", "closeStatements", "(", ")", "{", "try", "{", "if", "(", "findItemById", "!=", "null", ")", "{", "findItemById", ".", "close", "(", ")", ";", "}", "if", "(", "findItemByPath", "!=", "null", ")", "{", "findItemByPath", ".", "close", ...
Close all statements.
[ "Close", "all", "statements", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L517-L685
136,325
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.getNodesAndProperties
public List<NodeDataIndexing> getNodesAndProperties(String lastNodeId, int offset, int limit) throws RepositoryException, IllegalStateException { List<NodeDataIndexing> result = new ArrayList<NodeDataIndexing>(); checkIfOpened(); try { startTxIfNeeded(); ResultSet resultSet = findNodesAndProperties(lastNodeId, offset, limit); int processed = 0; try { TempNodeData tempNodeData = null; while (resultSet.next()) { if (tempNodeData == null) { tempNodeData = new TempNodeData(resultSet); processed++; } else if (!resultSet.getString(COLUMN_ID).equals(tempNodeData.cid)) { if (!needToSkipOffsetNodes() || processed > offset) { result.add(createNodeDataIndexing(tempNodeData)); } tempNodeData = new TempNodeData(resultSet); processed++; } if (!needToSkipOffsetNodes() || processed > offset) { String key = resultSet.getString("P_NAME"); SortedSet<TempPropertyData> values = tempNodeData.properties.get(key); if (values == null) { values = new TreeSet<TempPropertyData>(); tempNodeData.properties.put(key, values); } values.add(new ExtendedTempPropertyData(resultSet)); } } if (tempNodeData != null && (!needToSkipOffsetNodes() || processed > offset)) { result.add(createNodeDataIndexing(tempNodeData)); } } finally { try { resultSet.close(); } catch (SQLException e) { LOG.error("Can't close the ResultSet: " + e.getMessage()); } } } catch (IOException e) { throw new RepositoryException(e); } catch (IllegalNameException e) { throw new RepositoryException(e); } catch (SQLException e) { throw new RepositoryException(e); } if (LOG.isTraceEnabled()) { LOG.trace("getNodesAndProperties(%s, %s, %s) = %s elements", lastNodeId, offset, limit, result.size()); } return result; }
java
public List<NodeDataIndexing> getNodesAndProperties(String lastNodeId, int offset, int limit) throws RepositoryException, IllegalStateException { List<NodeDataIndexing> result = new ArrayList<NodeDataIndexing>(); checkIfOpened(); try { startTxIfNeeded(); ResultSet resultSet = findNodesAndProperties(lastNodeId, offset, limit); int processed = 0; try { TempNodeData tempNodeData = null; while (resultSet.next()) { if (tempNodeData == null) { tempNodeData = new TempNodeData(resultSet); processed++; } else if (!resultSet.getString(COLUMN_ID).equals(tempNodeData.cid)) { if (!needToSkipOffsetNodes() || processed > offset) { result.add(createNodeDataIndexing(tempNodeData)); } tempNodeData = new TempNodeData(resultSet); processed++; } if (!needToSkipOffsetNodes() || processed > offset) { String key = resultSet.getString("P_NAME"); SortedSet<TempPropertyData> values = tempNodeData.properties.get(key); if (values == null) { values = new TreeSet<TempPropertyData>(); tempNodeData.properties.put(key, values); } values.add(new ExtendedTempPropertyData(resultSet)); } } if (tempNodeData != null && (!needToSkipOffsetNodes() || processed > offset)) { result.add(createNodeDataIndexing(tempNodeData)); } } finally { try { resultSet.close(); } catch (SQLException e) { LOG.error("Can't close the ResultSet: " + e.getMessage()); } } } catch (IOException e) { throw new RepositoryException(e); } catch (IllegalNameException e) { throw new RepositoryException(e); } catch (SQLException e) { throw new RepositoryException(e); } if (LOG.isTraceEnabled()) { LOG.trace("getNodesAndProperties(%s, %s, %s) = %s elements", lastNodeId, offset, limit, result.size()); } return result; }
[ "public", "List", "<", "NodeDataIndexing", ">", "getNodesAndProperties", "(", "String", "lastNodeId", ",", "int", "offset", ",", "int", "limit", ")", "throws", "RepositoryException", ",", "IllegalStateException", "{", "List", "<", "NodeDataIndexing", ">", "result", ...
Returns from storage the next page of nodes and its properties.
[ "Returns", "from", "storage", "the", "next", "page", "of", "nodes", "and", "its", "properties", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L1287-L1371
136,326
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.getNodesCount
public long getNodesCount() throws RepositoryException { try { ResultSet countNodes = findNodesCount(); try { if (countNodes.next()) { return countNodes.getLong(1); } else { throw new SQLException("ResultSet has't records."); } } finally { JDBCUtils.freeResources(countNodes, null, null); } } catch (SQLException e) { throw new RepositoryException("Can not calculate nodes count", e); } }
java
public long getNodesCount() throws RepositoryException { try { ResultSet countNodes = findNodesCount(); try { if (countNodes.next()) { return countNodes.getLong(1); } else { throw new SQLException("ResultSet has't records."); } } finally { JDBCUtils.freeResources(countNodes, null, null); } } catch (SQLException e) { throw new RepositoryException("Can not calculate nodes count", e); } }
[ "public", "long", "getNodesCount", "(", ")", "throws", "RepositoryException", "{", "try", "{", "ResultSet", "countNodes", "=", "findNodesCount", "(", ")", ";", "try", "{", "if", "(", "countNodes", ".", "next", "(", ")", ")", "{", "return", "countNodes", "....
Reads count of nodes in workspace. @return nodes count @throws RepositoryException if a database access error occurs
[ "Reads", "count", "of", "nodes", "in", "workspace", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L1533-L1558
136,327
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.getWorkspaceDataSize
public long getWorkspaceDataSize() throws RepositoryException { long dataSize = 0; ResultSet result = null; try { result = findWorkspaceDataSize(); try { if (result.next()) { dataSize += result.getLong(1); } } finally { JDBCUtils.freeResources(result, null, null); } result = findWorkspacePropertiesOnValueStorage(); try { while (result.next()) { String storageDesc = result.getString(DBConstants.COLUMN_VSTORAGE_DESC); String propertyId = result.getString(DBConstants.COLUMN_VPROPERTY_ID); int orderNum = result.getInt(DBConstants.COLUMN_VORDERNUM); ValueIOChannel channel = containerConfig.valueStorageProvider.getChannel(storageDesc); dataSize += channel.getValueSize(getIdentifier(propertyId), orderNum); } } finally { JDBCUtils.freeResources(result, null, null); } } catch (IOException e) { throw new RepositoryException(e); } catch (SQLException e) { throw new RepositoryException(e.getMessage(), e); } return dataSize; }
java
public long getWorkspaceDataSize() throws RepositoryException { long dataSize = 0; ResultSet result = null; try { result = findWorkspaceDataSize(); try { if (result.next()) { dataSize += result.getLong(1); } } finally { JDBCUtils.freeResources(result, null, null); } result = findWorkspacePropertiesOnValueStorage(); try { while (result.next()) { String storageDesc = result.getString(DBConstants.COLUMN_VSTORAGE_DESC); String propertyId = result.getString(DBConstants.COLUMN_VPROPERTY_ID); int orderNum = result.getInt(DBConstants.COLUMN_VORDERNUM); ValueIOChannel channel = containerConfig.valueStorageProvider.getChannel(storageDesc); dataSize += channel.getValueSize(getIdentifier(propertyId), orderNum); } } finally { JDBCUtils.freeResources(result, null, null); } } catch (IOException e) { throw new RepositoryException(e); } catch (SQLException e) { throw new RepositoryException(e.getMessage(), e); } return dataSize; }
[ "public", "long", "getWorkspaceDataSize", "(", ")", "throws", "RepositoryException", "{", "long", "dataSize", "=", "0", ";", "ResultSet", "result", "=", "null", ";", "try", "{", "result", "=", "findWorkspaceDataSize", "(", ")", ";", "try", "{", "if", "(", ...
Calculates workspace data size. @throws RepositoryException if a database access error occurs
[ "Calculates", "workspace", "data", "size", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L1566-L1615
136,328
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.getNodeDataSize
public long getNodeDataSize(String nodeIdentifier) throws RepositoryException { long dataSize = 0; ResultSet result = null; try { result = findNodeDataSize(getInternalId(nodeIdentifier)); try { if (result.next()) { dataSize += result.getLong(1); } } finally { JDBCUtils.freeResources(result, null, null); } result = findNodePropertiesOnValueStorage(getInternalId(nodeIdentifier)); try { while (result.next()) { String storageDesc = result.getString(DBConstants.COLUMN_VSTORAGE_DESC); String propertyId = result.getString(DBConstants.COLUMN_VPROPERTY_ID); int orderNum = result.getInt(DBConstants.COLUMN_VORDERNUM); ValueIOChannel channel = containerConfig.valueStorageProvider.getChannel(storageDesc); dataSize += channel.getValueSize(getIdentifier(propertyId), orderNum); } } finally { JDBCUtils.freeResources(result, null, null); } } catch (IOException e) { throw new RepositoryException(e); } catch (SQLException e) { throw new RepositoryException(e.getMessage(), e); } return dataSize; }
java
public long getNodeDataSize(String nodeIdentifier) throws RepositoryException { long dataSize = 0; ResultSet result = null; try { result = findNodeDataSize(getInternalId(nodeIdentifier)); try { if (result.next()) { dataSize += result.getLong(1); } } finally { JDBCUtils.freeResources(result, null, null); } result = findNodePropertiesOnValueStorage(getInternalId(nodeIdentifier)); try { while (result.next()) { String storageDesc = result.getString(DBConstants.COLUMN_VSTORAGE_DESC); String propertyId = result.getString(DBConstants.COLUMN_VPROPERTY_ID); int orderNum = result.getInt(DBConstants.COLUMN_VORDERNUM); ValueIOChannel channel = containerConfig.valueStorageProvider.getChannel(storageDesc); dataSize += channel.getValueSize(getIdentifier(propertyId), orderNum); } } finally { JDBCUtils.freeResources(result, null, null); } } catch (IOException e) { throw new RepositoryException(e); } catch (SQLException e) { throw new RepositoryException(e.getMessage(), e); } return dataSize; }
[ "public", "long", "getNodeDataSize", "(", "String", "nodeIdentifier", ")", "throws", "RepositoryException", "{", "long", "dataSize", "=", "0", ";", "ResultSet", "result", "=", "null", ";", "try", "{", "result", "=", "findNodeDataSize", "(", "getInternalId", "(",...
Calculates node data size. @throws RepositoryException if a database access error occurs
[ "Calculates", "node", "data", "size", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L1623-L1672
136,329
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.getItemByIdentifier
protected ItemData getItemByIdentifier(String cid) throws RepositoryException, IllegalStateException { checkIfOpened(); try { ResultSet item = findItemByIdentifier(cid); try { if (item.next()) { return itemData(null, item, item.getInt(COLUMN_CLASS), null); } return null; } finally { try { item.close(); } catch (SQLException e) { LOG.error("Can't close the ResultSet: " + e.getMessage()); } } } catch (SQLException e) { throw new RepositoryException("getItemData() error", e); } catch (IOException e) { throw new RepositoryException("getItemData() error", e); } }
java
protected ItemData getItemByIdentifier(String cid) throws RepositoryException, IllegalStateException { checkIfOpened(); try { ResultSet item = findItemByIdentifier(cid); try { if (item.next()) { return itemData(null, item, item.getInt(COLUMN_CLASS), null); } return null; } finally { try { item.close(); } catch (SQLException e) { LOG.error("Can't close the ResultSet: " + e.getMessage()); } } } catch (SQLException e) { throw new RepositoryException("getItemData() error", e); } catch (IOException e) { throw new RepositoryException("getItemData() error", e); } }
[ "protected", "ItemData", "getItemByIdentifier", "(", "String", "cid", ")", "throws", "RepositoryException", ",", "IllegalStateException", "{", "checkIfOpened", "(", ")", ";", "try", "{", "ResultSet", "item", "=", "findItemByIdentifier", "(", "cid", ")", ";", "try"...
Get Item By Identifier. @param cid Item id (container internal) @return ItemData @throws RepositoryException Repository error @throws IllegalStateException if connection is closed
[ "Get", "Item", "By", "Identifier", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L1687-L1721
136,330
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.getItemByName
protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name, ItemType itemType) throws RepositoryException, IllegalStateException { checkIfOpened(); try { ResultSet item = null; try { item = findItemByName(parentId, name.getAsString(), name.getIndex()); while (item.next()) { int columnClass = item.getInt(COLUMN_CLASS); if (itemType == ItemType.UNKNOWN || columnClass == itemType.ordinal()) { return itemData(parent.getQPath(), item, columnClass, parent.getACL()); } } return null; } finally { try { if (item != null) { item.close(); } } catch (SQLException e) { LOG.error("Can't close the ResultSet: " + e.getMessage()); } } } catch (SQLException e) { throw new RepositoryException(e); } catch (IOException e) { throw new RepositoryException(e); } }
java
protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name, ItemType itemType) throws RepositoryException, IllegalStateException { checkIfOpened(); try { ResultSet item = null; try { item = findItemByName(parentId, name.getAsString(), name.getIndex()); while (item.next()) { int columnClass = item.getInt(COLUMN_CLASS); if (itemType == ItemType.UNKNOWN || columnClass == itemType.ordinal()) { return itemData(parent.getQPath(), item, columnClass, parent.getACL()); } } return null; } finally { try { if (item != null) { item.close(); } } catch (SQLException e) { LOG.error("Can't close the ResultSet: " + e.getMessage()); } } } catch (SQLException e) { throw new RepositoryException(e); } catch (IOException e) { throw new RepositoryException(e); } }
[ "protected", "ItemData", "getItemByName", "(", "NodeData", "parent", ",", "String", "parentId", ",", "QPathEntry", "name", ",", "ItemType", "itemType", ")", "throws", "RepositoryException", ",", "IllegalStateException", "{", "checkIfOpened", "(", ")", ";", "try", ...
Gets an item data from database. @param parent - parent QPath @param parentId - parent container internal id (depends on Multi/Single DB) @param name - item name @param itemType - item type @return - ItemData instance @throws RepositoryException Repository error @throws IllegalStateException if connection is closed
[ "Gets", "an", "item", "data", "from", "database", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L1782-L1826
136,331
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.itemData
private ItemData itemData(QPath parentPath, ResultSet item, int itemClass, AccessControlList parentACL) throws RepositoryException, SQLException, IOException { String cid = item.getString(COLUMN_ID); String cname = item.getString(COLUMN_NAME); int cversion = item.getInt(COLUMN_VERSION); String cpid = item.getString(COLUMN_PARENTID); // if parent ID is empty string - it's a root node // cpid = cpid.equals(Constants.ROOT_PARENT_UUID) ? null : cpid; try { if (itemClass == I_CLASS_NODE) { int cindex = item.getInt(COLUMN_INDEX); int cnordernumb = item.getInt(COLUMN_NORDERNUM); return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion, cnordernumb, parentACL); } int cptype = item.getInt(COLUMN_PTYPE); boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED); return loadPropertyRecord(parentPath, cname, cid, cpid, cversion, cptype, cpmultivalued); } catch (InvalidItemStateException e) { throw new InvalidItemStateException("FATAL: Can't build item path for name " + cname + " id: " + getIdentifier(cid) + ". " + e); } }
java
private ItemData itemData(QPath parentPath, ResultSet item, int itemClass, AccessControlList parentACL) throws RepositoryException, SQLException, IOException { String cid = item.getString(COLUMN_ID); String cname = item.getString(COLUMN_NAME); int cversion = item.getInt(COLUMN_VERSION); String cpid = item.getString(COLUMN_PARENTID); // if parent ID is empty string - it's a root node // cpid = cpid.equals(Constants.ROOT_PARENT_UUID) ? null : cpid; try { if (itemClass == I_CLASS_NODE) { int cindex = item.getInt(COLUMN_INDEX); int cnordernumb = item.getInt(COLUMN_NORDERNUM); return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion, cnordernumb, parentACL); } int cptype = item.getInt(COLUMN_PTYPE); boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED); return loadPropertyRecord(parentPath, cname, cid, cpid, cversion, cptype, cpmultivalued); } catch (InvalidItemStateException e) { throw new InvalidItemStateException("FATAL: Can't build item path for name " + cname + " id: " + getIdentifier(cid) + ". " + e); } }
[ "private", "ItemData", "itemData", "(", "QPath", "parentPath", ",", "ResultSet", "item", ",", "int", "itemClass", ",", "AccessControlList", "parentACL", ")", "throws", "RepositoryException", ",", "SQLException", ",", "IOException", "{", "String", "cid", "=", "item...
Build ItemData. @param parentPath - parent path @param item database - ResultSet with Item record(s) @param itemClass - Item type (Node or Property) @param parentACL - parent ACL @return ItemData instance @throws RepositoryException Repository error @throws SQLException database error @throws IOException I/O error
[ "Build", "ItemData", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L1984-L2013
136,332
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.readMixins
protected MixinInfo readMixins(String cid) throws SQLException, IllegalNameException { ResultSet mtrs = findPropertyByName(cid, Constants.JCR_MIXINTYPES.getAsString()); try { List<InternalQName> mts = null; boolean owneable = false; boolean privilegeable = false; if (mtrs.next()) { mts = new ArrayList<InternalQName>(); do { byte[] mxnb = mtrs.getBytes(COLUMN_VDATA); if (mxnb != null) { InternalQName mxn = InternalQName.parse(new String(mxnb)); mts.add(mxn); if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn)) { privilegeable = true; } else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn)) { owneable = true; } } // else, if SQL NULL - skip it } while (mtrs.next()); } return new MixinInfo(mts, owneable, privilegeable); } finally { try { mtrs.close(); } catch (SQLException e) { LOG.error("Can't close the ResultSet: " + e.getMessage()); } } }
java
protected MixinInfo readMixins(String cid) throws SQLException, IllegalNameException { ResultSet mtrs = findPropertyByName(cid, Constants.JCR_MIXINTYPES.getAsString()); try { List<InternalQName> mts = null; boolean owneable = false; boolean privilegeable = false; if (mtrs.next()) { mts = new ArrayList<InternalQName>(); do { byte[] mxnb = mtrs.getBytes(COLUMN_VDATA); if (mxnb != null) { InternalQName mxn = InternalQName.parse(new String(mxnb)); mts.add(mxn); if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn)) { privilegeable = true; } else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn)) { owneable = true; } } // else, if SQL NULL - skip it } while (mtrs.next()); } return new MixinInfo(mts, owneable, privilegeable); } finally { try { mtrs.close(); } catch (SQLException e) { LOG.error("Can't close the ResultSet: " + e.getMessage()); } } }
[ "protected", "MixinInfo", "readMixins", "(", "String", "cid", ")", "throws", "SQLException", ",", "IllegalNameException", "{", "ResultSet", "mtrs", "=", "findPropertyByName", "(", "cid", ",", "Constants", ".", "JCR_MIXINTYPES", ".", "getAsString", "(", ")", ")", ...
Read mixins from database. @param cid - Item id (internal) @return MixinInfo @throws SQLException database error @throws IllegalNameException if nodetype name in mixin record is wrong
[ "Read", "mixins", "from", "database", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L2178-L2224
136,333
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.loadPropertyRecord
protected PersistedPropertyData loadPropertyRecord(QPath parentPath, String cname, String cid, String cpid, int cversion, int cptype, boolean cpmultivalued) throws RepositoryException, SQLException, IOException { // NOTE: cpid never should be null or root parent (' ') try { QPath qpath = QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) : parentPath, InternalQName.parse(cname)); String identifier = getIdentifier(cid); List<ValueDataWrapper> data = readValues(cid, cptype, identifier, cversion); long size = 0; List<ValueData> values = new ArrayList<ValueData>(); for (ValueDataWrapper vdDataWrapper : data) { values.add(vdDataWrapper.value); size += vdDataWrapper.size; } PersistedPropertyData pdata = new PersistedPropertyData(identifier, qpath, getIdentifier(cpid), cversion, cptype, cpmultivalued, values, new SimplePersistedSize(size)); return pdata; } catch (IllegalNameException e) { throw new RepositoryException(e); } }
java
protected PersistedPropertyData loadPropertyRecord(QPath parentPath, String cname, String cid, String cpid, int cversion, int cptype, boolean cpmultivalued) throws RepositoryException, SQLException, IOException { // NOTE: cpid never should be null or root parent (' ') try { QPath qpath = QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) : parentPath, InternalQName.parse(cname)); String identifier = getIdentifier(cid); List<ValueDataWrapper> data = readValues(cid, cptype, identifier, cversion); long size = 0; List<ValueData> values = new ArrayList<ValueData>(); for (ValueDataWrapper vdDataWrapper : data) { values.add(vdDataWrapper.value); size += vdDataWrapper.size; } PersistedPropertyData pdata = new PersistedPropertyData(identifier, qpath, getIdentifier(cpid), cversion, cptype, cpmultivalued, values, new SimplePersistedSize(size)); return pdata; } catch (IllegalNameException e) { throw new RepositoryException(e); } }
[ "protected", "PersistedPropertyData", "loadPropertyRecord", "(", "QPath", "parentPath", ",", "String", "cname", ",", "String", "cid", ",", "String", "cpid", ",", "int", "cversion", ",", "int", "cptype", ",", "boolean", "cpmultivalued", ")", "throws", "RepositoryEx...
Load PropertyData record. @param parentPath parent path @param cname Property name @param cid Property id @param cpid Property parent id @param cversion Property persistent verison @param cptype Property type @param cpmultivalued Property multivalued status @return PersistedPropertyData @throws RepositoryException Repository error @throws SQLException database error @throws IOException I/O error
[ "Load", "PropertyData", "record", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L2496-L2529
136,334
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.deleteValues
private void deleteValues(String cid, PropertyData pdata, boolean update, ChangedSizeHandler sizeHandler) throws IOException, SQLException, RepositoryException, InvalidItemStateException { Set<String> storages = new HashSet<String>(); final ResultSet valueRecords = findValueStorageDescAndSize(cid); try { if (valueRecords.next()) { do { final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC); if (!valueRecords.wasNull()) { storages.add(storageId); } else { sizeHandler.accumulatePrevSize(valueRecords.getLong(1)); } } while (valueRecords.next()); } // delete all values in value storage for (String storageId : storages) { final ValueIOChannel channel = this.containerConfig.valueStorageProvider.getChannel(storageId); try { sizeHandler.accumulatePrevSize(channel.getValueSize(pdata.getIdentifier())); channel.delete(pdata.getIdentifier()); valueChanges.add(channel); } finally { channel.close(); } } // delete all Values in database deleteValueData(cid); } finally { JDBCUtils.freeResources(valueRecords, null, null); } }
java
private void deleteValues(String cid, PropertyData pdata, boolean update, ChangedSizeHandler sizeHandler) throws IOException, SQLException, RepositoryException, InvalidItemStateException { Set<String> storages = new HashSet<String>(); final ResultSet valueRecords = findValueStorageDescAndSize(cid); try { if (valueRecords.next()) { do { final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC); if (!valueRecords.wasNull()) { storages.add(storageId); } else { sizeHandler.accumulatePrevSize(valueRecords.getLong(1)); } } while (valueRecords.next()); } // delete all values in value storage for (String storageId : storages) { final ValueIOChannel channel = this.containerConfig.valueStorageProvider.getChannel(storageId); try { sizeHandler.accumulatePrevSize(channel.getValueSize(pdata.getIdentifier())); channel.delete(pdata.getIdentifier()); valueChanges.add(channel); } finally { channel.close(); } } // delete all Values in database deleteValueData(cid); } finally { JDBCUtils.freeResources(valueRecords, null, null); } }
[ "private", "void", "deleteValues", "(", "String", "cid", ",", "PropertyData", "pdata", ",", "boolean", "update", ",", "ChangedSizeHandler", "sizeHandler", ")", "throws", "IOException", ",", "SQLException", ",", "RepositoryException", ",", "InvalidItemStateException", ...
Delete Property Values. @param cid Property id @param pdata PropertyData @param update boolean true if it's delete-add sequence (update operation) @param sizeHandler accumulates changed size @throws IOException i/O error @throws SQLException if database error occurs @throws RepositoryException @throws InvalidItemStateException
[ "Delete", "Property", "Values", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L2549-L2598
136,335
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.readValues
private List<ValueDataWrapper> readValues(String cid, int cptype, String identifier, int cversion) throws IOException, SQLException, ValueStorageNotFoundException { List<ValueDataWrapper> data = new ArrayList<ValueDataWrapper>(); final ResultSet valueRecords = findValuesByPropertyId(cid); try { while (valueRecords.next()) { final int orderNum = valueRecords.getInt(COLUMN_VORDERNUM); final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC); ValueDataWrapper vdWrapper = valueRecords.wasNull() ? ValueDataUtil.readValueData(cid, cptype, orderNum, cversion, valueRecords.getBinaryStream(COLUMN_VDATA), containerConfig.spoolConfig) : readValueData(identifier, orderNum, cptype, storageId); data.add(vdWrapper); } } finally { try { valueRecords.close(); } catch (SQLException e) { LOG.error("Can't close the ResultSet: " + e.getMessage()); } } return data; }
java
private List<ValueDataWrapper> readValues(String cid, int cptype, String identifier, int cversion) throws IOException, SQLException, ValueStorageNotFoundException { List<ValueDataWrapper> data = new ArrayList<ValueDataWrapper>(); final ResultSet valueRecords = findValuesByPropertyId(cid); try { while (valueRecords.next()) { final int orderNum = valueRecords.getInt(COLUMN_VORDERNUM); final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC); ValueDataWrapper vdWrapper = valueRecords.wasNull() ? ValueDataUtil.readValueData(cid, cptype, orderNum, cversion, valueRecords.getBinaryStream(COLUMN_VDATA), containerConfig.spoolConfig) : readValueData(identifier, orderNum, cptype, storageId); data.add(vdWrapper); } } finally { try { valueRecords.close(); } catch (SQLException e) { LOG.error("Can't close the ResultSet: " + e.getMessage()); } } return data; }
[ "private", "List", "<", "ValueDataWrapper", ">", "readValues", "(", "String", "cid", ",", "int", "cptype", ",", "String", "identifier", ",", "int", "cversion", ")", "throws", "IOException", ",", "SQLException", ",", "ValueStorageNotFoundException", "{", "List", ...
Read Property Values. @param identifier property identifier @param cid Property id @param pdata PropertyData @return list of ValueData @throws IOException i/O error @throws SQLException if database errro occurs @throws ValueStorageNotFoundException if no such storage found with Value storageId
[ "Read", "Property", "Values", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L2617-L2651
136,336
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
JDBCStorageConnection.readValueData
protected ValueDataWrapper readValueData(String identifier, int orderNumber, int type, String storageId) throws SQLException, IOException, ValueStorageNotFoundException { ValueIOChannel channel = this.containerConfig.valueStorageProvider.getChannel(storageId); try { return channel.read(identifier, orderNumber, type, containerConfig.spoolConfig); } finally { channel.close(); } }
java
protected ValueDataWrapper readValueData(String identifier, int orderNumber, int type, String storageId) throws SQLException, IOException, ValueStorageNotFoundException { ValueIOChannel channel = this.containerConfig.valueStorageProvider.getChannel(storageId); try { return channel.read(identifier, orderNumber, type, containerConfig.spoolConfig); } finally { channel.close(); } }
[ "protected", "ValueDataWrapper", "readValueData", "(", "String", "identifier", ",", "int", "orderNumber", ",", "int", "type", ",", "String", "storageId", ")", "throws", "SQLException", ",", "IOException", ",", "ValueStorageNotFoundException", "{", "ValueIOChannel", "c...
Read ValueData from External Storage. @param identifier PropertyData @param orderNumber Value order number @param type property type @param storageId external Value storage id @return ValueData @throws SQLException database error @throws IOException I/O error @throws ValueStorageNotFoundException if no such storage found with Value storageId
[ "Read", "ValueData", "from", "External", "Storage", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java#L2672-L2684
136,337
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java
IndexerCacheStore.getModeHandler
public IndexerIoModeHandler getModeHandler() { if (modeHandler == null) { if (ctx.getCache().getStatus() != ComponentStatus.RUNNING) { throw new IllegalStateException("The cache should be started first"); } synchronized (this) { if (modeHandler == null) { this.modeHandler = new IndexerIoModeHandler(cacheManager.isCoordinator() || ctx.getCache().getAdvancedCache().getRpcManager() == null ? IndexerIoMode.READ_WRITE : IndexerIoMode.READ_ONLY); } } } return modeHandler; }
java
public IndexerIoModeHandler getModeHandler() { if (modeHandler == null) { if (ctx.getCache().getStatus() != ComponentStatus.RUNNING) { throw new IllegalStateException("The cache should be started first"); } synchronized (this) { if (modeHandler == null) { this.modeHandler = new IndexerIoModeHandler(cacheManager.isCoordinator() || ctx.getCache().getAdvancedCache().getRpcManager() == null ? IndexerIoMode.READ_WRITE : IndexerIoMode.READ_ONLY); } } } return modeHandler; }
[ "public", "IndexerIoModeHandler", "getModeHandler", "(", ")", "{", "if", "(", "modeHandler", "==", "null", ")", "{", "if", "(", "ctx", ".", "getCache", "(", ")", ".", "getStatus", "(", ")", "!=", "ComponentStatus", ".", "RUNNING", ")", "{", "throw", "new...
Get the mode handler
[ "Get", "the", "mode", "handler" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java#L87-L108
136,338
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java
IndexerCacheStore.doPushState
@SuppressWarnings("rawtypes") protected void doPushState() { final boolean debugEnabled = LOG.isDebugEnabled(); if (debugEnabled) { LOG.debug("start pushing in-memory state to cache cacheLoader collection"); } Map<String, ChangesFilterListsWrapper> changesMap = new HashMap<String, ChangesFilterListsWrapper>(); List<ChangesKey> processedItemKeys = new ArrayList<ChangesKey>(); DataContainer dc = ctx.getCache().getAdvancedCache().getDataContainer(); Set keys = dc.keySet(); InternalCacheEntry entry; // collect all cache entries into the following map: // <WS ID> : <Contracted lists of added/removed nodes> for (Object k : keys) { if ((entry = dc.get(k)) != null) { if (entry.getValue() instanceof ChangesFilterListsWrapper && entry.getKey() instanceof ChangesKey) { if (debugEnabled) { LOG.debug("Received list wrapper, start indexing..."); } // get stale List that was not processed ChangesFilterListsWrapper staleListIncache = (ChangesFilterListsWrapper)entry.getValue(); ChangesKey key = (ChangesKey)entry.getKey(); // get newly created wrapper instance ChangesFilterListsWrapper listToPush = changesMap.get(key.getWsId()); if (listToPush == null) { listToPush = new ChangesFilterListsWrapper(new HashSet<String>(), new HashSet<String>(), new HashSet<String>(), new HashSet<String>()); changesMap.put(key.getWsId(), listToPush); } // copying lists into the new wrapper if (staleListIncache.getParentAddedNodes() != null) listToPush.getParentAddedNodes().addAll(staleListIncache.getParentAddedNodes()); if (staleListIncache.getParentRemovedNodes() != null) listToPush.getParentRemovedNodes().addAll(staleListIncache.getParentRemovedNodes()); if (staleListIncache.getAddedNodes() != null) listToPush.getAddedNodes().addAll(staleListIncache.getAddedNodes()); if (staleListIncache.getRemovedNodes() != null) listToPush.getRemovedNodes().addAll(staleListIncache.getRemovedNodes()); processedItemKeys.add(key); } } } // process all lists for each workspace for (Entry<String, ChangesFilterListsWrapper> changesEntry : changesMap.entrySet()) { // create key based on wsId and generated id ChangesKey changesKey = new ChangesKey(changesEntry.getKey(), IdGenerator.generate()); ctx.getCache().putAsync(changesKey, changesEntry.getValue()); } for (ChangesKey key : processedItemKeys) { ctx.getCache().removeAsync(key); } if (debugEnabled) { LOG.debug("in-memory state passed to cache cacheStore successfully"); } }
java
@SuppressWarnings("rawtypes") protected void doPushState() { final boolean debugEnabled = LOG.isDebugEnabled(); if (debugEnabled) { LOG.debug("start pushing in-memory state to cache cacheLoader collection"); } Map<String, ChangesFilterListsWrapper> changesMap = new HashMap<String, ChangesFilterListsWrapper>(); List<ChangesKey> processedItemKeys = new ArrayList<ChangesKey>(); DataContainer dc = ctx.getCache().getAdvancedCache().getDataContainer(); Set keys = dc.keySet(); InternalCacheEntry entry; // collect all cache entries into the following map: // <WS ID> : <Contracted lists of added/removed nodes> for (Object k : keys) { if ((entry = dc.get(k)) != null) { if (entry.getValue() instanceof ChangesFilterListsWrapper && entry.getKey() instanceof ChangesKey) { if (debugEnabled) { LOG.debug("Received list wrapper, start indexing..."); } // get stale List that was not processed ChangesFilterListsWrapper staleListIncache = (ChangesFilterListsWrapper)entry.getValue(); ChangesKey key = (ChangesKey)entry.getKey(); // get newly created wrapper instance ChangesFilterListsWrapper listToPush = changesMap.get(key.getWsId()); if (listToPush == null) { listToPush = new ChangesFilterListsWrapper(new HashSet<String>(), new HashSet<String>(), new HashSet<String>(), new HashSet<String>()); changesMap.put(key.getWsId(), listToPush); } // copying lists into the new wrapper if (staleListIncache.getParentAddedNodes() != null) listToPush.getParentAddedNodes().addAll(staleListIncache.getParentAddedNodes()); if (staleListIncache.getParentRemovedNodes() != null) listToPush.getParentRemovedNodes().addAll(staleListIncache.getParentRemovedNodes()); if (staleListIncache.getAddedNodes() != null) listToPush.getAddedNodes().addAll(staleListIncache.getAddedNodes()); if (staleListIncache.getRemovedNodes() != null) listToPush.getRemovedNodes().addAll(staleListIncache.getRemovedNodes()); processedItemKeys.add(key); } } } // process all lists for each workspace for (Entry<String, ChangesFilterListsWrapper> changesEntry : changesMap.entrySet()) { // create key based on wsId and generated id ChangesKey changesKey = new ChangesKey(changesEntry.getKey(), IdGenerator.generate()); ctx.getCache().putAsync(changesKey, changesEntry.getValue()); } for (ChangesKey key : processedItemKeys) { ctx.getCache().removeAsync(key); } if (debugEnabled) { LOG.debug("in-memory state passed to cache cacheStore successfully"); } }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "protected", "void", "doPushState", "(", ")", "{", "final", "boolean", "debugEnabled", "=", "LOG", ".", "isDebugEnabled", "(", ")", ";", "if", "(", "debugEnabled", ")", "{", "LOG", ".", "debug", "(", "\"st...
Flushes all cache content to underlying CacheStore
[ "Flushes", "all", "cache", "content", "to", "underlying", "CacheStore" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java#L166-L239
136,339
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavConst.java
WebDavConst.getStatusDescription
public static String getStatusDescription(int status) { String description = ""; Integer statusKey = new Integer(status); if (statusDescriptions.containsKey(statusKey)) { description = statusDescriptions.get(statusKey); } return String.format("%s %d %s", WebDavConst.HTTPVER, status, description); }
java
public static String getStatusDescription(int status) { String description = ""; Integer statusKey = new Integer(status); if (statusDescriptions.containsKey(statusKey)) { description = statusDescriptions.get(statusKey); } return String.format("%s %d %s", WebDavConst.HTTPVER, status, description); }
[ "public", "static", "String", "getStatusDescription", "(", "int", "status", ")", "{", "String", "description", "=", "\"\"", ";", "Integer", "statusKey", "=", "new", "Integer", "(", "status", ")", ";", "if", "(", "statusDescriptions", ".", "containsKey", "(", ...
Returns status description by it's code. @param status Status code @return Status Description
[ "Returns", "status", "description", "by", "it", "s", "code", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavConst.java#L540-L551
136,340
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
StreamPersistedValueData.spoolContent
private void spoolContent(InputStream is) throws IOException, FileNotFoundException { SwapFile swapFile = SwapFile.get(spoolConfig.tempDirectory, System.currentTimeMillis() + "_" + SEQUENCE.incrementAndGet(), spoolConfig.fileCleaner); try { OutputStream os = PrivilegedFileHelper.fileOutputStream(swapFile); try { byte[] bytes = new byte[1024]; int length; while ((length = is.read(bytes)) != -1) { os.write(bytes, 0, length); } } finally { os.close(); } } finally { swapFile.spoolDone(); is.close(); } tempFile = swapFile; }
java
private void spoolContent(InputStream is) throws IOException, FileNotFoundException { SwapFile swapFile = SwapFile.get(spoolConfig.tempDirectory, System.currentTimeMillis() + "_" + SEQUENCE.incrementAndGet(), spoolConfig.fileCleaner); try { OutputStream os = PrivilegedFileHelper.fileOutputStream(swapFile); try { byte[] bytes = new byte[1024]; int length; while ((length = is.read(bytes)) != -1) { os.write(bytes, 0, length); } } finally { os.close(); } } finally { swapFile.spoolDone(); is.close(); } tempFile = swapFile; }
[ "private", "void", "spoolContent", "(", "InputStream", "is", ")", "throws", "IOException", ",", "FileNotFoundException", "{", "SwapFile", "swapFile", "=", "SwapFile", ".", "get", "(", "spoolConfig", ".", "tempDirectory", ",", "System", ".", "currentTimeMillis", "(...
Spools the content extracted from the URL
[ "Spools", "the", "content", "extracted", "from", "the", "URL" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java#L369-L397
136,341
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/misc/Pattern.java
Pattern.match
public MatchResult match(QPath input) { try { return match(new Context(input)).getMatchResult(); } catch (RepositoryException e) { throw (IllegalArgumentException)new IllegalArgumentException("QPath not normalized").initCause(e); } }
java
public MatchResult match(QPath input) { try { return match(new Context(input)).getMatchResult(); } catch (RepositoryException e) { throw (IllegalArgumentException)new IllegalArgumentException("QPath not normalized").initCause(e); } }
[ "public", "MatchResult", "match", "(", "QPath", "input", ")", "{", "try", "{", "return", "match", "(", "new", "Context", "(", "input", ")", ")", ".", "getMatchResult", "(", ")", ";", "}", "catch", "(", "RepositoryException", "e", ")", "{", "throw", "("...
Matches this pattern against the input. @param input path to match with this pattern @return result from the matching <code>pattern</code> against <code>input</code> @throws IllegalArgumentException if <code>input</code> is not normalized
[ "Matches", "this", "pattern", "against", "the", "input", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/misc/Pattern.java#L43-L53
136,342
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/ChangesListener.java
ChangesListener.addPathsWithUnknownChangedSize
private void addPathsWithUnknownChangedSize(ChangesItem changesItem, ItemState state) { if (!state.isPersisted() && (state.isDeleted() || state.isRenamed())) { String itemPath = getPath(state.getData().getQPath()); for (String trackedPath : quotaPersister.getAllTrackedNodes(rName, wsName)) { if (itemPath.startsWith(trackedPath)) { changesItem.addPathWithUnknownChangedSize(itemPath); } } } }
java
private void addPathsWithUnknownChangedSize(ChangesItem changesItem, ItemState state) { if (!state.isPersisted() && (state.isDeleted() || state.isRenamed())) { String itemPath = getPath(state.getData().getQPath()); for (String trackedPath : quotaPersister.getAllTrackedNodes(rName, wsName)) { if (itemPath.startsWith(trackedPath)) { changesItem.addPathWithUnknownChangedSize(itemPath); } } } }
[ "private", "void", "addPathsWithUnknownChangedSize", "(", "ChangesItem", "changesItem", ",", "ItemState", "state", ")", "{", "if", "(", "!", "state", ".", "isPersisted", "(", ")", "&&", "(", "state", ".", "isDeleted", "(", ")", "||", "state", ".", "isRenamed...
Checks if changes were made but changed size is unknown. If so, determinate for which nodes data size should be recalculated at all and put those paths into respective collection.
[ "Checks", "if", "changes", "were", "made", "but", "changed", "size", "is", "unknown", ".", "If", "so", "determinate", "for", "which", "nodes", "data", "size", "should", "be", "recalculated", "at", "all", "and", "put", "those", "paths", "into", "respective", ...
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/ChangesListener.java#L188-L202
136,343
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/ChangesListener.java
ChangesListener.behaveWhenQuotaExceeded
private void behaveWhenQuotaExceeded(String message) throws ExceededQuotaLimitException { switch (exceededQuotaBehavior) { case EXCEPTION : throw new ExceededQuotaLimitException(message); case WARNING : LOG.warn(message); break; } }
java
private void behaveWhenQuotaExceeded(String message) throws ExceededQuotaLimitException { switch (exceededQuotaBehavior) { case EXCEPTION : throw new ExceededQuotaLimitException(message); case WARNING : LOG.warn(message); break; } }
[ "private", "void", "behaveWhenQuotaExceeded", "(", "String", "message", ")", "throws", "ExceededQuotaLimitException", "{", "switch", "(", "exceededQuotaBehavior", ")", "{", "case", "EXCEPTION", ":", "throw", "new", "ExceededQuotaLimitException", "(", "message", ")", "...
What to do if data size exceeded quota limit. Throwing exception or logging only. Depends on preconfigured parameter. @param message the detail message for exception or log operation @throws ExceededQuotaLimitException if current behavior is {@link ExceededQuotaBehavior#EXCEPTION}
[ "What", "to", "do", "if", "data", "size", "exceeded", "quota", "limit", ".", "Throwing", "exception", "or", "logging", "only", ".", "Depends", "on", "preconfigured", "parameter", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/ChangesListener.java#L382-L393
136,344
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/ChangesListener.java
ChangesListener.pushChangesToCoordinator
protected void pushChangesToCoordinator(ChangesItem changesItem) throws SecurityException, RPCException { if (!changesItem.isEmpty()) { rpcService.executeCommandOnCoordinator(applyPersistedChangesTask, true, changesItem); } }
java
protected void pushChangesToCoordinator(ChangesItem changesItem) throws SecurityException, RPCException { if (!changesItem.isEmpty()) { rpcService.executeCommandOnCoordinator(applyPersistedChangesTask, true, changesItem); } }
[ "protected", "void", "pushChangesToCoordinator", "(", "ChangesItem", "changesItem", ")", "throws", "SecurityException", ",", "RPCException", "{", "if", "(", "!", "changesItem", ".", "isEmpty", "(", ")", ")", "{", "rpcService", ".", "executeCommandOnCoordinator", "("...
Push changes to coordinator to apply.
[ "Push", "changes", "to", "coordinator", "to", "apply", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/ChangesListener.java#L432-L438
136,345
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/ChangesListener.java
ChangesListener.getPath
private String getPath(QPath path) { try { return lFactory.createJCRPath(path).getAsString(false); } catch (RepositoryException e) { throw new IllegalStateException(e.getMessage(), e); } }
java
private String getPath(QPath path) { try { return lFactory.createJCRPath(path).getAsString(false); } catch (RepositoryException e) { throw new IllegalStateException(e.getMessage(), e); } }
[ "private", "String", "getPath", "(", "QPath", "path", ")", "{", "try", "{", "return", "lFactory", ".", "createJCRPath", "(", "path", ")", ".", "getAsString", "(", "false", ")", ";", "}", "catch", "(", "RepositoryException", "e", ")", "{", "throw", "new",...
Returns item absolute path. @param path {@link QPath} representation @throws IllegalStateException if something wrong
[ "Returns", "item", "absolute", "path", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/ChangesListener.java#L463-L473
136,346
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/DummyRPCServiceImpl.java
DummyRPCServiceImpl.executeCommand
private Serializable executeCommand(RemoteCommand command, Serializable... args) throws RPCException { try { return command.execute(args); } catch (Throwable e)//NOSONAR { throw new RPCException(e.getMessage(), e); } }
java
private Serializable executeCommand(RemoteCommand command, Serializable... args) throws RPCException { try { return command.execute(args); } catch (Throwable e)//NOSONAR { throw new RPCException(e.getMessage(), e); } }
[ "private", "Serializable", "executeCommand", "(", "RemoteCommand", "command", ",", "Serializable", "...", "args", ")", "throws", "RPCException", "{", "try", "{", "return", "command", ".", "execute", "(", "args", ")", ";", "}", "catch", "(", "Throwable", "e", ...
Command executing.
[ "Command", "executing", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/quota/DummyRPCServiceImpl.java#L123-L133
136,347
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/ItemStateReader.java
ItemStateReader.read
public ItemState read(ObjectReader in) throws UnknownClassIdException, IOException { // read id int key; if ((key = in.readInt()) != SerializationConstants.ITEM_STATE) { throw new UnknownClassIdException("There is unexpected class [" + key + "]"); } ItemState is = null; try { int state = in.readInt(); boolean isPersisted = in.readBoolean(); boolean eventFire = in.readBoolean(); QPath oldPath = null; if (in.readInt() == SerializationConstants.NOT_NULL_DATA) { byte[] buf = new byte[in.readInt()]; in.readFully(buf); oldPath = QPath.parse(new String(buf, Constants.DEFAULT_ENCODING)); } boolean isNodeData = in.readBoolean(); if (isNodeData) { PersistedNodeDataReader rdr = new PersistedNodeDataReader(); is = new ItemState(rdr.read(in), state, eventFire, null, false, isPersisted, oldPath); } else { PersistedPropertyDataReader rdr = new PersistedPropertyDataReader(holder, spoolConfig); is = new ItemState(rdr.read(in), state, eventFire, null, false, isPersisted, oldPath); } return is; } catch (EOFException e) { throw new StreamCorruptedException("Unexpected EOF in middle of data block."); } catch (IllegalPathException e) { throw new IOException("Data corrupted", e); } }
java
public ItemState read(ObjectReader in) throws UnknownClassIdException, IOException { // read id int key; if ((key = in.readInt()) != SerializationConstants.ITEM_STATE) { throw new UnknownClassIdException("There is unexpected class [" + key + "]"); } ItemState is = null; try { int state = in.readInt(); boolean isPersisted = in.readBoolean(); boolean eventFire = in.readBoolean(); QPath oldPath = null; if (in.readInt() == SerializationConstants.NOT_NULL_DATA) { byte[] buf = new byte[in.readInt()]; in.readFully(buf); oldPath = QPath.parse(new String(buf, Constants.DEFAULT_ENCODING)); } boolean isNodeData = in.readBoolean(); if (isNodeData) { PersistedNodeDataReader rdr = new PersistedNodeDataReader(); is = new ItemState(rdr.read(in), state, eventFire, null, false, isPersisted, oldPath); } else { PersistedPropertyDataReader rdr = new PersistedPropertyDataReader(holder, spoolConfig); is = new ItemState(rdr.read(in), state, eventFire, null, false, isPersisted, oldPath); } return is; } catch (EOFException e) { throw new StreamCorruptedException("Unexpected EOF in middle of data block."); } catch (IllegalPathException e) { throw new IOException("Data corrupted", e); } }
[ "public", "ItemState", "read", "(", "ObjectReader", "in", ")", "throws", "UnknownClassIdException", ",", "IOException", "{", "// read id\r", "int", "key", ";", "if", "(", "(", "key", "=", "in", ".", "readInt", "(", ")", ")", "!=", "SerializationConstants", "...
Read and set ItemState data. @param in ObjectReader. @return ItemState 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", "ItemState", "data", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/ItemStateReader.java#L74-L119
136,348
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/SearchCommand.java
SearchCommand.search
public Response search(Session session, HierarchicalProperty body, String baseURI) { try { SearchRequestEntity requestEntity = new SearchRequestEntity(body); Query query = session.getWorkspace().getQueryManager().createQuery(requestEntity.getQuery(), requestEntity.getQueryLanguage()); QueryResult queryResult = query.execute(); WebDavNamespaceContext nsContext = new WebDavNamespaceContext(session); SearchResultResponseEntity searchResult = new SearchResultResponseEntity(queryResult, nsContext, baseURI); return Response.status(HTTPStatus.MULTISTATUS).entity(searchResult).build(); } catch (PathNotFoundException exc) { return Response.status(HTTPStatus.NOT_FOUND).entity(exc.getMessage()).build(); } catch (UnsupportedQueryException exc) { return Response.status(HTTPStatus.BAD_REQUEST).entity(exc.getMessage()).build(); } catch (Exception exc) { LOG.error(exc.getMessage(), exc); return Response.serverError().entity(exc.getMessage()).build(); } }
java
public Response search(Session session, HierarchicalProperty body, String baseURI) { try { SearchRequestEntity requestEntity = new SearchRequestEntity(body); Query query = session.getWorkspace().getQueryManager().createQuery(requestEntity.getQuery(), requestEntity.getQueryLanguage()); QueryResult queryResult = query.execute(); WebDavNamespaceContext nsContext = new WebDavNamespaceContext(session); SearchResultResponseEntity searchResult = new SearchResultResponseEntity(queryResult, nsContext, baseURI); return Response.status(HTTPStatus.MULTISTATUS).entity(searchResult).build(); } catch (PathNotFoundException exc) { return Response.status(HTTPStatus.NOT_FOUND).entity(exc.getMessage()).build(); } catch (UnsupportedQueryException exc) { return Response.status(HTTPStatus.BAD_REQUEST).entity(exc.getMessage()).build(); } catch (Exception exc) { LOG.error(exc.getMessage(), exc); return Response.serverError().entity(exc.getMessage()).build(); } }
[ "public", "Response", "search", "(", "Session", "session", ",", "HierarchicalProperty", "body", ",", "String", "baseURI", ")", "{", "try", "{", "SearchRequestEntity", "requestEntity", "=", "new", "SearchRequestEntity", "(", "body", ")", ";", "Query", "query", "=...
Webdav search method implementation. @param session current session @param body rrequest body @param baseURI base uri @return the instance of javax.ws.rs.core.Response
[ "Webdav", "search", "method", "implementation", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/SearchCommand.java#L59-L91
136,349
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScoreNode.java
ScoreNode.getDoc
public int getDoc(IndexReader reader) throws IOException { if (doc == -1) { TermDocs docs = reader.termDocs(new Term(FieldNames.UUID, id.toString())); try { if (docs.next()) { return docs.doc(); } else { throw new IOException("Node with id " + id + " not found in index"); } } finally { docs.close(); } } else { return doc; } }
java
public int getDoc(IndexReader reader) throws IOException { if (doc == -1) { TermDocs docs = reader.termDocs(new Term(FieldNames.UUID, id.toString())); try { if (docs.next()) { return docs.doc(); } else { throw new IOException("Node with id " + id + " not found in index"); } } finally { docs.close(); } } else { return doc; } }
[ "public", "int", "getDoc", "(", "IndexReader", "reader", ")", "throws", "IOException", "{", "if", "(", "doc", "==", "-", "1", ")", "{", "TermDocs", "docs", "=", "reader", ".", "termDocs", "(", "new", "Term", "(", "FieldNames", ".", "UUID", ",", "id", ...
Returns the document number for this score node. @param reader the current index reader to look up the document if needed. @return the document number. @throws IOException if an error occurs while reading from the index or the node is not present in the index.
[ "Returns", "the", "document", "number", "for", "this", "score", "node", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScoreNode.java#L93-L108
136,350
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeConverter.java
NodeTypeConverter.safeListToArray
private String[] safeListToArray(List<String> v) { return v != null ? v.toArray(new String[v.size()]) : new String[0]; }
java
private String[] safeListToArray(List<String> v) { return v != null ? v.toArray(new String[v.size()]) : new String[0]; }
[ "private", "String", "[", "]", "safeListToArray", "(", "List", "<", "String", ">", "v", ")", "{", "return", "v", "!=", "null", "?", "v", ".", "toArray", "(", "new", "String", "[", "v", ".", "size", "(", ")", "]", ")", ":", "new", "String", "[", ...
Convert list to array. @param v list of string @return array of string, empty array if list null.
[ "Convert", "list", "to", "array", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeConverter.java#L166-L169
136,351
exoplatform/jcr
exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/IndexCleanHelper.java
IndexCleanHelper.removeWorkspaceIndex
public void removeWorkspaceIndex(WorkspaceEntry wsConfig, boolean isSystem) throws RepositoryConfigurationException, IOException { String indexDirName = wsConfig.getQueryHandler().getParameterValue(QueryHandlerParams.PARAM_INDEX_DIR); File indexDir = new File(indexDirName); if (PrivilegedFileHelper.exists(indexDir)) { removeFolder(indexDir); } if (isSystem) { File systemIndexDir = new File(indexDirName + "_" + SystemSearchManager.INDEX_DIR_SUFFIX); if (PrivilegedFileHelper.exists(systemIndexDir)) { removeFolder(systemIndexDir); } } }
java
public void removeWorkspaceIndex(WorkspaceEntry wsConfig, boolean isSystem) throws RepositoryConfigurationException, IOException { String indexDirName = wsConfig.getQueryHandler().getParameterValue(QueryHandlerParams.PARAM_INDEX_DIR); File indexDir = new File(indexDirName); if (PrivilegedFileHelper.exists(indexDir)) { removeFolder(indexDir); } if (isSystem) { File systemIndexDir = new File(indexDirName + "_" + SystemSearchManager.INDEX_DIR_SUFFIX); if (PrivilegedFileHelper.exists(systemIndexDir)) { removeFolder(systemIndexDir); } } }
[ "public", "void", "removeWorkspaceIndex", "(", "WorkspaceEntry", "wsConfig", ",", "boolean", "isSystem", ")", "throws", "RepositoryConfigurationException", ",", "IOException", "{", "String", "indexDirName", "=", "wsConfig", ".", "getQueryHandler", "(", ")", ".", "getP...
Remove all file of workspace index. @param wsConfig - workspace configuration. @param isSystem - 'true' to clean system workspace. @throws RepositoryConfigurationException - exception on parsing workspace configuration @throws IOException - exception on remove index folder
[ "Remove", "all", "file", "of", "workspace", "index", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/IndexCleanHelper.java#L48-L67
136,352
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
SessionChangesLog.pushLog
public PlainChangesLog pushLog(QPath rootPath) { // session instance is always present in SessionChangesLog PlainChangesLog cLog = new PlainChangesLogImpl(getDescendantsChanges(rootPath), session); if (rootPath.equals(Constants.ROOT_PATH)) { clear(); } else { remove(rootPath); } return cLog; }
java
public PlainChangesLog pushLog(QPath rootPath) { // session instance is always present in SessionChangesLog PlainChangesLog cLog = new PlainChangesLogImpl(getDescendantsChanges(rootPath), session); if (rootPath.equals(Constants.ROOT_PATH)) { clear(); } else { remove(rootPath); } return cLog; }
[ "public", "PlainChangesLog", "pushLog", "(", "QPath", "rootPath", ")", "{", "// session instance is always present in SessionChangesLog", "PlainChangesLog", "cLog", "=", "new", "PlainChangesLogImpl", "(", "getDescendantsChanges", "(", "rootPath", ")", ",", "session", ")", ...
Creates new changes log with rootPath and its descendants of this one and removes those entries. @param rootPath @return ItemDataChangesLog
[ "Creates", "new", "changes", "log", "with", "rootPath", "and", "its", "descendants", "of", "this", "one", "and", "removes", "those", "entries", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java#L107-L120
136,353
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
SysViewWorkspaceInitializer.doRestore
protected void doRestore() throws Throwable { PlainChangesLog changes = read(); TransactionChangesLog tLog = new TransactionChangesLog(changes); tLog.setSystemId(Constants.JCR_CORE_RESTORE_WORKSPACE_INITIALIZER_SYSTEM_ID); // mark changes dataManager.save(tLog); }
java
protected void doRestore() throws Throwable { PlainChangesLog changes = read(); TransactionChangesLog tLog = new TransactionChangesLog(changes); tLog.setSystemId(Constants.JCR_CORE_RESTORE_WORKSPACE_INITIALIZER_SYSTEM_ID); // mark changes dataManager.save(tLog); }
[ "protected", "void", "doRestore", "(", ")", "throws", "Throwable", "{", "PlainChangesLog", "changes", "=", "read", "(", ")", ";", "TransactionChangesLog", "tLog", "=", "new", "TransactionChangesLog", "(", "changes", ")", ";", "tLog", ".", "setSystemId", "(", "...
Perform restore operation.
[ "Perform", "restore", "operation", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java#L532-L540
136,354
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserByQueryJCRUserListAccess.java
UserByQueryJCRUserListAccess.removeAsterisk
private String removeAsterisk(String str) { if (str.startsWith("*")) { str = str.substring(1); } if (str.endsWith("*")) { str = str.substring(0, str.length() - 1); } return str; }
java
private String removeAsterisk(String str) { if (str.startsWith("*")) { str = str.substring(1); } if (str.endsWith("*")) { str = str.substring(0, str.length() - 1); } return str; }
[ "private", "String", "removeAsterisk", "(", "String", "str", ")", "{", "if", "(", "str", ".", "startsWith", "(", "\"*\"", ")", ")", "{", "str", "=", "str", ".", "substring", "(", "1", ")", ";", "}", "if", "(", "str", ".", "endsWith", "(", "\"*\"", ...
Removes asterisk from beginning and from end of statement.
[ "Removes", "asterisk", "from", "beginning", "and", "from", "end", "of", "statement", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserByQueryJCRUserListAccess.java#L70-L83
136,355
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/VersionHistoryResource.java
VersionHistoryResource.getVersions
public Set<VersionResource> getVersions() throws RepositoryException, IllegalResourceTypeException { Set<VersionResource> resources = new HashSet<VersionResource>(); VersionIterator versions = versionHistory.getAllVersions(); while (versions.hasNext()) { Version version = versions.nextVersion(); if ("jcr:rootVersion".equals(version.getName())) { continue; } resources .add(new VersionResource(versionURI(version.getName()), versionedResource, version, namespaceContext)); } return resources; }
java
public Set<VersionResource> getVersions() throws RepositoryException, IllegalResourceTypeException { Set<VersionResource> resources = new HashSet<VersionResource>(); VersionIterator versions = versionHistory.getAllVersions(); while (versions.hasNext()) { Version version = versions.nextVersion(); if ("jcr:rootVersion".equals(version.getName())) { continue; } resources .add(new VersionResource(versionURI(version.getName()), versionedResource, version, namespaceContext)); } return resources; }
[ "public", "Set", "<", "VersionResource", ">", "getVersions", "(", ")", "throws", "RepositoryException", ",", "IllegalResourceTypeException", "{", "Set", "<", "VersionResource", ">", "resources", "=", "new", "HashSet", "<", "VersionResource", ">", "(", ")", ";", ...
Returns all versions of a resource. @return all versions of a resource @throws RepositoryException {@link RepositoryException} @throws IllegalResourceTypeException {@link IllegalResourceTypeException}
[ "Returns", "all", "versions", "of", "a", "resource", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/VersionHistoryResource.java#L97-L113
136,356
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/VersionHistoryResource.java
VersionHistoryResource.getVersion
public VersionResource getVersion(String name) throws RepositoryException, IllegalResourceTypeException { return new VersionResource(versionURI(name), versionedResource, versionHistory.getVersion(name), namespaceContext); }
java
public VersionResource getVersion(String name) throws RepositoryException, IllegalResourceTypeException { return new VersionResource(versionURI(name), versionedResource, versionHistory.getVersion(name), namespaceContext); }
[ "public", "VersionResource", "getVersion", "(", "String", "name", ")", "throws", "RepositoryException", ",", "IllegalResourceTypeException", "{", "return", "new", "VersionResource", "(", "versionURI", "(", "name", ")", ",", "versionedResource", ",", "versionHistory", ...
Returns the version of resouce by name. @param name version name @return version of a resource @throws RepositoryException {@link RepositoryException} @throws IllegalResourceTypeException {@link IllegalResourceTypeException}
[ "Returns", "the", "version", "of", "resouce", "by", "name", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/VersionHistoryResource.java#L123-L126
136,357
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/VersionHistoryResource.java
VersionHistoryResource.versionURI
protected final URI versionURI(String versionName) { return URI.create(versionedResource.getIdentifier().toASCIIString() + "?version=" + versionName); }
java
protected final URI versionURI(String versionName) { return URI.create(versionedResource.getIdentifier().toASCIIString() + "?version=" + versionName); }
[ "protected", "final", "URI", "versionURI", "(", "String", "versionName", ")", "{", "return", "URI", ".", "create", "(", "versionedResource", ".", "getIdentifier", "(", ")", ".", "toASCIIString", "(", ")", "+", "\"?version=\"", "+", "versionName", ")", ";", "...
Returns URI of the resource version. @param versionName version name @return URI of the resource version
[ "Returns", "URI", "of", "the", "resource", "version", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/VersionHistoryResource.java#L134-L137
136,358
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java
TreeFileIOChannel.buildPathX8
protected String buildPathX8(String fileName) { final int xLength = 8; char[] chs = fileName.toCharArray(); StringBuilder path = new StringBuilder(); for (int i = 0; i < xLength; i++) { path.append(File.separator).append(chs[i]); } path.append(fileName.substring(xLength)); return path.toString(); }
java
protected String buildPathX8(String fileName) { final int xLength = 8; char[] chs = fileName.toCharArray(); StringBuilder path = new StringBuilder(); for (int i = 0; i < xLength; i++) { path.append(File.separator).append(chs[i]); } path.append(fileName.substring(xLength)); return path.toString(); }
[ "protected", "String", "buildPathX8", "(", "String", "fileName", ")", "{", "final", "int", "xLength", "=", "8", ";", "char", "[", "]", "chs", "=", "fileName", ".", "toCharArray", "(", ")", ";", "StringBuilder", "path", "=", "new", "StringBuilder", "(", "...
best for now, 12.07.07
[ "best", "for", "now", "12", ".", "07", ".", "07" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java#L102-L113
136,359
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java
FileBasedNamespaceMappings.load
private void load() throws IOException { if (PrivilegedFileHelper.exists(storage)) { InputStream in = PrivilegedFileHelper.fileInputStream(storage); try { Properties props = new Properties(); log.debug("loading namespace mappings..."); props.load(in); // read mappings from properties Iterator<Object> iter = props.keySet().iterator(); while (iter.hasNext()) { String prefix = (String)iter.next(); String uri = props.getProperty(prefix); log.debug(prefix + " -> " + uri); prefixToURI.put(prefix, uri); uriToPrefix.put(uri, prefix); } prefixCount = props.size(); log.debug("namespace mappings loaded."); } finally { in.close(); } } }
java
private void load() throws IOException { if (PrivilegedFileHelper.exists(storage)) { InputStream in = PrivilegedFileHelper.fileInputStream(storage); try { Properties props = new Properties(); log.debug("loading namespace mappings..."); props.load(in); // read mappings from properties Iterator<Object> iter = props.keySet().iterator(); while (iter.hasNext()) { String prefix = (String)iter.next(); String uri = props.getProperty(prefix); log.debug(prefix + " -> " + uri); prefixToURI.put(prefix, uri); uriToPrefix.put(uri, prefix); } prefixCount = props.size(); log.debug("namespace mappings loaded."); } finally { in.close(); } } }
[ "private", "void", "load", "(", ")", "throws", "IOException", "{", "if", "(", "PrivilegedFileHelper", ".", "exists", "(", "storage", ")", ")", "{", "InputStream", "in", "=", "PrivilegedFileHelper", ".", "fileInputStream", "(", "storage", ")", ";", "try", "{"...
Loads currently known mappings from a .properties file. @throws IOException if an error occurs while reading from the file.
[ "Loads", "currently", "known", "mappings", "from", "a", ".", "properties", "file", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java#L148-L177
136,360
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java
FileBasedNamespaceMappings.store
private void store() throws IOException { Properties props = new Properties(); // store mappings in properties Iterator<String> iter = prefixToURI.keySet().iterator(); while (iter.hasNext()) { String prefix = iter.next(); String uri = prefixToURI.get(prefix); props.setProperty(prefix, uri); } OutputStream out = PrivilegedFileHelper.fileOutputStream(storage); try { out = new BufferedOutputStream(out); props.store(out, null); } finally { // make sure stream is closed out.close(); } }
java
private void store() throws IOException { Properties props = new Properties(); // store mappings in properties Iterator<String> iter = prefixToURI.keySet().iterator(); while (iter.hasNext()) { String prefix = iter.next(); String uri = prefixToURI.get(prefix); props.setProperty(prefix, uri); } OutputStream out = PrivilegedFileHelper.fileOutputStream(storage); try { out = new BufferedOutputStream(out); props.store(out, null); } finally { // make sure stream is closed out.close(); } }
[ "private", "void", "store", "(", ")", "throws", "IOException", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "// store mappings in properties", "Iterator", "<", "String", ">", "iter", "=", "prefixToURI", ".", "keySet", "(", ")", ".", "...
Writes the currently known mappings into a .properties file. @throws IOException if an error occurs while writing the file.
[ "Writes", "the", "currently", "known", "mappings", "into", "a", ".", "properties", "file", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java#L184-L208
136,361
exoplatform/jcr
exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RegistryEntry.java
RegistryEntry.parse
public static RegistryEntry parse(final byte[] bytes) throws IOException, SAXException, ParserConfigurationException { try { return SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<RegistryEntry>() { public RegistryEntry run() throws Exception { return new RegistryEntry(DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new ByteArrayInputStream(bytes))); } }); } catch (PrivilegedActionException pae) { Throwable cause = pae.getCause(); if (cause instanceof ParserConfigurationException) { throw (ParserConfigurationException)cause; } else if (cause instanceof IOException) { throw (IOException)cause; } else if (cause instanceof SAXException) { throw (SAXException)cause; } else if (cause instanceof RuntimeException) { throw (RuntimeException)cause; } else { throw new RuntimeException(cause); } } }
java
public static RegistryEntry parse(final byte[] bytes) throws IOException, SAXException, ParserConfigurationException { try { return SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<RegistryEntry>() { public RegistryEntry run() throws Exception { return new RegistryEntry(DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new ByteArrayInputStream(bytes))); } }); } catch (PrivilegedActionException pae) { Throwable cause = pae.getCause(); if (cause instanceof ParserConfigurationException) { throw (ParserConfigurationException)cause; } else if (cause instanceof IOException) { throw (IOException)cause; } else if (cause instanceof SAXException) { throw (SAXException)cause; } else if (cause instanceof RuntimeException) { throw (RuntimeException)cause; } else { throw new RuntimeException(cause); } } }
[ "public", "static", "RegistryEntry", "parse", "(", "final", "byte", "[", "]", "bytes", ")", "throws", "IOException", ",", "SAXException", ",", "ParserConfigurationException", "{", "try", "{", "return", "SecurityHelper", ".", "doPrivilegedExceptionAction", "(", "new"...
Factory method to create RegistryEntry from serialized XML @param bytes @return RegistryEntry @throws IOException @throws SAXException @throws ParserConfigurationException
[ "Factory", "method", "to", "create", "RegistryEntry", "from", "serialized", "XML" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RegistryEntry.java#L98-L135
136,362
EsotericSoftware/jsonbeans
src/com/esotericsoftware/jsonbeans/Json.java
Json.addClassTag
public void addClassTag (String tag, Class type) { tagToClass.put(tag, type); classToTag.put(type, tag); }
java
public void addClassTag (String tag, Class type) { tagToClass.put(tag, type); classToTag.put(type, tag); }
[ "public", "void", "addClassTag", "(", "String", "tag", ",", "Class", "type", ")", "{", "tagToClass", ".", "put", "(", "tag", ",", "type", ")", ";", "classToTag", ".", "put", "(", "type", ",", "tag", ")", ";", "}" ]
Sets a tag to use instead of the fully qualifier class name. This can make the JSON easier to read.
[ "Sets", "a", "tag", "to", "use", "instead", "of", "the", "fully", "qualifier", "class", "name", ".", "This", "can", "make", "the", "JSON", "easier", "to", "read", "." ]
ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f
https://github.com/EsotericSoftware/jsonbeans/blob/ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f/src/com/esotericsoftware/jsonbeans/Json.java#L96-L99
136,363
EsotericSoftware/jsonbeans
src/com/esotericsoftware/jsonbeans/Json.java
Json.setSerializer
public <T> void setSerializer (Class<T> type, JsonSerializer<T> serializer) { classToSerializer.put(type, serializer); }
java
public <T> void setSerializer (Class<T> type, JsonSerializer<T> serializer) { classToSerializer.put(type, serializer); }
[ "public", "<", "T", ">", "void", "setSerializer", "(", "Class", "<", "T", ">", "type", ",", "JsonSerializer", "<", "T", ">", "serializer", ")", "{", "classToSerializer", ".", "put", "(", "type", ",", "serializer", ")", ";", "}" ]
Registers a serializer to use for the specified type instead of the default behavior of serializing all of an objects fields.
[ "Registers", "a", "serializer", "to", "use", "for", "the", "specified", "type", "instead", "of", "the", "default", "behavior", "of", "serializing", "all", "of", "an", "objects", "fields", "." ]
ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f
https://github.com/EsotericSoftware/jsonbeans/blob/ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f/src/com/esotericsoftware/jsonbeans/Json.java#L126-L128
136,364
EsotericSoftware/jsonbeans
src/com/esotericsoftware/jsonbeans/Json.java
Json.setElementType
public void setElementType (Class type, String fieldName, Class elementType) { ObjectMap<String, FieldMetadata> fields = getFields(type); FieldMetadata metadata = fields.get(fieldName); if (metadata == null) throw new JsonException("Field not found: " + fieldName + " (" + type.getName() + ")"); metadata.elementType = elementType; }
java
public void setElementType (Class type, String fieldName, Class elementType) { ObjectMap<String, FieldMetadata> fields = getFields(type); FieldMetadata metadata = fields.get(fieldName); if (metadata == null) throw new JsonException("Field not found: " + fieldName + " (" + type.getName() + ")"); metadata.elementType = elementType; }
[ "public", "void", "setElementType", "(", "Class", "type", ",", "String", "fieldName", ",", "Class", "elementType", ")", "{", "ObjectMap", "<", "String", ",", "FieldMetadata", ">", "fields", "=", "getFields", "(", "type", ")", ";", "FieldMetadata", "metadata", ...
Sets the type of elements in a collection. When the element type is known, the class for each element in the collection does not need to be written unless different from the element type.
[ "Sets", "the", "type", "of", "elements", "in", "a", "collection", ".", "When", "the", "element", "type", "is", "known", "the", "class", "for", "each", "element", "in", "the", "collection", "does", "not", "need", "to", "be", "written", "unless", "different"...
ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f
https://github.com/EsotericSoftware/jsonbeans/blob/ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f/src/com/esotericsoftware/jsonbeans/Json.java#L141-L146
136,365
EsotericSoftware/jsonbeans
src/com/esotericsoftware/jsonbeans/Json.java
Json.setWriter
public void setWriter (Writer writer) { if (!(writer instanceof JsonWriter)) writer = new JsonWriter(writer); this.writer = (JsonWriter)writer; this.writer.setOutputType(outputType); this.writer.setQuoteLongValues(quoteLongValues); }
java
public void setWriter (Writer writer) { if (!(writer instanceof JsonWriter)) writer = new JsonWriter(writer); this.writer = (JsonWriter)writer; this.writer.setOutputType(outputType); this.writer.setQuoteLongValues(quoteLongValues); }
[ "public", "void", "setWriter", "(", "Writer", "writer", ")", "{", "if", "(", "!", "(", "writer", "instanceof", "JsonWriter", ")", ")", "writer", "=", "new", "JsonWriter", "(", "writer", ")", ";", "this", ".", "writer", "=", "(", "JsonWriter", ")", "wri...
Sets the writer where JSON output will be written. This is only necessary when not using the toJson methods.
[ "Sets", "the", "writer", "where", "JSON", "output", "will", "be", "written", ".", "This", "is", "only", "necessary", "when", "not", "using", "the", "toJson", "methods", "." ]
ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f
https://github.com/EsotericSoftware/jsonbeans/blob/ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f/src/com/esotericsoftware/jsonbeans/Json.java#L251-L256
136,366
EsotericSoftware/jsonbeans
src/com/esotericsoftware/jsonbeans/Json.java
Json.writeFields
public void writeFields (Object object) { Class type = object.getClass(); Object[] defaultValues = getDefaultValues(type); OrderedMap<String, FieldMetadata> fields = getFields(type); int i = 0; for (FieldMetadata metadata : new OrderedMapValues<FieldMetadata>(fields)) { Field field = metadata.field; try { Object value = field.get(object); if (defaultValues != null) { Object defaultValue = defaultValues[i++]; if (value == null && defaultValue == null) continue; if (value != null && defaultValue != null) { if (value.equals(defaultValue)) continue; if (value.getClass().isArray() && defaultValue.getClass().isArray()) { equals1[0] = value; equals2[0] = defaultValue; if (Arrays.deepEquals(equals1, equals2)) continue; } } } if (debug) System.out.println("Writing field: " + field.getName() + " (" + type.getName() + ")"); writer.name(field.getName()); writeValue(value, field.getType(), metadata.elementType); } catch (IllegalAccessException ex) { throw new JsonException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex); } catch (JsonException ex) { ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } catch (Exception runtimeEx) { JsonException ex = new JsonException(runtimeEx); ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } } }
java
public void writeFields (Object object) { Class type = object.getClass(); Object[] defaultValues = getDefaultValues(type); OrderedMap<String, FieldMetadata> fields = getFields(type); int i = 0; for (FieldMetadata metadata : new OrderedMapValues<FieldMetadata>(fields)) { Field field = metadata.field; try { Object value = field.get(object); if (defaultValues != null) { Object defaultValue = defaultValues[i++]; if (value == null && defaultValue == null) continue; if (value != null && defaultValue != null) { if (value.equals(defaultValue)) continue; if (value.getClass().isArray() && defaultValue.getClass().isArray()) { equals1[0] = value; equals2[0] = defaultValue; if (Arrays.deepEquals(equals1, equals2)) continue; } } } if (debug) System.out.println("Writing field: " + field.getName() + " (" + type.getName() + ")"); writer.name(field.getName()); writeValue(value, field.getType(), metadata.elementType); } catch (IllegalAccessException ex) { throw new JsonException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex); } catch (JsonException ex) { ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } catch (Exception runtimeEx) { JsonException ex = new JsonException(runtimeEx); ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } } }
[ "public", "void", "writeFields", "(", "Object", "object", ")", "{", "Class", "type", "=", "object", ".", "getClass", "(", ")", ";", "Object", "[", "]", "defaultValues", "=", "getDefaultValues", "(", "type", ")", ";", "OrderedMap", "<", "String", ",", "Fi...
Writes all fields of the specified object to the current JSON object.
[ "Writes", "all", "fields", "of", "the", "specified", "object", "to", "the", "current", "JSON", "object", "." ]
ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f
https://github.com/EsotericSoftware/jsonbeans/blob/ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f/src/com/esotericsoftware/jsonbeans/Json.java#L263-L301
136,367
EsotericSoftware/jsonbeans
src/com/esotericsoftware/jsonbeans/Json.java
Json.writeField
public void writeField (Object object, String fieldName, String jsonName, Class elementType) { Class type = object.getClass(); ObjectMap<String, FieldMetadata> fields = getFields(type); FieldMetadata metadata = fields.get(fieldName); if (metadata == null) throw new JsonException("Field not found: " + fieldName + " (" + type.getName() + ")"); Field field = metadata.field; if (elementType == null) elementType = metadata.elementType; try { if (debug) System.out.println("Writing field: " + field.getName() + " (" + type.getName() + ")"); writer.name(jsonName); writeValue(field.get(object), field.getType(), elementType); } catch (IllegalAccessException ex) { throw new JsonException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex); } catch (JsonException ex) { ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } catch (Exception runtimeEx) { JsonException ex = new JsonException(runtimeEx); ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } }
java
public void writeField (Object object, String fieldName, String jsonName, Class elementType) { Class type = object.getClass(); ObjectMap<String, FieldMetadata> fields = getFields(type); FieldMetadata metadata = fields.get(fieldName); if (metadata == null) throw new JsonException("Field not found: " + fieldName + " (" + type.getName() + ")"); Field field = metadata.field; if (elementType == null) elementType = metadata.elementType; try { if (debug) System.out.println("Writing field: " + field.getName() + " (" + type.getName() + ")"); writer.name(jsonName); writeValue(field.get(object), field.getType(), elementType); } catch (IllegalAccessException ex) { throw new JsonException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex); } catch (JsonException ex) { ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } catch (Exception runtimeEx) { JsonException ex = new JsonException(runtimeEx); ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } }
[ "public", "void", "writeField", "(", "Object", "object", ",", "String", "fieldName", ",", "String", "jsonName", ",", "Class", "elementType", ")", "{", "Class", "type", "=", "object", ".", "getClass", "(", ")", ";", "ObjectMap", "<", "String", ",", "FieldMe...
Writes the specified field to the current JSON object. @param elementType May be null if the type is unknown.
[ "Writes", "the", "specified", "field", "to", "the", "current", "JSON", "object", "." ]
ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f
https://github.com/EsotericSoftware/jsonbeans/blob/ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f/src/com/esotericsoftware/jsonbeans/Json.java#L355-L376
136,368
EsotericSoftware/jsonbeans
src/com/esotericsoftware/jsonbeans/Json.java
Json.writeValue
public void writeValue (String name, Object value) { try { writer.name(name); } catch (IOException ex) { throw new JsonException(ex); } if (value == null) writeValue(value, null, null); else writeValue(value, value.getClass(), null); }
java
public void writeValue (String name, Object value) { try { writer.name(name); } catch (IOException ex) { throw new JsonException(ex); } if (value == null) writeValue(value, null, null); else writeValue(value, value.getClass(), null); }
[ "public", "void", "writeValue", "(", "String", "name", ",", "Object", "value", ")", "{", "try", "{", "writer", ".", "name", "(", "name", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "JsonException", "(", "ex", ")", ";",...
Writes the value as a field on the current JSON object, without writing the actual class. @param value May be null. @see #writeValue(String, Object, Class, Class)
[ "Writes", "the", "value", "as", "a", "field", "on", "the", "current", "JSON", "object", "without", "writing", "the", "actual", "class", "." ]
ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f
https://github.com/EsotericSoftware/jsonbeans/blob/ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f/src/com/esotericsoftware/jsonbeans/Json.java#L381-L391
136,369
EsotericSoftware/jsonbeans
src/com/esotericsoftware/jsonbeans/Json.java
Json.writeValue
public void writeValue (String name, Object value, Class knownType) { try { writer.name(name); } catch (IOException ex) { throw new JsonException(ex); } writeValue(value, knownType, null); }
java
public void writeValue (String name, Object value, Class knownType) { try { writer.name(name); } catch (IOException ex) { throw new JsonException(ex); } writeValue(value, knownType, null); }
[ "public", "void", "writeValue", "(", "String", "name", ",", "Object", "value", ",", "Class", "knownType", ")", "{", "try", "{", "writer", ".", "name", "(", "name", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "JsonExcepti...
Writes the value as a field on the current JSON object, writing the class of the object if it differs from the specified known type. @param value May be null. @param knownType May be null if the type is unknown. @see #writeValue(String, Object, Class, Class)
[ "Writes", "the", "value", "as", "a", "field", "on", "the", "current", "JSON", "object", "writing", "the", "class", "of", "the", "object", "if", "it", "differs", "from", "the", "specified", "known", "type", "." ]
ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f
https://github.com/EsotericSoftware/jsonbeans/blob/ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f/src/com/esotericsoftware/jsonbeans/Json.java#L398-L405
136,370
EsotericSoftware/jsonbeans
src/com/esotericsoftware/jsonbeans/Json.java
Json.writeValue
public void writeValue (Object value) { if (value == null) writeValue(value, null, null); else writeValue(value, value.getClass(), null); }
java
public void writeValue (Object value) { if (value == null) writeValue(value, null, null); else writeValue(value, value.getClass(), null); }
[ "public", "void", "writeValue", "(", "Object", "value", ")", "{", "if", "(", "value", "==", "null", ")", "writeValue", "(", "value", ",", "null", ",", "null", ")", ";", "else", "writeValue", "(", "value", ",", "value", ".", "getClass", "(", ")", ",",...
Writes the value, without writing the class of the object. @param value May be null.
[ "Writes", "the", "value", "without", "writing", "the", "class", "of", "the", "object", "." ]
ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f
https://github.com/EsotericSoftware/jsonbeans/blob/ff4502d0ff86cc77aa5c61d47371d0c66c14fe2f/src/com/esotericsoftware/jsonbeans/Json.java#L423-L428
136,371
Coreoz/Wisp
src/main/java/com/coreoz/wisp/LongRunningJobMonitor.java
LongRunningJobMonitor.detectLongRunningJob
boolean detectLongRunningJob(long currentTime, Job job) { if(job.status() == JobStatus.RUNNING && !longRunningJobs.containsKey(job)) { int jobExecutionsCount = job.executionsCount(); Long jobStartedtimeInMillis = job.lastExecutionStartedTimeInMillis(); Thread threadRunningJob = job.threadRunningJob(); if(jobStartedtimeInMillis != null && threadRunningJob != null && currentTime - jobStartedtimeInMillis > detectionThresholdInMillis) { logger.warn( "Job '{}' is still running after {}ms (detection threshold = {}ms), stack trace = {}", job.name(), currentTime - jobStartedtimeInMillis, detectionThresholdInMillis, Stream .of(threadRunningJob.getStackTrace()) .map(StackTraceElement::toString) .collect(Collectors.joining("\n ")) ); longRunningJobs.put( job, new LongRunningJobInfo(jobStartedtimeInMillis, jobExecutionsCount) ); return true; } } return false; }
java
boolean detectLongRunningJob(long currentTime, Job job) { if(job.status() == JobStatus.RUNNING && !longRunningJobs.containsKey(job)) { int jobExecutionsCount = job.executionsCount(); Long jobStartedtimeInMillis = job.lastExecutionStartedTimeInMillis(); Thread threadRunningJob = job.threadRunningJob(); if(jobStartedtimeInMillis != null && threadRunningJob != null && currentTime - jobStartedtimeInMillis > detectionThresholdInMillis) { logger.warn( "Job '{}' is still running after {}ms (detection threshold = {}ms), stack trace = {}", job.name(), currentTime - jobStartedtimeInMillis, detectionThresholdInMillis, Stream .of(threadRunningJob.getStackTrace()) .map(StackTraceElement::toString) .collect(Collectors.joining("\n ")) ); longRunningJobs.put( job, new LongRunningJobInfo(jobStartedtimeInMillis, jobExecutionsCount) ); return true; } } return false; }
[ "boolean", "detectLongRunningJob", "(", "long", "currentTime", ",", "Job", "job", ")", "{", "if", "(", "job", ".", "status", "(", ")", "==", "JobStatus", ".", "RUNNING", "&&", "!", "longRunningJobs", ".", "containsKey", "(", "job", ")", ")", "{", "int", ...
Check whether a job is running for too long or not. @return true if the is running for too long, else false. Returned value is made available for testing purposes.
[ "Check", "whether", "a", "job", "is", "running", "for", "too", "long", "or", "not", "." ]
6d5de3b88fbe259e327296eea167b18cf41c7641
https://github.com/Coreoz/Wisp/blob/6d5de3b88fbe259e327296eea167b18cf41c7641/src/main/java/com/coreoz/wisp/LongRunningJobMonitor.java#L81-L110
136,372
Coreoz/Wisp
src/main/java/com/coreoz/wisp/Scheduler.java
Scheduler.schedule
public Job schedule(Runnable runnable, Schedule when) { return schedule(null, runnable, when); }
java
public Job schedule(Runnable runnable, Schedule when) { return schedule(null, runnable, when); }
[ "public", "Job", "schedule", "(", "Runnable", "runnable", ",", "Schedule", "when", ")", "{", "return", "schedule", "(", "null", ",", "runnable", ",", "when", ")", ";", "}" ]
Schedule the executions of a process. @param runnable The process to be executed at a schedule @param when The {@link Schedule} at which the process will be executed @return The corresponding {@link Job} created. @throws NullPointerException if {@code runnable} or {@code when} are {@code null} @throws IllegalArgumentException if the same instance of {@code runnable} is scheduled twice whereas the corresponding job status is not {@link JobStatus#DONE}
[ "Schedule", "the", "executions", "of", "a", "process", "." ]
6d5de3b88fbe259e327296eea167b18cf41c7641
https://github.com/Coreoz/Wisp/blob/6d5de3b88fbe259e327296eea167b18cf41c7641/src/main/java/com/coreoz/wisp/Scheduler.java#L163-L165
136,373
Coreoz/Wisp
src/main/java/com/coreoz/wisp/Scheduler.java
Scheduler.findJob
public Optional<Job> findJob(String name) { return Optional.ofNullable(indexedJobsByName.get(name)); }
java
public Optional<Job> findJob(String name) { return Optional.ofNullable(indexedJobsByName.get(name)); }
[ "public", "Optional", "<", "Job", ">", "findJob", "(", "String", "name", ")", "{", "return", "Optional", ".", "ofNullable", "(", "indexedJobsByName", ".", "get", "(", "name", ")", ")", ";", "}" ]
Find a job by its name
[ "Find", "a", "job", "by", "its", "name" ]
6d5de3b88fbe259e327296eea167b18cf41c7641
https://github.com/Coreoz/Wisp/blob/6d5de3b88fbe259e327296eea167b18cf41c7641/src/main/java/com/coreoz/wisp/Scheduler.java#L215-L217
136,374
Coreoz/Wisp
src/main/java/com/coreoz/wisp/Scheduler.java
Scheduler.gracefullyShutdown
@SneakyThrows public void gracefullyShutdown(Duration timeout) { logger.info("Shutting down..."); if(!shuttingDown) { synchronized (this) { shuttingDown = true; threadPoolExecutor.shutdown(); } // stops jobs that have not yet started to be executed for(Job job : jobStatus()) { Runnable runningJob = job.runningJob(); if(runningJob != null) { threadPoolExecutor.remove(runningJob); } job.status(JobStatus.DONE); } synchronized (launcherNotifier) { launcherNotifier.set(false); launcherNotifier.notify(); } } threadPoolExecutor.awaitTermination(timeout.toMillis(), TimeUnit.MILLISECONDS); }
java
@SneakyThrows public void gracefullyShutdown(Duration timeout) { logger.info("Shutting down..."); if(!shuttingDown) { synchronized (this) { shuttingDown = true; threadPoolExecutor.shutdown(); } // stops jobs that have not yet started to be executed for(Job job : jobStatus()) { Runnable runningJob = job.runningJob(); if(runningJob != null) { threadPoolExecutor.remove(runningJob); } job.status(JobStatus.DONE); } synchronized (launcherNotifier) { launcherNotifier.set(false); launcherNotifier.notify(); } } threadPoolExecutor.awaitTermination(timeout.toMillis(), TimeUnit.MILLISECONDS); }
[ "@", "SneakyThrows", "public", "void", "gracefullyShutdown", "(", "Duration", "timeout", ")", "{", "logger", ".", "info", "(", "\"Shutting down...\"", ")", ";", "if", "(", "!", "shuttingDown", ")", "{", "synchronized", "(", "this", ")", "{", "shuttingDown", ...
Wait until the current running jobs are executed and cancel jobs that are planned to be executed. @param timeout The maximum time to wait @throws InterruptedException if the shutdown lasts more than 10 seconds
[ "Wait", "until", "the", "current", "running", "jobs", "are", "executed", "and", "cancel", "jobs", "that", "are", "planned", "to", "be", "executed", "." ]
6d5de3b88fbe259e327296eea167b18cf41c7641
https://github.com/Coreoz/Wisp/blob/6d5de3b88fbe259e327296eea167b18cf41c7641/src/main/java/com/coreoz/wisp/Scheduler.java#L292-L317
136,375
Coreoz/Wisp
src/main/java/com/coreoz/wisp/Scheduler.java
Scheduler.launcher
@SneakyThrows private void launcher() { while(!shuttingDown) { Long timeBeforeNextExecution = null; synchronized (this) { if(nextExecutionsOrder.size() > 0) { timeBeforeNextExecution = nextExecutionsOrder.get(0).nextExecutionTimeInMillis() - timeProvider.currentTime(); } } if(timeBeforeNextExecution == null || timeBeforeNextExecution > 0L) { synchronized (launcherNotifier) { if(shuttingDown) { return; } // If someone has notified the launcher // then the launcher must check again the next job to execute. // We must be sure not to miss any changes that would have // happened after the timeBeforeNextExecution calculation. if(launcherNotifier.get()) { if(timeBeforeNextExecution == null) { launcherNotifier.wait(); } else { launcherNotifier.wait(timeBeforeNextExecution); } } launcherNotifier.set(true); } } else { synchronized (this) { if(shuttingDown) { return; } if(nextExecutionsOrder.size() > 0) { Job jobToRun = nextExecutionsOrder.remove(0); jobToRun.status(JobStatus.READY); jobToRun.runningJob(() -> runJob(jobToRun)); if(threadPoolExecutor.getActiveCount() == threadPoolExecutor.getMaximumPoolSize()) { logger.warn( "Job thread pool is full, either tasks take too much time to execute" + " or either the thread pool is too small" ); } threadPoolExecutor.execute(jobToRun.runningJob()); } } } } }
java
@SneakyThrows private void launcher() { while(!shuttingDown) { Long timeBeforeNextExecution = null; synchronized (this) { if(nextExecutionsOrder.size() > 0) { timeBeforeNextExecution = nextExecutionsOrder.get(0).nextExecutionTimeInMillis() - timeProvider.currentTime(); } } if(timeBeforeNextExecution == null || timeBeforeNextExecution > 0L) { synchronized (launcherNotifier) { if(shuttingDown) { return; } // If someone has notified the launcher // then the launcher must check again the next job to execute. // We must be sure not to miss any changes that would have // happened after the timeBeforeNextExecution calculation. if(launcherNotifier.get()) { if(timeBeforeNextExecution == null) { launcherNotifier.wait(); } else { launcherNotifier.wait(timeBeforeNextExecution); } } launcherNotifier.set(true); } } else { synchronized (this) { if(shuttingDown) { return; } if(nextExecutionsOrder.size() > 0) { Job jobToRun = nextExecutionsOrder.remove(0); jobToRun.status(JobStatus.READY); jobToRun.runningJob(() -> runJob(jobToRun)); if(threadPoolExecutor.getActiveCount() == threadPoolExecutor.getMaximumPoolSize()) { logger.warn( "Job thread pool is full, either tasks take too much time to execute" + " or either the thread pool is too small" ); } threadPoolExecutor.execute(jobToRun.runningJob()); } } } } }
[ "@", "SneakyThrows", "private", "void", "launcher", "(", ")", "{", "while", "(", "!", "shuttingDown", ")", "{", "Long", "timeBeforeNextExecution", "=", "null", ";", "synchronized", "(", "this", ")", "{", "if", "(", "nextExecutionsOrder", ".", "size", "(", ...
The daemon that will be in charge of placing the jobs in the thread pool when they are ready to be executed.
[ "The", "daemon", "that", "will", "be", "in", "charge", "of", "placing", "the", "jobs", "in", "the", "thread", "pool", "when", "they", "are", "ready", "to", "be", "executed", "." ]
6d5de3b88fbe259e327296eea167b18cf41c7641
https://github.com/Coreoz/Wisp/blob/6d5de3b88fbe259e327296eea167b18cf41c7641/src/main/java/com/coreoz/wisp/Scheduler.java#L413-L463
136,376
Coreoz/Wisp
src/main/java/com/coreoz/wisp/Scheduler.java
Scheduler.runJob
private void runJob(Job jobToRun) { long startExecutionTime = timeProvider.currentTime(); long timeBeforeNextExecution = jobToRun.nextExecutionTimeInMillis() - startExecutionTime; if(timeBeforeNextExecution < 0) { logger.debug("Job '{}' execution is {}ms late", jobToRun.name(), -timeBeforeNextExecution); } jobToRun.status(JobStatus.RUNNING); jobToRun.lastExecutionStartedTimeInMillis(startExecutionTime); jobToRun.threadRunningJob(Thread.currentThread()); try { jobToRun.runnable().run(); } catch(Throwable t) { logger.error("Error during job '{}' execution", jobToRun.name(), t); } jobToRun.executionsCount(jobToRun.executionsCount() + 1); jobToRun.lastExecutionEndedTimeInMillis(timeProvider.currentTime()); jobToRun.threadRunningJob(null); if(logger.isDebugEnabled()) { logger.debug( "Job '{}' executed in {}ms", jobToRun.name(), timeProvider.currentTime() - startExecutionTime ); } if(shuttingDown) { return; } synchronized (this) { scheduleNextExecution(jobToRun); } }
java
private void runJob(Job jobToRun) { long startExecutionTime = timeProvider.currentTime(); long timeBeforeNextExecution = jobToRun.nextExecutionTimeInMillis() - startExecutionTime; if(timeBeforeNextExecution < 0) { logger.debug("Job '{}' execution is {}ms late", jobToRun.name(), -timeBeforeNextExecution); } jobToRun.status(JobStatus.RUNNING); jobToRun.lastExecutionStartedTimeInMillis(startExecutionTime); jobToRun.threadRunningJob(Thread.currentThread()); try { jobToRun.runnable().run(); } catch(Throwable t) { logger.error("Error during job '{}' execution", jobToRun.name(), t); } jobToRun.executionsCount(jobToRun.executionsCount() + 1); jobToRun.lastExecutionEndedTimeInMillis(timeProvider.currentTime()); jobToRun.threadRunningJob(null); if(logger.isDebugEnabled()) { logger.debug( "Job '{}' executed in {}ms", jobToRun.name(), timeProvider.currentTime() - startExecutionTime ); } if(shuttingDown) { return; } synchronized (this) { scheduleNextExecution(jobToRun); } }
[ "private", "void", "runJob", "(", "Job", "jobToRun", ")", "{", "long", "startExecutionTime", "=", "timeProvider", ".", "currentTime", "(", ")", ";", "long", "timeBeforeNextExecution", "=", "jobToRun", ".", "nextExecutionTimeInMillis", "(", ")", "-", "startExecutio...
The wrapper around a job that will be executed in the thread pool. It is especially in charge of logging, changing the job status and checking for the next job to be executed. @param jobToRun the job to execute
[ "The", "wrapper", "around", "a", "job", "that", "will", "be", "executed", "in", "the", "thread", "pool", ".", "It", "is", "especially", "in", "charge", "of", "logging", "changing", "the", "job", "status", "and", "checking", "for", "the", "next", "job", "...
6d5de3b88fbe259e327296eea167b18cf41c7641
https://github.com/Coreoz/Wisp/blob/6d5de3b88fbe259e327296eea167b18cf41c7641/src/main/java/com/coreoz/wisp/Scheduler.java#L471-L503
136,377
mmazi/rescu
src/main/java/si/mazi/rescu/HttpTemplate.java
HttpTemplate.configureURLConnection
private HttpURLConnection configureURLConnection(HttpMethod method, String urlString, Map<String, String> httpHeaders, int contentLength) throws IOException { preconditionNotNull(method, "method cannot be null"); preconditionNotNull(urlString, "urlString cannot be null"); preconditionNotNull(httpHeaders, "httpHeaders cannot be null"); HttpURLConnection connection = getHttpURLConnection(urlString); connection.setRequestMethod(method.name()); Map<String, String> headerKeyValues = new HashMap<>(defaultHttpHeaders); headerKeyValues.putAll(httpHeaders); for (Map.Entry<String, String> entry : headerKeyValues.entrySet()) { connection.setRequestProperty(entry.getKey(), entry.getValue()); log.trace("Header request property: key='{}', value='{}'", entry.getKey(), entry.getValue()); } // Perform additional configuration for POST if (contentLength > 0) { connection.setDoOutput(true); connection.setDoInput(true); } connection.setRequestProperty("Content-Length", Integer.toString(contentLength)); return connection; }
java
private HttpURLConnection configureURLConnection(HttpMethod method, String urlString, Map<String, String> httpHeaders, int contentLength) throws IOException { preconditionNotNull(method, "method cannot be null"); preconditionNotNull(urlString, "urlString cannot be null"); preconditionNotNull(httpHeaders, "httpHeaders cannot be null"); HttpURLConnection connection = getHttpURLConnection(urlString); connection.setRequestMethod(method.name()); Map<String, String> headerKeyValues = new HashMap<>(defaultHttpHeaders); headerKeyValues.putAll(httpHeaders); for (Map.Entry<String, String> entry : headerKeyValues.entrySet()) { connection.setRequestProperty(entry.getKey(), entry.getValue()); log.trace("Header request property: key='{}', value='{}'", entry.getKey(), entry.getValue()); } // Perform additional configuration for POST if (contentLength > 0) { connection.setDoOutput(true); connection.setDoInput(true); } connection.setRequestProperty("Content-Length", Integer.toString(contentLength)); return connection; }
[ "private", "HttpURLConnection", "configureURLConnection", "(", "HttpMethod", "method", ",", "String", "urlString", ",", "Map", "<", "String", ",", "String", ">", "httpHeaders", ",", "int", "contentLength", ")", "throws", "IOException", "{", "preconditionNotNull", "(...
Provides an internal convenience method to allow easy overriding by test classes @param method The HTTP method (e.g. GET, POST etc) @param urlString A string representation of a URL @param httpHeaders The HTTP headers (will override the defaults) @param contentLength The Content-Length request property @return An HttpURLConnection based on the given parameters @throws IOException If something goes wrong
[ "Provides", "an", "internal", "convenience", "method", "to", "allow", "easy", "overriding", "by", "test", "classes" ]
8a4f9367994da0a2617bd37acf0320c942e62de3
https://github.com/mmazi/rescu/blob/8a4f9367994da0a2617bd37acf0320c942e62de3/src/main/java/si/mazi/rescu/HttpTemplate.java#L153-L179
136,378
mmazi/rescu
src/main/java/si/mazi/rescu/HttpTemplate.java
HttpTemplate.getResponseEncoding
String getResponseEncoding(URLConnection connection) { String charset = null; String contentType = connection.getHeaderField("Content-Type"); if (contentType != null) { for (String param : contentType.replace(" ", "").split(";")) { if (param.startsWith("charset=")) { charset = param.split("=", 2)[1]; break; } } } return charset; }
java
String getResponseEncoding(URLConnection connection) { String charset = null; String contentType = connection.getHeaderField("Content-Type"); if (contentType != null) { for (String param : contentType.replace(" ", "").split(";")) { if (param.startsWith("charset=")) { charset = param.split("=", 2)[1]; break; } } } return charset; }
[ "String", "getResponseEncoding", "(", "URLConnection", "connection", ")", "{", "String", "charset", "=", "null", ";", "String", "contentType", "=", "connection", ".", "getHeaderField", "(", "\"Content-Type\"", ")", ";", "if", "(", "contentType", "!=", "null", ")...
Determine the response encoding if specified @param connection The HTTP connection @return The response encoding as a string (taken from "Content-Type")
[ "Determine", "the", "response", "encoding", "if", "specified" ]
8a4f9367994da0a2617bd37acf0320c942e62de3
https://github.com/mmazi/rescu/blob/8a4f9367994da0a2617bd37acf0320c942e62de3/src/main/java/si/mazi/rescu/HttpTemplate.java#L253-L267
136,379
rototor/pdfbox-graphics2d
src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawerDefaultFonts.java
PdfBoxGraphics2DFontTextDrawerDefaultFonts.mapDefaultFonts
public static PDFont mapDefaultFonts(Font font) { /* * Map default font names to the matching families. */ if (fontNameEqualsAnyOf(font, Font.SANS_SERIF, Font.DIALOG, Font.DIALOG_INPUT, "Arial", "Helvetica")) return chooseMatchingHelvetica(font); if (fontNameEqualsAnyOf(font, Font.MONOSPACED, "courier", "courier new")) return chooseMatchingCourier(font); if (fontNameEqualsAnyOf(font, Font.SERIF, "Times", "Times New Roman", "Times Roman")) return chooseMatchingTimes(font); if (fontNameEqualsAnyOf(font, "Symbol")) return PDType1Font.SYMBOL; if (fontNameEqualsAnyOf(font, "ZapfDingbats", "Dingbats")) return PDType1Font.ZAPF_DINGBATS; return null; }
java
public static PDFont mapDefaultFonts(Font font) { /* * Map default font names to the matching families. */ if (fontNameEqualsAnyOf(font, Font.SANS_SERIF, Font.DIALOG, Font.DIALOG_INPUT, "Arial", "Helvetica")) return chooseMatchingHelvetica(font); if (fontNameEqualsAnyOf(font, Font.MONOSPACED, "courier", "courier new")) return chooseMatchingCourier(font); if (fontNameEqualsAnyOf(font, Font.SERIF, "Times", "Times New Roman", "Times Roman")) return chooseMatchingTimes(font); if (fontNameEqualsAnyOf(font, "Symbol")) return PDType1Font.SYMBOL; if (fontNameEqualsAnyOf(font, "ZapfDingbats", "Dingbats")) return PDType1Font.ZAPF_DINGBATS; return null; }
[ "public", "static", "PDFont", "mapDefaultFonts", "(", "Font", "font", ")", "{", "/*\n\t\t * Map default font names to the matching families.\n\t\t */", "if", "(", "fontNameEqualsAnyOf", "(", "font", ",", "Font", ".", "SANS_SERIF", ",", "Font", ".", "DIALOG", ",", "Fon...
Find a PDFont for the given font object, which does not need to be embedded. @param font font for which to find a suitable default font @return null if no default font is found or a default font which does not need to be embedded.
[ "Find", "a", "PDFont", "for", "the", "given", "font", "object", "which", "does", "not", "need", "to", "be", "embedded", "." ]
86d53942cf2c137edca59d45766927c077f49230
https://github.com/rototor/pdfbox-graphics2d/blob/86d53942cf2c137edca59d45766927c077f49230/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawerDefaultFonts.java#L41-L56
136,380
rototor/pdfbox-graphics2d
src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawerDefaultFonts.java
PdfBoxGraphics2DFontTextDrawerDefaultFonts.chooseMatchingTimes
public static PDFont chooseMatchingTimes(Font font) { if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD)) return PDType1Font.TIMES_BOLD_ITALIC; if ((font.getStyle() & Font.ITALIC) == Font.ITALIC) return PDType1Font.TIMES_ITALIC; if ((font.getStyle() & Font.BOLD) == Font.BOLD) return PDType1Font.TIMES_BOLD; return PDType1Font.TIMES_ROMAN; }
java
public static PDFont chooseMatchingTimes(Font font) { if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD)) return PDType1Font.TIMES_BOLD_ITALIC; if ((font.getStyle() & Font.ITALIC) == Font.ITALIC) return PDType1Font.TIMES_ITALIC; if ((font.getStyle() & Font.BOLD) == Font.BOLD) return PDType1Font.TIMES_BOLD; return PDType1Font.TIMES_ROMAN; }
[ "public", "static", "PDFont", "chooseMatchingTimes", "(", "Font", "font", ")", "{", "if", "(", "(", "font", ".", "getStyle", "(", ")", "&", "(", "Font", ".", "ITALIC", "|", "Font", ".", "BOLD", ")", ")", "==", "(", "Font", ".", "ITALIC", "|", "Font...
Get a PDType1Font.TIMES-variant, which matches the given font @param font Font to get the styles from @return a PDFont Times variant which matches the style in the given Font object.
[ "Get", "a", "PDType1Font", ".", "TIMES", "-", "variant", "which", "matches", "the", "given", "font" ]
86d53942cf2c137edca59d45766927c077f49230
https://github.com/rototor/pdfbox-graphics2d/blob/86d53942cf2c137edca59d45766927c077f49230/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawerDefaultFonts.java#L75-L83
136,381
rototor/pdfbox-graphics2d
src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawerDefaultFonts.java
PdfBoxGraphics2DFontTextDrawerDefaultFonts.chooseMatchingCourier
public static PDFont chooseMatchingCourier(Font font) { if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD)) return PDType1Font.COURIER_BOLD_OBLIQUE; if ((font.getStyle() & Font.ITALIC) == Font.ITALIC) return PDType1Font.COURIER_OBLIQUE; if ((font.getStyle() & Font.BOLD) == Font.BOLD) return PDType1Font.COURIER_BOLD; return PDType1Font.COURIER; }
java
public static PDFont chooseMatchingCourier(Font font) { if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD)) return PDType1Font.COURIER_BOLD_OBLIQUE; if ((font.getStyle() & Font.ITALIC) == Font.ITALIC) return PDType1Font.COURIER_OBLIQUE; if ((font.getStyle() & Font.BOLD) == Font.BOLD) return PDType1Font.COURIER_BOLD; return PDType1Font.COURIER; }
[ "public", "static", "PDFont", "chooseMatchingCourier", "(", "Font", "font", ")", "{", "if", "(", "(", "font", ".", "getStyle", "(", ")", "&", "(", "Font", ".", "ITALIC", "|", "Font", ".", "BOLD", ")", ")", "==", "(", "Font", ".", "ITALIC", "|", "Fo...
Get a PDType1Font.COURIER-variant, which matches the given font @param font Font to get the styles from @return a PDFont Courier variant which matches the style in the given Font object.
[ "Get", "a", "PDType1Font", ".", "COURIER", "-", "variant", "which", "matches", "the", "given", "font" ]
86d53942cf2c137edca59d45766927c077f49230
https://github.com/rototor/pdfbox-graphics2d/blob/86d53942cf2c137edca59d45766927c077f49230/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawerDefaultFonts.java#L93-L101
136,382
rototor/pdfbox-graphics2d
src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawerDefaultFonts.java
PdfBoxGraphics2DFontTextDrawerDefaultFonts.chooseMatchingHelvetica
public static PDFont chooseMatchingHelvetica(Font font) { if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD)) return PDType1Font.HELVETICA_BOLD_OBLIQUE; if ((font.getStyle() & Font.ITALIC) == Font.ITALIC) return PDType1Font.HELVETICA_OBLIQUE; if ((font.getStyle() & Font.BOLD) == Font.BOLD) return PDType1Font.HELVETICA_BOLD; return PDType1Font.HELVETICA; }
java
public static PDFont chooseMatchingHelvetica(Font font) { if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD)) return PDType1Font.HELVETICA_BOLD_OBLIQUE; if ((font.getStyle() & Font.ITALIC) == Font.ITALIC) return PDType1Font.HELVETICA_OBLIQUE; if ((font.getStyle() & Font.BOLD) == Font.BOLD) return PDType1Font.HELVETICA_BOLD; return PDType1Font.HELVETICA; }
[ "public", "static", "PDFont", "chooseMatchingHelvetica", "(", "Font", "font", ")", "{", "if", "(", "(", "font", ".", "getStyle", "(", ")", "&", "(", "Font", ".", "ITALIC", "|", "Font", ".", "BOLD", ")", ")", "==", "(", "Font", ".", "ITALIC", "|", "...
Get a PDType1Font.HELVETICA-variant, which matches the given font @param font Font to get the styles from @return a PDFont Helvetica variant which matches the style in the given Font object.
[ "Get", "a", "PDType1Font", ".", "HELVETICA", "-", "variant", "which", "matches", "the", "given", "font" ]
86d53942cf2c137edca59d45766927c077f49230
https://github.com/rototor/pdfbox-graphics2d/blob/86d53942cf2c137edca59d45766927c077f49230/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawerDefaultFonts.java#L111-L119
136,383
rototor/pdfbox-graphics2d
src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java
PdfBoxGraphics2DFontTextDrawer.registerFont
@SuppressWarnings("WeakerAccess") public void registerFont(String fontName, File fontFile) { if (!fontFile.exists()) throw new IllegalArgumentException("Font " + fontFile + " does not exist!"); FontEntry entry = new FontEntry(); entry.overrideName = fontName; entry.file = fontFile; fontFiles.add(entry); }
java
@SuppressWarnings("WeakerAccess") public void registerFont(String fontName, File fontFile) { if (!fontFile.exists()) throw new IllegalArgumentException("Font " + fontFile + " does not exist!"); FontEntry entry = new FontEntry(); entry.overrideName = fontName; entry.file = fontFile; fontFiles.add(entry); }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "public", "void", "registerFont", "(", "String", "fontName", ",", "File", "fontFile", ")", "{", "if", "(", "!", "fontFile", ".", "exists", "(", ")", ")", "throw", "new", "IllegalArgumentException", "(", ...
Register a font. @param fontName the name of the font to use. If null, the name is taken from the font. @param fontFile the font file. This file must exist for the live time of this object, as the font data will be read lazy on demand
[ "Register", "a", "font", "." ]
86d53942cf2c137edca59d45766927c077f49230
https://github.com/rototor/pdfbox-graphics2d/blob/86d53942cf2c137edca59d45766927c077f49230/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java#L106-L114
136,384
rototor/pdfbox-graphics2d
src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java
PdfBoxGraphics2DFontTextDrawer.registerFont
@SuppressWarnings("WeakerAccess") public void registerFont(String name, PDFont font) { fontMap.put(name, font); }
java
@SuppressWarnings("WeakerAccess") public void registerFont(String name, PDFont font) { fontMap.put(name, font); }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "public", "void", "registerFont", "(", "String", "name", ",", "PDFont", "font", ")", "{", "fontMap", ".", "put", "(", "name", ",", "font", ")", ";", "}" ]
Register a font which is already associated with the PDDocument @param name the name of the font as returned by {@link java.awt.Font#getFontName()}. This name is used for the mapping the java.awt.Font to this PDFont. @param font the PDFont to use. This font must be loaded in the current document.
[ "Register", "a", "font", "which", "is", "already", "associated", "with", "the", "PDDocument" ]
86d53942cf2c137edca59d45766927c077f49230
https://github.com/rototor/pdfbox-graphics2d/blob/86d53942cf2c137edca59d45766927c077f49230/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java#L152-L155
136,385
rototor/pdfbox-graphics2d
src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java
PdfBoxGraphics2DFontTextDrawer.mapFont
@SuppressWarnings("WeakerAccess") protected PDFont mapFont(final Font font, final IFontTextDrawerEnv env) throws IOException, FontFormatException { /* * If we have any font registering's, we must perform them now */ for (final FontEntry fontEntry : fontFiles) { if (fontEntry.overrideName == null) { Font javaFont = Font.createFont(Font.TRUETYPE_FONT, fontEntry.file); fontEntry.overrideName = javaFont.getFontName(); } if (fontEntry.file.getName().toLowerCase(Locale.US).endsWith(".ttc")) { TrueTypeCollection collection = new TrueTypeCollection(fontEntry.file); collection.processAllFonts(new TrueTypeCollection.TrueTypeFontProcessor() { @Override public void process(TrueTypeFont ttf) throws IOException { PDFont pdFont = PDType0Font.load(env.getDocument(), ttf, true); fontMap.put(fontEntry.overrideName, pdFont); fontMap.put(pdFont.getName(), pdFont); } }); } else { /* * We load the font using the file. */ PDFont pdFont = PDType0Font.load(env.getDocument(), fontEntry.file); fontMap.put(fontEntry.overrideName, pdFont); } } fontFiles.clear(); return fontMap.get(font.getFontName()); }
java
@SuppressWarnings("WeakerAccess") protected PDFont mapFont(final Font font, final IFontTextDrawerEnv env) throws IOException, FontFormatException { /* * If we have any font registering's, we must perform them now */ for (final FontEntry fontEntry : fontFiles) { if (fontEntry.overrideName == null) { Font javaFont = Font.createFont(Font.TRUETYPE_FONT, fontEntry.file); fontEntry.overrideName = javaFont.getFontName(); } if (fontEntry.file.getName().toLowerCase(Locale.US).endsWith(".ttc")) { TrueTypeCollection collection = new TrueTypeCollection(fontEntry.file); collection.processAllFonts(new TrueTypeCollection.TrueTypeFontProcessor() { @Override public void process(TrueTypeFont ttf) throws IOException { PDFont pdFont = PDType0Font.load(env.getDocument(), ttf, true); fontMap.put(fontEntry.overrideName, pdFont); fontMap.put(pdFont.getName(), pdFont); } }); } else { /* * We load the font using the file. */ PDFont pdFont = PDType0Font.load(env.getDocument(), fontEntry.file); fontMap.put(fontEntry.overrideName, pdFont); } } fontFiles.clear(); return fontMap.get(font.getFontName()); }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "protected", "PDFont", "mapFont", "(", "final", "Font", "font", ",", "final", "IFontTextDrawerEnv", "env", ")", "throws", "IOException", ",", "FontFormatException", "{", "/*\n\t\t * If we have any font registering's, ...
Try to map the java.awt.Font to a PDFont. @param font the java.awt.Font for which a mapping should be found @param env environment of the font mapper @return the PDFont or null if none can be found.
[ "Try", "to", "map", "the", "java", ".", "awt", ".", "Font", "to", "a", "PDFont", "." ]
86d53942cf2c137edca59d45766927c077f49230
https://github.com/rototor/pdfbox-graphics2d/blob/86d53942cf2c137edca59d45766927c077f49230/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java#L408-L439
136,386
telly/MrVector
library/src/main/java/com/telly/mrvector/VectorDrawable.java
VectorDrawable.getPixelSize
public float getPixelSize() { if (mVectorState == null && mVectorState.mVPathRenderer == null || mVectorState.mVPathRenderer.mBaseWidth == 0 || mVectorState.mVPathRenderer.mBaseHeight == 0 || mVectorState.mVPathRenderer.mViewportHeight == 0 || mVectorState.mVPathRenderer.mViewportWidth == 0) { return 1; // fall back to 1:1 pixel mapping. } float intrinsicWidth = mVectorState.mVPathRenderer.mBaseWidth; float intrinsicHeight = mVectorState.mVPathRenderer.mBaseHeight; float viewportWidth = mVectorState.mVPathRenderer.mViewportWidth; float viewportHeight = mVectorState.mVPathRenderer.mViewportHeight; float scaleX = viewportWidth / intrinsicWidth; float scaleY = viewportHeight / intrinsicHeight; return Math.min(scaleX, scaleY); }
java
public float getPixelSize() { if (mVectorState == null && mVectorState.mVPathRenderer == null || mVectorState.mVPathRenderer.mBaseWidth == 0 || mVectorState.mVPathRenderer.mBaseHeight == 0 || mVectorState.mVPathRenderer.mViewportHeight == 0 || mVectorState.mVPathRenderer.mViewportWidth == 0) { return 1; // fall back to 1:1 pixel mapping. } float intrinsicWidth = mVectorState.mVPathRenderer.mBaseWidth; float intrinsicHeight = mVectorState.mVPathRenderer.mBaseHeight; float viewportWidth = mVectorState.mVPathRenderer.mViewportWidth; float viewportHeight = mVectorState.mVPathRenderer.mViewportHeight; float scaleX = viewportWidth / intrinsicWidth; float scaleY = viewportHeight / intrinsicHeight; return Math.min(scaleX, scaleY); }
[ "public", "float", "getPixelSize", "(", ")", "{", "if", "(", "mVectorState", "==", "null", "&&", "mVectorState", ".", "mVPathRenderer", "==", "null", "||", "mVectorState", ".", "mVPathRenderer", ".", "mBaseWidth", "==", "0", "||", "mVectorState", ".", "mVPathR...
The size of a pixel when scaled from the intrinsic dimension to the viewport dimension. This is used to calculate the path animation accuracy. @hide
[ "The", "size", "of", "a", "pixel", "when", "scaled", "from", "the", "intrinsic", "dimension", "to", "the", "viewport", "dimension", ".", "This", "is", "used", "to", "calculate", "the", "path", "animation", "accuracy", "." ]
846cd05ab6e57dcdc1cae28e796ac84b1d6365d5
https://github.com/telly/MrVector/blob/846cd05ab6e57dcdc1cae28e796ac84b1d6365d5/library/src/main/java/com/telly/mrvector/VectorDrawable.java#L410-L425
136,387
otto-de/edison-hal
example-springboot/src/main/java/de/otto/edison/hal/example/web/HomeController.java
HomeController.getHomeDocument
@RequestMapping( path = "/api", method = RequestMethod.GET, produces = {"application/hal+json", "application/json"} ) public HalRepresentation getHomeDocument(final HttpServletRequest request) { final String homeUrl = request.getRequestURL().toString(); return new HalRepresentation( linkingTo() .self(homeUrl) .single(linkBuilder("search", "/api/products{?q,embedded}") .withTitle("Search Products") .withType("application/hal+json") .build()) .build() ); }
java
@RequestMapping( path = "/api", method = RequestMethod.GET, produces = {"application/hal+json", "application/json"} ) public HalRepresentation getHomeDocument(final HttpServletRequest request) { final String homeUrl = request.getRequestURL().toString(); return new HalRepresentation( linkingTo() .self(homeUrl) .single(linkBuilder("search", "/api/products{?q,embedded}") .withTitle("Search Products") .withType("application/hal+json") .build()) .build() ); }
[ "@", "RequestMapping", "(", "path", "=", "\"/api\"", ",", "method", "=", "RequestMethod", ".", "GET", ",", "produces", "=", "{", "\"application/hal+json\"", ",", "\"application/json\"", "}", ")", "public", "HalRepresentation", "getHomeDocument", "(", "final", "Htt...
Entry point for the products REST API. @param request current request @return application/hal+json document containing links to the API.
[ "Entry", "point", "for", "the", "products", "REST", "API", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/example-springboot/src/main/java/de/otto/edison/hal/example/web/HomeController.java#L22-L38
136,388
otto-de/edison-hal
src/main/java/de/otto/edison/hal/Link.java
Link.copyOf
public static Builder copyOf(final Link prototype) { return new Builder(prototype.rel, prototype.href) .withType(prototype.type) .withProfile(prototype.profile) .withTitle(prototype.title) .withName(prototype.name) .withDeprecation(prototype.deprecation) .withHrefLang(prototype.hreflang); }
java
public static Builder copyOf(final Link prototype) { return new Builder(prototype.rel, prototype.href) .withType(prototype.type) .withProfile(prototype.profile) .withTitle(prototype.title) .withName(prototype.name) .withDeprecation(prototype.deprecation) .withHrefLang(prototype.hreflang); }
[ "public", "static", "Builder", "copyOf", "(", "final", "Link", "prototype", ")", "{", "return", "new", "Builder", "(", "prototype", ".", "rel", ",", "prototype", ".", "href", ")", ".", "withType", "(", "prototype", ".", "type", ")", ".", "withProfile", "...
Create a Builder instance and initialize it from a prototype Link. @param prototype the prototype link @return a Builder for a Link. @since 0.1.0
[ "Create", "a", "Builder", "instance", "and", "initialize", "it", "from", "a", "prototype", "Link", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/Link.java#L232-L240
136,389
otto-de/edison-hal
src/main/java/de/otto/edison/hal/Embedded.java
Embedded.embedded
public static Embedded embedded(final String rel, final HalRepresentation embeddedItem) { return new Embedded(singletonMap(rel, embeddedItem)); }
java
public static Embedded embedded(final String rel, final HalRepresentation embeddedItem) { return new Embedded(singletonMap(rel, embeddedItem)); }
[ "public", "static", "Embedded", "embedded", "(", "final", "String", "rel", ",", "final", "HalRepresentation", "embeddedItem", ")", "{", "return", "new", "Embedded", "(", "singletonMap", "(", "rel", ",", "embeddedItem", ")", ")", ";", "}" ]
Create an Embedded instance with a single embedded HalRepresentations that will be rendered as a single item instead of an array of embedded items. @param rel the link-relation type of the embedded items @param embeddedItem the single embedded item @return Embedded @since 2.0.0
[ "Create", "an", "Embedded", "instance", "with", "a", "single", "embedded", "HalRepresentations", "that", "will", "be", "rendered", "as", "a", "single", "item", "instead", "of", "an", "array", "of", "embedded", "items", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/Embedded.java#L121-L124
136,390
otto-de/edison-hal
src/main/java/de/otto/edison/hal/Embedded.java
Embedded.embedded
public static Embedded embedded(final String rel, final List<? extends HalRepresentation> embeddedRepresentations) { return new Embedded(singletonMap(rel, new ArrayList<>(embeddedRepresentations))); }
java
public static Embedded embedded(final String rel, final List<? extends HalRepresentation> embeddedRepresentations) { return new Embedded(singletonMap(rel, new ArrayList<>(embeddedRepresentations))); }
[ "public", "static", "Embedded", "embedded", "(", "final", "String", "rel", ",", "final", "List", "<", "?", "extends", "HalRepresentation", ">", "embeddedRepresentations", ")", "{", "return", "new", "Embedded", "(", "singletonMap", "(", "rel", ",", "new", "Arra...
Create an Embedded instance with a list of nested HalRepresentations for a single link-relation type. @param rel the link-relation type of the embedded representations @param embeddedRepresentations the list of embedded representations @return Embedded @since 0.1.0
[ "Create", "an", "Embedded", "instance", "with", "a", "list", "of", "nested", "HalRepresentations", "for", "a", "single", "link", "-", "relation", "type", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/Embedded.java#L135-L138
136,391
otto-de/edison-hal
src/main/java/de/otto/edison/hal/paging/NumberedPaging.java
NumberedPaging.calcLastPage
private int calcLastPage(int total, int pageSize) { if (total == 0) { return firstPage; } else { final int zeroBasedPageNo = total % pageSize > 0 ? total / pageSize : total / pageSize - 1; return firstPage + zeroBasedPageNo; } }
java
private int calcLastPage(int total, int pageSize) { if (total == 0) { return firstPage; } else { final int zeroBasedPageNo = total % pageSize > 0 ? total / pageSize : total / pageSize - 1; return firstPage + zeroBasedPageNo; } }
[ "private", "int", "calcLastPage", "(", "int", "total", ",", "int", "pageSize", ")", "{", "if", "(", "total", "==", "0", ")", "{", "return", "firstPage", ";", "}", "else", "{", "final", "int", "zeroBasedPageNo", "=", "total", "%", "pageSize", ">", "0", ...
Returns the number of the last page, if the total number of items is known. @param total total number of items @param pageSize the current page size @return page number of the last page
[ "Returns", "the", "number", "of", "the", "last", "page", "if", "the", "total", "number", "of", "items", "is", "known", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/paging/NumberedPaging.java#L321-L330
136,392
otto-de/edison-hal
src/main/java/de/otto/edison/hal/paging/NumberedPaging.java
NumberedPaging.pageUri
private String pageUri(final UriTemplate uriTemplate, final int pageNumber, final int pageSize) { if (pageSize == MAX_VALUE) { return uriTemplate.expand(); } return uriTemplate.set(pageNumberVar(), pageNumber).set(pageSizeVar(), pageSize).expand(); }
java
private String pageUri(final UriTemplate uriTemplate, final int pageNumber, final int pageSize) { if (pageSize == MAX_VALUE) { return uriTemplate.expand(); } return uriTemplate.set(pageNumberVar(), pageNumber).set(pageSizeVar(), pageSize).expand(); }
[ "private", "String", "pageUri", "(", "final", "UriTemplate", "uriTemplate", ",", "final", "int", "pageNumber", ",", "final", "int", "pageSize", ")", "{", "if", "(", "pageSize", "==", "MAX_VALUE", ")", "{", "return", "uriTemplate", ".", "expand", "(", ")", ...
Return the HREF of the page specified by UriTemplate, pageNumber and pageSize. @param uriTemplate the template used to build hrefs. @param pageNumber the number of the linked page. @param pageSize the size of the pages. @return href of the linked page.
[ "Return", "the", "HREF", "of", "the", "page", "specified", "by", "UriTemplate", "pageNumber", "and", "pageSize", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/paging/NumberedPaging.java#L340-L345
136,393
otto-de/edison-hal
src/main/java/de/otto/edison/hal/Links.java
Links.stream
@SuppressWarnings("rawtypes") public Stream<Link> stream() { return links.values() .stream() .map(obj -> { if (obj instanceof List) { return (List) obj; } else { return singletonList(obj); } }) .flatMap(Collection::stream); }
java
@SuppressWarnings("rawtypes") public Stream<Link> stream() { return links.values() .stream() .map(obj -> { if (obj instanceof List) { return (List) obj; } else { return singletonList(obj); } }) .flatMap(Collection::stream); }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "Stream", "<", "Link", ">", "stream", "(", ")", "{", "return", "links", ".", "values", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "obj", "->", "{", "if", "(", "obj", "instanceof", ...
Returns a Stream of links. @return Stream of Links
[ "Returns", "a", "Stream", "of", "links", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/Links.java#L136-L148
136,394
otto-de/edison-hal
src/main/java/de/otto/edison/hal/paging/SkipLimitPaging.java
SkipLimitPaging.calcLastPageSkip
private int calcLastPageSkip(int total, int skip, int limit) { if (skip > total - limit) { return skip; } if (total % limit > 0) { return total - total % limit; } return total - limit; }
java
private int calcLastPageSkip(int total, int skip, int limit) { if (skip > total - limit) { return skip; } if (total % limit > 0) { return total - total % limit; } return total - limit; }
[ "private", "int", "calcLastPageSkip", "(", "int", "total", ",", "int", "skip", ",", "int", "limit", ")", "{", "if", "(", "skip", ">", "total", "-", "limit", ")", "{", "return", "skip", ";", "}", "if", "(", "total", "%", "limit", ">", "0", ")", "{...
Calculate the number of items to skip for the last page. @param total total number of items. @param skip number of items to skip for the current page. @param limit page size @return skipped items
[ "Calculate", "the", "number", "of", "items", "to", "skip", "for", "the", "last", "page", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/paging/SkipLimitPaging.java#L278-L286
136,395
otto-de/edison-hal
src/main/java/de/otto/edison/hal/paging/SkipLimitPaging.java
SkipLimitPaging.pageUri
private String pageUri(final UriTemplate uriTemplate, final int skip, final int limit) { if (limit == MAX_VALUE) { return uriTemplate.expand(); } return uriTemplate.set(skipVar(), skip).set(limitVar(), limit).expand(); }
java
private String pageUri(final UriTemplate uriTemplate, final int skip, final int limit) { if (limit == MAX_VALUE) { return uriTemplate.expand(); } return uriTemplate.set(skipVar(), skip).set(limitVar(), limit).expand(); }
[ "private", "String", "pageUri", "(", "final", "UriTemplate", "uriTemplate", ",", "final", "int", "skip", ",", "final", "int", "limit", ")", "{", "if", "(", "limit", "==", "MAX_VALUE", ")", "{", "return", "uriTemplate", ".", "expand", "(", ")", ";", "}", ...
Return the URI of the page with N skipped items and a page limitted to pages of size M. @param uriTemplate the template used to create the link @param skip the number of skipped items @param limit the page size @return href
[ "Return", "the", "URI", "of", "the", "page", "with", "N", "skipped", "items", "and", "a", "page", "limitted", "to", "pages", "of", "size", "M", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/paging/SkipLimitPaging.java#L295-L300
136,396
otto-de/edison-hal
example-springboot/src/main/java/de/otto/edison/hal/example/shop/ProductSearchService.java
ProductSearchService.searchFor
public List<Product> searchFor(final Optional<String> searchTerm) { if (searchTerm.isPresent()) { return products .stream() .filter(matchingProductsFor(searchTerm.get())) .collect(toList()); } else { return products; } }
java
public List<Product> searchFor(final Optional<String> searchTerm) { if (searchTerm.isPresent()) { return products .stream() .filter(matchingProductsFor(searchTerm.get())) .collect(toList()); } else { return products; } }
[ "public", "List", "<", "Product", ">", "searchFor", "(", "final", "Optional", "<", "String", ">", "searchTerm", ")", "{", "if", "(", "searchTerm", ".", "isPresent", "(", ")", ")", "{", "return", "products", ".", "stream", "(", ")", ".", "filter", "(", ...
Searches for products using a case-insensitive search term. @param searchTerm expression to search for @return List of matching products, or an empty list.
[ "Searches", "for", "products", "using", "a", "case", "-", "insensitive", "search", "term", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/example-springboot/src/main/java/de/otto/edison/hal/example/shop/ProductSearchService.java#L62-L72
136,397
otto-de/edison-hal
src/main/java/de/otto/edison/hal/HalRepresentation.java
HalRepresentation.mergeWithEmbedding
HalRepresentation mergeWithEmbedding(final Curies curies) { this.curies = this.curies.mergeWith(curies); if (this.links != null) { removeDuplicateCuriesFromEmbedding(curies); this.links = this.links.using(this.curies); if (embedded != null) { embedded = embedded.using(this.curies); } } else { if (embedded != null) { embedded = embedded.using(curies); } } return this; }
java
HalRepresentation mergeWithEmbedding(final Curies curies) { this.curies = this.curies.mergeWith(curies); if (this.links != null) { removeDuplicateCuriesFromEmbedding(curies); this.links = this.links.using(this.curies); if (embedded != null) { embedded = embedded.using(this.curies); } } else { if (embedded != null) { embedded = embedded.using(curies); } } return this; }
[ "HalRepresentation", "mergeWithEmbedding", "(", "final", "Curies", "curies", ")", "{", "this", ".", "curies", "=", "this", ".", "curies", ".", "mergeWith", "(", "curies", ")", ";", "if", "(", "this", ".", "links", "!=", "null", ")", "{", "removeDuplicateCu...
Merges the Curies of an embedded resource with the Curies of this resource and updates link-relation types in _links and _embedded items. @param curies the Curies of the embedding resource @return this
[ "Merges", "the", "Curies", "of", "an", "embedded", "resource", "with", "the", "Curies", "of", "this", "resource", "and", "updates", "link", "-", "relation", "types", "in", "_links", "and", "_embedded", "items", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/HalRepresentation.java#L238-L254
136,398
otto-de/edison-hal
src/main/java/de/otto/edison/hal/HalParser.java
HalParser.as
public <T extends HalRepresentation> T as(final Class<T> type) throws IOException { return objectMapper.readValue(json, type); }
java
public <T extends HalRepresentation> T as(final Class<T> type) throws IOException { return objectMapper.readValue(json, type); }
[ "public", "<", "T", "extends", "HalRepresentation", ">", "T", "as", "(", "final", "Class", "<", "T", ">", "type", ")", "throws", "IOException", "{", "return", "objectMapper", ".", "readValue", "(", "json", ",", "type", ")", ";", "}" ]
Specify the type that is used to parse and map the json. @param type the java type used to parse the JSON @param <T> the type of the class, extending HalRepresentation @return instance of T, containing the data of the parsed HAL document. @throws IOException if a low-level I/O problem (unexpected end-of-input, network error) occurs. @throws JsonParseException if the json document can not be parsed by Jackson's ObjectMapper @throws JsonMappingException if the input JSON structure can not be mapped to the specified HalRepresentation type @since 0.1.0
[ "Specify", "the", "type", "that", "is", "used", "to", "parse", "and", "map", "the", "json", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/HalParser.java#L133-L135
136,399
otto-de/edison-hal
src/main/java/de/otto/edison/hal/HalParser.java
HalParser.findPossiblyCuriedEmbeddedNode
private Optional<JsonNode> findPossiblyCuriedEmbeddedNode(final HalRepresentation halRepresentation, final JsonNode jsonNode, final String rel) { final JsonNode embedded = jsonNode.get("_embedded"); if (embedded != null) { final Curies curies = halRepresentation.getCuries(); final JsonNode curiedNode = embedded.get(curies.resolve(rel)); if (curiedNode == null) { return Optional.ofNullable(embedded.get(curies.expand(rel))); } else { return Optional.of(curiedNode); } } else { return Optional.empty(); } }
java
private Optional<JsonNode> findPossiblyCuriedEmbeddedNode(final HalRepresentation halRepresentation, final JsonNode jsonNode, final String rel) { final JsonNode embedded = jsonNode.get("_embedded"); if (embedded != null) { final Curies curies = halRepresentation.getCuries(); final JsonNode curiedNode = embedded.get(curies.resolve(rel)); if (curiedNode == null) { return Optional.ofNullable(embedded.get(curies.expand(rel))); } else { return Optional.of(curiedNode); } } else { return Optional.empty(); } }
[ "private", "Optional", "<", "JsonNode", ">", "findPossiblyCuriedEmbeddedNode", "(", "final", "HalRepresentation", "halRepresentation", ",", "final", "JsonNode", "jsonNode", ",", "final", "String", "rel", ")", "{", "final", "JsonNode", "embedded", "=", "jsonNode", "....
Returns the JsonNode of the embedded items by link-relation type and resolves possibly curied rels. @param halRepresentation the HAL document including the 'curies' links. @param jsonNode the JsonNode of the document @param rel the link-relation type of interest @return JsonNode @since 0.3.0
[ "Returns", "the", "JsonNode", "of", "the", "embedded", "items", "by", "link", "-", "relation", "type", "and", "resolves", "possibly", "curied", "rels", "." ]
1582d2b49d1f0d9103e03bf742f18afa9d166992
https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/HalParser.java#L250-L265