Exemplo n.º 1
1
 /**
  * Does a newly submitted SE have the same hostname+service type
  * as an existing service linked to another site.
  *
  * The ACE operations tool chokes if GOCDB has two services with the same
  * hostname+service_type under two different sites.
  * Note that a duplicate host+service_type is allowed under the one site as this
  * is potentially required for UNICORE SEs with multiple URLs.
  * (as explained by Rajesh Kalmady)
  *
  * @param string $hostName New hostname
  * @param ServiceType $serviceType New service type
  * @param Site $site The site to add the SE to
  * @return null
  */
 private function uniqueCheck($hostName, \ServiceType $serviceType, \Site $site)
 {
     // Get all existing services with this hostname and service type, not under this site
     $dql = "SELECT se from Service se\n                JOIN se.serviceType st\n                JOIN se.parentSite s\n                WHERE se.hostName = :hostName\n                AND st.id = :stId\n                AND s.id != :siteId";
     $ses = $this->em->createQuery($dql)->setParameter('hostName', $hostName)->setParameter('stId', $serviceType->getId())->setParameter('siteId', $site->getId())->getResult();
     if (sizeof($ses) != 0) {
         throw new \Exception("A {$serviceType} service named {$hostName} already exists.");
     }
 }
Exemplo n.º 2
0
 /**
  * Deletes a downtime
  * @param \Downtime $dt
  * @param \User $user
  */
 public function deleteServiceType(\ServiceType $serviceType, \User $user = null)
 {
     //Check the portal is not in read only mode, throws exception if it is
     $this->checkPortalIsNotReadOnlyOrUserIsAdmin($user);
     //Throws exception if user is not an administrator
     $this->checkUserIsAdmin($user);
     //Start a transaction
     $this->em->getConnection()->beginTransaction();
     try {
         //Check there are no services with this service type
         if (sizeof($this->getServices($serviceType->getId())) != 0) {
             throw new \Exception("This Service Type is in use");
         }
         //remove the service type
         $this->em->remove($serviceType);
         $this->em->flush();
         $this->em->getConnection()->commit();
     } catch (\Exception $e) {
         $this->em->getConnection()->rollback();
         $this->em->close();
         throw $e;
     }
 }