code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static SiblingCounter constant( final int count ) {
assert count > -1;
return new SiblingCounter() {
@Override
public int countSiblingsNamed( Name childName ) {
return count;
}
};
} | java |
public static SiblingCounter alter( final SiblingCounter counter,
final int delta ) {
assert counter != null;
return new SiblingCounter() {
@Override
public int countSiblingsNamed( Name childName ) {
int count = counter.coun... | java |
public RestWorkspaces getWorkspaces( HttpServletRequest request,
String repositoryName ) throws RepositoryException {
assert request != null;
assert repositoryName != null;
RestWorkspaces workspaces = new RestWorkspaces();
Session session = getSe... | java |
public Response backupRepository( ServletContext context,
HttpServletRequest request,
String repositoryName,
BackupOptions options ) throws RepositoryException {
final File backupLocation = resolv... | java |
public Response restoreRepository( ServletContext context,
HttpServletRequest request,
String repositoryName,
String backupName,
RestoreOptions options ) throws ... | java |
public void add( T value ) {
Lock lock = this.lock.writeLock();
try {
lock.lock();
doAddValue(value);
} finally {
lock.unlock();
}
} | java |
public T getTotal() {
Lock lock = this.lock.readLock();
lock.lock();
try {
return this.total;
} finally {
lock.unlock();
}
} | java |
public T getMaximum() {
Lock lock = this.lock.readLock();
lock.lock();
try {
return this.maximum;
} finally {
lock.unlock();
}
} | java |
public T getMinimum() {
Lock lock = this.lock.readLock();
lock.lock();
try {
return this.minimum != null ? this.minimum : (T)this.math.createZeroValue();
} finally {
lock.unlock();
}
} | java |
public int getCount() {
Lock lock = this.lock.readLock();
lock.lock();
try {
return this.count;
} finally {
lock.unlock();
}
} | java |
public void reset() {
Lock lock = this.lock.writeLock();
lock.lock();
try {
doReset();
} finally {
lock.unlock();
}
} | java |
public static String getSubstitutedProperty( String value,
PropertyAccessor propertyAccessor ) {
if (value == null || value.trim().length() == 0) return value;
StringBuilder sb = new StringBuilder(value);
// Get the index of the first constant,... | java |
private static List<String> split( String str,
String splitter ) {
StringTokenizer tokens = new StringTokenizer(str, splitter);
ArrayList<String> l = new ArrayList<>(tokens.countTokens());
while (tokens.hasMoreTokens()) {
l.add(tokens.nextToken(... | java |
protected void checkFileNotExcluded( String id,
File file ) {
if (isExcluded(file)) {
String msg = JcrI18n.fileConnectorCannotStoreFileThatIsExcluded.text(getSourceName(), id, file.getAbsolutePath());
throw new DocumentStoreException(id, msg);
... | java |
public static String filter( String message ) {
if (message == null) {
return (null);
}
char content[] = new char[message.length()];
message.getChars(0, message.length(), content, 0);
StringBuilder result = new StringBuilder(content.length + 50);
for (int i ... | java |
public static Cookie[] parseCookieHeader( String header ) {
if ((header == null) || (header.length() < 1)) {
return (new Cookie[0]);
}
ArrayList<Cookie> cookies = new ArrayList<Cookie>();
while (header.length() > 0) {
int semicolon = header.indexOf(';');
... | java |
public static String URLDecode( String str,
String enc ) {
if (str == null) {
return (null);
}
// use the specified encoding to extract bytes out of the
// given string so that the encoding is not lost. If an
// encoding is not sp... | java |
public static String URLDecode( byte[] bytes,
String enc ) {
if (bytes == null) {
return (null);
}
int len = bytes.length;
int ix = 0;
int ox = 0;
while (ix < len) {
byte b = bytes[ix++]; // Get byte to test
... | java |
public static boolean streamNotConsumed( HttpServletRequest request ) {
try {
ServletInputStream servletInputStream = request.getInputStream();
//in servlet >= 3.0, available will throw an exception (while previously it didn't)
return request.getContentLength() != 0 && servle... | java |
public static JcrAccessControlList defaultAcl( AccessControlManagerImpl acm ) {
JcrAccessControlList acl = new JcrAccessControlList("/");
try {
acl.principals.put(SimplePrincipal.EVERYONE, new AccessControlEntryImpl(SimplePrincipal.EVERYONE, acm.privileges()));
} catch (AccessControl... | java |
public boolean hasPrivileges( SecurityContext sc,
Privilege[] privileges ) {
for (AccessControlEntryImpl ace : principals.values()) {
// check access list for everyone
if (ace.getPrincipal().getName().equals(SimplePrincipal.EVERYONE.getName())) {
... | java |
public Privilege[] getPrivileges( SecurityContext context ) {
ArrayList<Privilege> privs = new ArrayList<Privilege>();
for (AccessControlEntryImpl ace : principals.values()) {
// add privileges granted for everyone
if (ace.getPrincipal().equals(SimplePrincipal.EVERYONE)) {
... | java |
private String username( String username ) {
return (username.startsWith("<") && username.endsWith(">")) ? username.substring(1, username.length() - 1) : username;
} | java |
public NodeCache getNodeCache( String workspaceName ) throws WorkspaceNotFoundException {
NodeCache cache = overriddenNodeCachesByWorkspaceName.get(workspaceName);
if (cache == null) {
cache = repositoryCache.getWorkspaceCache(workspaceName);
}
return cache;
} | java |
public QueryContext with( Schemata schemata ) {
CheckArg.isNotNull(schemata, "schemata");
return new QueryContext(context, repositoryCache, workspaceNames, overriddenNodeCachesByWorkspaceName, schemata,
indexDefns, nodeTypes, bufferManager, hints, problems, variables);
... | java |
public QueryContext with( Problems problems ) {
return new QueryContext(context, repositoryCache, workspaceNames, overriddenNodeCachesByWorkspaceName, schemata,
indexDefns, nodeTypes, bufferManager, hints, problems, variables);
} | java |
public QueryContext with( Map<String, Object> variables ) {
return new QueryContext(context, repositoryCache, workspaceNames, overriddenNodeCachesByWorkspaceName, schemata,
indexDefns, nodeTypes, bufferManager, hints, problems, variables);
} | java |
public void scoreText( String text,
int factor,
String... keywords ) {
if (text != null && keywords != null) {
// Increment the score once for each keyword that is found within the text ...
String lowercaseText = text.toLowerCase();
... | java |
protected String removeUnusedPredicates( String expression ) {
assert expression != null;
java.util.regex.Matcher matcher = UNUSABLE_PREDICATE_PATTERN.matcher(expression);
// CHECKSTYLE IGNORE check FOR NEXT 1 LINES
StringBuffer sb = new StringBuffer();
if (matcher.find()) {
... | java |
protected String replaceXPathPatterns( String expression ) {
assert expression != null;
// replace 2 or more sequential '|' characters in an OR expression
expression = expression.replaceAll("[\\|]{2,}", "|");
// if there is an empty expression in an OR expression, make the whole segment ... | java |
public Object get(String name) {
Object obj = document.get(name);
return (obj instanceof BasicArray) ? ((BasicArray)obj).toArray() : obj;
} | java |
private void readFromStream(InputStream in) throws IOException {
document = DocumentFactory.newDocument(Json.read(in));
} | java |
public final String[] getPathExpressions() {
String pathExpression = this.pathExpression;
Object[] pathExpressions = this.pathExpressions;
if (pathExpression == null && (pathExpressions == null || pathExpressions.length == 0)) {
// there's none ...
return new String[] {};... | java |
public final boolean isAccepted( String mimeType ) {
if (mimeType != null && hasAcceptedMimeTypes()) {
return getAcceptedMimeTypes().contains(mimeType.trim());
}
return true; // accept all mime types
} | java |
private List<SessionNode> getChangedNodesAtOrBelowChildrenFirst( Path nodePath ) {
List<SessionNode> changedNodesChildrenFirst = new ArrayList<SessionNode>();
for (NodeKey key : changedNodes.keySet()) {
SessionNode changedNode = changedNodes.get(key);
boolean isAtOrBelow = false;... | java |
private void completeTransaction(final String txId, String wsName) {
getWorkspace().clear();
// reset the ws cache to the shared (global one)
setWorkspaceCache(sharedWorkspaceCache());
// and clear some tx specific data
COMPLETE_FUNCTION_BY_TX_AND_WS.compute(txId, (transactionId,... | java |
private void rollback(Transaction txn, Exception cause) throws Exception {
try {
txn.rollback();
} catch (Exception e) {
logger.debug(e, "Error while rolling back transaction " + txn);
} finally {
throw cause;
}
} | java |
public static Date createDate( Calendar target ) {
return new java.sql.Date(target.getTime().getTime());
} | java |
public void mergeNodes( DdlTokenStream tokens,
AstNode firstNode,
AstNode secondNode ) {
assert tokens != null;
assert firstNode != null;
assert secondNode != null;
int firstStartIndex = (Integer)firstNode.getProperty(DDL_START_CHA... | java |
protected AstNode parseCreateStatement( DdlTokenStream tokens,
AstNode parentNode ) throws ParsingException {
assert tokens != null;
assert parentNode != null;
AstNode stmtNode = null;
// DEFAULT DOES NOTHING
// Subclasses can impleme... | java |
protected AstNode parseAlterStatement( DdlTokenStream tokens,
AstNode parentNode ) throws ParsingException {
assert tokens != null;
assert parentNode != null;
if (tokens.matches(ALTER, TABLE)) {
return parseAlterTableStatement(tokens, paren... | java |
protected String getTableElementsString( DdlTokenStream tokens,
boolean useTerminator ) throws ParsingException {
assert tokens != null;
StringBuilder sb = new StringBuilder(100);
if (useTerminator) {
while (!isTerminator(tokens)) {
... | java |
protected void parseConstraintAttributes( DdlTokenStream tokens,
AstNode constraintNode ) throws ParsingException {
assert tokens != null;
assert constraintNode != null;
// Now we need to check for constraint attributes:
// <constraint attr... | java |
protected List<String> getDataTypeStartWords() {
if (allDataTypeStartWords == null) {
allDataTypeStartWords = new ArrayList<String>();
allDataTypeStartWords.addAll(DataTypes.DATATYPE_START_WORDS);
allDataTypeStartWords.addAll(getCustomDataTypeStartWords());
}
... | java |
protected String consumeIdentifier( DdlTokenStream tokens ) throws ParsingException {
String value = tokens.consume();
// This may surrounded by quotes, so remove them ...
if (value.charAt(0) == '"') {
int length = value.length();
// Check for the end quote ...
... | java |
protected boolean parseColumnNameList( DdlTokenStream tokens,
AstNode parentNode,
String referenceType ) {
boolean parsedColumns = false;
// CONSUME COLUMNS
List<String> columnNameList = new ArrayList<String>()... | java |
protected List<String> parseNameList( DdlTokenStream tokens ) throws ParsingException {
List<String> names = new LinkedList<String>();
while (true) {
names.add(parseName(tokens));
if (!tokens.canConsume(COMMA)) {
break;
}
}
return na... | java |
protected String parseUntilTerminator( DdlTokenStream tokens ) throws ParsingException {
final StringBuilder sb = new StringBuilder();
boolean lastTokenWasPeriod = false;
Position prevPosition = (tokens.hasNext() ? tokens.nextPosition() : Position.EMPTY_CONTENT_POSITION);
String prevToke... | java |
protected String parseUntilSemiColon( DdlTokenStream tokens ) throws ParsingException {
StringBuilder sb = new StringBuilder();
boolean lastTokenWasPeriod = false;
while (tokens.hasNext() && !tokens.matches(SEMICOLON)) {
String thisToken = tokens.consume();
boolean thisT... | java |
final boolean registerListener( NodeTypes.Listener listener ) {
return listener != null ? this.listeners.addIfAbsent(listener) : false;
} | java |
boolean isNodeTypeInUse( Name nodeTypeName ) throws InvalidQueryException {
String nodeTypeString = nodeTypeName.getString(context.getNamespaceRegistry());
String expression = "SELECT * from [" + nodeTypeString + "] LIMIT 1";
TypeSystem typeSystem = context.getValueFactories().getTypeSystem();
... | java |
protected void doInitialize( IndexProvider provider ) throws RepositoryException {
// Set the execution context instance ...
Reflection.setValue(provider, "context", repository.context());
// Set the environment
Reflection.setValue(provider, "environment", repository.environmen... | java |
IndexWriter getIndexWriterForProviders( Set<String> providerNames ) {
List<IndexProvider> reindexProviders = new LinkedList<>();
for (IndexProvider provider : providers.values()) {
if (providerNames.contains(provider.getName())) {
reindexProviders.add(provider);
}... | java |
public void start() {
ObjectName beanName = null;
try {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
beanName = getObjectName();
server.registerMBean(this, beanName);
} catch (InstanceAlreadyExistsException e) {
LOGGER.warn(JcrI... | java |
public void stop() {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName beanName = null;
try {
beanName = getObjectName();
server.unregisterMBean(beanName);
} catch (InstanceNotFoundException e) {
LOGGER.debug("JMX bean {0} not... | java |
public void show(String repository, final boolean changeHistory) {
this.repository = repository;
refreshWorkspacesAndReloadNode(null, ROOT_PATH, changeHistory);
} | java |
public void show(final String repository, final String workspace,
final String path, final boolean changeHistory) {
this.repository = repository;
this.refreshWorkspacesAndReloadNode(null, path, changeHistory);
} | java |
private void refreshWorkspacesAndReloadNode(final String name, final String path,
final boolean changeHistory) {
showLoadIcon();
console.jcrService().getWorkspaces(repository, new AsyncCallback<String[]>() {
@Override
public void onFailure(Throwable caught) {
... | java |
public void getAndDisplayNode(final String path, final boolean changeHistory) {
showLoadIcon();
console.jcrService().node(repository(), workspace(), path, new AsyncCallback<JcrNode>() {
@Override
public void onFailure(Throwable caught) {
hideLoadIcon();
... | java |
private void displayNode(JcrNode node) {
this.node = node;
this.path = node.getPath();
pathLabel.display(node.getPath());
//display childs, properties and ACLs
childrenEditor.show(node);
propertiesEditor.show(node);
permissionsEditor.show(node);
display... | java |
public void save() {
SC.ask("Do you want to save changes", new BooleanCallback() {
@Override
public void execute(Boolean yesSelected) {
if (yesSelected) {
jcrService().save(repository(), workspace(), new BaseCallback<Object>() {
... | java |
public void showAddNodeDialog() {
jcrService().getPrimaryTypes(node.getRepository(),
node.getWorkspace(),
null,
false, new AsyncCallback<String[]>() {
@Override
public void onFailure(Throwable caught) {
SC.say(caught.getMess... | java |
public void exportXML(String name, boolean skipBinary, boolean noRecurse) {
console.jcrService().export(repository, workspace(), path(), name, true, true, new AsyncCallback<Object>() {
@Override
public void onFailure(Throwable caught) {
SC.say(caught.getMessage());
... | java |
public void importXML(String name, int option) {
console.jcrService().importXML(repository, workspace(), path(), name,
option, new AsyncCallback<Object>() {
@Override
public void onFailure(Throwable caught) {
SC.say(caught.getMessage());
}
... | java |
protected String branchRefForName( String branchName ) {
String remoteName = connector.remoteName();
return remoteName != null ? remoteBranchPrefix(remoteName) + branchName : LOCAL_BRANCH_PREFIX + branchName;
} | java |
protected void addBranchesAsChildren( Git git,
CallSpecification spec,
DocumentWriter writer ) throws GitAPIException {
Set<String> remoteBranchPrefixes = remoteBranchPrefixes();
if (remoteBranchPrefixes.isEmpty()) {
... | java |
protected void addTagsAsChildren( Git git,
CallSpecification spec,
DocumentWriter writer ) throws GitAPIException {
// Generate the child references to the branches, which will be sorted by name (by the command).
ListTagCommand ... | java |
protected void addCommitsAsChildren( Git git,
CallSpecification spec,
DocumentWriter writer,
int pageSize ) throws GitAPIException {
// Add commits in the log ...
LogCommand command... | java |
protected void addCommitsAsPageOfChildren( Git git,
Repository repository,
CallSpecification spec,
PageWriter writer,
PageKey pageKe... | java |
boolean isAsOrMoreConstrainedThan( PropertyDefinition other,
ExecutionContext context ) {
String[] otherConstraints = other.getValueConstraints();
if (otherConstraints == null || otherConstraints.length == 0) {
// The ancestor's definition is less const... | java |
@Override
protected void initializeStorage( File directory ) throws BinaryStoreException {
// make sure the directory doesn't exist
FileUtil.delete(directory);
if (!directory.exists()) {
logger.debug("Creating temporary directory for transient binary store: {0}", directory.getAbs... | java |
public Workspace addWorkspace( String name,
String repositoryUrl ) {
Workspace workspace = new Workspace(name, repositoryUrl);
workspaces.add(workspace);
return workspace;
} | java |
protected void modifyProperties( NodeKey key,
Name primaryType,
Set<Name> mixinTypes,
Map<Name, AbstractPropertyChange> propChanges ) {
} | java |
protected void addNode( String workspaceName,
NodeKey key,
Path path,
Name primaryType,
Set<Name> mixinTypes,
Properties properties ) {
} | java |
protected void removeNode( String workspaceName,
NodeKey key,
NodeKey parentKey,
Path path,
Name primaryType,
Set<Name> mixinTypes ) {
} | java |
protected void changeNode( String workspaceName,
NodeKey key,
Path path,
Name primaryType,
Set<Name> mixinTypes ) {
} | java |
protected void moveNode( String workspaceName,
NodeKey key,
Name primaryType,
Set<Name> mixinTypes,
NodeKey oldParent,
NodeKey newParent,
Path new... | java |
protected void renameNode( String workspaceName,
NodeKey key,
Path newPath,
Segment oldSegment,
Name primaryType,
Set<Name> mixinTypes ) {
} | java |
protected void reorderNode( String workspaceName,
NodeKey key,
Name primaryType,
Set<Name> mixinTypes,
NodeKey parent,
Path newPath,
... | java |
public static <T1, T2> TypeFactory<Tuple2<T1, T2>> typeFactory( TypeFactory<T1> type1,
TypeFactory<T2> type2 ) {
return new Tuple2TypeFactory<>(type1, type2);
} | java |
public static <T1, T2, T3> TypeFactory<Tuple3<T1, T2, T3>> typeFactory( TypeFactory<T1> type1,
TypeFactory<T2> type2,
TypeFactory<T3> type3 ) {
return new Tuple... | java |
public static <T1, T2, T3, T4> TypeFactory<Tuple4<T1, T2, T3, T4>> typeFactory( TypeFactory<T1> type1,
TypeFactory<T2> type2,
TypeFactory<T3> type3,
... | java |
public static TypeFactory<?> typeFactory( TypeFactory<?> type,
int tupleSize ) {
if (tupleSize <= 1) return type;
if (tupleSize == 2) return typeFactory(type, type);
if (tupleSize == 3) return typeFactory(type, type, type);
if (tupleSize == 4... | java |
private Privilege[] privileges( Set<String> names ) throws ValueFormatException, AccessControlException, RepositoryException {
Privilege[] privileges = new Privilege[names.size()];
int i = 0;
for (String name : names) {
privileges[i++] = privilegeFromName(name);
}
ret... | java |
protected static String determineMethodsAllowed( StoredObject so ) {
try {
if (so != null) {
if (so.isNullResource()) {
return NULL_RESOURCE_METHODS_ALLOWED;
} else if (so.isFolder()) {
return RESOURCE_METHODS_ALLOWED + FOLDE... | java |
protected AstNode parseCreateIndex( DdlTokenStream tokens,
AstNode parentNode ) throws ParsingException {
assert tokens != null;
assert parentNode != null;
markStartOfStatement(tokens);
// CREATE [UNIQUE] INDEX index-Name
// ON table-Name ... | java |
protected AstNode parseCreateRole( DdlTokenStream tokens,
AstNode parentNode ) throws ParsingException {
assert tokens != null;
assert parentNode != null;
markStartOfStatement(tokens);
tokens.consume(CREATE, "ROLE");
String functionName =... | java |
protected void parseColumns( DdlTokenStream tokens,
AstNode tableNode,
boolean isAlterTable ) throws ParsingException {
String tableElementString = getTableElementsString(tokens, false);
DdlTokenStream localTokens = new DdlTokenStream(ta... | java |
public static Set<Column> getColumnsReferencedBy( Visitable visitable ) {
if (visitable == null) return Collections.emptySet();
final Set<Column> symbols = new HashSet<Column>();
// Walk the entire structure, so only supply a StrategyVisitor (that does no navigation) ...
Visitors.visitAl... | java |
protected static void removeTralingZeros( StringBuilder sb ) {
int endIndex = sb.length();
if (endIndex > 0) {
--endIndex;
int index = endIndex;
while (sb.charAt(index) == '0') {
--index;
}
if (index < endIndex) sb.delete(index ... | java |
public static void write( String content,
File file ) throws IOException {
CheckArg.isNotNull(file, "destination file");
if (content != null) {
write(content, new FileOutputStream(file));
}
} | java |
public static void closeQuietly( Closeable closeable ) {
if (closeable == null) {
return;
}
try {
closeable.close();
} catch (Throwable t) {
LOGGER.debug(t, "Ignored error at closing stream");
}
} | java |
public void setNullResource( boolean f ) {
this.isNullRessource = f;
this.isFolder = false;
this.creationDate = null;
this.lastModified = null;
// this.content = null;
this.contentLength = 0;
this.mimeType = null;
} | java |
protected void endContent() throws RepositoryException {
// Process the content of the element ...
String content = StringUtil.normalize(contentBuilder.toString());
// Null-out builder to setup for subsequent content.
// Must be done before call to startElement below to prevent infinite ... | java |
public void show(int x, int y) {
disabledHLayout.setSize("100%", "100%");
disabledHLayout.setStyleName("disabledBackgroundStyle");
disabledHLayout.show();
loadingImg.setSize("100px", "100px");
loadingImg.setTop(y); //loading image height is 50px
loadingImg.setLeft(x); //... | java |
void checkout( AbstractJcrNode node ) throws LockException, RepositoryException {
checkVersionable(node);
// Check this separately since it throws a different type of exception
if (node.isLocked() && !node.holdsLock()) {
throw new LockException(JcrI18n.lockTokenNotHeld.text(node.get... | java |
public ExecutionContext with( Map<String, String> data ) {
Map<String, String> newData = data;
if (newData == null) {
if (this.data.isEmpty()) return this;
} else {
// Copy the data in the map ...
newData = Collections.unmodifiableMap(new HashMap<String, Strin... | java |
public ExecutionContext with( String key,
String value ) {
Map<String, String> newData = data;
if (value == null) {
// Remove the value with the key ...
if (this.data.isEmpty() || !this.data.containsKey(key)) {
// nothing to remov... | java |
public ExecutionContext with(Locale locale) {
return new ExecutionContext(securityContext, namespaceRegistry, propertyFactory, threadPools, binaryStore, data,
processId, decoder, encoder, stringFactory, binaryFactory, booleanFactory, dateFactory,
... | java |
protected void initializeDefaultNamespaces( NamespaceRegistry namespaceRegistry ) {
if (namespaceRegistry == null) return;
namespaceRegistry.register(JcrLexicon.Namespace.PREFIX, JcrLexicon.Namespace.URI);
namespaceRegistry.register(JcrMixLexicon.Namespace.PREFIX, JcrMixLexicon.Namespace.URI);
... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.