mirror of
https://github.com/sismics/docs.git
synced 2024-11-21 21:47:57 +01:00
Cleanup code
This commit is contained in:
parent
48d363352c
commit
7822045ee7
@ -146,36 +146,11 @@
|
|||||||
<extraClasspath>target/classes;../docs-core/target/classes</extraClasspath>
|
<extraClasspath>target/classes;../docs-core/target/classes</extraClasspath>
|
||||||
<overrideDescriptor>src/dev/main/webapp/web-override.xml</overrideDescriptor>
|
<overrideDescriptor>src/dev/main/webapp/web-override.xml</overrideDescriptor>
|
||||||
</webAppConfig>
|
</webAppConfig>
|
||||||
|
<stopKey>STOPKEY</stopKey>
|
||||||
|
<stopPort>1099</stopPort>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -251,6 +226,8 @@
|
|||||||
<extraClasspath>target/classes;../docs-core/target/classes</extraClasspath>
|
<extraClasspath>target/classes;../docs-core/target/classes</extraClasspath>
|
||||||
<overrideDescriptor>src/dev/main/webapp/web-override.xml</overrideDescriptor>
|
<overrideDescriptor>src/dev/main/webapp/web-override.xml</overrideDescriptor>
|
||||||
</webAppConfig>
|
</webAppConfig>
|
||||||
|
<stopKey>STOPKEY</stopKey>
|
||||||
|
<stopPort>1099</stopPort>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -81,7 +81,7 @@ public class AppResource extends BaseResource {
|
|||||||
* @param message Filter on message
|
* @param message Filter on message
|
||||||
* @param limit Page limit
|
* @param limit Page limit
|
||||||
* @param offset Page offset
|
* @param offset Page offset
|
||||||
* @return
|
* @return Response
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@ -115,7 +115,7 @@ public class AppResource extends BaseResource {
|
|||||||
PaginatedList<LogEntry> paginatedList = PaginatedLists.create(limit, offset);
|
PaginatedList<LogEntry> paginatedList = PaginatedLists.create(limit, offset);
|
||||||
memoryAppender.find(logCriteria, paginatedList);
|
memoryAppender.find(logCriteria, paginatedList);
|
||||||
JSONObject response = new JSONObject();
|
JSONObject response = new JSONObject();
|
||||||
List<JSONObject> logs = new ArrayList<JSONObject>();
|
List<JSONObject> logs = new ArrayList<>();
|
||||||
for (LogEntry logEntry : paginatedList.getResultList()) {
|
for (LogEntry logEntry : paginatedList.getResultList()) {
|
||||||
JSONObject log = new JSONObject();
|
JSONObject log = new JSONObject();
|
||||||
log.put("date", logEntry.getTimestamp());
|
log.put("date", logEntry.getTimestamp());
|
||||||
|
@ -65,7 +65,7 @@ public class DocumentResource extends BaseResource {
|
|||||||
// Get tags
|
// Get tags
|
||||||
TagDao tagDao = new TagDao();
|
TagDao tagDao = new TagDao();
|
||||||
List<TagDto> tagDtoList = tagDao.getByDocumentId(id);
|
List<TagDto> tagDtoList = tagDao.getByDocumentId(id);
|
||||||
List<JSONObject> tags = new ArrayList<JSONObject>();
|
List<JSONObject> tags = new ArrayList<>();
|
||||||
for (TagDto tagDto : tagDtoList) {
|
for (TagDto tagDto : tagDtoList) {
|
||||||
JSONObject tag = new JSONObject();
|
JSONObject tag = new JSONObject();
|
||||||
tag.put("id", tagDto.getId());
|
tag.put("id", tagDto.getId());
|
||||||
@ -107,7 +107,7 @@ public class DocumentResource extends BaseResource {
|
|||||||
Date createDateMax = ValidationUtil.validateDate(createDateMaxStr, "create_date_max", true);
|
Date createDateMax = ValidationUtil.validateDate(createDateMaxStr, "create_date_max", true);
|
||||||
|
|
||||||
JSONObject response = new JSONObject();
|
JSONObject response = new JSONObject();
|
||||||
List<JSONObject> documents = new ArrayList<JSONObject>();
|
List<JSONObject> documents = new ArrayList<>();
|
||||||
|
|
||||||
DocumentDao documentDao = new DocumentDao();
|
DocumentDao documentDao = new DocumentDao();
|
||||||
TagDao tagDao = new TagDao();
|
TagDao tagDao = new TagDao();
|
||||||
@ -132,7 +132,7 @@ public class DocumentResource extends BaseResource {
|
|||||||
|
|
||||||
// Get tags
|
// Get tags
|
||||||
List<TagDto> tagDtoList = tagDao.getByDocumentId(documentDto.getId());
|
List<TagDto> tagDtoList = tagDao.getByDocumentId(documentDto.getId());
|
||||||
List<JSONObject> tags = new ArrayList<JSONObject>();
|
List<JSONObject> tags = new ArrayList<>();
|
||||||
for (TagDto tagDto : tagDtoList) {
|
for (TagDto tagDto : tagDtoList) {
|
||||||
JSONObject tag = new JSONObject();
|
JSONObject tag = new JSONObject();
|
||||||
tag.put("id", tagDto.getId());
|
tag.put("id", tagDto.getId());
|
||||||
@ -260,8 +260,8 @@ public class DocumentResource extends BaseResource {
|
|||||||
private void updateTagList(String documentId, List<String> tagList) throws JSONException {
|
private void updateTagList(String documentId, List<String> tagList) throws JSONException {
|
||||||
if (tagList != null) {
|
if (tagList != null) {
|
||||||
TagDao tagDao = new TagDao();
|
TagDao tagDao = new TagDao();
|
||||||
Set<String> tagSet = new HashSet<String>();
|
Set<String> tagSet = new HashSet<>();
|
||||||
Set<String> tagIdSet = new HashSet<String>();
|
Set<String> tagIdSet = new HashSet<>();
|
||||||
List<Tag> tagDbList = tagDao.getByUserId(principal.getId());
|
List<Tag> tagDbList = tagDao.getByUserId(principal.getId());
|
||||||
for (Tag tagDb : tagDbList) {
|
for (Tag tagDb : tagDbList) {
|
||||||
tagIdSet.add(tagDb.getId());
|
tagIdSet.add(tagDb.getId());
|
||||||
|
@ -54,7 +54,7 @@ public class FileResource extends BaseResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileDao fileDao = new FileDao();
|
FileDao fileDao = new FileDao();
|
||||||
File fileDb = null;
|
File fileDb;
|
||||||
try {
|
try {
|
||||||
fileDb = fileDao.getFile(id);
|
fileDb = fileDao.getFile(id);
|
||||||
} catch (NoResultException e) {
|
} catch (NoResultException e) {
|
||||||
@ -73,7 +73,7 @@ public class FileResource extends BaseResource {
|
|||||||
/**
|
/**
|
||||||
* Add a file to a document.
|
* Add a file to a document.
|
||||||
*
|
*
|
||||||
* @param id Document ID
|
* @param documentId Document ID
|
||||||
* @param fileBodyPart File to add
|
* @param fileBodyPart File to add
|
||||||
* @return Response
|
* @return Response
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
@ -94,7 +94,7 @@ public class FileResource extends BaseResource {
|
|||||||
|
|
||||||
// Get the document
|
// Get the document
|
||||||
DocumentDao documentDao = new DocumentDao();
|
DocumentDao documentDao = new DocumentDao();
|
||||||
Document document = null;
|
Document document;
|
||||||
try {
|
try {
|
||||||
document = documentDao.getDocument(documentId, principal.getId());
|
document = documentDao.getDocument(documentId, principal.getId());
|
||||||
} catch (NoResultException e) {
|
} catch (NoResultException e) {
|
||||||
@ -105,7 +105,7 @@ public class FileResource extends BaseResource {
|
|||||||
|
|
||||||
// Validate mime type
|
// Validate mime type
|
||||||
InputStream is = new BufferedInputStream(fileBodyPart.getValueAs(InputStream.class));
|
InputStream is = new BufferedInputStream(fileBodyPart.getValueAs(InputStream.class));
|
||||||
String mimeType = null;
|
String mimeType;
|
||||||
try {
|
try {
|
||||||
mimeType = MimeTypeUtil.guessMimeType(is);
|
mimeType = MimeTypeUtil.guessMimeType(is);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -145,8 +145,8 @@ public class FileResource extends BaseResource {
|
|||||||
/**
|
/**
|
||||||
* Reorder files.
|
* Reorder files.
|
||||||
*
|
*
|
||||||
* @param id Document ID
|
* @param documentId Document ID
|
||||||
* @param order List of files ID in the new order
|
* @param idList List of files ID in the new order
|
||||||
* @return Response
|
* @return Response
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
@ -190,7 +190,7 @@ public class FileResource extends BaseResource {
|
|||||||
/**
|
/**
|
||||||
* Returns files linked to a document.
|
* Returns files linked to a document.
|
||||||
*
|
*
|
||||||
* @param id Document ID
|
* @param documentId Document ID
|
||||||
* @return Response
|
* @return Response
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
@ -207,7 +207,7 @@ public class FileResource extends BaseResource {
|
|||||||
List<File> fileList = fileDao.getByDocumentId(documentId);
|
List<File> fileList = fileDao.getByDocumentId(documentId);
|
||||||
|
|
||||||
JSONObject response = new JSONObject();
|
JSONObject response = new JSONObject();
|
||||||
List<JSONObject> files = new ArrayList<JSONObject>();
|
List<JSONObject> files = new ArrayList<>();
|
||||||
|
|
||||||
for (File fileDb : fileList) {
|
for (File fileDb : fileList) {
|
||||||
JSONObject file = new JSONObject();
|
JSONObject file = new JSONObject();
|
||||||
@ -240,7 +240,7 @@ public class FileResource extends BaseResource {
|
|||||||
|
|
||||||
// Get the file
|
// Get the file
|
||||||
FileDao fileDao = new FileDao();
|
FileDao fileDao = new FileDao();
|
||||||
File file = null;
|
File file;
|
||||||
try {
|
try {
|
||||||
file = fileDao.getFile(id);
|
file = fileDao.getFile(id);
|
||||||
} catch (NoResultException e) {
|
} catch (NoResultException e) {
|
||||||
@ -275,7 +275,7 @@ public class FileResource extends BaseResource {
|
|||||||
|
|
||||||
// Get the file
|
// Get the file
|
||||||
FileDao fileDao = new FileDao();
|
FileDao fileDao = new FileDao();
|
||||||
File file = null;
|
File file;
|
||||||
try {
|
try {
|
||||||
file = fileDao.getFile(id);
|
file = fileDao.getFile(id);
|
||||||
} catch (NoResultException e) {
|
} catch (NoResultException e) {
|
||||||
@ -284,7 +284,7 @@ public class FileResource extends BaseResource {
|
|||||||
|
|
||||||
|
|
||||||
// Get the stored file
|
// Get the stored file
|
||||||
java.io.File storedfile = null;
|
java.io.File storedfile;
|
||||||
if (thumbnail) {
|
if (thumbnail) {
|
||||||
if (ImageUtil.isImage(file.getMimeType())) {
|
if (ImageUtil.isImage(file.getMimeType())) {
|
||||||
storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), id + "_thumb").toFile();
|
storedfile = Paths.get(DirectoryUtil.getStorageDirectory().getPath(), id + "_thumb").toFile();
|
||||||
|
@ -32,7 +32,7 @@ public class LocaleResource extends BaseResource {
|
|||||||
LocaleDao localeDao = new LocaleDao();
|
LocaleDao localeDao = new LocaleDao();
|
||||||
List<Locale> localeList = localeDao.findAll();
|
List<Locale> localeList = localeDao.findAll();
|
||||||
JSONObject response = new JSONObject();
|
JSONObject response = new JSONObject();
|
||||||
List<JSONObject> items = new ArrayList<JSONObject>();
|
List<JSONObject> items = new ArrayList<>();
|
||||||
for (Locale locale : localeList) {
|
for (Locale locale : localeList) {
|
||||||
JSONObject item = new JSONObject();
|
JSONObject item = new JSONObject();
|
||||||
item.put("id", locale.getId());
|
item.put("id", locale.getId());
|
||||||
|
@ -41,7 +41,7 @@ public class TagResource extends BaseResource {
|
|||||||
TagDao tagDao = new TagDao();
|
TagDao tagDao = new TagDao();
|
||||||
List<Tag> tagList = tagDao.getByUserId(principal.getId());
|
List<Tag> tagList = tagDao.getByUserId(principal.getId());
|
||||||
JSONObject response = new JSONObject();
|
JSONObject response = new JSONObject();
|
||||||
List<JSONObject> items = new ArrayList<JSONObject>();
|
List<JSONObject> items = new ArrayList<>();
|
||||||
for (Tag tag : tagList) {
|
for (Tag tag : tagList) {
|
||||||
JSONObject item = new JSONObject();
|
JSONObject item = new JSONObject();
|
||||||
item.put("id", tag.getId());
|
item.put("id", tag.getId());
|
||||||
@ -70,7 +70,7 @@ public class TagResource extends BaseResource {
|
|||||||
TagDao tagDao = new TagDao();
|
TagDao tagDao = new TagDao();
|
||||||
List<TagStatDto> tagStatDtoList = tagDao.getStats(principal.getId());
|
List<TagStatDto> tagStatDtoList = tagDao.getStats(principal.getId());
|
||||||
JSONObject response = new JSONObject();
|
JSONObject response = new JSONObject();
|
||||||
List<JSONObject> items = new ArrayList<JSONObject>();
|
List<JSONObject> items = new ArrayList<>();
|
||||||
for (TagStatDto tagStatDto : tagStatDtoList) {
|
for (TagStatDto tagStatDto : tagStatDtoList) {
|
||||||
JSONObject item = new JSONObject();
|
JSONObject item = new JSONObject();
|
||||||
item.put("id", tagStatDto.getId());
|
item.put("id", tagStatDto.getId());
|
||||||
@ -167,7 +167,7 @@ public class TagResource extends BaseResource {
|
|||||||
/**
|
/**
|
||||||
* Delete a tag.
|
* Delete a tag.
|
||||||
*
|
*
|
||||||
* @param name Name
|
* @param tagId Tag ID
|
||||||
* @return Response
|
* @return Response
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
|
@ -31,7 +31,7 @@ public class ThemeResource extends BaseResource {
|
|||||||
ThemeDao themeDao = new ThemeDao();
|
ThemeDao themeDao = new ThemeDao();
|
||||||
List<String> themeList = themeDao.findAll();
|
List<String> themeList = themeDao.findAll();
|
||||||
JSONObject response = new JSONObject();
|
JSONObject response = new JSONObject();
|
||||||
List<JSONObject> items = new ArrayList<JSONObject>();
|
List<JSONObject> items = new ArrayList<>();
|
||||||
for (String theme : themeList) {
|
for (String theme : themeList) {
|
||||||
JSONObject item = new JSONObject();
|
JSONObject item = new JSONObject();
|
||||||
item.put("id", theme);
|
item.put("id", theme);
|
||||||
|
@ -109,10 +109,6 @@ public class UserResource extends BaseResource {
|
|||||||
* @param email E-Mail
|
* @param email E-Mail
|
||||||
* @param themeId Theme
|
* @param themeId Theme
|
||||||
* @param localeId Locale ID
|
* @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.
|
* @param firstConnection True if the user hasn't acknowledged the first connection wizard yet.
|
||||||
* @return Response
|
* @return Response
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
@ -156,7 +152,7 @@ public class UserResource extends BaseResource {
|
|||||||
|
|
||||||
if (StringUtils.isNotBlank(password)) {
|
if (StringUtils.isNotBlank(password)) {
|
||||||
user.setPassword(password);
|
user.setPassword(password);
|
||||||
user = userDao.updatePassword(user);
|
userDao.updatePassword(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always return "ok"
|
// Always return "ok"
|
||||||
@ -173,10 +169,6 @@ public class UserResource extends BaseResource {
|
|||||||
* @param email E-Mail
|
* @param email E-Mail
|
||||||
* @param themeId Theme
|
* @param themeId Theme
|
||||||
* @param localeId Locale ID
|
* @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
|
* @return Response
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
@ -224,7 +216,7 @@ public class UserResource extends BaseResource {
|
|||||||
if (StringUtils.isNotBlank(password)) {
|
if (StringUtils.isNotBlank(password)) {
|
||||||
// Change the password
|
// Change the password
|
||||||
user.setPassword(password);
|
user.setPassword(password);
|
||||||
user = userDao.updatePassword(user);
|
userDao.updatePassword(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always return "ok"
|
// Always return "ok"
|
||||||
@ -511,7 +503,7 @@ public class UserResource extends BaseResource {
|
|||||||
checkBaseFunction(BaseFunction.ADMIN);
|
checkBaseFunction(BaseFunction.ADMIN);
|
||||||
|
|
||||||
JSONObject response = new JSONObject();
|
JSONObject response = new JSONObject();
|
||||||
List<JSONObject> users = new ArrayList<JSONObject>();
|
List<JSONObject> users = new ArrayList<>();
|
||||||
|
|
||||||
PaginatedList<UserDto> paginatedList = PaginatedLists.create(limit, offset);
|
PaginatedList<UserDto> paginatedList = PaginatedLists.create(limit, offset);
|
||||||
SortCriteria sortCriteria = new SortCriteria(sortColumn, asc);
|
SortCriteria sortCriteria = new SortCriteria(sortColumn, asc);
|
||||||
@ -557,7 +549,7 @@ public class UserResource extends BaseResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSONObject response = new JSONObject();
|
JSONObject response = new JSONObject();
|
||||||
List<JSONObject> sessions = new ArrayList<JSONObject>();
|
List<JSONObject> sessions = new ArrayList<>();
|
||||||
|
|
||||||
AuthenticationTokenDao authenticationTokenDao = new AuthenticationTokenDao();
|
AuthenticationTokenDao authenticationTokenDao = new AuthenticationTokenDao();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user