<commit_before><?php
/**
 * File containing the ezcWebdavLockMakeCollectionRequestResponseHandler 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
 *
 * @access private
 */
/**
 * Handler class for the MKCOL request.
 * 
 * @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
 *
 * @access private
 */
class ezcWebdavLockMakeCollectionRequestResponseHandler extends ezcWebdavLockRequestResponseHandler
{
    /**
     * MKCOL request. 
     * 
     * @var ezcWebdavMakeCollectionRequst
     */
    protected $request;
    
    /**
     * Lock property to be updated after processing. 
     * 
     * @var ezcWebdavLockDiscoveryProperty
     */
    protected $lockDiscoveryProp;

    /**
     * Lock property to be updated after processing. 
     * 
     * @var ezcWebdavLockInfoProperty
     */
    protected $lockInfoProp;

    /**
     * Handles GET requests.
     *
     * @param ezcWebdavUnlockRequest $request 
     * @return ezcWebdavResponse
     */
    public function receivedRequest( ezcWebdavRequest $request )
    {
        $this->request = $request;

        $target = $request->requestUri;
        $parent = dirname( $target );

        $ifHeader   = $request->getHeader( 'If' );
        $authHeader = $request->getHeader( 'Authorization' );

        $observer = new ezcWebdavLockMultipleCheckObserver();

        $targetLockRefresher = null;
        if ( $ifHeader !== null )
        {
            $targetLockRefresher = new ezcWebdavLockRefreshRequestGenerator(
                $request
            );
            $observer->attach( $targetLockRefresher );
        }

        $propertyCollector = new ezcWebdavLockCheckPropertyCollector();
        $observer->attach( $propertyCollector );

        $violation = $this->tools->checkViolations(
            new ezcWebdavLockCheckInfo(
                $target,
                ezcWebdavRequest::DEPTH_ZERO,
                $ifHeader,
                $authHeader,
                ezcWebdavAuthorizer::ACCESS_WRITE,
                $observer
            ),
            true
        );

        $targetExists = true;
        if ( $violation !== null )
        {
            if ( $violation->status !== ezcWebdavResponse::STATUS_404 )
            {
                // Desired collection exists and conditions are violated
                return $violation;
            }
            if ( $violation->status === ezcWebdavResponse::STATUS_404 )
            {
                $targetExists = false;
                // Desired collection does not exist, check parent
                $violation = $this->tools->checkViolations(
                    new ezcWebdavLockCheckInfo(
                        $parent,
                        ezcWebdavRequest::DEPTH_ZERO,
                        $ifHeader,
                        $authHeader,
                        ezcWebdavAuthorizer::ACCESS_WRITE,
                        $observer
                    ),
                    true
                );
                if ( $violation !== null )
                {
                    return $violation;
                }
            }
        }

        // Lock refresh must occur no matter if the request succeeds
        if ( $targetLockRefresher !== null )
        {
            $targetLockRefresher->sendRequests();
        }

        // Delete lock null before performing the request
        if ( $targetExists )
        {
            $targetProps  = $propertyCollector->getProperties( $target );
            $lockInfoProp = $targetProps->get(
                'lockinfo',
                ezcWebdavLockPlugin::XML_NAMESPACE
            );

            if ( $lockInfoProp !== null && $lockInfoProp->null )
            {
                $deleteReq = new ezcWebdavDeleteRequest( $target );
                ezcWebdavLockTools::cloneRequestHeaders( $request, $deleteReq );
                $deleteReq->validateHeaders();
                $deleteRes = ezcWebdavServer::getInstance()->backend->delete(<commit_msg>- Fixed error code on MKCOL, if parent collection does not exist. # Litmus test identified this issue.<commit_after><?php
/**
 * File containing the ezcWebdavLockMakeCollectionRequestResponseHandler 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
 *
 * @access private
 */
/**
 * Handler class for the MKCOL request.
 * 
 * @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
 *
 * @access private
 */
class ezcWebdavLockMakeCollectionRequestResponseHandler extends ezcWebdavLockRequestResponseHandler
{
    /**
     * MKCOL request. 
     * 
     * @var ezcWebdavMakeCollectionRequst
     */
    protected $request;
    
    /**
     * Lock property to be updated after processing. 
     * 
     * @var ezcWebdavLockDiscoveryProperty
     */
    protected $lockDiscoveryProp;

    /**
     * Lock property to be updated after processing. 
     * 
     * @var ezcWebdavLockInfoProperty
     */
    protected $lockInfoProp;

    /**
     * Handles GET requests.
     *
     * @param ezcWebdavUnlockRequest $request 
     * @return ezcWebdavResponse
     */
    public function receivedRequest( ezcWebdavRequest $request )
    {
        $this->request = $request;

        $target = $request->requestUri;
        $parent = dirname( $target );

        $ifHeader   = $request->getHeader( 'If' );
        $authHeader = $request->getHeader( 'Authorization' );

        $observer = new ezcWebdavLockMultipleCheckObserver();

        $targetLockRefresher = null;
        if ( $ifHeader !== null )
        {
            $targetLockRefresher = new ezcWebdavLockRefreshRequestGenerator(
                $request
            );
            $observer->attach( $targetLockRefresher );
        }

        $propertyCollector = new ezcWebdavLockCheckPropertyCollector();
        $observer->attach( $propertyCollector );

        $violation = $this->tools->checkViolations(
            new ezcWebdavLockCheckInfo(
                $target,
                ezcWebdavRequest::DEPTH_ZERO,
                $ifHeader,
                $authHeader,
                ezcWebdavAuthorizer::ACCESS_WRITE,
                $observer
            ),
            true
        );

        $targetExists = true;
        if ( $violation !== null )
        {
            if ( $violation->status !== ezcWebdavResponse::STATUS_404 )
            {
                // Desired collection exists and conditions are violated
                return $violation;
            }
            if ( $violation->status === ezcWebdavResponse::STATUS_404 )
            {
                $targetExists = false;
                // Desired collection does not exist, check parent
                $violation = $this->tools->checkViolations(
                    new ezcWebdavLockCheckInfo(
                        $parent,
                        ezcWebdavRequest::DEPTH_ZERO,
                        $ifHeader,
                        $authHeader,
                        ezcWebdavAuthorizer::ACCESS_WRITE,
                        $observer
                    ),
                    true
                );
                if ( $violation !== null )
                {
                    if ( $violation->status === ezcWebdavResponse::STATUS_404 )
                    {
                        // The parent does not exist, not the target.
                        $violation->status = ezcWebdavResponse::STATUS_409;
                    }
                    return $violation;
                }
            }
        }

        // Lock refresh must occur no matter if the request succeeds
        if ( $targetLockRefresher !== null )
        {
            $targetLockRefresher->sendRequests();
        }

        // Delete lock null before performing the request
        if ( $targetExists )
        {
            $targetProps  = $propertyCollector->getProperties( $target );
            $lockInfoProp = $targetProps->get(
                'lockinfo',
                ezcWebdavLockPlugin::XML_NAMESPACE
            );

            if ( $lockInfoProp !== null && $lockInfoProp->null )
            {
                $deleteReq = new ezcWebdavDeleteRequest( $target );
                ezcWebdavLockTools::cloneRequestHeaders( $request, $deleteReq );
                $deleteReq->validateHeaders();
                $deleteRes = ezcWebdavServer::getInstance()->backend->delete(
{'fraction_non_alphanumeric': 0.0942944994875299, 'fraction_numerical': 0.005694112287894317, 'mean_word_length': 1.6579903147699757, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '6942203', 'n_tokens_mistral': 2464, 'n_tokens_neox': 2192, 'n_words': 490}