private String restValueForReference( Value value, String baseUrl, Session session ) throws RepositoryException { String nodeId = value.getString(); Node referredNode = session.getNodeByIdentifier(nodeId); if (referredNode != null) { return RestHelper.urlFrom(baseUrl, ITEMS_METHOD_NAME, encodedPath(referredNode.getPath())); } logger.warn("Cannot resolve reference with id: {0}", nodeId); return nodeId; }
/** * Returns a set with all the names of the available repositories. * @return a set with the names, never {@code null} */ public static Set<String> getJcrRepositoryNames() { try { return repositoriesContainer.getRepositoryNames(Collections.unmodifiableMap(factoryParams)); } catch (RepositoryException e) { LOGGER.error(e, WebJcrI18n.cannotLoadRepositoryNames.text()); return Collections.emptySet(); } }
private Name primaryTypeFor( Path resolvedPath ) { boolean isFolder = Files.isDirectory(resolvedPath, LinkOption.NOFOLLOW_LINKS); boolean isFile = Files.isRegularFile(resolvedPath, LinkOption.NOFOLLOW_LINKS); if (!isFile && !isFolder) { connector.log().debug("The entry at {0} is neither a file nor a folder", resolvedPath); return null; } return isFolder ? JcrNtLexicon.FOLDER : JcrNtLexicon.FILE; } }
/** * Cleans up any resources related to {@link AbstractHandler#ACTIVE_SESSION} */ public static void cleanupActiveSession() { Session session = AbstractHandler.ACTIVE_SESSION.get(); if (session != null) { try { AbstractHandler.ACTIVE_SESSION.remove(); session.logout(); LOGGER.debug("Logged out REST service session"); } catch (Exception e) { LOGGER.warn(e, "Error while trying to logout REST service session"); } } }
@Override public void filter( ContainerRequestContext requestContext ) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Received request: {0}", requestContext.getUriInfo().getRequestUri().toString()); LOGGER.debug("Executing method: {0}", requestContext.getMethod()); } } }
logger().debug("Initializing the local index provider '{0}' in repository '{1}' at: {2}", getName(), getRepositoryName(), directory); logger().debug("Attempting to create directory for local indexes in repository '{1}' at: {0}", dir.getAbsolutePath(), getRepositoryName()); if (dir.mkdirs()) { logger().debug("Created directory for local indexes in repository '{1}' at: {0}", dir.getAbsolutePath(), getRepositoryName()); } else { logger().debug("Unable to create directory for local indexes in repository '{1}' at: {0}", dir.getAbsolutePath(), getRepositoryName()); if (logger().isDebugEnabled()) { String action = file.exists() ? "Opening" : "Creating"; logger().debug("{0} the local index provider database for repository '{1}' at: {2}", action, getRepositoryName(), file.getAbsolutePath()); if (this.cacheSize != null) { dbMaker.cacheSize(cacheSize); logger().debug("MapDB cache size set to {0} for index provider {1}", cacheSize, getName()); logger().debug("MapDB cacheLRU enabled for index provider {0}", getName()); logger().debug("MapDB mmapFiles enabled for index provider {0}", getName()); logger().debug("MapDB commitFileSync enabled for index provider {0}", getName()); logger().debug("MapDB transactions disabled for index provider {0}", getName());
private boolean processUsingAdvancedMetadata( Node imageNode, Binary binaryValue, boolean imageParsedUsingDefaultMetadata ) throws Exception { try (InputStream stream = binaryValue.getStream()) { Metadata advancedMetadata = ImageMetadataReader.readMetadata(new BufferedInputStream(stream), false); ExifIFD0Directory exifIFD0Directory = advancedMetadata.getDirectory(ExifIFD0Directory.class); if (exifIFD0Directory == null || !hasTags(exifIFD0Directory, EXIF_TAGS)) { if (!imageParsedUsingDefaultMetadata) { getLogger().info("Neither default nor advanced metadata parser can resolve image. Ignoring sequencing"); } getLogger().debug("No relevant IFD0 information found, ignoring EXIF node."); return imageParsedUsingDefaultMetadata; } if (!imageParsedUsingDefaultMetadata) { //it's a format not supported by the default metadata and since we're reading the IFD0 descriptor, mark the image //as a TIFF getLogger().info( "Image has IFD0 block information but is not one of the standard image types, marking it as TIFF"); imageNode.setProperty(ImageMetadataLexicon.FORMAT_NAME, TIFF_FORMAT); imageNode.setProperty(JcrConstants.JCR_MIME_TYPE, IMAGE_TIFF_DEFAULT_MIME_TYPE); } addEXIFNode(imageNode, exifIFD0Directory); return true; } catch (Exception e) { getLogger().debug(e, "Cannot process image for advanced metadata"); return imageParsedUsingDefaultMetadata; } }
@Override public void filter( ContainerRequestContext requestContext, ContainerResponseContext responseContext ) { LOGGER.trace("Executing cleanup filter..."); AbstractHandler.cleanupActiveSession(); } }
ManagedIndex index, IndexDefinition defn ) { boolean traceEnabled = logger().isTraceEnabled(); if (!defn.isEnabled()) { if (traceEnabled) { logger().trace("Skipping index '{0}' in '{1}' provider because it is not enabled", defn.getName(), getName()); logger().trace("Skipping index '{0}' in '{1}' provider for query because it doest not match the '{2}' workspace", defn.getName(), getName(), workspaceName); logger().trace("Considering index '{0}' in '{1}' provider for query in workspace '{2}'", defn.getName(), getName(), logger().trace("Skipping index '{0}' in '{1}' provider for query because the index definition node type '{2}' does not match the selected node types '{3}'", defn.getName(), getName(), defn.getNodeTypeName(), calculator.selectedNodeTypes());
doDelete(path, session); } catch (NotFoundException e) { logger.info("Node at path {0} already deleted", path);
@SuppressWarnings( "synthetic-access" ) private void fireEntryModified( ConnectorChangeSet connectorChangeSet, Path resolvedPath ) { connector.log().debug("Received ENTRY_MODIFY event on '{0}'", resolvedPath); connector.log().debug("The entry at {0} is not a regular file; ignoring modify event", resolvedPath); return; connector.log().warn("Cannot get binary value for '{0}'", resolvedPath);
} catch (RuntimeException e) { String msg = "Error updating index '{0}' in workspace '{1}' with definition: {2}"; logger().error(e, msg, defn.getName(), workspaceName, defn); if (!isChanged(oldDefn, defn)) { logger().debug("Index provider '{0}' is not updating index in workspace '{1}' because there were no changes: {2}", getName(), workspaceName, defn); continue; } catch (RuntimeException e) { String msg = "Error updating index '{0}' in workspace '{1}' with definition: {2}"; logger().error(e, msg, defn.getName(), workspaceName, defn); } catch (RuntimeException e) { String msg = "Error adding index '{0}' in workspace '{1}' with definition: {2}"; logger().error(e, msg, defn.getName(), workspaceName, defn);
logger().debug("Initializing the local index provider '{0}' in repository '{1}' at: {2}", getName(), getRepositoryName(), directory); logger().debug("Attempting to create directory for local indexes in repository '{1}' at: {0}", dir.getAbsolutePath(), getRepositoryName()); if (dir.mkdirs()) { logger().debug("Created directory for local indexes in repository '{1}' at: {0}", dir.getAbsolutePath(), getRepositoryName()); } else { logger().debug("Unable to create directory for local indexes in repository '{1}' at: {0}", dir.getAbsolutePath(), getRepositoryName()); if (logger().isDebugEnabled()) { String action = file.exists() ? "Opening" : "Creating"; logger().debug("{0} the local index provider database for repository '{1}' at: {2}", action, getRepositoryName(), file.getAbsolutePath()); if (this.cacheSize != null) { dbMaker.cacheSize(cacheSize); logger().debug("MapDB cache size set to {0} for index provider {1}", cacheSize, getName()); logger().debug("MapDB cacheLRU enabled for index provider {0}", getName()); logger().debug("MapDB mmapFiles enabled for index provider {0}", getName()); logger().debug("MapDB commitFileSync enabled for index provider {0}", getName()); logger().debug("MapDB transactions disabled for index provider {0}", getName());
private boolean processUsingAdvancedMetadata( Node imageNode, Binary binaryValue, boolean imageParsedUsingDefaultMetadata ) throws Exception { try (InputStream stream = binaryValue.getStream()) { Metadata advancedMetadata = ImageMetadataReader.readMetadata(new BufferedInputStream(stream), false); ExifIFD0Directory exifIFD0Directory = advancedMetadata.getDirectory(ExifIFD0Directory.class); if (exifIFD0Directory == null || !hasTags(exifIFD0Directory, EXIF_TAGS)) { if (!imageParsedUsingDefaultMetadata) { getLogger().info("Neither default nor advanced metadata parser can resolve image. Ignoring sequencing"); } getLogger().debug("No relevant IFD0 information found, ignoring EXIF node."); return imageParsedUsingDefaultMetadata; } if (!imageParsedUsingDefaultMetadata) { //it's a format not supported by the default metadata and since we're reading the IFD0 descriptor, mark the image //as a TIFF getLogger().info( "Image has IFD0 block information but is not one of the standard image types, marking it as TIFF"); imageNode.setProperty(ImageMetadataLexicon.FORMAT_NAME, TIFF_FORMAT); imageNode.setProperty(JcrConstants.JCR_MIME_TYPE, IMAGE_TIFF_DEFAULT_MIME_TYPE); } addEXIFNode(imageNode, exifIFD0Directory); return true; } catch (Exception e) { getLogger().debug(e, "Cannot process image for advanced metadata"); return imageParsedUsingDefaultMetadata; } }
/** * Get the queryable index with the given name and applicable for the given workspace. * * @param indexName the name of the index in this provider; never null * @param workspaceName the name of the workspace; never null * @return the queryable index, or null if there is no such index */ public final Index getIndex( String indexName, String workspaceName ) { logger().trace("Looking for index '{0}' in '{1}' provider for query in workspace '{2}'", indexName, getName(), workspaceName); Map<String, AtomicIndex> byWorkspaceNames = providedIndexesByWorkspaceNameByIndexName.get(indexName); return byWorkspaceNames == null ? null : byWorkspaceNames.get(workspaceName); }
ManagedIndex index, IndexDefinition defn ) { boolean traceEnabled = logger().isTraceEnabled(); if (!defn.isEnabled()) { if (traceEnabled) { logger().trace("Skipping index '{0}' in '{1}' provider because it is not enabled", defn.getName(), getName()); logger().trace("Skipping index '{0}' in '{1}' provider for query because it doest not match the '{2}' workspace", defn.getName(), getName(), workspaceName); logger().trace("Considering index '{0}' in '{1}' provider for query in workspace '{2}'", defn.getName(), getName(), logger().trace("Skipping index '{0}' in '{1}' provider for query because the index definition node type '{2}' does not match the selected node types '{3}'", defn.getName(), getName(), defn.getNodeTypeName(), calculator.selectedNodeTypes());
private String restValueForBinary( String absPropertyPath, String baseUrl ) { if (absPropertyPath == null) { logger.warn("Cannot generate rest representation of a binary value, because the property is unknown"); return null; } return RestHelper.urlFrom(baseUrl, BINARY_METHOD_NAME, encodedPath(absPropertyPath)); }
private Name primaryTypeFor( Path resolvedPath ) { boolean isFolder = Files.isDirectory(resolvedPath, LinkOption.NOFOLLOW_LINKS); boolean isFile = Files.isRegularFile(resolvedPath, LinkOption.NOFOLLOW_LINKS); if (!isFile && !isFolder) { connector.log().debug("The entry at {0} is neither a file nor a folder", resolvedPath); return null; } return isFolder ? JcrNtLexicon.FOLDER : JcrNtLexicon.FILE; } }
@SuppressWarnings( "synthetic-access" ) private void fireEntryModified( ConnectorChangeSet connectorChangeSet, Path resolvedPath ) { connector.log().debug("Received ENTRY_MODIFY event on '{0}'", resolvedPath); connector.log().debug("The entry at {0} is not a regular file; ignoring modify event", resolvedPath); return; connector.log().warn("Cannot get binary value for '{0}'", resolvedPath);