/**
  * Convert's the passed DTOs into a JSON-API document representation.
  *
  * @param \AppserverIo\Collections\CollectionInterface $applications The application DTOs to convert
  *
  * @return Tobscure\JsonApi\Document The JSON-API document representation
  */
 protected function toApplicationOverviewData(CollectionInterface $applications)
 {
     // create a new collection of naming directories
     $collection = new Collection($applications->toArray(), new ApplicationSerializer());
     // create a new JSON-API document with that collection as the data
     $document = new Document($collection);
     // add metadata and links
     $document->addMeta('total', count($applications));
     // return the JSON-API representation
     return $document;
 }
 /**
  * Convert's the passed virtual host DTOs into a JSON-API document representation.
  *
  * @param \AppserverIo\Collections\CollectionInterface $virtualHosts The virtual host DTOs to convert
  *
  * @return Tobscure\JsonApi\Document The JSON-API document representation
  */
 protected function toVirtualHostOverviewData(CollectionInterface $virtualHosts)
 {
     // create a new collection of naming directories
     $collection = new Collection($virtualHosts->toArray(), new VirtualHostSerializer());
     // create a new JSON-API document with that collection as the data
     $document = new Document($collection);
     // add metadata and links
     $document->addMeta('total', count($virtualHosts));
     // return the stdClass representation of the naming directories
     return $document;
 }
 /**
  * Find or create a Group with the given name. Subclasses should use this
  * method to locate the 'Roles' group or create additional types of groups.
  *
  * @param \AppserverIo\Lang\String                     $name       The name of the group to create
  * @param \AppserverIo\Collections\CollectionInterface $principals The list of principals
  *
  * @return \AppserverIo\Psr\Security\Acl\GroupInterface A named group from the principals set
  */
 protected function createGroup(string $name, CollectionInterface $principals)
 {
     // initialize the group
     /** \AppserverIo\Psr\Security\Acl\GroupInterface $roles */
     $roles = null;
     // iterate over the passed principals
     foreach ($principals as $principal) {
         // query whether we found a group or not, proceed if not
         if ($principal instanceof GroupInterface == false) {
             continue;
         }
         // the principal is a group
         $grp = $principal;
         // if the group already exists, stop searching
         if ($grp->getName()->equals($name)) {
             $roles = $grp;
             break;
         }
     }
     // if we did not find a group create one
     if ($roles == null) {
         $roles = new SimpleGroup($name);
         $principals->add($roles);
     }
     // return the group
     return $roles;
 }
 /**
  * This method sorts the passed collection depending
  * on the comparator.
  *
  * @param \AppserverIo\Collections\CollectionInterface $collection Holds the Collection that should be sorted
  * @param \AppserverIo\Collections\ComparatorInterface $comperator The Comparator that should be used for compare purposes
  *
  * @return void
  */
 public static function sort(CollectionInterface $collection, ComparatorInterface $comperator)
 {
     // initialize the ArrayList that should be returned
     // sort the ArrayList
     $return = CollectionUtils::arraySort($collection->toArray(), 0, $collection->size(), $comperator);
     // clear all elements and add the sorted
     $collection->clear();
     $collection->addAll($return);
 }
 /**
  * Initializes a new session instance.
  *
  * @return \AppserverIo\RemoteMethodInvocation\SessionInterface The session instance
  * @see \AppserverIo\RemoteMethodInvocation\ConnectionInterface::createContextSession()
  */
 public function createContextSession()
 {
     $this->sessions->add($session = new ContextSession($this));
     return $session;
 }
 /**
  * This method merges the elements of the passed map
  * with the elements of the actual map.
  *
  * If the keys are equal, the existing value is taken, else
  * the new one is appended.
  *
  * @param \AppserverIo\Collections\CollectionInterface $col Holds the Collection with the values to merge
  *
  * @return void
  * @deprecated Does not work correctly
  */
 public function merge(CollectionInterface $col)
 {
     // union the items of the two maps
     $this->items = $this->items + $col->toArray();
 }