Java Code Examples for org.apache.jackrabbit.util.Text#getName()

The following examples show how to use org.apache.jackrabbit.util.Text#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DavResourceImpl.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Adds a new member to this resource.
 * 
 * @see DavResource#addMember(DavResource,
 *      org.apache.jackrabbit.webdav.io.InputContext)
 */
public void addMember(DavResource member, InputContext inputContext) throws DavException {
	if (!exists()) {
		throw new DavException(DavServletResponse.SC_CONFLICT);
	}
	if (isLocked(this) || isLocked(member)) {
		throw new DavException(DavServletResponse.SC_LOCKED);
	}

	try {
		String memberName = Text.getName(member.getLocator().getResourcePath());

		ImportContext ctx = getImportContext(inputContext, memberName);

		if (!config.getIOManager().importContent(ctx, member)) {
			// any changes should have been reverted in the importer
			throw new DavException(DavServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
		}
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
}
 
Example 2
Source File: DocumentViewXmlContentHandler.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param filePath the relative file to the docview file (relative to the jcr_root folder)
 * @param basePath the absolute file path of the the jcr_root folder (to which {@code filePath} is relative)
 * @param rootNodePath the node path of the root node covered by this docview file
 * @param documentViewXmlValidators the validators to call for this docview file
 */
public DocumentViewXmlContentHandler(@NotNull Path filePath, @NotNull Path basePath, String rootNodePath, Map<String, DocumentViewXmlValidator> documentViewXmlValidators) {
    this.filePath = filePath;
    this.basePath = basePath;
    if (rootNodePath.equals("/")) {
        rootNodePath = "";
    }
    if (rootNodePath.endsWith("/")) {
        throw new IllegalArgumentException("rootPath must not end with \"/\" but is " + rootNodePath);
    }
    if (rootNodePath.contains("\\")) {
        throw new IllegalArgumentException("rootPath must not contain backslashes, only forward slashes should be used as separator!");
    }
    nodePathsAndLineNumbers = new HashMap<>();
    rootNodeName = Text.getName(rootNodePath);
    rootNodeParentPath = Text.getRelativeParent(rootNodePath, 1);
    if (rootNodeParentPath.equals("/")) {
        rootNodeParentPath = "";
    }

    elementNameStack = new LinkedList<>();
    nodeStack = new LinkedList<>();
    nodePathStack = new LinkedList<>();
    this.validators = documentViewXmlValidators;
    violations = new LinkedList<>();
    namespaceRegistry = new HashMap<>();
}
 
Example 3
Source File: ArchivaVirtualDavResource.java    From archiva with Apache License 2.0 5 votes vote down vote up
@Override
public String getDisplayName()
{
    String resPath = getResourcePath();

    return ( resPath != null ) ? Text.getName( resPath ) : resPath;
}
 
Example 4
Source File: ArchivaDavResource.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public String getDisplayName()
{
    String resPath = getResourcePath();
    return ( resPath != null ) ? Text.getName( resPath ) : resPath;
}
 
Example 5
Source File: DavResourceImpl.java    From document-management-software with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Returns the the last segment of the resource path.
 * <p>
 * Note that this must not correspond to the name of the underlying
 * repository item for two reasons:
 * <ul>
 * <li>SameNameSiblings have an index appended to their item name.</li>
 * <li>the resource path may differ from the item path.</li>
 * </ul>
 * Using the item name as DAV:displayname caused problems with XP built-in
 * client in case of resources representing SameNameSibling nodes.
 * 
 * @see DavResource#getDisplayName()
 */
public String getDisplayName() {
	String resPath = getResourcePath();
	return (resPath != null) ? Text.getName(resPath) : resPath;
}