public function copyInstance()
    {
        if (
            $this->hasRequestParameter('destinationClassUri')
            && $this->hasRequestParameter('uri')
            && common_Utils::isUri($this->getRequestParameter('destinationClassUri'))
        ) {
            $this->validateInstanceRoot(
                $this->getRequestParameter('uri')
            );

            $this->signatureValidator->checkSignature(
                $this->getRequestParameter('signature'),
                $this->getRequestParameter('uri')
            );

            $instance  = $this->getCurrentInstance();
            $destinationClass = $this->getClass($this->getRequestParameter('destinationClassUri'));

            if ($this->hasWriteAccess($destinationClass->getUri())) {
                $copy = $this->getClassService()->cloneInstance($instance, $destinationClass);

                if(!is_null($copy)){
                    return $this->returnJson([
                        'success'  => true,
                        'data' => [
                            'label' => $copy->getLabel(),
                            'uri'   => $copy->getUri()
                        ]
                    ]);
                }
                return $this->returnJson([
                    'success'  => false,
                    'errorCode' => 204,
                    'errorMessage' =>  __("Unable to copy the resource")
                ], 204);
            }
            return $this->returnJson([
                'success'  => false,
                'errorCode' => 401,
                'errorMessage' =>  __("Permission denied to write in the selected class")
            ], 401);
        }
        return $this->returnJson([
            'success' => false,
            'errorCode' => 412,
            'errorMessage' => __('Missing Parameters')
        ], 412);
    }
public function copyInstance()
    {
        if (
            $this->hasRequestParameter('destinationClassUri')
            && $this->hasRequestParameter('uri')
            && common_Utils::isUri($this->getRequestParameter('destinationClassUri'))
        ) {
            $this->validateInstanceRoot(
                $this->getRequestParameter('uri')
            );

            $this->signatureValidator->checkSignature(
                $this->getRequestParameter('signature'),
                $this->getRequestParameter('uri')
            );

            $instance  = $this->getCurrentInstance();
            $destinationClass = $this->getClass($this->getRequestParameter('destinationClassUri'));

            if ($this->hasWriteAccess($destinationClass->getUri())) {
                $copy = $this->getClassService()->cloneInstance($instance, $destinationClass);

                if(!is_null($copy)){
                    return $this->returnJson([
                        'success'  => true,
                        'data' => [
                            'label' => $copy->getLabel(),
                            'uri'   => $copy->getUri()
                        ]
                    ]);
                }
                return $this->returnJson([
                    'success'  => false,
                    'errorCode' => 204,
                    'errorMessage' =>  __("Unable to copy the resource")
                ], 204);
            }
            return $this->returnJson([
                'success'  => false,
                'errorCode' => 401,
                'errorMessage' =>  __("Permission denied to write in the selected class")
            ], 401);
        }
        return $this->returnJson([
            'success' => false,
            'errorCode' => 412,
            'errorMessage' => __('Missing Parameters')
        ], 412);
    }
public function copyInstance ( ) { if ( $ this -> hasRequestParameter ( 'destinationClassUri' ) && $ this -> hasRequestParameter ( 'uri' ) && common_Utils :: isUri ( $ this -> getRequestParameter ( 'destinationClassUri' ) ) ) { $ this -> validateInstanceRoot ( $ this -> getRequestParameter ( 'uri' ) ) ; $ this -> signatureValidator -> checkSignature ( $ this -> getRequestParameter ( 'signature' ) , $ this -> getRequestParameter ( 'uri' ) ) ; $ instance = $ this -> getCurrentInstance ( ) ; $ destinationClass = $ this -> getClass ( $ this -> getRequestParameter ( 'destinationClassUri' ) ) ; if ( $ this -> hasWriteAccess ( $ destinationClass -> getUri ( ) ) ) { $ copy = $ this -> getClassService ( ) -> cloneInstance ( $ instance , $ destinationClass ) ; if ( ! is_null ( $ copy ) ) { return $ this -> returnJson ( [ 'success' => true , 'data' => [ 'label' => $ copy -> getLabel ( ) , 'uri' => $ copy -> getUri ( ) ] ] ) ; } return $ this -> returnJson ( [ 'success' => false , 'errorCode' => 204 , 'errorMessage' => __ ( "Unable to copy the resource" ) ] , 204 ) ; } return $ this -> returnJson ( [ 'success' => false , 'errorCode' => 401 , 'errorMessage' => __ ( "Permission denied to write in the selected class" ) ] , 401 ) ; } return $ this -> returnJson ( [ 'success' => false , 'errorCode' => 412 , 'errorMessage' => __ ( 'Missing Parameters' ) ] , 412 ) ; }
Copy a resource to a destination

@requiresRight uri READ
Copy a resource to a destination