Cleanup code

This commit is contained in:
jendib 2013-08-13 20:20:28 +02:00
parent 48d363352c
commit 7822045ee7
8 changed files with 31 additions and 62 deletions

View File

@ -146,36 +146,11 @@
<extraClasspath>target/classes;../docs-core/target/classes</extraClasspath>
<overrideDescriptor>src/dev/main/webapp/web-override.xml</overrideDescriptor>
</webAppConfig>
<stopKey>STOPKEY</stopKey>
<stopPort>1099</stopPort>
</configuration>
</plugin>
<!-- Cargo Plugin -->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>jetty8x</containerId>
<type>remote</type>
</container>
<deployer>
<type>remote</type>
</deployer>
<deployables>
<deployable>
<groupId>com.sismics.docs</groupId>
<artifactId>docs-web</artifactId>
<type>war</type>
<properties>
<context>/docs</context>
</properties>
<pingURL>http://localhost:8080/docs/index.html</pingURL>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
@ -251,6 +226,8 @@
<extraClasspath>target/classes;../docs-core/target/classes</extraClasspath>
<overrideDescriptor>src/dev/main/webapp/web-override.xml</overrideDescriptor>
</webAppConfig>
<stopKey>STOPKEY</stopKey>
<stopPort>1099</stopPort>
</configuration>
</plugin>
</plugins>

View File

@ -81,7 +81,7 @@ public class AppResource extends BaseResource {
* @param message Filter on message
* @param limit Page limit
* @param offset Page offset
* @return
* @return Response
* @throws JSONException
*/
@GET
@ -115,7 +115,7 @@ public class AppResource extends BaseResource {
PaginatedList<LogEntry> paginatedList = PaginatedLists.create(limit, offset);
memoryAppender.find(logCriteria, paginatedList);
JSONObject response = new JSONObject();
List<JSONObject> logs = new ArrayList<JSONObject>();
List<JSONObject> logs = new ArrayList<>();
for (LogEntry logEntry : paginatedList.getResultList()) {
JSONObject log = new JSONObject();
log.put("date", logEntry.getTimestamp());

View File

@ -65,7 +65,7 @@ public class DocumentResource extends BaseResource {
// Get tags
TagDao tagDao = new TagDao();
List<TagDto> tagDtoList = tagDao.getByDocumentId(id);
List<JSONObject> tags = new ArrayList<JSONObject>();
List<JSONObject> tags = new ArrayList<>();
for (TagDto tagDto : tagDtoList) {
JSONObject tag = new JSONObject();
tag.put("id", tagDto.getId());
@ -107,7 +107,7 @@ public class DocumentResource extends BaseResource {
Date createDateMax = ValidationUtil.validateDate(createDateMaxStr, "create_date_max", true);
JSONObject response = new JSONObject();
List<JSONObject> documents = new ArrayList<JSONObject>();
List<JSONObject> documents = new ArrayList<>();
DocumentDao documentDao = new DocumentDao();
TagDao tagDao = new TagDao();
@ -132,7 +132,7 @@ public class DocumentResource extends BaseResource {
// Get tags
List<TagDto> tagDtoList = tagDao.getByDocumentId(documentDto.getId());
List<JSONObject> tags = new ArrayList<JSONObject>();
List<JSONObject> tags = new ArrayList<>();
for (TagDto tagDto : tagDtoList) {
JSONObject tag = new JSONObject();
tag.put("id", tagDto.getId());
@ -260,8 +260,8 @@ public class DocumentResource extends BaseResource {
private void updateTagList(String documentId, List<String> tagList) throws JSONException {
if (tagList != null) {
TagDao tagDao = new TagDao();
Set<String> tagSet = new HashSet<String>();
Set<String> tagIdSet = new HashSet<String>();
Set<String> tagSet = new HashSet<>();
Set<String> tagIdSet = new HashSet<>();
List<Tag> tagDbList = tagDao.getByUserId(principal.getId());
for (Tag tagDb : tagDbList) {
tagIdSet.add(tagDb.getId());

View File

@ -54,7 +54,7 @@ public class FileResource extends BaseResource {
}
FileDao fileDao = new FileDao();
File fileDb = null;
File fileDb;
try {
fileDb = fileDao.getFile(id);
} catch (NoResultException e) {
@ -73,7 +73,7 @@ public class FileResource extends BaseResource {
/**
* Add a file to a document.
*
* @param id Document ID
* @param documentId Document ID
* @param fileBodyPart File to add
* @return Response
* @throws JSONException
@ -94,7 +94,7 @@ public class FileResource extends BaseResource {
// Get the document
DocumentDao documentDao = new DocumentDao();
Document document = null;
Document document;
try {
document = documentDao.getDocument(documentId, principal.getId());
} catch (NoResultException e) {
@ -105,7 +105,7 @@ public class FileResource extends BaseResource {
// Validate mime type
InputStream is = new BufferedInputStream(fileBodyPart.getValueAs(InputStream.class));
String mimeType = null;
String mimeType;
try {
mimeType = MimeTypeUtil.guessMimeType(is);
} catch (Exception e) {
@ -145,8 +145,8 @@ public class FileResource extends BaseResource {
/**
* Reorder files.
*
* @param id Document ID
* @param order List of files ID in the new order
* @param documentId Document ID
* @param idList List of files ID in the new order
* @return Response
* @throws JSONException
*/
@ -190,7 +190,7 @@ public class FileResource extends BaseResource {
/**
* Returns files linked to a document.
*
* @param id Document ID
* @param documentId Document ID
* @return Response
* @throws JSONException
*/
@ -207,7 +207,7 @@ public class FileResource extends BaseResource {
List<File> fileList = fileDao.getByDocumentId(documentId);
JSONObject response = new JSONObject();
List<JSONObject> files = new ArrayList<JSONObject>();
List<JSONObject> files = new ArrayList<>();
for (File fileDb : fileList) {
JSONObject file = new JSONObject();
@ -240,7 +240,7 @@ public class FileResource extends BaseResource {
// Get the file
FileDao fileDao = new FileDao();
File file = null;
File file;
try {
file = fileDao.getFile(id);
} catch (NoResultException e) {
@ -275,7 +275,7 @@ public class FileResource extends BaseResource {
// Get the file
FileDao fileDao = new FileDao();
File file = null;
File file;
try {
file = fileDao.getFile(id);
} catch (NoResultException e) {
@ -284,7 +284,7 @@ public class FileResource extends BaseResource {
// Get the stored file
java.io.File storedfile = null;
java.io.File storedfile;
if (thumbnail) {
if (ImageUtil.isImage(file.getMimeType())) {
storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), id + "_thumb").toFile();

View File

@ -32,7 +32,7 @@ public class LocaleResource extends BaseResource {
LocaleDao localeDao = new LocaleDao();
List<Locale> localeList = localeDao.findAll();
JSONObject response = new JSONObject();
List<JSONObject> items = new ArrayList<JSONObject>();
List<JSONObject> items = new ArrayList<>();
for (Locale locale : localeList) {
JSONObject item = new JSONObject();
item.put("id", locale.getId());

View File

@ -41,7 +41,7 @@ public class TagResource extends BaseResource {
TagDao tagDao = new TagDao();
List<Tag> tagList = tagDao.getByUserId(principal.getId());
JSONObject response = new JSONObject();
List<JSONObject> items = new ArrayList<JSONObject>();
List<JSONObject> items = new ArrayList<>();
for (Tag tag : tagList) {
JSONObject item = new JSONObject();
item.put("id", tag.getId());
@ -70,7 +70,7 @@ public class TagResource extends BaseResource {
TagDao tagDao = new TagDao();
List<TagStatDto> tagStatDtoList = tagDao.getStats(principal.getId());
JSONObject response = new JSONObject();
List<JSONObject> items = new ArrayList<JSONObject>();
List<JSONObject> items = new ArrayList<>();
for (TagStatDto tagStatDto : tagStatDtoList) {
JSONObject item = new JSONObject();
item.put("id", tagStatDto.getId());
@ -167,7 +167,7 @@ public class TagResource extends BaseResource {
/**
* Delete a tag.
*
* @param name Name
* @param tagId Tag ID
* @return Response
* @throws JSONException
*/

View File

@ -31,7 +31,7 @@ public class ThemeResource extends BaseResource {
ThemeDao themeDao = new ThemeDao();
List<String> themeList = themeDao.findAll();
JSONObject response = new JSONObject();
List<JSONObject> items = new ArrayList<JSONObject>();
List<JSONObject> items = new ArrayList<>();
for (String theme : themeList) {
JSONObject item = new JSONObject();
item.put("id", theme);

View File

@ -109,10 +109,6 @@ public class UserResource extends BaseResource {
* @param email E-Mail
* @param themeId Theme
* @param localeId Locale ID
* @param displayTitleWeb Display only article titles (web application).
* @param displayTitleMobile Display only article titles (mobile application).
* @param displayUnreadWeb Display only unread titles (web application).
* @param displayUnreadMobile Display only unread titles (mobile application).
* @param firstConnection True if the user hasn't acknowledged the first connection wizard yet.
* @return Response
* @throws JSONException
@ -156,7 +152,7 @@ public class UserResource extends BaseResource {
if (StringUtils.isNotBlank(password)) {
user.setPassword(password);
user = userDao.updatePassword(user);
userDao.updatePassword(user);
}
// Always return "ok"
@ -173,10 +169,6 @@ public class UserResource extends BaseResource {
* @param email E-Mail
* @param themeId Theme
* @param localeId Locale ID
* @param displayTitleWeb Display only article titles (web application).
* @param displayTitleMobile Display only article titles (mobile application).
* @param displayUnreadWeb Display only unread titles (web application).
* @param displayUnreadMobile Display only unread titles (mobile application).
* @return Response
* @throws JSONException
*/
@ -224,7 +216,7 @@ public class UserResource extends BaseResource {
if (StringUtils.isNotBlank(password)) {
// Change the password
user.setPassword(password);
user = userDao.updatePassword(user);
userDao.updatePassword(user);
}
// Always return "ok"
@ -511,7 +503,7 @@ public class UserResource extends BaseResource {
checkBaseFunction(BaseFunction.ADMIN);
JSONObject response = new JSONObject();
List<JSONObject> users = new ArrayList<JSONObject>();
List<JSONObject> users = new ArrayList<>();
PaginatedList<UserDto> paginatedList = PaginatedLists.create(limit, offset);
SortCriteria sortCriteria = new SortCriteria(sortColumn, asc);
@ -557,7 +549,7 @@ public class UserResource extends BaseResource {
}
JSONObject response = new JSONObject();
List<JSONObject> sessions = new ArrayList<JSONObject>();
List<JSONObject> sessions = new ArrayList<>();
AuthenticationTokenDao authenticationTokenDao = new AuthenticationTokenDao();