org.apache.jackrabbit.webdav.DavServletRequest Java Examples

The following examples show how to use org.apache.jackrabbit.webdav.DavServletRequest. 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: DavResourceFactoryImpl.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public DavResource createResource(DavResourceLocator locator, DavServletRequest request, DavSession session)
		throws DavException {

	try {
		String resourcePath = locator.getResourcePath();
		Matcher matcher = versionRequestPattern.matcher(locator.getResourcePath());

		String version = null;
		if (matcher.matches() == true) {
			version = matcher.group(1);
			resourcePath = resourcePath.replaceFirst("/vstore/" + version, "");
		}

		DavResource resource;

		Resource repositoryResource = resourceService.getResource(resourcePath, session);

		if (repositoryResource == null) {
			boolean isCollection = DavMethods.isCreateCollectionRequest(request);
			resource = createNullResource(locator, session, isCollection);
		} else {
			repositoryResource.setVersionLabel(version);
			repositoryResource.setRequestedPerson(Long.parseLong(session.getObject("id").toString()));
			resource = new VersionControlledResourceImpl(locator, this, session, resourceConfig, repositoryResource);
		}

		putInCache(session, resource);
		return resource;
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e);
	}
}
 
Example #2
Source File: CosmoDavMethods.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Augments superclass method to also return <code>true</code> for
 * <code>MKCALENDAR</code> requests.
 * @param request DavServletRequest.
 * @return If the request is created or not.
 */
public static boolean isCreateRequest(DavServletRequest request) {
    if (getMethodCode(request.getMethod()) == DAV_MKCALENDAR) {
        return true;
    }
    return DavMethods.isCreateRequest(request);
}
 
Example #3
Source File: CosmoDavMethods.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Augments superclass method to also return <code>true</code> for
 * <code>MKCALENDAR</code> requests.
 * @param request DavServletRequest.
 * @return If the collection request is created.
 */
public static boolean isCreateCollectionRequest(DavServletRequest request) {
    if (getMethodCode(request.getMethod()) == DAV_MKCALENDAR) {
        return true;
    }
    return DavMethods.isCreateCollectionRequest(request);
}
 
Example #4
Source File: CosmoDavMethods.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Augments superclass method to also return <code>true</code> for
 * <code>MKCALENDAR</code> requests.
 * @param request DavServletRequest.
 * @return IF the calendar collection request is created.
 */
public static boolean
    isCreateCalendarCollectionRequest(DavServletRequest request) {
    if (getMethodCode(request.getMethod()) == DAV_MKCALENDAR) {
        return true;
    }
    return false;
}
 
Example #5
Source File: ArchivaDavSessionProvider.java    From archiva with Apache License 2.0 5 votes vote down vote up
private String removeContextPath( final DavServletRequest request )
{
    String path = request.getRequestURI();
    String ctx = request.getContextPath();
    if ( path.startsWith( ctx ) )
    {
        path = path.substring( ctx.length() );
    }
    return path;
}
 
Example #6
Source File: DavResourceTest.java    From archiva with Apache License 2.0 5 votes vote down vote up
@Override
public DavResource createResource( DavResourceLocator locator, DavServletRequest request,
                                   DavServletResponse response )
    throws DavException
{
    throw new UnsupportedOperationException( "Not supported yet." );
}
 
Example #7
Source File: ArchivaDavResourceFactoryTest.java    From archiva with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean isAuthorized( DavServletRequest request, String repositoryId )
    throws DavException
{
    if ( RELEASES_REPO.equals( repositoryId ) )
    {
        throw new UnauthorizedDavException( repositoryId,
                                            "You are not authenticated and authorized to access any repository." );
    }
    else
    {
        return true;
    }
}
 
Example #8
Source File: DavResourceFactory.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public DavResource createResource(DavResourceLocator locator, DavServletRequest request, DavSession session)
throws DavException;
 
Example #9
Source File: DavResourceFactoryImpl.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public DavResource createResource(DavResourceLocator locator, DavServletRequest request) throws DavException {
	return createResource(locator, request, (DavSession) request.getDavSession());
}
 
Example #10
Source File: ArchivaDavResourceFactory.java    From archiva with Apache License 2.0 4 votes vote down vote up
protected String getActivePrincipal( DavServletRequest request )
{
    User sessionUser = httpAuth.getSessionUser( request.getSession() );
    return sessionUser != null ? sessionUser.getUsername() : UserManager.GUEST_USERNAME;
}
 
Example #11
Source File: UnauthenticatedDavResourceFactory.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean isAuthorized( DavServletRequest request, String repositoryId )
    throws DavException
{
    return true;
}
 
Example #12
Source File: ArchivaDavResourceFactoryTest.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Before
@Override
public void setUp()
    throws Exception
{
    super.setUp();

    requestControl = createControl();
    request = requestControl.createMock( DavServletRequest.class );

    responseControl = createControl();
    response = responseControl.createMock( DavServletResponse.class );
    //responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );

    archivaConfigurationControl = createControl();
    archivaConfiguration = archivaConfigurationControl.createMock( ArchivaConfiguration.class );

    config = new Configuration();
    expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 2, 20 );
    expect (archivaConfiguration.getDefaultLocale()).andReturn( Locale.getDefault() ).anyTimes();
    archivaConfiguration.addListener( EasyMock.anyObject(  ) );
    expectLastCall().times(0, 4);
    archivaConfiguration.save( config );

    expectLastCall().times( 0, 5 );
    archivaConfigurationControl.replay();

    defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfiguration );
    repositoryRegistry.setArchivaConfiguration( archivaConfiguration );
    repositoryRegistry.reload();
    ( (DefaultRepositoryCommonValidator) defaultManagedRepositoryAdmin.getRepositoryCommonValidator() ).setArchivaConfiguration(
        archivaConfiguration );
    if ( defaultManagedRepositoryAdmin.getManagedRepository( RELEASES_REPO ) == null )
    {
        defaultManagedRepositoryAdmin.addManagedRepository(
            createManagedRepository( RELEASES_REPO, getProjectBase().resolve( "target/test-classes/" + RELEASES_REPO ).toString(),
                                     "default" ), false, null );
    }
    if ( defaultManagedRepositoryAdmin.getManagedRepository( INTERNAL_REPO ) == null )
    {
        defaultManagedRepositoryAdmin.addManagedRepository(
            createManagedRepository( INTERNAL_REPO, getProjectBase().resolve( "target/test-classes/" + INTERNAL_REPO ).toString(),
                                     "default" ), false, null );
    }
    RepositoryGroup repoGroupConfig = new RepositoryGroup();
    repoGroupConfig.setId( LOCAL_REPO_GROUP );
    repoGroupConfig.addRepository( RELEASES_REPO );
    repoGroupConfig.addRepository( INTERNAL_REPO );

    defaultRepositoryGroupAdmin.setArchivaConfiguration( archivaConfiguration );
    if ( defaultManagedRepositoryAdmin.getManagedRepository( LOCAL_REPO_GROUP ) == null )
    {
        defaultRepositoryGroupAdmin.addRepositoryGroup( repoGroupConfig, null );
    }

    repoContentFactoryControl = createControl();
    repoFactory = repoContentFactoryControl.createMock( RepositoryContentFactory.class );

    repoRequestControl = createControl();
    repoRequest = repoRequestControl.createMock( MavenRepositoryRequestInfo.class );

    resourceFactory =
        new OverridingArchivaDavResourceFactory( applicationContext, archivaConfiguration );
    resourceFactory.setArchivaConfiguration( archivaConfiguration );
    proxyRegistry.getAllHandler().get(RepositoryType.MAVEN).clear();
    proxyRegistry.getAllHandler().get(RepositoryType.MAVEN).add(new OverridingRepositoryProxyHandler(this));
    resourceFactory.setProxyRegistry(proxyRegistry);
    resourceFactory.setRemoteRepositoryAdmin( remoteRepositoryAdmin );
    resourceFactory.setManagedRepositoryAdmin( defaultManagedRepositoryAdmin );
    resourceFactory.setRepositoryRegistry( repositoryRegistry );
}
 
Example #13
Source File: ArchivaDavResourceFactoryTest.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
protected String getActivePrincipal( DavServletRequest request )
{
    return "guest";
}
 
Example #14
Source File: AbstractWebdavServlet.java    From document-management-software with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Return a new <code>InputContext</code> used for adding resource members
 * 
 * @param request the DAV request
 * @param in the stream of the request
 * 
 * @return the input context
 * @see #spoolResource(WebdavRequest, WebdavResponse, DavResource, boolean)
 */
protected InputContext getInputContext(DavServletRequest request, InputStream in) {
	return new InputContextImpl(request, in);
}
 
Example #15
Source File: DavResourceFactory.java    From document-management-software with GNU Lesser General Public License v3.0 votes vote down vote up
public DavResource createResource(DavResourceLocator locator, DavServletRequest request) throws DavException;