Beispiel #1
0
 public function deleteEndpoint(\EndpointLocation $endpoint, \User $user)
 {
     require_once __DIR__ . '/../DAOs/ServiceDAO.php';
     //Check the portal is not in read only mode, throws exception if it is
     $this->checkPortalIsNotReadOnlyOrUserIsAdmin($user);
     $service = $endpoint->getService();
     // check user has permission to edit endpoint's service
     $this->validateAddEditDeleteActions($user, $service);
     $this->em->getConnection()->beginTransaction();
     try {
         $serviceDAO = new \ServiceDAO();
         $serviceDAO->setEntityManager($this->em);
         $serviceDAO->removeEndpoint($endpoint);
         $this->em->flush();
         $this->em->getConnection()->commit();
     } catch (\Exception $e) {
         $this->em->getConnection()->rollback();
         $this->em->close();
         throw $e;
     }
 }
Beispiel #2
0
 /**
  * Remove the downtime from the specified ELs list of downtimes and 
  * then remoeve it from this downtime's EL list.  
  * calls to <code>$endpointLocation->_removeDowntime($this)</code> to 
  * keep both sides of the relationship consistent (i.e. no need to 
  * call <code>$endpointLocation->removeDowntime($this)</code> in client code).  
  * <p>
  * This is the OWNING side so this method WILL remove the relationship from
  * the database.
  * 
  * @param EndpointLocation $endpointLocation endpoint location for removal
  */
 public function removeEndpointLocation(EndpointLocation $endpointLocation)
 {
     $endpointLocation->getDowntimes()->removeElement($this);
     //$endpointLocation->_remove Downtime($this);
     $this->endpointLocations->removeElement($endpointLocation);
 }
Beispiel #3
0
 public static function createSampleEndpointLocation()
 {
     $el = new EndpointLocation();
     $el->setUrl("https://google.co.uk");
     return $el;
 }
Beispiel #4
0
 /**
  * Add the given EL to the list. This method internally calls 
  * <code>$endpointLocation->setServiceDoJoin($this)</code> to keep both  
  * sides of the bidirectional relationship consistent (i.e. don't separately 
  * call <code>$endpointLocation->setServiceDoJoin($this)</code>). 
  * <p>
  * Service is the INVERSE side of the relation so the internal call to 
  * <code>$endpointLocation->setServiceDoJoin($this)</code> actually establishes the relationship in the DB. 
  * 
  * @param EndpointLocation $endpointLocation
  */
 public function addEndpointLocationDoJoin(EndpointLocation $endpointLocation)
 {
     $this->endpointLocations[] = $endpointLocation;
     $endpointLocation->setServiceDoJoin($this);
 }
Beispiel #5
0
 /**
  * Queues an EndpointLocation for removal by unlinking its associations 
  * with Service and Downtime.
  * <p> 
  * No authorisation or validation occurs here.
  * Non-transactional - invokes remove() of the EntityManager 
  * but does not call flush(), commit() or rollback(). 
  * 
  * @param \EndpointLocation $endpoint
  */
 public function removeEndpoint(\EndpointLocation $endpoint)
 {
     $service = $endpoint->getService();
     // unset relation on both sides (SE<-->EL)
     $service->getEndpointLocations()->removeElement($endpoint);
     $endpoint->setServiceDoJoin(NULL);
     // unset relation on both sides (EL<-->DT)
     foreach ($endpoint->getDowntimes() as $dt) {
         $endpoint->getDowntimes()->removeElement($dt);
         $dt->getEndpointLocations()->removeElement($endpoint);
     }
     // Once relationships are removed delete the actual element
     $this->em->remove($endpoint);
 }
        $doctrineSe->setMonitored(false);
    }
    // Set the scope
    if ((string) $xmlSe->SCOPE == "EGI") {
        $doctrineSe->addScope($egiScope);
    } else {
        if ((string) $xmlSe->SCOPE == 'Local') {
            $doctrineSe->addScope($localScope);
        } else {
            throw new Exception("Unknown scope " . $xmlSe->SCOPE . " for SE " . $xmlSe->HOSTNAME);
        }
    }
    //set creation date
    $creationDate = new \DateTime("now", new DateTimeZone('UTC'));
    $doctrineSe->setCreationDate($creationDate);
    $doctrineSe->setDn((string) $xmlSe->HOSTDN);
    $doctrineSe->setIpAddress((string) $xmlSe->HOST_IP);
    $doctrineSe->setOperatingSystem((string) $xmlSe->HOST_OS);
    $doctrineSe->setArchitecture((string) $xmlSe->HOST_ARCH);
    $doctrineSe->setHostName((string) $xmlSe->HOSTNAME);
    $doctrineSe->setDescription((string) $xmlSe->DESCRIPTION);
    // A service has ELs
    $doctrineEndpointLocation = new EndpointLocation();
    $doctrineEndpointLocation->setUrl((string) $xmlSe->URL);
    $doctrineEndpointLocation->setName('sampleEndpoint');
    $doctrineEndpointLocation->setInterfaceName((string) $doctrineSe->getServiceType()->getName());
    $doctrineSe->addEndpointLocationDoJoin($doctrineEndpointLocation);
    $entityManager->persist($doctrineSe);
    $entityManager->persist($doctrineEndpointLocation);
}
$entityManager->flush();