org.apache.jackrabbit.webdav.io.InputContext Java Examples

The following examples show how to use org.apache.jackrabbit.webdav.io.InputContext. 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: DavContentBase.java    From cosmo with Apache License 2.0 6 votes vote down vote up
/** */
protected void populateItem(InputContext inputContext)
    throws CosmoDavException {
    super.populateItem(inputContext);

    ContentItem content = (ContentItem) getItem();
    
    User user = getSecurityManager().getSecurityContext().getUser();
    content.setLastModifiedBy(user != null ? user.getEmail() : "");

    if (content.getUid() == null) {
        content.setTriageStatus(TriageStatusUtil.initialize(content
                .getFactory().createTriageStatus()));
        content.setLastModification(ContentItem.Action.CREATED);
        content.setSent(Boolean.FALSE);
        content.setNeedsReply(Boolean.FALSE);
    } else {
        content.setLastModification(ContentItem.Action.EDITED);
    }
}
 
Example #3
Source File: DavCalendarCollection.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/** */
protected void populateItem(InputContext inputContext) throws CosmoDavException {
    super.populateItem(inputContext);

    CalendarCollectionStamp cc = getCalendarCollectionStamp();

    try {
        cc.setDescription(getItem().getName());
        // XXX: language should come from the input context
    } catch (DataSizeException e) {
        throw new MaxResourceSizeException(e.getMessage());
    }
}
 
Example #4
Source File: DavItemResourceBase.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the properties of the item backing this resource from the given
 * input context.
 */
protected void populateItem(InputContext inputContext)
        throws CosmoDavException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("populating item for " + getResourcePath());
    }

    if (item.getUid() == null) {
        try {
            item.setName(UrlEncoding.decode(PathUtil.getBasename(getResourcePath()), "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new CosmoDavException(e);
        }
        if (item.getDisplayName() == null){
            item.setDisplayName(item.getName());
        }
    }

    // if we don't know specifically who the user is, then the
    // owner of the resource becomes the person who issued the
    // ticket

    // Only initialize owner once
    if (item.getOwner() == null) {
        User owner = getSecurityManager().getSecurityContext().getUser();
        if (owner == null) {
            Ticket ticket = getSecurityManager().getSecurityContext()
                    .getTicket();
            owner = ticket.getOwner();
        }
        item.setOwner(owner);
    }

    if (item.getUid() == null) {
        item.setClientCreationDate(Calendar.getInstance().getTime());
        item.setClientModifiedDate(item.getClientCreationDate());
    }
}
 
Example #5
Source File: DavCalendarResource.java    From cosmo with Apache License 2.0 5 votes vote down vote up
@Override
protected void populateItem(InputContext inputContext)
    throws CosmoDavException {
    super.populateItem(inputContext);

    DavInputContext dic = (DavInputContext) inputContext;
    Calendar calendar = dic.getCalendar();

    setCalendar(calendar);
}
 
Example #6
Source File: DavCollectionBase.java    From cosmo with Apache License 2.0 5 votes vote down vote up
public void addContent(DavContent content, InputContext context) throws CosmoDavException {
    if(!(content instanceof DavContentBase)) {
        throw new IllegalArgumentException("Expected instance of : [" + DavContentBase.class.getName() + "]");
    }
    
    DavContentBase base = (DavContentBase) content;
    base.populateItem(context);
    saveContent(base);
    members.add(base);
}
 
Example #7
Source File: BaseProvider.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param request
 * @return InputContext
 * @throws CosmoDavException
 * @throws IOException
 */
protected InputContext createInputContext(DavRequest request) throws CosmoDavException, IOException {
    String xfer = request.getHeader("Transfer-Encoding");
    boolean chunked = xfer != null && xfer.equals("chunked");
    if (xfer != null && !chunked) {
        throw new BadRequestException("Unknown Transfer-Encoding " + xfer);
    }
    if (request.getContentLength() <= 0) {
        throw new BadRequestException("no content length set to input stream.");
    }

    return new DavInputContext(request, request.getInputStream());
}
 
Example #8
Source File: DavEvent.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * this method is added as an extension to cosmo, to allow updating an event based on ticket auth.
 * 
 * @param content
 * @param context
 * @throws CosmoDavException
 */
public void updateContent(DavContent content, InputContext context) throws CosmoDavException {
    if (!(content instanceof DavContentBase)) {
        throw new IllegalArgumentException(
                "Expected type for 'content' member :[" + DavContentBase.class.getName() + "]");
    }

    DavContentBase base = (DavContentBase) content;
    base.populateItem(context);
    updateItem();
}
 
Example #9
Source File: DavOutboxCollection.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public void addMember(org.apache.jackrabbit.webdav.DavResource member,
                      InputContext inputContext)
    throws org.apache.jackrabbit.webdav.DavException {
    throw new UnsupportedOperationException();
}
 
Example #10
Source File: ArchivaVirtualDavResource.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public void addMember( DavResource arg0, InputContext arg1 )
    throws DavException
{

}
 
Example #11
Source File: DavInboxCollection.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public void addContent(DavContent content, InputContext context) throws CosmoDavException {
    throw new UnsupportedOperationException();
}
 
Example #12
Source File: DavInboxCollection.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public void addMember(org.apache.jackrabbit.webdav.DavResource member, InputContext inputContext)
        throws org.apache.jackrabbit.webdav.DavException {
    throw new UnsupportedOperationException();
}
 
Example #13
Source File: DavCollectionBase.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public void addMember(org.apache.jackrabbit.webdav.DavResource member,
        InputContext inputContext)
        throws org.apache.jackrabbit.webdav.DavException {
    throw new UnsupportedOperationException();
}
 
Example #14
Source File: DavOutboxCollection.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public void addContent(DavContent content,
                       InputContext context)
    throws CosmoDavException {
    throw new UnsupportedOperationException();
}
 
Example #15
Source File: DavContentBase.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public void addMember(org.apache.jackrabbit.webdav.DavResource member,
                      InputContext inputContext)
    throws org.apache.jackrabbit.webdav.DavException {
    throw new UnsupportedOperationException();
}
 
Example #16
Source File: DavCollection.java    From cosmo with Apache License 2.0 4 votes vote down vote up
/**
 * Adds a new content item to this resource.
 */
void addContent(DavContent content,
                       InputContext input)
    throws CosmoDavException;
 
Example #17
Source File: DavUserPrincipalCollection.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public void addContent(DavContent content, InputContext context) throws CosmoDavException {
    throw new UnsupportedOperationException();
}
 
Example #18
Source File: DavUserPrincipalCollection.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public void addMember(org.apache.jackrabbit.webdav.DavResource member, InputContext inputContext)
        throws org.apache.jackrabbit.webdav.DavException {
    throw new UnsupportedOperationException();
}
 
Example #19
Source File: DavUserPrincipal.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public void addMember(org.apache.jackrabbit.webdav.DavResource member,
                      InputContext inputContext)
    throws org.apache.jackrabbit.webdav.DavException {
    throw new UnsupportedOperationException();
}
 
Example #20
Source File: ImportContextImpl.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ImportContextImpl(Resource resource, String systemId, InputContext inputCtx) throws IOException {
	this(resource, systemId, (inputCtx != null) ? inputCtx.getInputStream() : null);
	this.inputCtx = inputCtx;
}
 
Example #21
Source File: VersionResourceImpl.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void addMember(DavResource member, InputContext inputContext) throws DavException {
    throw new DavException(DavServletResponse.SC_FORBIDDEN);
}
 
Example #22
Source File: VersionHistoryResourceImpl.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void addMember(DavResource member, InputContext inputContext) throws DavException {
	throw new DavException(DavServletResponse.SC_FORBIDDEN);
}
 
Example #23
Source File: DavResourceImpl.java    From document-management-software with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * 
 * @param inputCtx input context
 * @param systemId identifier of the system
 * 
 * @return the import context
 * 
 * @see org.apache.jackrabbit.webdav.simple.DavResourceImpl#getImportContext(InputContext,
 *      String)
 */
protected ImportContext getImportContext(InputContext inputCtx, String systemId) throws IOException {
	return new ImportContextImpl(resource, systemId, inputCtx);
}
 
Example #24
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);
}