code
stringlengths
73
34.1k
label
stringclasses
1 value
private void postDelete(UserProfile userProfile) throws Exception { for (UserProfileEventListener listener : listeners) { listener.postDelete(userProfile); } }
java
protected void addScripts() { if (loadPlugins == null || loadPlugins.size() == 0) { return; } for (GroovyScript2RestLoaderPlugin loadPlugin : loadPlugins) { // If no one script configured then skip this item, // there is no reason to do anything. if (...
java
protected Node createScript(Node parent, String name, boolean autoload, InputStream stream) throws Exception { Node scriptFile = parent.addNode(name, "nt:file"); Node script = scriptFile.addNode("jcr:content", getNodeType()); script.setProperty("exo:autoload", autoload); script.setProperty("j...
java
protected void setAttributeSmart(Element element, String attr, String value) { if (value == null) { element.removeAttribute(attr); } else { element.setAttribute(attr, value); } }
java
@POST @Path("load/{repository}/{workspace}/{path:.*}") @RolesAllowed({"administrators"}) public Response load(@PathParam("repository") String repository, @PathParam("workspace") String workspace, @PathParam("path") String path, @DefaultValue("true") @QueryParam("state") boolean state, @QueryParam("...
java
@POST @Path("delete/{repository}/{workspace}/{path:.*}") public Response deleteScript(@PathParam("repository") String repository, @PathParam("workspace") String workspace, @PathParam("path") String path) { Session ses = null; try { ses = sessionProviderService.getSe...
java
@POST @Produces({"script/groovy"}) @Path("src/{repository}/{workspace}/{path:.*}") public Response getScript(@PathParam("repository") String repository, @PathParam("workspace") String workspace, @PathParam("path") String path) { Session ses = null; try { ses = se...
java
@POST @Produces({MediaType.APPLICATION_JSON}) @Path("meta/{repository}/{workspace}/{path:.*}") public Response getScriptMetadata(@PathParam("repository") String repository, @PathParam("workspace") String workspace, @PathParam("path") String path) { Session ses = null; try { ...
java
@POST @Produces(MediaType.APPLICATION_JSON) @Path("list/{repository}/{workspace}") public Response list(@PathParam("repository") String repository, @PathParam("workspace") String workspace, @QueryParam("name") String name) { Session ses = null; try { ses = sessio...
java
protected static String getPath(String fullPath) { int sl = fullPath.lastIndexOf('/'); return sl > 0 ? "/" + fullPath.substring(0, sl) : "/"; }
java
protected static String getName(String fullPath) { int sl = fullPath.lastIndexOf('/'); return sl >= 0 ? fullPath.substring(sl + 1) : fullPath; }
java
public HierarchicalProperty getChild(QName name) { for (HierarchicalProperty child : children) { if (child.getName().equals(name)) return child; } return null; }
java
public static String md5(String data, String enc) throws UnsupportedEncodingException { try { return digest("MD5", data.getBytes(enc)); } catch (NoSuchAlgorithmException e) { throw new InternalError("MD5 digest not available???"); } }
java
public static String[] explode(String str, int ch, boolean respectEmpty) { if (str == null || str.length() == 0) { return new String[0]; } ArrayList strings = new ArrayList(); int pos; int lastpos = 0; // add snipples while ((pos = str.indexOf(ch, lastpos)) ...
java
public static String implode(String[] arr, String delim) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < arr.length; i++) { if (i > 0) { buf.append(delim); } buf.append(arr[i]); } return buf.toString(); }
java
public static String encodeIllegalXMLCharacters(String text) { if (text == null) { throw new IllegalArgumentException("null argument"); } StringBuilder buf = null; int length = text.length(); int pos = 0; for (int i = 0; i < length; i++) { int ch = te...
java
public static String getName(String path) { int pos = path.lastIndexOf('/'); return pos >= 0 ? path.substring(pos + 1) : ""; }
java
public static boolean isSibling(String p1, String p2) { int pos1 = p1.lastIndexOf('/'); int pos2 = p2.lastIndexOf('/'); return (pos1 == pos2 && pos1 >= 0 && p1.regionMatches(0, p2, 0, pos1)); }
java
private InternalQName getNodeTypeName(Node config) throws IllegalNameException, RepositoryException { String ntString = config.getAttributes().getNamedItem("primaryType").getNodeValue(); return resolver.parseJCRName(ntString).getInternalName(); }
java
@SuppressWarnings("unchecked") private boolean isIndexRecoveryRequired() throws RepositoryException { // instantiate filters first, if not initialized if (recoveryFilters == null) { recoveryFilters = new ArrayList<AbstractRecoveryFilter>(); log.info("Initializing RecoveryFilter...
java
public MultiColumnQueryHits executeQuery(SessionImpl session, AbstractQueryImpl queryImpl, Query query, QPath[] orderProps, boolean[] orderSpecs, long resultFetchHint) throws IOException, RepositoryException { waitForResuming(); checkOpen(); workingThreads.incrementAndGet(); try ...
java
public IndexFormatVersion getIndexFormatVersion() { if (indexFormatVersion == null) { if (getContext().getParentHandler() instanceof SearchIndex) { SearchIndex parent = (SearchIndex)getContext().getParentHandler(); if (parent.getIndexFormatVersion().getVersion() ...
java
protected IndexReader getIndexReader(boolean includeSystemIndex) throws IOException { // deny query execution if index in offline mode and allowQuery is false if (!indexRegister.getDefaultIndex().isOnline() && !allowQuery.get()) { throw new IndexOfflineIOException("Index is offline"); ...
java
protected SortField[] createSortFields(QPath[] orderProps, boolean[] orderSpecs, FieldComparatorSource scs) throws RepositoryException { List<SortField> sortFields = new ArrayList<SortField>(); for (int i = 0; i < orderProps.length; i++) { if (orderProps[i].getEntries().length == 1 &...
java
public MultiIndex createNewIndex(String suffix) throws IOException { IndexInfos indexInfos = new IndexInfos(); IndexUpdateMonitor indexUpdateMonitor = new DefaultIndexUpdateMonitor(); IndexerIoModeHandler modeHandler = new IndexerIoModeHandler(IndexerIoMode.READ_WRITE); MultiIndex newIndex = ...
java
protected DirectoryManager cloneDirectoryManager(DirectoryManager directoryManager, String suffix) throws IOException { try { DirectoryManager df = directoryManager.getClass().newInstance(); df.init(this.path + suffix); return df; } catch (IOException e) { ...
java
protected InputStream createSynonymProviderConfigResource() throws IOException { if (synonymProviderConfigPath != null) { InputStream fsr; // simple sanity check String separator = PrivilegedSystemHelper.getProperty("file.separator"); if (synonymProviderConfigPath.ends...
java
protected SpellChecker createSpellChecker() { // spell checker config SpellChecker spCheck = null; if (spellCheckerClass != null) { try { spCheck = spellCheckerClass.newInstance(); spCheck.init(SearchIndex.this, spellCheckerMinDistance, spellCheckerMo...
java
public ErrorLog doInitErrorLog(String path) throws IOException { File file = new File(new File(path), ERROR_LOG); return new ErrorLog(file, errorLogfileSize); }
java
void waitForResuming() throws IOException { if (isSuspended.get()) { try { latcher.get().await(); } catch (InterruptedException e) { throw new IOException(e); } } }
java
Node getUsersStorageNode(Session session) throws PathNotFoundException, RepositoryException { return (Node)session.getItem(service.getStoragePath() + "/" + JCROrganizationServiceImpl.STORAGE_JOS_USERS); }
java
Node getMembershipTypeStorageNode(Session session) throws PathNotFoundException, RepositoryException { return (Node)session.getItem(service.getStoragePath() + "/" + JCROrganizationServiceImpl.STORAGE_JOS_MEMBERSHIP_TYPES); }
java
Node getUserNode(Session session, String userName) throws PathNotFoundException, RepositoryException { return (Node)session.getItem(getUserNodePath(userName)); }
java
String getUserNodePath(String userName) throws RepositoryException { return service.getStoragePath() + "/" + JCROrganizationServiceImpl.STORAGE_JOS_USERS + "/" + userName; }
java
Node getMembershipTypeNode(Session session, String name) throws PathNotFoundException, RepositoryException { return (Node)session.getItem(getMembershipTypeNodePath(name)); }
java
Node getProfileNode(Session session, String userName) throws PathNotFoundException, RepositoryException { return (Node)session.getItem(service.getStoragePath() + "/" + JCROrganizationServiceImpl.STORAGE_JOS_USERS + "/" + userName + "/" + JCROrganizationServiceImpl.JOS_PROFILE); }
java
String getMembershipTypeNodePath(String name) throws RepositoryException { return service.getStoragePath() + "/" + JCROrganizationServiceImpl.STORAGE_JOS_MEMBERSHIP_TYPES + "/" + (name.equals(MembershipTypeHandler.ANY_MEMBERSHIP_TYPE) ? JCROrganizationServiceImpl...
java
GroupIds getGroupIds(Node groupNode) throws RepositoryException { String storagePath = getGroupStoragePath(); String nodePath = groupNode.getPath(); String groupId = nodePath.substring(storagePath.length()); String parentId = groupId.substring(0, groupId.lastIndexOf("/")); return new ...
java
IdComponents splitId(String id) throws IndexOutOfBoundsException { String[] membershipIDs = id.split(","); String groupNodeId = membershipIDs[0]; String userName = membershipIDs[1]; String type = membershipIDs[2]; return new IdComponents(groupNodeId, userName, type); }
java
public void printData(PrintWriter pw) { long lmin = min.get(); if (lmin == Long.MAX_VALUE) { lmin = -1; } long lmax = max.get(); long ltotal = total.get(); long ltimes = times.get(); float favg = ltimes == 0 ? 0f : (float)ltotal / ltimes; pw.print(lmin);...
java
public void reset() { min.set(Long.MAX_VALUE); max.set(0); total.set(0); times.set(0); }
java
protected void refreshIndexes(Set<String> set) { // do nothing if null is passed if (set == null) { return; } setNames(set); // callback multiIndex to refresh lists try { MultiIndex multiIndex = getMultiIndex(); if (multiIndex != ...
java
protected void visitChildProperties(NodeData node) throws RepositoryException { if (isInterrupted()) return; for (PropertyData data : dataManager.getChildPropertiesData(node)) { if (isInterrupted()) return; data.accept(this); } }
java
protected void visitChildNodes(NodeData node) throws RepositoryException { if (isInterrupted()) return; for (NodeData data : dataManager.getChildNodesData(node)) { if (isInterrupted()) return; data.accept(this); } }
java
public QueryNode[] getPredicates() { if (operands == null) { return EMPTY; } else { return (QueryNode[]) operands.toArray(new QueryNode[operands.size()]); } }
java
public Boolean getParameterBoolean(String name, Boolean defaultValue) { String value = getParameterValue(name, null); if (value != null) { return new Boolean(value); } return defaultValue; }
java
@Override protected QPath traverseQPath(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException { return traverseQPathSQ(cpid); }
java
protected void prepareRootDir(String rootDirPath) throws IOException, RepositoryConfigurationException { this.rootDir = new File(rootDirPath); if (!rootDir.exists()) { if (rootDir.mkdirs()) { LOG.info("Value storage directory created: " + rootDir.getAbsolutePath()); ...
java
private void addChild(Session session, GroupImpl parent, GroupImpl child, boolean broadcast) throws Exception { Node parentNode = utils.getGroupNode(session, parent); Node groupNode = parentNode.addNode(child.getGroupName(), JCROrganizationServiceImpl.JOS_HIERARCHY_GROUP_NODETYPE); String...
java
private Collection<Group> findGroups(Session session, Group parent, boolean recursive) throws Exception { List<Group> groups = new ArrayList<Group>(); String parentId = parent == null ? "" : parent.getId(); NodeIterator childNodes = utils.getGroupNode(session, parentId).getNodes(); while (c...
java
private Group removeGroup(Session session, Group group, boolean broadcast) throws Exception { if (group == null) { throw new OrganizationServiceException("Can not remove group, since it is null"); } Node groupNode = utils.getGroupNode(session, group); // need to minus one bec...
java
private void removeMemberships(Node groupNode, boolean broadcast) throws RepositoryException { NodeIterator refUsers = groupNode.getNode(JCROrganizationServiceImpl.JOS_MEMBERSHIP).getNodes(); while (refUsers.hasNext()) { refUsers.nextNode().remove(); } }
java
void migrateGroup(Node oldGroupNode) throws Exception { String groupName = oldGroupNode.getName(); String desc = utils.readString(oldGroupNode, GroupProperties.JOS_DESCRIPTION); String label = utils.readString(oldGroupNode, GroupProperties.JOS_LABEL); String parentId = utils.readString(oldGro...
java
private Group readGroup(Node groupNode) throws Exception { String groupName = groupNode.getName(); String desc = utils.readString(groupNode, GroupProperties.JOS_DESCRIPTION); String label = utils.readString(groupNode, GroupProperties.JOS_LABEL); String parentId = utils.getGroupIds(groupNode)....
java
private void writeGroup(Group group, Node node) throws OrganizationServiceException { try { node.setProperty(GroupProperties.JOS_LABEL, group.getLabel()); node.setProperty(GroupProperties.JOS_DESCRIPTION, group.getDescription()); } catch (RepositoryException e) { ...
java
private Group getFromCache(String groupId) { return (Group)cache.get(groupId, CacheType.GROUP); }
java
private void putInCache(Group group) { cache.put(group.getId(), group, CacheType.GROUP); }
java
private void removeAllRelatedFromCache(String groupId) { cache.remove(CacheHandler.GROUP_PREFIX + groupId, CacheType.MEMBERSHIP); }
java
private void preSave(Group group, boolean isNew) throws Exception { for (GroupEventListener listener : listeners) { listener.preSave(group, isNew); } }
java
private void postSave(Group group, boolean isNew) throws Exception { for (GroupEventListener listener : listeners) { listener.postSave(group, isNew); } }
java
private void preDelete(Group group) throws Exception { for (GroupEventListener listener : listeners) { listener.preDelete(group); } }
java
private void postDelete(Group group) throws Exception { for (GroupEventListener listener : listeners) { listener.postDelete(group); } }
java
public void execute(Runnable command) { adjustPoolSize(); if (numProcessors == 1) { // if there is only one processor execute with current thread command.run(); } else { try { executor.execute(command); } catch (InterruptedException...
java
public Result[] executeAndWait(Command[] commands) { Result[] results = new Result[commands.length]; if (numProcessors == 1) { // optimize for one processor for (int i = 0; i < commands.length; i++) { Object obj = null; InvocationTargetException ex...
java
private void adjustPoolSize() { if (lastCheck + 1000 < System.currentTimeMillis()) { int n = Runtime.getRuntime().availableProcessors(); if (numProcessors != n) { executor.setMaximumPoolSize(n); numProcessors = n; } lastCheck = Syst...
java
private void registerListener(final ChangesLogWrapper logWrapper, TransactionableResourceManager txResourceManager) throws RepositoryException { try { // Why calling the listeners non tx aware has been done like this: // 1. If we call them in the commit phase and we use Arjuna wit...
java
protected ItemData getCachedItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException { return cache.isEnabled() ? cache.get(parentData.getIdentifier(), name, itemType) : null; }
java
protected ItemData getCachedItemData(String identifier) throws RepositoryException { return cache.isEnabled() ? cache.get(identifier) : null; }
java
protected List<NodeData> getChildNodesData(final NodeData nodeData, boolean forcePersistentRead) throws RepositoryException { List<NodeData> childNodes = null; if (!forcePersistentRead && cache.isEnabled()) { childNodes = cache.getChildNodes(nodeData); if (childNodes != nul...
java
protected List<PropertyData> getReferencedPropertiesData(final String identifier) throws RepositoryException { List<PropertyData> refProps = null; if (cache.isEnabled()) { refProps = cache.getReferencedProperties(identifier); if (refProps != null) { return ref...
java
protected List<PropertyData> getCachedCleanChildPropertiesData(NodeData nodeData) { if (cache.isEnabled()) { List<PropertyData> childProperties = cache.getChildProperties(nodeData); if (childProperties != null) { boolean skip = false; for (PropertyData ...
java
protected List<PropertyData> getChildPropertiesData(final NodeData nodeData, boolean forcePersistentRead) throws RepositoryException { List<PropertyData> childProperties = null; if (!forcePersistentRead) { childProperties = getCachedCleanChildPropertiesData(nodeData); if (c...
java
protected ItemData getPersistedItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException { ItemData data = super.getItemData(parentData, name, itemType); if (cache.isEnabled()) { if (data == null) { if (itemType == ItemType.NODE...
java
private void initRemoteCommands() { if (rpcService != null) { // register commands suspend = rpcService.registerCommand(new RemoteCommand() { public String getId() { return "org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableW...
java
private void unregisterRemoteCommands() { if (rpcService != null) { rpcService.unregisterCommand(suspend); rpcService.unregisterCommand(resume); rpcService.unregisterCommand(requestForResponsibleForResuming); } }
java
private ItemData initACL(NodeData parent, NodeData node) throws RepositoryException { return initACL(parent, node, null); }
java
private NodeData getACL(String identifier, ACLSearch search) throws RepositoryException { final ItemData item = getItemData(identifier, false); return item != null && item.isNode() ? initACL(null, (NodeData)item, search) : null; }
java
public List<ACLHolder> getACLHolders() throws RepositoryException { WorkspaceStorageConnection conn = dataContainer.openConnection(); try { return conn.getACLHolders(); } finally { conn.close(); } }
java
protected boolean loadFilters(final boolean cleanOnFail, boolean asynchronous) { if (!filtersSupported.get()) { if (LOG.isWarnEnabled()) { LOG.warn("The bloom filters are not supported therefore they cannot be reloaded"); } return false; } filte...
java
private boolean forceLoad(PropertyData prop) { final List<ValueData> vals = prop.getValues(); for (int i = 0; i < vals.size(); i++) { ValueData vd = vals.get(i); if (!vd.isByteArray()) { // check if file is correct FilePersistedValueData fpvd = (Fi...
java
public Response move(Session session, String srcPath, String destPath) { try { session.move(srcPath, destPath); session.save(); // If the source resource was successfully moved // to a pre-existing destination resource. if (itemExisted) { ...
java
protected List<ValueData> loadPropertyValues(NodeData parentNode, ItemData property , InternalQName propertyName) throws RepositoryException { if(property == null) { property = dataManager.getItemData(parentNode, new QPathEntry(propertyName, 1), ItemType.PROPERTY); } if (prope...
java
protected void awaitTasksTermination() { delegated.shutdown(); try { delegated.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); } catch (InterruptedException e) { LOG.warn("Termination has been interrupted"); } }
java
public int closeSessions(String workspaceName) { int closedSessions = 0; for (SessionImpl session : sessionsMap.values()) { if (session.getWorkspace().getName().equals(workspaceName)) { session.logout(); closedSessions++; } } return c...
java
public void commitTransaction() { CompressedISPNChangesBuffer changesContainer = getChangesBufferSafe(); final TransactionManager tm = getTransactionManager(); try { final List<ChangesContainer> containers = changesContainer.getSortedList(); commitChanges(tm, containers); ...
java
public void setLocal(boolean local) { // start local transaction if (local && changesList.get() == null) { beginTransaction(); } this.local.set(local); }
java
private CompressedISPNChangesBuffer getChangesBufferSafe() { CompressedISPNChangesBuffer changesContainer = changesList.get(); if (changesContainer == null) { throw new IllegalStateException("changesContainer should not be empty"); } return changesContainer; }
java
@GET @Path("/{path:.*}/") public Response getResource(@PathParam("path") String mavenPath, final @Context UriInfo uriInfo, final @QueryParam("view") String view, final @QueryParam("gadget") String gadget) { String resourcePath = mavenRoot + mavenPath; // JCR resource String shaResourcePath =...
java
@GET public Response getRootNodeList(final @Context UriInfo uriInfo, final @QueryParam("view") String view, final @QueryParam("gadget") String gadget) { return getResource("", uriInfo, view, gadget); }
java
private static boolean isFile(Node node) throws RepositoryException { if (!node.isNodeType("nt:file")) { return false; } if (!node.getNode("jcr:content").isNodeType("nt:resource")) { return false; } return true; }
java
private Response downloadArtifact(Node node) throws Exception { NodeRepresentation nodeRepresentation = nodeRepresentationService.getNodeRepresentation(node, null); if (node.canAddMixin("exo:mavencounter")) { node.addMixin("exo:mavencounter"); node.getSession().save(); } ...
java
public static void registerStatistics(String category, Statistics global, Map<String, Statistics> allStatistics) { if (category == null || category.length() == 0) { throw new IllegalArgumentException("The category of the statistics cannot be empty"); } if (allStatistics == null || al...
java
private static void startIfNeeded() { if (!STARTED) { synchronized (JCRStatisticsManager.class) { if (!STARTED) { addTriggers(); ExoContainer container = ExoContainerContext.getTopContainer(); ManagementContext ctx = n...
java
private static void addTriggers() { if (!PERSISTENCE_ENABLED) { return; } Runtime.getRuntime().addShutdownHook(new Thread("JCRStatisticsManager-Hook") { @Override public void run() { printData(); } }); Thread t = new T...
java
private static void printData() { Map<String, StatisticsContext> tmpContexts = CONTEXTS; for (StatisticsContext context : tmpContexts.values()) { printData(context); } }
java
private static void printData(StatisticsContext context) { if (context.writer == null) { return; } boolean first = true; if (context.global != null) { context.global.printData(context.writer); first = false; } for (Statistics s : context.allS...
java
private static StatisticsContext getContext(String category) { if (category == null) { return null; } return CONTEXTS.get(category); }
java
static String formatName(String name) { return name == null ? null : name.replaceAll(" ", "").replaceAll("[,;]", ", "); }
java
private static Statistics getStatistics(String category, String name) { StatisticsContext context = getContext(category); if (context == null) { return null; } // Format the name name = formatName(name); if (name == null) { return null; } ...
java
@Managed @ManagedDescription("Reset all the statistics.") public static void resetAll( @ManagedDescription("The name of the category of the statistics") @ManagedName("categoryName") String category) { StatisticsContext context = getContext(category); if (context != null) { ...
java