List of usage examples for javax.ejb TransactionAttributeType SUPPORTS
TransactionAttributeType SUPPORTS
To view the source code for javax.ejb TransactionAttributeType SUPPORTS.
Click Source Link
REQUIRED
case. From source file:org.ejbca.core.ejb.ra.UserAdminSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override//from w ww .java 2s .co m public boolean checkForHardTokenProfileId(Admin admin, int profileid) { if (log.isTraceEnabled()) { log.trace(">checkForHardTokenProfileId()"); } return UserData.countByHardTokenProfileId(entityManager, profileid) > 0; }
From source file:org.ejbca.core.ejb.ra.UserAdminSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/*from w ww . j a va2 s . co m*/ public boolean existsUser(Admin admin, String username) { boolean returnval = true; if (UserData.findByUsername(entityManager, username) == null) { returnval = false; } return returnval; }
From source file:org.ejbca.core.ejb.services.ServiceSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override//from w w w. j a va 2 s . c o m public boolean removeService(AuthenticationToken admin, String name) { if (log.isTraceEnabled()) { log.trace(">removeService(name: " + name + ")"); } boolean retval = false; try { ServiceData htp = serviceDataSession.findByName(name); if (htp == null) { throw new FinderException("Cannot find service " + name); } ServiceConfiguration serviceConfiguration = htp.getServiceConfiguration(); if (isAuthorizedToEditService(admin)) { IWorker worker = getWorker(serviceConfiguration, name, htp.getRunTimeStamp(), htp.getNextRunTimeStamp()); if (worker != null) { serviceSession.cancelTimer(htp.getId()); } serviceDataSession.removeServiceData(htp.getId()); final String msg = intres.getLocalizedMessage("services.serviceremoved", name); final Map<String, Object> details = new LinkedHashMap<String, Object>(); details.put("msg", msg); auditSession.log(EjbcaEventTypes.SERVICE_REMOVE, EventStatus.SUCCESS, EjbcaModuleTypes.SERVICE, EjbcaServiceTypes.EJBCA, admin.toString(), null, null, null, details); retval = true; } else { final String msg = intres.getLocalizedMessage("services.notauthorizedtoedit", name); log.info(msg); } } catch (Exception e) { final String msg = intres.getLocalizedMessage("services.errorremovingservice", name); final Map<String, Object> details = new LinkedHashMap<String, Object>(); details.put("msg", msg); details.put("error", e.getMessage()); auditSession.log(EjbcaEventTypes.SERVICE_REMOVE, EventStatus.FAILURE, EjbcaModuleTypes.SERVICE, EjbcaServiceTypes.EJBCA, admin.toString(), null, null, null, details); } log.trace("<removeService)"); return retval; }
From source file:org.ejbca.core.ejb.services.ServiceSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override//from w w w .j av a 2s . com public ServiceConfiguration getService(String name) { if (log.isTraceEnabled()) { log.trace(">getService: " + name); } ServiceConfiguration returnval = null; ServiceData serviceData = serviceDataSession.findByName(name); if (serviceData != null) { returnval = serviceData.getServiceConfiguration(); } if (log.isTraceEnabled()) { log.trace("<getService: " + name); } return returnval; }
From source file:org.ejbca.core.ejb.services.ServiceSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override//from w w w .j a va2 s .c om public int getServiceId(String name) { int returnval = 0; ServiceData serviceData = serviceDataSession.findByName(name); if (serviceData != null) { returnval = serviceData.getId(); } return returnval; }
From source file:org.ejbca.core.ejb.services.ServiceSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/*w w w .ja va2 s.c om*/ public void activateServiceTimer(AuthenticationToken admin, String name) { if (log.isTraceEnabled()) { log.trace(">activateServiceTimer(name: " + name + ")"); } ServiceData htp = serviceDataSession.findByName(name); if (htp != null) { ServiceConfiguration serviceConfiguration = htp.getServiceConfiguration(); if (isAuthorizedToEditService(admin)) { IWorker worker = getWorker(serviceConfiguration, name, htp.getRunTimeStamp(), htp.getNextRunTimeStamp()); if (worker != null) { serviceSession.cancelTimer(htp.getId()); if (serviceConfiguration.isActive() && worker.getNextInterval() != IInterval.DONT_EXECUTE) { addTimer(worker.getNextInterval() * 1000, htp.getId()); } } } else { final String msg = intres.getLocalizedMessage("services.notauthorizedtoedit", name); log.info(msg); } } else { log.error("Can not find service: " + name); } log.trace("<activateServiceTimer()"); }
From source file:org.ejbca.core.ejb.services.ServiceSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/*w w w .j av a2s . c om*/ public String getServiceName(int id) { if (log.isTraceEnabled()) { log.trace(">getServiceName(id: " + id + ")"); } String returnval = null; ServiceData serviceData = serviceDataSession.findById(id); if (serviceData != null) { returnval = serviceData.getName(); } if (log.isTraceEnabled()) { log.trace("<getServiceName()"); } return returnval; }
From source file:org.ejbca.core.ejb.services.ServiceSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override// w ww . j ava 2 s.c om public void changeService(AuthenticationToken admin, String name, ServiceConfiguration serviceConfiguration, boolean noLogging) { if (log.isTraceEnabled()) { log.trace(">changeService(name: " + name + ")"); } if (isAuthorizedToEditService(admin)) { ServiceData oldservice = serviceDataSession.findByName(name); if (oldservice != null) { final Map<Object, Object> diff = oldservice.getServiceConfiguration().diff(serviceConfiguration); if (serviceDataSession.updateServiceConfiguration(name, serviceConfiguration)) { final String msg = intres.getLocalizedMessage("services.serviceedited", name); if (noLogging) { log.info(msg); } else { final Map<String, Object> details = new LinkedHashMap<String, Object>(); details.put("msg", msg); for (Map.Entry<Object, Object> entry : diff.entrySet()) { details.put(entry.getKey().toString(), entry.getValue().toString()); } auditSession.log(EjbcaEventTypes.SERVICE_EDIT, EventStatus.SUCCESS, EjbcaModuleTypes.SERVICE, EjbcaServiceTypes.EJBCA, intAdmin.toString(), null, null, null, details); } } else { String msg = intres.getLocalizedMessage("services.serviceedited", name); if (noLogging) { log.error(msg); } else { final Map<String, Object> details = new LinkedHashMap<String, Object>(); details.put("msg", msg); auditSession.log(EjbcaEventTypes.SERVICE_EDIT, EventStatus.FAILURE, EjbcaModuleTypes.SERVICE, EjbcaServiceTypes.EJBCA, intAdmin.toString(), null, null, null, details); } } } else { log.error("Can not find service to change: " + name); } } else { String msg = intres.getLocalizedMessage("services.notauthorizedtoedit", name); log.info(msg); } log.trace("<changeService()"); }
From source file:org.ejbca.core.ejb.services.ServiceSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override/*from w w w. j a va 2s .c om*/ public ServiceConfiguration getServiceConfiguration(AuthenticationToken admin, int id) { if (log.isTraceEnabled()) { log.trace(">getServiceConfiguration: " + id); } ServiceConfiguration returnval = null; try { ServiceData serviceData = serviceDataSession.findById(Integer.valueOf(id)); if (serviceData != null) { returnval = serviceData.getServiceConfiguration(); } else { if (log.isDebugEnabled()) { log.debug("Returnval is null for service id: " + id); } } } catch (Exception e) { // return null if we cant find it, if it is not due to underlying // database error log.debug("Got an Exception for service with id " + id + ": " + e.getMessage()); /* * If we don't re-throw here it will be treated as the service id * does not exist and the service will not be rescheduled to run. */ throw new EJBException(e); } if (log.isTraceEnabled()) { log.trace("<getServiceConfiguration: " + id); } return returnval; }
From source file:org.ejbca.core.ejb.services.ServiceSessionBean.java
@TransactionAttribute(TransactionAttributeType.SUPPORTS) @Override//from ww w . ja v a2 s . co m public HashMap<Integer, String> getServiceIdToNameMap() { HashMap<Integer, String> returnval = new HashMap<Integer, String>(); Collection<ServiceData> result = serviceDataSession.findAll(); for (ServiceData next : result) { returnval.put(next.getId(), next.getName()); } return returnval; }