Ignore:
Timestamp:
09/20/11 03:16:11 (8 months ago)
Author:
delmitz
Branch:
default
Convert:
svn:7c3792e6-d75b-4784-96a6-b298f655ee64/trunk@2782
Message:

modified API interfaces.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kraken-dom/src/main/java/org/krakenapps/dom/api/impl/HostApiImpl.java

    r2 r348  
    5959                EntityManager em = entityManagerService.getEntityManager(); 
    6060                try { 
    61                         return (HostExtension) em.createQuery("FROM HostExtension e WHERE e.className = ?").setParameter(1, 
    62                                         className).getSingleResult(); 
     61                        return (HostExtension) em.createQuery("FROM HostExtension e WHERE e.className = ?") 
     62                                        .setParameter(1, className).getSingleResult(); 
    6363                } catch (NoResultException e) { 
    6464                        return null; 
     
    8383 
    8484        @Override 
    85         public int createHost(int organizationId, int hostTypeId, int areaId, String name, String description) { 
     85        public Host createHost(int organizationId, int hostTypeId, int areaId, String name, String description) { 
    8686                Host host = createHostInternal(organizationId, hostTypeId, areaId, name, description); 
    8787                fireEntityAdded(host); 
    88                 return host.getId(); 
     88                return host; 
    8989        } 
    9090 
     
    129129 
    130130        @Override 
    131         public void updateHost(int organizationId, int hostId, String name, String description) { 
     131        public Host updateHost(int organizationId, int hostId, String name, String description) { 
    132132                Host host = updateHostInternal(organizationId, hostId, name, description); 
    133133                fireEntityUpdated(host); 
     134                return host; 
    134135        } 
    135136 
     
    154155        } 
    155156 
    156         @Transactional 
    157         @Override 
    158         public void updateHostGuid(int organizationId, int hostId, String guid) { 
    159                 EntityManager em = entityManagerService.getEntityManager(); 
    160  
    161                 try { 
    162                         Host host = getHost(organizationId, hostId); 
    163                         if (host == null) 
    164                                 throw new HostNotFoundException(); 
    165  
    166                         host.setGuid(guid); 
    167                         em.merge(host); 
    168  
    169                         fireEntityUpdated(host); 
    170                 } catch (NoResultException e) { 
    171                         throw new HostNotFoundException(); 
    172                 } 
     157        @Override 
     158        public Host updateHostGuid(int organizationId, int hostId, String guid) { 
     159                Host host = updateHostGuidInternal(organizationId, hostId, guid); 
     160                fireEntityUpdated(host); 
     161                return host; 
     162        } 
     163 
     164        @Transactional 
     165        private Host updateHostGuidInternal(int organizationId, int hostId, String guid) { 
     166                EntityManager em = entityManagerService.getEntityManager(); 
     167                Host host = getHost(organizationId, hostId); 
     168                if (host == null) 
     169                        throw new HostNotFoundException(); 
     170 
     171                host.setGuid(guid); 
     172                em.merge(host); 
     173                return host; 
    173174        } 
    174175 
     
    206207                EntityManager em = entityManagerService.getEntityManager(); 
    207208                try { 
    208                         Host host = (Host) em.createNamedQuery("Host.findById").setParameter(1, organizationId).setParameter(2, 
    209                                         hostId).getSingleResult(); 
     209                        Host host = (Host) em.createNamedQuery("Host.findById").setParameter(1, organizationId) 
     210                                        .setParameter(2, hostId).getSingleResult(); 
    210211 
    211212                        host.getExtensions().size(); // force loading 
     
    225226        } 
    226227 
    227         @Transactional 
    228         @Override 
    229         public void moveHost(int organizationId, int hostId, int areaId) { 
     228        @Override 
     229        public Host moveHost(int organizationId, int hostId, int areaId) { 
     230                Host host = moveHostInternal(organizationId, hostId, areaId); 
     231                fireEntityUpdated(host); 
     232                return host; 
     233        } 
     234 
     235        @Transactional 
     236        private Host moveHostInternal(int organizationId, int hostId, int areaId) { 
    230237                EntityManager em = entityManagerService.getEntityManager(); 
    231238 
     
    238245 
    239246                em.merge(host); 
    240         } 
    241  
    242         @Override 
    243         public void removeHost(int organizationId, int hostId) { 
    244                 Host host = getHost(organizationId, hostId); 
    245                 if (host == null) 
    246                         throw new HostNotFoundException(); 
    247  
     247                return host; 
     248        } 
     249 
     250        @Override 
     251        public Host removeHost(int organizationId, int hostId) { 
     252                Host host = getHost(organizationId, hostId); 
     253                if (host == null) 
     254                        throw new HostNotFoundException(); 
    248255                fireEntityRemoving(host); 
    249256                removeHostInternal(organizationId, hostId); 
    250257                fireEntityRemoved(host); 
     258                return host; 
    251259        } 
    252260 
     
    255263                EntityManager em = entityManagerService.getEntityManager(); 
    256264                Host host = getHost(organizationId, hostId); 
    257  
    258265                host.getExtensions().clear(); 
    259  
    260266                em.remove(host); 
    261267        } 
    262268 
    263         @Transactional 
    264         @Override 
    265         public void mapHostExtensions(int organizationId, int hostId, Set<String> hostExtensionNames) { 
     269        @Override 
     270        public Host mapHostExtensions(int organizationId, int hostId, Set<String> hostExtensionNames) { 
     271                Host host = mapHostExtensionsInternal(organizationId, hostId, hostExtensionNames); 
     272                fireEntityUpdated(host); 
     273                return host; 
     274        } 
     275 
     276        @Transactional 
     277        private Host mapHostExtensionsInternal(int organizationId, int hostId, Set<String> hostExtensionNames) { 
    266278                EntityManager em = entityManagerService.getEntityManager(); 
    267279                Host host = getHost(organizationId, hostId); 
     
    280292                        em.merge(host); 
    281293                } 
     294 
     295                return host; 
    282296        } 
    283297 
     
    292306        } 
    293307 
    294         @Transactional 
    295         @Override 
    296         public void unmapHostExtensions(int organizationId, int hostId, Set<String> hostExtensionNames) { 
     308        @Override 
     309        public Host unmapHostExtensions(int organizationId, int hostId, Set<String> hostExtensionNames) { 
     310                Host host = unmapHostExtensionsInternal(organizationId, hostId, hostExtensionNames); 
     311                fireEntityUpdated(host); 
     312                return host; 
     313        } 
     314 
     315        @Transactional 
     316        private Host unmapHostExtensionsInternal(int organizationId, int hostId, Set<String> hostExtensionNames) { 
    297317                EntityManager em = entityManagerService.getEntityManager(); 
    298318                Host host = getHost(organizationId, hostId); 
     
    311331                        em.merge(host); 
    312332                } 
     333 
     334                return host; 
    313335        } 
    314336 
Note: See TracChangeset for help on using the changeset viewer.