aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-04-12 18:56:59 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2014-04-12 18:56:59 +1200
commit500751368e7f8fc381f720a0c40cd00d8a9914ed (patch)
treeadb6182f7e89d6daf17982fd832b61c4744dd985 /src/org
parent891abffcf8c76fff62b2c4a35a41818d3eab6bc2 (diff)
downloadtrackermap-web-500751368e7f8fc381f720a0c40cd00d8a9914ed.tar.gz
trackermap-web-500751368e7f8fc381f720a0c40cd00d8a9914ed.tar.bz2
trackermap-web-500751368e7f8fc381f720a0c40cd00d8a9914ed.zip
Fix code formatting
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/web/client/controller/DeviceController.java4
-rw-r--r--src/org/traccar/web/server/model/DataServiceImpl.java139
2 files changed, 71 insertions, 72 deletions
diff --git a/src/org/traccar/web/client/controller/DeviceController.java b/src/org/traccar/web/client/controller/DeviceController.java
index b884537b..e9940aa2 100644
--- a/src/org/traccar/web/client/controller/DeviceController.java
+++ b/src/org/traccar/web/client/controller/DeviceController.java
@@ -87,7 +87,7 @@ public class DeviceController implements ContentController, DeviceView.DeviceHan
}
@Override
public void onFailure(Throwable caught) {
- new AlertMessageBox("Error", "Device with this Unique ID already exists").show();
+ new AlertMessageBox("Error", "Device with this Unique ID already exists").show();
}
});
}
@@ -106,7 +106,7 @@ public class DeviceController implements ContentController, DeviceView.DeviceHan
}
@Override
public void onFailure(Throwable caught) {
- new AlertMessageBox("Error", "Device with this Unique ID already exists").show();
+ new AlertMessageBox("Error", "Device with this Unique ID already exists").show();
}
});
}
diff --git a/src/org/traccar/web/server/model/DataServiceImpl.java b/src/org/traccar/web/server/model/DataServiceImpl.java
index 2c88800c..d1a6eec9 100644
--- a/src/org/traccar/web/server/model/DataServiceImpl.java
+++ b/src/org/traccar/web/server/model/DataServiceImpl.java
@@ -147,26 +147,26 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService
@Override
public User register(String login, String password) {
if (getApplicationSettings().getRegistrationEnabled()) {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
-
- TypedQuery<User> query = entityManager.createQuery(
- "SELECT x FROM User x WHERE x.login = :login", User.class);
- query.setParameter("login", login);
- List<User> results = query.getResultList();
- if (results.isEmpty()) {
- User user = new User();
- user.setLogin(login);
- user.setPassword(password);
- createUser(getSessionEntityManager(), user);
- setSessionUser(user);
- return user;
- }
- else
- {
- throw new IllegalStateException();
- }
- }
+ EntityManager entityManager = getSessionEntityManager();
+ synchronized (entityManager) {
+
+ TypedQuery<User> query = entityManager.createQuery(
+ "SELECT x FROM User x WHERE x.login = :login", User.class);
+ query.setParameter("login", login);
+ List<User> results = query.getResultList();
+ if (results.isEmpty()) {
+ User user = new User();
+ user.setLogin(login);
+ user.setPassword(password);
+ createUser(getSessionEntityManager(), user);
+ setSessionUser(user);
+ return user;
+ }
+ else
+ {
+ throw new IllegalStateException();
+ }
+ }
} else {
throw new SecurityException();
}
@@ -191,26 +191,26 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService
if (currentUser.getAdmin()) {
EntityManager entityManager = getSessionEntityManager();
synchronized (entityManager) {
-
- String login = user.getLogin();
- TypedQuery<User> query = entityManager.createQuery("SELECT x FROM User x WHERE x.login = :login", User.class);
- query.setParameter("login", login);
- List<User> results = query.getResultList();
-
- if (results.isEmpty()) {
- entityManager.getTransaction().begin();
- try {
- entityManager.persist(user);
- entityManager.getTransaction().commit();
- return user;
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
- } else {
- throw new IllegalStateException();
- }
- }
+
+ String login = user.getLogin();
+ TypedQuery<User> query = entityManager.createQuery("SELECT x FROM User x WHERE x.login = :login", User.class);
+ query.setParameter("login", login);
+ List<User> results = query.getResultList();
+
+ if (results.isEmpty()) {
+ entityManager.getTransaction().begin();
+ try {
+ entityManager.persist(user);
+ entityManager.getTransaction().commit();
+ return user;
+ } catch (RuntimeException e) {
+ entityManager.getTransaction().rollback();
+ throw e;
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+ }
} else {
throw new SecurityException();
}
@@ -308,20 +308,20 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService
if (results.isEmpty()) {
entityManager.getTransaction().begin();
- try {
- entityManager.persist(device);
- user.getDevices().add(device);
- entityManager.getTransaction().commit();
- return device;
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
+ try {
+ entityManager.persist(device);
+ user.getDevices().add(device);
+ entityManager.getTransaction().commit();
+ return device;
+ } catch (RuntimeException e) {
+ entityManager.getTransaction().rollback();
+ throw e;
+ }
+ }
+ else
+ {
+ throw new IllegalStateException();
}
- else
- {
- throw new IllegalStateException();
- }
}
}
@@ -331,26 +331,25 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService
EntityManager entityManager = getSessionEntityManager();
synchronized (entityManager) {
- TypedQuery<Device> query = entityManager.createQuery("SELECT x FROM Device x WHERE x.uniqueId = :id", Device.class);
- query.setParameter("id", device.getUniqueId());
- List<Device> results = query.getResultList();
-
+ TypedQuery<Device> query = entityManager.createQuery("SELECT x FROM Device x WHERE x.uniqueId = :id", Device.class);
+ query.setParameter("id", device.getUniqueId());
+ List<Device> results = query.getResultList();
if (results.isEmpty()) {
- entityManager.getTransaction().begin();
- try {
- device = entityManager.merge(device);
- entityManager.getTransaction().commit();
- return device;
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
+ entityManager.getTransaction().begin();
+ try {
+ device = entityManager.merge(device);
+ entityManager.getTransaction().commit();
+ return device;
+ } catch (RuntimeException e) {
+ entityManager.getTransaction().rollback();
+ throw e;
+ }
+ }
+ else
+ {
+ throw new IllegalStateException();
}
- else
- {
- throw new IllegalStateException();
- }
}
}