@param string $targetFeedSlug
@param string $targetUserId
@param int $activityCopyLimit

@return mixed

@throws StreamFeedException
549041
public function follow($targetFeedSlug, $targetUserId, $activityCopyLimit = 300)
    {
        $data = [
            'target' => "$targetFeedSlug:$targetUserId",
            'activity_copy_limit' => $activityCopyLimit
        ];
        if (null !== $this->client) {
            $target_feed = $this->client->feed($targetFeedSlug, $targetUserId);
            $data['target_token'] = $target_feed->getToken();
        }

        return $this->makeHttpRequest("{$this->base_feed_url}/follows/", 'POST', $data, null, 'follower', 'write');
    }
1340005
@Override
    public void mark(int readlimit) {
        abortIfNeeded();
        if ( !isAtStart )
            throw new UnsupportedOperationException("Chunk-encoded stream only supports mark() at the start of the stream.");
        if (is.markSupported()) {
            if (log.isDebugEnabled()) {
                log.debug("AwsChunkedEncodingInputStream marked at the start of the stream "
                        + "(will directly mark the wrapped stream since it's mark-supported).");
            }
            is.mark(readlimit);
        }
        else {
            if (log.isDebugEnabled()) {
                log.debug("AwsChunkedEncodingInputStream marked at the start of the stream "
                        + "(initializing the buffer since the wrapped stream is not mark-supported).");
            }
            decodedStreamBuffer = new DecodedStreamBuffer(maxBufferSize);
        }
    }
1186112
public function getAvailableRollbacksByTarget(Target $target, $limit = 50, $page = 0)
    {
        $dql = sprintf(self::DQL_ROLLBACKS, Release::class);
        $params = [
            'target' => $target,
            'release_status' => JobStatusEnum::TYPE_SUCCESS,
            'build_status' => JobStatusEnum::TYPE_SUCCESS,
        ];

        return $this->getPaginator($dql, $limit, $page, $params);
    }
615749
public function getFileLink($fileId, $target)
    {
        $file = Yii::$app->storage->getFile($fileId);
        if ($file) {
            $file->setTarget($target);
        }
        return $file;
    }
487446
public function copyFile($origFilePath, $targetFilePath, $publicAccess = true)
	{
		$origFilePath = str_replace('//', '/', $origFilePath);
		$targetFilePath = str_replace('//', '/', $targetFilePath);
		$result = $this->s3Client->copyObject(array(
			'Bucket' => $this->getBucket(),
			'CopySource' => $origFilePath,
			'Key'    => $targetFilePath,
			'ACL'    => $publicAccess ? self::PUBLIC_READ : self::PRIVATE_ACCESS
		));

		return $result;
	}
715828
public function createFile(
        FolderInterface $targetFolder,
        FileSourceInterface $fileSource,
        array $attributes,
        $userId)
    {
        $hash = $this->driver->getHashCalculator()->fromFileSource($fileSource);

        $fileClass = $this->driver->getFileClass();
        $file = new $fileClass();
        /* @var $file FileInterface */
        $file
            ->setVolume($this)
            ->setId(UuidUtil::generate())
            ->setFolder($targetFolder)
            ->setCreatedAt(new \DateTime())
            ->setCreateUserId($userId);

        $this->applyFile($file, 1, $fileSource->getName(), $fileSource->getMimeType(), $fileSource->getSize(), $hash, $attributes, $file->getCreateUserId(), $file->getCreatedAt());

        $event = new CreateFileEvent($file, $fileSource);
        if ($this->eventDispatcher->dispatch(VolumeEvents::BEFORE_CREATE_FILE, $event)->isPropagationStopped()) {
            throw new IOException("Create file {$file->getName()} failed.");
        }

        $this->driver->createFile($file, $fileSource);

        $event = new FileEvent($file);
        $this->eventDispatcher->dispatch(VolumeEvents::CREATE_FILE, $event);

        if ($this->hasFeature('versions')) {
            $this->createFileVersion($file, $fileSource, $attributes, $userId);
        }

        return $file;
    }
847815
static function fetchListForUser( $userID, $offset = false, $limit = false )
    {
        $objectList = eZPersistentObject::fetchObjectList( eZContentBrowseBookmark::definition(),
                                                            null,
                                                            array( 'user_id' => $userID ),
                                                            array( 'id' => 'desc' ),
                                                            array( 'offset' => $offset, 'length' => $limit ),
                                                            true );
        return $objectList;
    }
372294
public function addChild($kind, $parentId, $userId, array $data=null, array $targetFeeds=null)
    {
        $payload = [
            'kind' => $kind,
            'parent' => $parentId,
            'user_id' => $userId,
        ];
        if( $data !== null ){
            $payload['data'] = $data;
        }
        if( $targetFeeds !== null ){
            $payload['target_feeds'] = join(',', $targetFeeds);
        }
        $response = $this->doRequest('POST', 'reaction/', $payload);
        $body = $response->getBody()->getContents();
        return json_decode($body, true);
    }
1078911
protected function describeTargetFile($extension) {
		if ($this->targetDirectory === null) {
			throw new TargetDirectoryNotSpecifiedError();
		}

		$targetFilename = isset($this->targetFilename) ? $this->targetFilename : self::createRandomString();

		if (!File::mayNameBeValid($targetFilename)) {
			throw new InvalidFilenameException();
		}

		if (!$this->targetDirectory->exists() && !$this->targetDirectory->createRecursively(0755)) {
			throw new TargetFileWriteError();
		}

		return new File($this->targetDirectory, $targetFilename, $extension);
	}
1210776
static function checkObjectAccess( $contentObject, $policyID, $userIDArray, $userLimits = false )
    {
        $policy = eZPolicy::fetch( $policyID );
        if ( $userLimits )
        {
            reset( $userLimits );
            $policy->setAttribute( 'limit_identifier', 'User_' . key( $userLimits ) );
            $policy->setAttribute( 'limit_value', current( $userLimits ) );
        }

        $limitationArray = $policy->accessArray();
        $limitationArray = current( current( $limitationArray ) );
        $accessUserIDArray = $userIDArray;

        if ( isset( $limitationArray['*'] ) &&
             $limitationArray['*'] == '*' )
        {
            $returnArray = array();
            foreach ( $accessUserIDArray as $userID )
            {
                $returnArray[] = $userID;
            }
            return $returnArray;
        }

        $limitationArray = current( $limitationArray );

        $user = eZUser::currentUser();
        $classID = $contentObject->attribute( 'contentclass_id' );
        $nodeArray = $contentObject->attribute( 'assigned_nodes' );

        if ( isset( $limitationArray['Subtree' ] ) )
        {
            $checkedSubtree = false;
        }
        else
        {
            $checkedSubtree = true;
            $nodeSubtree = true;
        }
        if ( isset( $limitationArray['Node'] ) )
        {
            $checkedNode = false;
        }
        else
        {
            $checkedNode = true;
            $nodeLimit = true;
        }

        foreach ( array_keys( $limitationArray ) as $key )
        {
            if ( count( $accessUserIDArray ) == 0 )
            {
                return array();
            }
            switch( $key )
            {
                case 'Class':
                {
                    if ( !in_array( $contentObject->attribute( 'contentclass_id' ), $limitationArray[$key] )  )
                    {
                        return array();
                    }
                } break;

                case 'ParentClass':
                {

                    if ( !in_array( $contentObject->attribute( 'contentclass_id' ), $limitationArray[$key]  ) )
                    {
                        return array();
                    }
                } break;

                case 'Section':
                case 'User_Section':
                {
                    if ( !in_array( $contentObject->attribute( 'section_id' ), $limitationArray[$key]  ) )
                    {
                        return array();
                    }
                } break;

                case 'Owner':
                {
                    if ( in_array( $contentObject->attribute( 'owner_id' ), $userIDArray ) )
                    {
                        $accessUserIDArray = array( $contentObject->attribute( 'owner_id' ) );
                    }
                    else if ( in_array( $contentObject->attribute( 'id' ), $userIDArray ) )
                    {
                        $accessUserIDArray = array( $contentObject->attribute( 'id' ) );
                    }
                    else
                    {
                        return array();
                    }
                } break;

                case 'Node':
                {
                    $nodeLimit = true;
                    foreach ( $nodeArray as $node )
                    {
                        if( in_array( $node->attribute( 'node_id' ), $limitationArray[$key] ) )
                        {
                            $nodeLimit = false;
                            break;
                        }
                    }
                    if ( $nodeLimit && $checkedSubtree && $nodeSubtree )
                    {
                        return array();
                    }
                    $checkedNode = true;
                } break;

                case 'Subtree':
                {
                    $nodeSubtree = true;
                    foreach ( $nodeArray as $node )
                    {
                        $path = $node->attribute( 'path_string' );
                        $subtreeArray = $limitationArray[$key];
                        $validSubstring = false;
                        foreach ( $subtreeArray as $subtreeString )
                        {
                            if ( strstr( $path, $subtreeString ) )
                            {
                                $nodeSubtree = false;
                                break;
                            }
                        }
                        if ( !$nodeSubtree )
                        {
                            break;
                        }
                    }
                    if ( $nodeSubtree && $checkedNode && $nodeLimit )
                    {
                        return array();
                    }
                    $checkedSubtree = true;
                } break;

                case 'User_Subtree':
                {
                    $userSubtreeLimit = true;
                    foreach ( $nodeArray as $node )
                    {
                        $path = $node->attribute( 'path_string' );
                        $subtreeArray = $limitationArray[$key];
                        $validSubstring = false;
                        foreach ( $subtreeArray as $subtreeString )
                        {
                            if ( strstr( $path, $subtreeString ) )
                            {
                                $userSubtreeLimit = false;
                                break;
                            }
                        }
                        if ( !$userSubtreeLimit )
                        {
                            break;
                        }
                    }
                    if ( $userSubtreeLimit )
                    {
                        return array();
                    }
                } break;
                default:
                {
                    //check object state group limitation
                    if ( strncmp( $key, 'StateGroup_', 11 ) === 0 )
                    {
                        if ( count( array_intersect( $limitationArray[$key],
                                                     $contentObject->attribute( 'state_id_array' ) ) ) == 0 )
                        {
                            return array();
                        }
                    }
                }
            }
        }

        $returnArray = array();
        foreach ( $accessUserIDArray as $userID )
        {
            $returnArray[] = $userID;
        }
        return $returnArray;
    }
1334673
public function getUserBlockList($userIdentifier, $accessToken, $limit = 25, $offset = 0)
    {
        if ($this->apiVersionIsGreaterThanV3() && !is_numeric($userIdentifier)) {
            throw new InvalidIdentifierException('user');
        }

        if (!$this->isValidLimit($limit)) {
            throw new InvalidLimitException();
        }

        if (!$this->isValidOffset($offset)) {
            throw new InvalidOffsetException();
        }

        $params = [
            'limit' => intval($limit),
            'offset' => intval($offset),
        ];

        return $this->get(sprintf('users/%s/blocks', $userIdentifier), $params, $accessToken);
    }
334629
public function copyAction($sourceId, $targetId, $lang)
    {
        $em = $this->getDoctrine()->getManager();
        $source = $this->getPage($sourceId);
        $target = $this->getPage($targetId);
        $newPage = clone($source);
        $newPage->setParent($target);
        // Children page
        if ($target->getLang())
        {
            $newPage->setLang($target->getLang());
        }
        else
        {
            $newPage->setLang($lang);
            $newPage->setPosition($em->getRepository('FulgurioLightCMSBundle:Page')->getNextPosition($target));
        }
        $newPage->setStatus('draft');
        $newPage->setSourceId($sourceId);
        $models = $this->container->getParameter('fulgurio_light_cms.models');
        return $this->createPage($newPage, array('pageMetas' => $this->getPageMetas($sourceId), 'parent' => $target, 'sourceId' => $sourceId), $models);
    }
556792
public function add($sourceId, $targetId, $roleId)
    {
        $request = (new RequestDescriptor())
            ->setUrl($this->buildUrl(self::IDP_ATTRIBUTIONS_API))
            ->setMethod('POST');

        $request->setBodyParams([
            'data' => json_encode([
                'source_id' => $sourceId,
                'target_id' => $targetId,
                'role_id' => $roleId,
            ])
        ]);

        try {
            $response = json_decode($this->send($request)->getBody(), true);
            return (count($response['added']) > 0 ? reset($response['added']) : null);
        } catch (\Exception $e) {
            $previous = $e->getPrevious();

            if ($previous instanceof BadResponseException) {
                $error = json_decode($previous->getResponse()->getBody(), true);

                throw new UserAttributionException($error['error'], $error['code'], $previous);
            }

            throw new UserAttributionException($e->getMessage(), $e->getCode(), $e->getPrevious());
        }
    }
617837
public function copyRecursive($source, $target, $fileFilter = '/.*/')
    {
        $filesystem = new Filesystem();
        $finder = new Finder();
        $finder->files()->in($source)->name($fileFilter);

        /** @var SplFileInfo $file */
        foreach ($finder as $file) {
            $filesystem->copy($file, $target . DIRECTORY_SEPARATOR . $file->getRelativePathname());
        }
    }
912635
private static function restrictFeedItemToAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $feedId,
        $feedItemId,
        $adGroupId
    ) {
        $feedItemTargetService = $adWordsServices->get(
            $session,
            FeedItemTargetService::class
        );

        // Create a feed item ad group target.
        $feedItemAdGroupTarget = new FeedItemAdGroupTarget();
        $feedItemAdGroupTarget->setFeedId($feedId);
        $feedItemAdGroupTarget->setFeedItemId($feedItemId);
        $feedItemAdGroupTarget->setAdGroupId($adGroupId);

        // Create a feed item ad group target operation.
        $operation = new FeedItemTargetOperation();
        $operation->setOperand($feedItemAdGroupTarget);
        $operation->setOperator(Operator::ADD);

        // Create the feed item ad group target on the server and print out
        // some information.
        $result = $feedItemTargetService->mutate([$operation]);
        $feedItemAdGroupTarget = $result->getValue()[0];
        printf(
            'Feed item target for feed ID %d and feed item ID %d was '
            . 'created to restrict serving to ad group ID %d.%s',
            $feedItemAdGroupTarget->getFeedId(),
            $feedItemAdGroupTarget->getFeedItemId(),
            $feedItemAdGroupTarget->getAdGroupId(),
            PHP_EOL
        );
    }
181077
public void connectUsingTrmWithTargetData(String targetType, String targetSignificance, String target)
                    throws ResourceException
    {
        final String methodName = "connectUsingTrmWithTargetData";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.entry(this, TRACE, methodName, new Object[] { targetType, targetSignificance, target });
        }

        synchronized (_connections)
        {
            // At this point in the code path we can be sure that:
            // 1. There are no local preferred ME's (this method would not be called if there were)
            // 2. Target data has been set (we are in the else block of the "if (target == null)" block
            // 
            // Since we have been passed target data it means we are attempting to create a connection
            // to a preferred (or required) ME (no target data is ever passed if we are trying to create
            // a connection to a non preferred ME). With this in mind, if we are currently connected to
            // a non preferred ME (_connectToPreferred is false) or we do not currently have a connection
            // then we'll try and create a connection that matches our target data. If a connection
            // is created then we should close any non preferred connections (if they are any).
            if ((!_connectedToPreferred) || (_connections.size() == 0))
            {
                // Set to required (even if user opted for preferred)
                // Pass targetType and target from user data.
                SibRaMessagingEngineConnection newConnection = null;
                try
                {
                    newConnection = new SibRaMessagingEngineConnection(this, _endpointConfiguration.getBusName(),
                                    targetType, SibTrmConstants.TARGET_SIGNIFICANCE_REQUIRED, target);

                    dropNonPreferredConnections();

                    if (newConnection.getConnection() != null) {
                        _connections.put(newConnection.getConnection().getMeUuid(), newConnection);
                        createListener(newConnection);

                    }

                    if (_connections.size() > 0)
                    {
                        _connectedRemotely = checkIfRemote(_connections.values()
                                        .iterator().next());
                        _connectedToPreferred = true;

                        if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
                        {
                            SibTr.debug(TRACE, "We have connect <remote=" + _connectedRemotely + " > <preferred="
                                               + _connectedToPreferred + ">");
                        }
                    }
                } catch (final SIResourceException exception)
                {
                    // No FFDC code needed
                    // We are potentially connecting remotely so this error may be transient
                    // Possibly the remote ME is not available
                    SibTr.warning(TRACE, SibTr.Suppressor.ALL_FOR_A_WHILE, "TARGETTED_CONNECTION_FAILED_CWSIV0787",
                                  new Object[] { targetType, targetSignificance, target, _endpointConfiguration.getBusName() });
                    if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
                    {
                        SibTr.debug(TRACE, "Failed to obtain a connection - retry after a set interval");
                    }
                } catch (final SIException exception)
                {
                    FFDCFilter.processException(exception, CLASS_NAME + "." + methodName, "1:711:1.45", this);

                    if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled())
                    {
                        SibTr.exception(this, TRACE, exception);
                    }

                    throw new ResourceException(NLS.getFormattedMessage("CONNECT_FAILED_CWSIV0782", new Object[] {
                                                                                                                  _endpointConfiguration.getDestination().getDestinationName(),
                                                                                                                  _endpointConfiguration.getBusName(), this, exception }, null), exception);
                }
            }
        } // Sync block

        // Failed to get a preferred one, try for any ME next.
        // Also if we have connected to a remote non preferred ME we may wish to try again for a local
        // non preferred ME (We know there is not a local preferred ME as we would not be in this
        // method if there were).
        if (((_connections.size() == 0) || (_connectedRemotely && !_connectedToPreferred && _destinationStrategy
                        .isDropRemoteNonPreferredForLocalNonPreferred()))
            && (targetSignificance.equals(SibTrmConstants.TARGET_SIGNIFICANCE_PREFERRED)))
        {
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
            {
                SibTr.debug(TRACE,
                            "Could not obtain the preferred connection - try again without any target preferences");
            }
            // For durable pub sub there are no local preferred MEs, for point to point and non durable pub
            // sub then they all count as preferred
            connect(_destinationStrategy.isDurablePubsSub() ? null : getMEsToCheck(), null, null, null, false);
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.exit(TRACE, methodName);
        }
    }
953585
public function zip_plugin_folder($folderpath, $targetzip) {

        if (file_exists($targetzip)) {
            throw new coding_exception('Attempting to create already existing ZIP file', $targetzip);
        }

        if (!is_writable(dirname($targetzip))) {
            throw new coding_exception('Target ZIP location not writable', dirname($targetzip));
        }

        if (!is_dir($folderpath)) {
            throw new coding_exception('Attempting to ZIP non-existing source directory', $folderpath);
        }

        $files = $this->list_plugin_folder_files($folderpath);
        $fp = get_file_packer('application/zip');
        return $fp->archive_to_pathname($files, $targetzip, false);
    }