xref: /trunk/main/ucb/source/ucp/webdav/LockRequest.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*51ba086bSDamjan Jovanovic /**************************************************************
2*51ba086bSDamjan Jovanovic  *
3*51ba086bSDamjan Jovanovic  * Licensed to the Apache Software Foundation (ASF) under one
4*51ba086bSDamjan Jovanovic  * or more contributor license agreements.  See the NOTICE file
5*51ba086bSDamjan Jovanovic  * distributed with this work for additional information
6*51ba086bSDamjan Jovanovic  * regarding copyright ownership.  The ASF licenses this file
7*51ba086bSDamjan Jovanovic  * to you under the Apache License, Version 2.0 (the
8*51ba086bSDamjan Jovanovic  * "License"); you may not use this file except in compliance
9*51ba086bSDamjan Jovanovic  * with the License.  You may obtain a copy of the License at
10*51ba086bSDamjan Jovanovic  *
11*51ba086bSDamjan Jovanovic  *   http://www.apache.org/licenses/LICENSE-2.0
12*51ba086bSDamjan Jovanovic  *
13*51ba086bSDamjan Jovanovic  * Unless required by applicable law or agreed to in writing,
14*51ba086bSDamjan Jovanovic  * software distributed under the License is distributed on an
15*51ba086bSDamjan Jovanovic  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*51ba086bSDamjan Jovanovic  * KIND, either express or implied.  See the License for the
17*51ba086bSDamjan Jovanovic  * specific language governing permissions and limitations
18*51ba086bSDamjan Jovanovic  * under the License.
19*51ba086bSDamjan Jovanovic  *
20*51ba086bSDamjan Jovanovic  *************************************************************/
21*51ba086bSDamjan Jovanovic 
22*51ba086bSDamjan Jovanovic // MARKER(update_precomp.py): autogen include statement, do not remove
23*51ba086bSDamjan Jovanovic #include "precompiled_webdav.hxx"
24*51ba086bSDamjan Jovanovic 
25*51ba086bSDamjan Jovanovic #include <rtl/ustrbuf.hxx>
26*51ba086bSDamjan Jovanovic #include "LockRequest.hxx"
27*51ba086bSDamjan Jovanovic 
28*51ba086bSDamjan Jovanovic using namespace http_dav_ucp;
29*51ba086bSDamjan Jovanovic 
30*51ba086bSDamjan Jovanovic #define LOCK_HEADER "<?xml version=\"1.0\" encoding=\"utf-8\"?><lockinfo xmlns=\"DAV:\">"
31*51ba086bSDamjan Jovanovic #define LOCK_TYPE "<locktype><write/></locktype>"
32*51ba086bSDamjan Jovanovic #define LOCK_TRAILER "</lockinfo>"
33*51ba086bSDamjan Jovanovic 
generateRequestBody(const ucb::Lock & inLock)34*51ba086bSDamjan Jovanovic rtl::OString LockRequest::generateRequestBody( const ucb::Lock& inLock )
35*51ba086bSDamjan Jovanovic {
36*51ba086bSDamjan Jovanovic     const char *lockScope = NULL;
37*51ba086bSDamjan Jovanovic     switch ( inLock.Scope )
38*51ba086bSDamjan Jovanovic     {
39*51ba086bSDamjan Jovanovic         //i126305 TODO investigate on this case...
40*51ba086bSDamjan Jovanovic     case ucb::LockScope_MAKE_FIXED_SIZE:
41*51ba086bSDamjan Jovanovic 
42*51ba086bSDamjan Jovanovic     case ucb::LockScope_EXCLUSIVE:
43*51ba086bSDamjan Jovanovic         lockScope = "<lockscope><exclusive/></lockscope>";
44*51ba086bSDamjan Jovanovic         break;
45*51ba086bSDamjan Jovanovic     case ucb::LockScope_SHARED:
46*51ba086bSDamjan Jovanovic         lockScope = "<lockscope><shared/></lockscope>";
47*51ba086bSDamjan Jovanovic         break;
48*51ba086bSDamjan Jovanovic     }
49*51ba086bSDamjan Jovanovic 
50*51ba086bSDamjan Jovanovic     rtl::OUStringBuffer aBuffer;
51*51ba086bSDamjan Jovanovic     aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( LOCK_HEADER ));
52*51ba086bSDamjan Jovanovic     aBuffer.appendAscii( lockScope );
53*51ba086bSDamjan Jovanovic     aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( LOCK_TYPE ));
54*51ba086bSDamjan Jovanovic     aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<owner>" ));
55*51ba086bSDamjan Jovanovic     rtl::OUString aStr;
56*51ba086bSDamjan Jovanovic     inLock.Owner >>= aStr;
57*51ba086bSDamjan Jovanovic     aBuffer.appendAscii( rtl::OUStringToOString( aStr, RTL_TEXTENCODING_UTF8 ).getStr() );
58*51ba086bSDamjan Jovanovic     aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "</owner>" ));
59*51ba086bSDamjan Jovanovic     aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( LOCK_TRAILER ));
60*51ba086bSDamjan Jovanovic     return rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
61*51ba086bSDamjan Jovanovic }
62