<commit_before><?php
/**
 * File containing the ezcWebdavLockLockRequestGenerator class.
 *
 * @package Webdav
 * @version //autogentag//
 * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 */
/**
 * Request generator used to generate PROPPATCH requests to realize the LOCK.
 *
 * @package Webdav
 * @version //autogen//
 * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 */
class ezcWebdavLockLockRequestGenerator implements ezcWebdavLockCheckObserver
{
    /**
     * Generated requests. 
     * 
     * @var array(ezcWebdavPropPatchRequest)
     */
    protected $requests = array();

    /**
     * Request that issued the lock. 
     * 
     * @var ezcWebdavLockRequest
     */
    protected $issuingRequest;

    /**
     * Active lock information part of lock response.
     * 
     * @var ezcWebdavLockDiscoveryPropertyActiveLock
     */
    protected $activeLock;

    /**
     * Creates a new request generator.
     *
     * The $request is the LOCK requst object, which was sent by the client.
     * The $activeLock part will be attached to the <lockdiscovery> property of
     * every affected resource.
     * 
     * @param ezcWebdavLockRequest $request 
     * @param string $lockToken
     */
    public function __construct(
        ezcWebdavLockRequest $request,
        ezcWebdavLockDiscoveryPropertyActiveLock $activeLock
    )
    {
        $this->issuingRequest = $request;
        $this->activeLock     = $activeLock;
    }

    /**
     * Notify the generator about a response.
     *
     * Notifies the request generator that a request should be generated w.r.t.
     * the given $response.
     * 
     * @param ezcWebdavPropFindResponse $propFind 
     * @return void
     */
    public function notify( ezcWebdavPropFindResponse $response )
    {
        $propPatch = new ezcWebdavPropPatchRequest( $response->node->path );

        // Overwrite properties, since only 1 lock is allowed at a time (currently)!

        $lockDiscoveryProp = new ezcWebdavLockDiscoveryProperty(
            new ArrayObject(
                array( clone $this->activeLock )
            )
        );
        
        $propPatch->updates->attach(
            $lockDiscoveryProp,
            ezcWebdavPropPatchRequest::SET
        );

        $lockInfoProperty = new ezcWebdavLockInfoProperty(
            new ArrayObject(
                new ezcWebdavLockTokenInfo(
                    $this->activeLock->token,
                    // Set $lockBase, if this resource is not the base
                    ( $this->issuingRequest->requestUri !== $response->node->path ? $requests->requestUri : null ),
                    // Set $lastAccess for the lock base (used for lock timeouts)
                    ( $this->issuingRequest->requestUri === $response->node->path ? new DateTime() : null )
                )
            )
        );

        $propPatch->updates->attach(
            $lockInfoProperty,
            ezcWebdavPropPatchRequest::SET
        );

        $this->requests[] = $propPatch;
    }

    /**
     * Returns all collected requests generated in the processor. 
     * 
     * @return array(ezcWebdavRequest)
     */
    public function getRequests()
    {
        return $this->requests;
    }
}

?><commit_msg>- Fixed creation of <lockinfo> property.<commit_after><?php
/**
 * File containing the ezcWebdavLockLockRequestGenerator class.
 *
 * @package Webdav
 * @version //autogentag//
 * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 */
/**
 * Request generator used to generate PROPPATCH requests to realize the LOCK.
 *
 * @package Webdav
 * @version //autogen//
 * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 */
class ezcWebdavLockLockRequestGenerator implements ezcWebdavLockCheckObserver
{
    /**
     * Generated requests. 
     * 
     * @var array(ezcWebdavPropPatchRequest)
     */
    protected $requests = array();

    /**
     * Request that issued the lock. 
     * 
     * @var ezcWebdavLockRequest
     */
    protected $issuingRequest;

    /**
     * Active lock information part of lock response.
     * 
     * @var ezcWebdavLockDiscoveryPropertyActiveLock
     */
    protected $activeLock;

    /**
     * Creates a new request generator.
     *
     * The $request is the LOCK requst object, which was sent by the client.
     * The $activeLock part will be attached to the <lockdiscovery> property of
     * every affected resource.
     * 
     * @param ezcWebdavLockRequest $request 
     * @param string $lockToken
     */
    public function __construct(
        ezcWebdavLockRequest $request,
        ezcWebdavLockDiscoveryPropertyActiveLock $activeLock
    )
    {
        $this->issuingRequest = $request;
        $this->activeLock     = $activeLock;
    }

    /**
     * Notify the generator about a response.
     *
     * Notifies the request generator that a request should be generated w.r.t.
     * the given $response.
     * 
     * @param ezcWebdavPropFindResponse $propFind 
     * @return void
     */
    public function notify( ezcWebdavPropFindResponse $response )
    {
        $originalRequestUri = $this->issuingRequest->requestUri;
        $path               = $response->node->path;

        $propPatch = new ezcWebdavPropPatchRequest( $response->node->path );

        // Overwrite properties, since only 1 lock is allowed at a time (currently)!

        $lockDiscoveryProp = new ezcWebdavLockDiscoveryProperty(
            new ArrayObject(
                array( clone $this->activeLock )
            )
        );
        
        $propPatch->updates->attach(
            $lockDiscoveryProp,
            ezcWebdavPropPatchRequest::SET
        );

        $lockInfoProperty = new ezcWebdavLockInfoProperty(
            new ArrayObject(
                array(
                    new ezcWebdavLockTokenInfo(
                        (string) $this->activeLock->token,
                        // Set $lockBase, if this resource is not the base
                        ( $originalRequestUri !== $path ? $originalRequestUri : null ),
                        // Set $lastAccess for the lock base (used for lock timeouts)
                        ( $originalRequestUri === $path ? new DateTime() : null )
                    )
                )
            )
        );

        $propPatch->updates->attach(
            $lockInfoProperty,
            ezcWebdavPropPatchRequest::SET
        );

        $this->requests[] = $propPatch;
    }

    /**
     * Returns all collected requests generated in the processor. 
     * 
     * @return array(ezcWebdavRequest)
     */
    public function getRequests()
    {
        return $this->requests;
    }
}

?>
{'fraction_non_alphanumeric': 0.09451307095662166, 'fraction_numerical': 0.004883654122378627, 'mean_word_length': 2.0606593406593405, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3005134', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1846, 'n_words': 507}