code
stringlengths
73
34.1k
label
stringclasses
1 value
public List<ItemState> getChildrenChanges(String rootIdentifier, boolean forNodes) { List<ItemState> children = forNodes ? childNodeStates.get(rootIdentifier) : childPropertyStates.get(rootIdentifier); return children == null ? new ArrayList<ItemState>() : children; }
java
public ItemState getItemState(String itemIdentifier, int state) { return index.get(new IDStateBasedKey(itemIdentifier, state)); }
java
public ItemState getItemState(NodeData parentData, QPathEntry name, ItemType itemType) throws IllegalPathException { if (itemType != ItemType.UNKNOWN) { return index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, itemType)); } else { ItemState state = ...
java
public List<ItemState> getItemStates(String itemIdentifier) { List<ItemState> states = new ArrayList<ItemState>(); List<ItemState> currentStates = getAllStates(); for (int i = 0, length = currentStates.size(); i < length; i++) { ItemState state = currentStates.get(i); if (st...
java
public ItemState findItemState(String id, Boolean isPersisted, int... states) throws IllegalPathException { List<ItemState> allStates = getAllStates(); // search from the end for state for (int i = allStates.size() - 1; i >= 0; i--) { ItemState istate = allStates.get(i); boo...
java
private String checkIfFile(Node node) { return ResourceUtil.isFile(node) ? Boolean.TRUE.toString() : Boolean.FALSE.toString(); }
java
private void onConnectionClosed() { ConnectionEvent evt = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED); for (ConnectionEventListener listener : listeners) { try { listener.connectionClosed(evt); } catch (Exception e1) { ...
java
public PropertyDefinitionData[] readPropertyDefinitions(NodeData nodeData) throws NodeTypeReadException, RepositoryException { List<PropertyDefinitionData> propertyDefinitionDataList; List<NodeData> childDefinitions = dataManager.getChildNodesData(nodeData); InternalQName name = null; ...
java
public static String getPath(String relativePath, String backupDirCanonicalPath) throws MalformedURLException { String path = "file:" + backupDirCanonicalPath + "/" + relativePath; URL urlPath = new URL(resolveFileURL(path)); return urlPath.getFile(); }
java
protected void rollback(WorkspaceStorageConnection conn) { try { if (conn != null) { conn.rollback(); } } catch (IllegalStateException e) { LOG.error("Can not rollback connection", e); } catch (RepositoryException e) { ...
java
private void cleanupSwapDirectory() { PrivilegedAction<Void> action = new PrivilegedAction<Void>() { public Void run() { File[] files = containerConfig.spoolConfig.tempDirectory.listFiles(); if (files != null && files.length > 0) { LOG....
java
protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig) throws RepositoryConfigurationException { DatabaseStructureType dbType = DBInitializerHelper.getDatabaseType(wsConfig); for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries()) { if (wsEntry.getN...
java
private String validateDialect(String confParam) { for (String dbType : DBConstants.DB_DIALECTS) { if (confParam.equals(dbType)) { return dbType; } } return DBConstants.DB_DIALECT_AUTO; // by default }
java
private String composeWorkspaceUniqueName(String repositoryName, String workspaceName) { StringBuilder builder = new StringBuilder(); builder.append(repositoryName); builder.append('/'); builder.append(workspaceName); builder.append('/'); return builder.toString(); }
java
private void waitForCoordinator() { LOG.info("Waiting to be released by the coordinator"); try { lock.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
java
public static void configureCacheStore(MappedParametrizedObjectEntry parameterEntry, String dataSourceParamName, String dataColumnParamName, String idColumnParamName, String timeColumnParamName, String dialectParamName) throws RepositoryException { String dataSou...
java
@Group public final String getGroup() { if (fullGroupName != null) { return fullGroupName; } StringBuilder sb = new StringBuilder(); if (ownerId != null) { sb.append(ownerId).append('-'); } return fullGroupName = sb.append(group == null...
java
public long getGlobalDataSizeDirectly() throws QuotaManagerException { long size = 0; for (RepositoryQuotaManager rqm : rQuotaManagers.values()) { size += rqm.getRepositoryDataSizeDirectly(); } return size; }
java
private PathQueryNode createPathQueryNode(SimpleNode node) { root.setLocationNode(factory.createPathQueryNode(root)); node.childrenAccept(this, root.getLocationNode()); return root.getLocationNode(); }
java
public static Calendar parse(String dateString) throws ValueFormatException { try { return ISO8601.parseEx(dateString); } catch (ParseException e) { throw new ValueFormatException("Can not parse date from [" + dateString + "]", e); } catch (NumberFormatExce...
java
public static long createHash(byte[] data) { long h = 0; byte[] res; synchronized (digestFunction) { res = digestFunction.digest(data); } for (int i = 0; i < 4; i++) { h <<= 8; h |= ((int) res[i]) & 0xFF; } return ...
java
public static void backup(File storageDir, Connection jdbcConn, Map<String, String> scripts) throws BackupException { Exception exc = null; ZipObjectWriter contentWriter = null; ZipObjectWriter contentLenWriter = null; try { contentWriter = new ZipObjectWriter(Pri...
java
private static void dumpTable(Connection jdbcConn, String tableName, String script, File storageDir, ZipObjectWriter contentWriter, ZipObjectWriter contentLenWriter) throws IOException, SQLException { SecurityManager security = System.getSecurityManager(); if (security != null) { sec...
java
BackupChain startBackup(BackupConfig config, BackupJobListener jobListener) throws BackupOperationException, BackupConfigurationException, RepositoryException, RepositoryConfigurationException { validateBackupConfig(config); Calendar startTime = Calendar.getInstance(); File dir = Fi...
java
private void validateBackupConfig(RepositoryBackupConfig config) throws BackupConfigurationException { if (config.getIncrementalJobPeriod() < 0) { throw new BackupConfigurationException("The parameter 'incremental job period' can not be negative."); } if (config.getIncrementalJobNum...
java
private void readParamsFromFile() { PropertiesParam pps = initParams.getPropertiesParam(BACKUP_PROPERTIES); backupDir = pps.getProperty(BACKUP_DIR); // full backup type can be not defined. Using default. fullBackupType = pps.getProperty(FULL_BACKUP_TYPE) == null ? DEFAULT_VALUE_FULL...
java
public synchronized void endLog() { if (!finalized) { finishedTime = Calendar.getInstance(); finalized = true; logWriter.writeEndLog(); //copy backup chain log file in into Backupset files itself for portability (e.g. on another server) try { ...
java
public Response delete(Session session, String path, String lockTokenHeader) { try { if (lockTokenHeader == null) { lockTokenHeader = ""; } Item item = session.getItem(path); if (item.isNode()) { Node node = (Node)...
java
protected void spoolInputStream() { if (spoolFile != null || data != null) // already spooled { return; } byte[] buffer = new byte[0]; byte[] tmpBuff = new byte[2048]; int read = 0; int len = 0; SpoolFile sf = null; OutputStream sfout = null; try...
java
private void removeSpoolFile() throws IOException { if (spoolFile != null) { if (spoolFile instanceof SpoolFile) { (spoolFile).release(this); } if (PrivilegedFileHelper.exists(spoolFile)) { if (!PrivilegedFileHelper.delete(spoolFile)) ...
java
public boolean validateNodeType() { boolean hasValidated = false; if (primaryItemName != null) { if (primaryItemName.length() <= 0) { primaryItemName = null; hasValidated = true; } } if (declaredSupertypeNames == null) { ...
java
public Value[] getValueArray() throws RepositoryException { Value[] values = new Value[propertyData.getValues().size()]; for (int i = 0; i < values.length; i++) { values[i] = valueFactory.loadValue(propertyData.getValues().get(i), propertyData.getType()); } return values; }
java
public String dump() { StringBuilder vals = new StringBuilder("Property "); try { vals = new StringBuilder(getPath()).append(" values: "); for (int i = 0; i < getValueArray().length; i++) { vals.append(ValueDataUtil.getString(((BaseValue)getValueArray()[i]).ge...
java
public void setParentId(String parentId) { this.parentId = (parentId == null || parentId.equals("") ? null : parentId); setGroupName(groupName); }
java
public void skip(long n) throws IllegalArgumentException, NoSuchElementException { if (n < 0) { throw new IllegalArgumentException("skip(" + n + ")"); } for (long i = 0; i < n; i++) { next(); } }
java
public static List<File> listFiles(File srcPath) throws IOException { List<File> result = new ArrayList<File>(); if (!srcPath.isDirectory()) { throw new IOException(srcPath.getAbsolutePath() + " is a directory"); } for (File subFile : srcPath.listFiles()) { ...
java
public static void copyDirectory(File srcPath, File dstPath) throws IOException { if (srcPath.isDirectory()) { if (!dstPath.exists()) { dstPath.mkdirs(); } String files[] = srcPath.list(); for (int i = 0; i < files.length; i++) ...
java
public static void removeDirectory(File dir) throws IOException { if (dir.isDirectory()) { for (File subFile : dir.listFiles()) { removeDirectory(subFile); } if (!dir.delete()) { throw new IOException("Can't remove folder : ...
java
private static void compressDirectory(String relativePath, File srcPath, ZipOutputStream zip) throws IOException { if (srcPath.isDirectory()) { zip.putNextEntry(new ZipEntry(relativePath + "/" + srcPath.getName() + "/")); zip.closeEntry(); String files[] = srcPath.list(...
java
public static void deleteDstAndRename(File srcFile, File dstFile) throws IOException { if (dstFile.exists()) { if (!dstFile.delete()) { throw new IOException("Cannot delete " + dstFile); } } renameFile(srcFile, dstFile); }
java
public static void renameFile(File srcFile, File dstFile) throws IOException { // Rename the srcFile file to the new one. Unfortunately, the renameTo() // method does not work reliably under some JVMs. Therefore, if the // rename fails, we manually rename by copying the srcFile file to the new...
java
public static long getSize(File dir) { long size = 0; for (File file : dir.listFiles()) { if (file.isFile()) { size += file.length(); } else { size += getSize(file); } } return size; }
java
protected void removeWorkspace(ManageableRepository mr, String workspaceName) throws RepositoryException { boolean isExists = false; for (String wsName : mr.getWorkspaceNames()) if (workspaceName.equals(wsName)) { isExists = true; break; } if (is...
java
private void removeChildrenItems(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException, IllegalNameException, IllegalStateException, UnsupportedOperationException, InvalidItemStateException, RepositoryException { String parentId = resultSet.getString(DBConstants.COLUMN_ID); String se...
java
private void loadScript(Node node) throws Exception { ResourceId key = new NodeScriptKey(repository.getConfiguration().getName(), workspaceName, node); ObjectFactory<AbstractResourceDescriptor> resource = groovyScript2RestLoader.groovyPublisher.unpublishResource(key); if (resource != null)...
java
private void unloadScript(String path) throws Exception { ResourceId key = new NodeScriptKey(repository.getConfiguration().getName(), workspaceName, path); groovyScript2RestLoader.groovyPublisher.unpublishResource(key); }
java
private ExoContainer getContainer() throws ResourceException { ExoContainer container = ExoContainerContext.getCurrentContainer(); if (container instanceof RootContainer) { String portalContainerName = portalContainer == null ? PortalContainer.DEFAULT_PORTAL_CONTAINER_NAME : po...
java
public static ValueDataWrapper readValueData(String cid, int type, int orderNumber, int version, final InputStream content, SpoolConfig spoolConfig) throws IOException { ValueDataWrapper vdDataWrapper = new ValueDataWrapper(); byte[] buffer = new byte[0]; byte[] spoolBuffer = new byte[ValueF...
java
public static ValueDataWrapper readValueData(int type, int orderNumber, File file, SpoolConfig spoolConfig) throws IOException { ValueDataWrapper vdDataWrapper = new ValueDataWrapper(); long fileSize = file.length(); vdDataWrapper.size = fileSize; if (fileSize > spoolConfig.maxBufferS...
java
public static PersistedValueData createValueData(int type, int orderNumber, byte[] data) throws IOException { switch (type) { case PropertyType.BINARY : case PropertyType.UNDEFINED : return new ByteArrayPersistedValueData(orderNumber, data); case PropertyType.BOOLE...
java
private boolean isRecordAlreadyExistsException(SQLException e) { // Search in UPPER case // MySQL 5.0.x - com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: // Duplicate entry '4f684b34c0a800030018c34f99165791-0' for key 1 // HSQLDB 8.x - java.sql.SQLException: Violati...
java
public boolean isTextContent() { try { return dataProperty().getType() != PropertyType.BINARY; } catch (RepositoryException exc) { LOG.error(exc.getMessage(), exc); return false; } }
java
public QName createQName(String strName) { String[] parts = strName.split(":"); if (parts.length > 1) return new QName(getNamespaceURI(parts[0]), parts[1], parts[0]); else return new QName(parts[0]); }
java
public String getNamespaceURI(String prefix) { String uri = null; try { uri = namespaceRegistry.getURI(prefix); } catch (NamespaceException exc) { uri = namespaces.get(prefix); } catch (RepositoryException exc) { log.error(...
java
public String getPrefix(String namespaceURI) { String prefix = null; try { prefix = namespaceRegistry.getPrefix(namespaceURI); } catch (NamespaceException exc) { prefix = prefixes.get(namespaceURI); } catch (RepositoryException exc) ...
java
public Iterator<String> getPrefixes(String namespaceURI) { List<String> list = new ArrayList<String>(); list.add(getPrefix(namespaceURI)); return list.iterator(); }
java
private static Map<String, String[]> getSynonyms(InputStream config) throws IOException { try { Map<String, String[]> synonyms = new HashMap<String, String[]>(); Properties props = new Properties(); props.load(config); Iterator<Map.Entry<Object, Object>> it = props.ent...
java
private static void addSynonym(String term, String synonym, Map<String, String[]> synonyms) { term = term.toLowerCase(); String[] syns = synonyms.get(term); if (syns == null) { syns = new String[]{synonym}; } else { String[] tmp = new String[syns.length + 1...
java
public Response uncheckout(Session session, String path) { try { Node node = session.getRootNode().getNode(TextUtil.relativizePath(path)); Version restoreVersion = node.getBaseVersion(); node.restore(restoreVersion, true); return Response.ok().header(HttpH...
java
protected boolean isDbInitialized(final Connection con) { return SecurityHelper.doPrivilegedAction(new PrivilegedAction<Boolean>() { public Boolean run() { return JDBCUtils.tableExists(configTableName, con); } }); }
java
public boolean aquire(final Object resource, final ValueLockSupport lockHolder) throws InterruptedException, IOException { final Thread myThread = Thread.currentThread(); final VDResource res = resources.get(resource); if (res != null) { if (res.addUserLock(myThread, loc...
java
public boolean release(final Object resource) throws IOException { final Thread myThread = Thread.currentThread(); final VDResource res = resources.get(resource); if (res != null) { if (res.removeUserLock(myThread)) { synchronized (res.lock) ...
java
public PropertyData getProperty(String name) { return properties == null ? null : properties.get(name); }
java
public PersistedPropertyData read(ObjectReader in) throws UnknownClassIdException, IOException { // read id int key; if ((key = in.readInt()) != SerializationConstants.PERSISTED_PROPERTY_DATA) { throw new UnknownClassIdException("There is unexpected class [" + key + "]"); } ...
java
void addDocuments(final Document[] docs) throws IOException { final IndexWriter writer = getIndexWriter(); IOException ioExc = null; try { for (Document doc : docs) { try { writer.addDocument(doc); } catch (Thro...
java
synchronized void close() { releaseWriterAndReaders(); if (directory != null) { try { directory.close(); } catch (IOException e) { directory = null; } } }
java
protected void releaseWriterAndReaders() { if (indexWriter != null) { try { indexWriter.close(); } catch (IOException e) { log.warn("Exception closing index writer: " + e.toString()); } indexWriter = null; } ...
java
protected synchronized void invalidateSharedReader() throws IOException { // also close the read-only reader if (readOnlyReader != null) { readOnlyReader.release(); readOnlyReader = null; } // invalidate shared reader if (sharedReader != null) { sh...
java
public String getQueryLanguage() throws UnsupportedQueryException { if (body.getChild(0).getName().getNamespaceURI().equals("DAV:") && body.getChild(0).getName().getLocalPart().equals("sql")) { return "sql"; } else if (body.getChild(0).getName().getNamespaceURI().equals("DAV...
java
public String getQuery() throws UnsupportedQueryException { if (body.getChild(0).getName().getNamespaceURI().equals("DAV:") && body.getChild(0).getName().getLocalPart().equals("sql")) { return body.getChild(0).getValue(); } else if (body.getChild(0).getName().getNamespaceURI...
java
public synchronized void setMode(IndexerIoMode mode) { if (this.mode != mode) { log.info("Indexer io mode=" + mode); this.mode = mode; for (IndexerIoModeListener listener : listeners) { listener.onChangeMode(mode); } } }
java
public void read() throws IOException { SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { // Known issue for NFS bases on ext3. Need to refresh directory to read actual data. dir.listAll(...
java
public void write() throws IOException { SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { // do not write if not dirty if (!dirty) { return null; }...
java
private void rename(String from, String to) throws IOException { IndexOutputStream out = null; IndexInputStream in = null; try { out = new IndexOutputStream(dir.createOutput(to)); in = new IndexInputStream(dir.openInput(from)); DirectoryHelper.transfer(in, out); ...
java
public void addName(String name) { if (names.contains(name)) { throw new IllegalArgumentException("already contains: " + name); } indexes.add(name); names.add(name); dirty = true; }
java
protected void setNames(Set<String> names) { this.names.clear(); this.indexes.clear(); this.names.addAll(names); this.indexes.addAll(names); // new list of indexes if thought to be up to date dirty = false; }
java
public void addPermissions(String identity, String[] perm) throws RepositoryException { for (String p : perm) { accessList.add(new AccessControlEntry(identity, p)); } }
java
public void removePermissions(String identity) { for (Iterator<AccessControlEntry> iter = accessList.iterator(); iter.hasNext();) { AccessControlEntry a = iter.next(); if (a.getIdentity().equals(identity)) iter.remove(); } }
java
public List<AccessControlEntry> getPermissionEntries() { List<AccessControlEntry> list = new ArrayList<AccessControlEntry>(); for (int i = 0, length = accessList.size(); i < length; i++) { AccessControlEntry entry = accessList.get(i); list.add(new AccessControlEntry(entry.getIdent...
java
public LocationStepQueryNode[] getPathSteps() { if (operands == null) { return EMPTY; } else { return (LocationStepQueryNode[]) operands.toArray(new LocationStepQueryNode[operands.size()]); } }
java
protected boolean isResidualMatch(InternalQName itemName, T[] recipientDefinition) { boolean containsResidual = false; for (int i = 0; i < recipientDefinition.length; i++) { if (itemName.equals(recipientDefinition[i].getName())) return false; else if (Constants.JCR_ANY...
java
private Thread createThreadFindNodesCount(final Reindexable reindexableComponent) { return new Thread("Nodes count(" + handler.getContext().getWorkspaceName() + ")") { public void run() { try { if (reindexableComponent != null) { ...
java
int numDocs() throws IOException { if (indexNames.size() == 0) { return volatileIndex.getNumDocuments(); } else { CachingMultiIndexReader reader = getIndexReader(); try { return reader.numDocs(); } finally { ...
java
public void reindex(ItemDataConsumer stateMgr) throws IOException, RepositoryException { if (stopped.get()) { throw new IllegalStateException("Can't invoke reindexing on closed index."); } if (online.get()) { throw new IllegalStateException("Can't invoke reindexing wh...
java
synchronized void update(final Collection<String> remove, final Collection<Document> add) throws IOException { if (!online.get()) { doUpdateOffline(remove, add); } else if (modeHandler.getMode() == IndexerIoMode.READ_WRITE && redoLog != null) { doUpdateRW(remove, add);...
java
private void doUpdateRW(final Collection<String> remove, final Collection<Document> add) throws IOException { // make sure a reader is available during long updates if (add.size() > handler.getBufferSize()) { try { releaseMultiReader(); } catch (IOExc...
java
private void doUpdateOffline(final Collection<String> remove, final Collection<Document> add) throws IOException { SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { for (Iterator<String> it = remove....
java
void addDocument(Document doc) throws IOException { update(Collections.<String> emptyList(), Arrays.asList(new Document[]{doc})); }
java
private void initMerger() throws IOException { if (merger == null) { merger = new IndexMerger(this); merger.setMaxMergeDocs(handler.getMaxMergeDocs()); merger.setMergeFactor(handler.getMergeFactor()); merger.setMinMergeDocs(handler.getMinMergeDocs()); for (Ob...
java
private void scheduleFlushTask() { // cancel task if (flushTask != null) { flushTask.cancel(); } // clear canceled tasks FLUSH_TIMER.purge(); // new flush task, cause canceled can't be re-used flushTask = new TimerTask() { @Override pub...
java
private void resetVolatileIndex() throws IOException { volatileIndex = new VolatileIndex(handler.getTextAnalyzer(), handler.getSimilarity()); volatileIndex.setUseCompoundFile(handler.getUseCompoundFile()); volatileIndex.setMaxFieldLength(handler.getMaxFieldLength()); volatileIndex.setBufferSi...
java
private void commitVolatileIndex() throws IOException { // check if volatile index contains documents at all if (volatileIndex.getNumDocuments() > 0) { long time = 0; if (LOG.isDebugEnabled()) { time = System.currentTimeMillis(); } // creat...
java
private void removeDeletable() { String fileName = "deletable"; try { if (indexDir.fileExists(fileName)) { indexDir.deleteFile(fileName); } } catch (IOException e) { LOG.warn("Unable to remove file 'deletable'.", e); } }
java
protected void setReadOnly() { // try to stop merger in safe way if (merger != null) { merger.dispose(); merger = null; } if (flushTask != null) { flushTask.cancel(); } FLUSH_TIMER.purge(); this.redoLog = null; }
java
protected void setReadWrite() throws IOException { // Release all the current threads synchronized (updateMonitor) { indexUpdateMonitor.setUpdateInProgress(false, true); updateMonitor.notifyAll(); releaseMultiReader(); } this.redoLog = new RedoLog(indexDir); ...
java
public void refreshIndexList() throws IOException { synchronized (updateMonitor) { // release reader if any releaseMultiReader(); // prepare added/removed sets Set<String> newList = new HashSet<String>(indexNames.getNames()); // remove removed indexes ...
java
public synchronized void setOnline(boolean isOnline, boolean dropStaleIndexes, boolean initMerger) throws IOException { // if mode really changed if (online.get() != isOnline) { // switching to ONLINE if (isOnline) { LOG.info("Setting index ONLINE ({})", handl...
java
private boolean recoveryIndexFromCoordinator() throws IOException { File indexDirectory = new File(handler.getContext().getIndexDirectory()); try { IndexRecovery indexRecovery = handler.getContext().getIndexRecovery(); // check if index not ready if (!indexRecovery.check...
java
private boolean rsyncRecoveryIndexFromCoordinator() throws IOException { File indexDirectory = new File(handler.getContext().getIndexDirectory()); RSyncConfiguration rSyncConfiguration = handler.getRsyncConfiguration(); try { IndexRecovery indexRecovery = handler.getContext().getIn...
java
public boolean hasDeletions() throws CorruptIndexException, IOException { boolean result = false; for (PersistentIndex index : indexes) { IndexWriter writer = index.getIndexWriter(); result |= writer.hasDeletions(); } return result; }
java