Exemplo n.º 1
0
 public function editEndpoint(\Service $service, \User $user, \EndpointLocation $endpoint, $newValues)
 {
     //Check the portal is not in read only mode, throws exception if it is
     $this->checkPortalIsNotReadOnlyOrUserIsAdmin($user);
     $name = $newValues['SERVICEENDPOINT']['NAME'];
     $url = $newValues['SERVICEENDPOINT']['URL'];
     if ($newValues['SERVICEENDPOINT']['INTERFACENAME'] != '') {
         $interfaceName = $newValues['SERVICEENDPOINT']['INTERFACENAME'];
     } else {
         $interfaceName = (string) $service->getServiceType();
     }
     $description = $newValues['SERVICEENDPOINT']['DESCRIPTION'];
     $this->validate($newValues['SERVICEENDPOINT'], 'endpoint');
     if (empty($name)) {
         throw new \Exception("An endpoint must have a name.");
     }
     if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
         throw new \Exception("An endpoint must have a valid url.");
     }
     // check endpoint's name is unique under the service
     foreach ($service->getEndpointLocations() as $endpointL) {
         // exclude itself
         if ($endpoint != $endpointL && $endpointL->getName() == $name) {
             throw new \Exception("Please provide a unique name for this endpoint.");
         }
     }
     $this->em->getConnection()->beginTransaction();
     try {
         // Set the endpoints new member variables
         $endpoint->setName($name);
         $endpoint->setUrl($url);
         $endpoint->setInterfaceName($interfaceName);
         $endpoint->setDescription($description);
         $this->em->merge($endpoint);
         $this->em->flush();
         $this->em->getConnection()->commit();
     } catch (\Exception $ex) {
         $this->em->getConnection()->rollback();
         $this->em->close();
         throw $ex;
     }
 }
Exemplo n.º 2
0
        $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();