Hi ,
 
I am trying to update a file from mac using jackrabbit. But it always fails.
When I see the memberName it says .dat085.2  something. And when trying  to
get data it give empty array. So my application break. This works from
windows
 
I am using latest version of Jack rabbit 2.2.1 , Tomcat server 
 
Below is my code : Any help appreciated Thanks in advance
 
public void addMember(DavResource member, InputContext inputContext) throws
DavException {
                if (!exists()) {
                        throw new DavException(HttpServletResponse.SC_CONFLICT);
                }
                if (isLocked(this) || isLocked(member)) {
                        throw new DavException(DavServletResponse.SC_LOCKED);
                }
                if (!document.isFolder()) {
                        // TODO convert all exceptions to DavException?
                        throw new RuntimeException("Can only add members to 
folders");
                }
 
                DocumentRepository documentRepository =
ServiceLocator.getDocumentRepository();
                String memberName =
StringUtils.substringAfterLast(member.getLocator().getRepositoryPath(),
"/");
 
                if (member.isCollection()) {
                        // create folder
                        documentRepository.createSubFolder(memberName, 
document);
                } else {
 
                        // read file data
                        byte[] data;
                        try {
                                data = 
IOUtils.toByteArray(inputContext.getInputStream());
                        } catch (IOException e) {
                                throw new RuntimeException(e);
                        }
 
                        // check if file exists or if this is a new file
                        if (member.exists() || !document.isNewEntity()) {
                                // we've already tested if isLocked(member) 
above, so we know it's not
checked out by another user
                                // TODO there's a small window where another 
user could lock this
between test above
                                // (probably not worth dealing with, but worth 
documenting here or
catching optimistic lock error?)
                                boolean wasCheckedOut = true;
                                if (((DavResourceImpl) 
member).document.getCheckedOutBy() == null) {
                                        wasCheckedOut = false; // When a new 
file is moved into a dav folder
                                        
documentRepository.checkOut(((DavResourceImpl) member).document);
                                }
                                //Check-in the changes
                                documentRepository.checkIn(((DavResourceImpl) 
member).document, data,
"Webdav Check-in");
 
                                //Keep document checkedout, only if it was 
checked out before
                                //Fix for defect 082710-35767
                                if (wasCheckedOut) {
                                        
documentRepository.checkOut(((DavResourceImpl) member).document);
                                }
 
                        } else {
                                String fileExtension = 
StringUtils.substringAfterLast(memberName, ".");
                                Document newDocument = 
DocumentFactory.newFile(memberName,
fileExtension, data, document);
                                //Document newDocument = 
DocumentFactory.newFile(memberName,
documentContentType.getFileExtension(), data, document);
                                documentRepository.insertDocument(newDocument);
                        }
 
                }
        }
-- 
View this message in context: 
http://jackrabbit.510166.n4.nabble.com/WebDav-Updating-file-fails-from-MAC-Please-Help-tp3217987p3217987.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Reply via email to