Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
d93e378b
Unverified
Commit
d93e378b
authored
Sep 30, 2018
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🏗
#12515 移除 Repository 层接口
parent
9e9a8ec9
Changes
43
Hide whitespace changes
Inline
Side-by-side
Showing
43 changed files
with
819 additions
and
1388 deletions
+819
-1388
src/main/java/org/b3log/solo/SoloServletListener.java
src/main/java/org/b3log/solo/SoloServletListener.java
+1
-2
src/main/java/org/b3log/solo/event/ArticleCommentReplyNotifier.java
...ava/org/b3log/solo/event/ArticleCommentReplyNotifier.java
+1
-2
src/main/java/org/b3log/solo/event/PageCommentReplyNotifier.java
...n/java/org/b3log/solo/event/PageCommentReplyNotifier.java
+1
-2
src/main/java/org/b3log/solo/event/PluginRefresher.java
src/main/java/org/b3log/solo/event/PluginRefresher.java
+1
-2
src/main/java/org/b3log/solo/filter/PermalinkFilter.java
src/main/java/org/b3log/solo/filter/PermalinkFilter.java
+2
-4
src/main/java/org/b3log/solo/processor/SitemapProcessor.java
src/main/java/org/b3log/solo/processor/SitemapProcessor.java
+2
-2
src/main/java/org/b3log/solo/repository/ArchiveDateArticleRepository.java
...g/b3log/solo/repository/ArchiveDateArticleRepository.java
+2
-0
src/main/java/org/b3log/solo/repository/ArchiveDateRepository.java
...java/org/b3log/solo/repository/ArchiveDateRepository.java
+2
-0
src/main/java/org/b3log/solo/repository/ArticleRepository.java
...ain/java/org/b3log/solo/repository/ArticleRepository.java
+2
-0
src/main/java/org/b3log/solo/repository/CategoryRepository.java
...in/java/org/b3log/solo/repository/CategoryRepository.java
+98
-11
src/main/java/org/b3log/solo/repository/CategoryTagRepository.java
...java/org/b3log/solo/repository/CategoryTagRepository.java
+44
-10
src/main/java/org/b3log/solo/repository/CommentRepository.java
...ain/java/org/b3log/solo/repository/CommentRepository.java
+132
-18
src/main/java/org/b3log/solo/repository/LinkRepository.java
src/main/java/org/b3log/solo/repository/LinkRepository.java
+83
-15
src/main/java/org/b3log/solo/repository/OptionRepository.java
...main/java/org/b3log/solo/repository/OptionRepository.java
+84
-5
src/main/java/org/b3log/solo/repository/PageRepository.java
src/main/java/org/b3log/solo/repository/PageRepository.java
+128
-16
src/main/java/org/b3log/solo/repository/PluginRepository.java
...main/java/org/b3log/solo/repository/PluginRepository.java
+14
-3
src/main/java/org/b3log/solo/repository/TagArticleRepository.java
.../java/org/b3log/solo/repository/TagArticleRepository.java
+32
-13
src/main/java/org/b3log/solo/repository/TagRepository.java
src/main/java/org/b3log/solo/repository/TagRepository.java
+58
-9
src/main/java/org/b3log/solo/repository/UserRepository.java
src/main/java/org/b3log/solo/repository/UserRepository.java
+109
-7
src/main/java/org/b3log/solo/repository/impl/CategoryRepositoryImpl.java
...rg/b3log/solo/repository/impl/CategoryRepositoryImpl.java
+0
-185
src/main/java/org/b3log/solo/repository/impl/CategoryTagRepositoryImpl.java
...b3log/solo/repository/impl/CategoryTagRepositoryImpl.java
+0
-87
src/main/java/org/b3log/solo/repository/impl/CommentRepositoryImpl.java
...org/b3log/solo/repository/impl/CommentRepositoryImpl.java
+0
-176
src/main/java/org/b3log/solo/repository/impl/LinkRepositoryImpl.java
...va/org/b3log/solo/repository/impl/LinkRepositoryImpl.java
+0
-140
src/main/java/org/b3log/solo/repository/impl/OptionRepositoryImpl.java
.../org/b3log/solo/repository/impl/OptionRepositoryImpl.java
+0
-114
src/main/java/org/b3log/solo/repository/impl/PageRepositoryImpl.java
...va/org/b3log/solo/repository/impl/PageRepositoryImpl.java
+0
-174
src/main/java/org/b3log/solo/repository/impl/PluginRepositoryImpl.java
.../org/b3log/solo/repository/impl/PluginRepositoryImpl.java
+0
-42
src/main/java/org/b3log/solo/repository/impl/TagArticleRepositoryImpl.java
.../b3log/solo/repository/impl/TagArticleRepositoryImpl.java
+0
-63
src/main/java/org/b3log/solo/repository/impl/TagRepositoryImpl.java
...ava/org/b3log/solo/repository/impl/TagRepositoryImpl.java
+0
-117
src/main/java/org/b3log/solo/repository/impl/UserRepositoryImpl.java
...va/org/b3log/solo/repository/impl/UserRepositoryImpl.java
+0
-145
src/main/webapp/skins
src/main/webapp/skins
+1
-1
src/test/java/org/b3log/solo/AbstractTestCase.java
src/test/java/org/b3log/solo/AbstractTestCase.java
+10
-11
src/test/java/org/b3log/solo/repository/ArchiveDateArticleRepositoryImplTestCase.java
.../repository/ArchiveDateArticleRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/ArchiveDateRepositoryImplTestCase.java
...og/solo/repository/ArchiveDateRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/ArticleRepositoryImplTestCase.java
.../b3log/solo/repository/ArticleRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/CategoryRepositoryImplTestCase.java
...b3log/solo/repository/CategoryRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/CommentRepositoryImplTestCase.java
.../b3log/solo/repository/CommentRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/LinkRepositoryImplTestCase.java
...org/b3log/solo/repository/LinkRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/OptionRepositoryImplTestCase.java
...g/b3log/solo/repository/OptionRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/PageRepositoryImplTestCase.java
...org/b3log/solo/repository/PageRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/PluginRepositoryImplTestCase.java
...g/b3log/solo/repository/PluginRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/TagArticleRepositoryImplTestCase.java
...log/solo/repository/TagArticleRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/TagRepositoryImplTestCase.java
.../org/b3log/solo/repository/TagRepositoryImplTestCase.java
+1
-1
src/test/java/org/b3log/solo/repository/UserRepositoryImplTestCase.java
...org/b3log/solo/repository/UserRepositoryImplTestCase.java
+1
-1
No files found.
src/main/java/org/b3log/solo/SoloServletListener.java
View file @
d93e378b
...
...
@@ -35,7 +35,6 @@ import org.b3log.solo.event.*;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Skin
;
import
org.b3log.solo.repository.OptionRepository
;
import
org.b3log.solo.repository.impl.OptionRepositoryImpl
;
import
org.b3log.solo.service.*
;
import
org.b3log.solo.util.Skins
;
import
org.b3log.solo.util.Solos
;
...
...
@@ -92,7 +91,7 @@ public final class SoloServletListener extends AbstractServletListener {
JdbcRepository
.
dispose
();
final
OptionRepository
optionRepository
=
beanManager
.
getReference
(
OptionRepository
Impl
.
class
);
final
OptionRepository
optionRepository
=
beanManager
.
getReference
(
OptionRepository
.
class
);
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
try
{
loadPreference
();
...
...
src/main/java/org/b3log/solo/event/ArticleCommentReplyNotifier.java
View file @
d93e378b
...
...
@@ -34,7 +34,6 @@ import org.b3log.solo.model.Article;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.b3log.solo.repository.impl.CommentRepositoryImpl
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.util.Solos
;
import
org.json.JSONObject
;
...
...
@@ -87,7 +86,7 @@ public class ArticleCommentReplyNotifier extends AbstractEventListener<JSONObjec
final
BeanManager
beanManager
=
BeanManager
.
getInstance
();
final
PreferenceQueryService
preferenceQueryService
=
beanManager
.
getReference
(
PreferenceQueryService
.
class
);
final
CommentRepository
commentRepository
=
beanManager
.
getReference
(
CommentRepository
Impl
.
class
);
final
CommentRepository
commentRepository
=
beanManager
.
getReference
(
CommentRepository
.
class
);
try
{
final
String
commentEmail
=
comment
.
getString
(
Comment
.
COMMENT_EMAIL
);
...
...
src/main/java/org/b3log/solo/event/PageCommentReplyNotifier.java
View file @
d93e378b
...
...
@@ -35,7 +35,6 @@ import org.b3log.solo.model.Comment;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.b3log.solo.repository.impl.CommentRepositoryImpl
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.util.Solos
;
import
org.json.JSONObject
;
...
...
@@ -81,7 +80,7 @@ public class PageCommentReplyNotifier extends AbstractEventListener<JSONObject>
final
BeanManager
beanManager
=
BeanManager
.
getInstance
();
final
PreferenceQueryService
preferenceQueryService
=
beanManager
.
getReference
(
PreferenceQueryService
.
class
);
final
CommentRepository
commentRepository
=
beanManager
.
getReference
(
CommentRepository
Impl
.
class
);
final
CommentRepository
commentRepository
=
beanManager
.
getReference
(
CommentRepository
.
class
);
try
{
final
String
commentEmail
=
comment
.
getString
(
Comment
.
COMMENT_EMAIL
);
...
...
src/main/java/org/b3log/solo/event/PluginRefresher.java
View file @
d93e378b
...
...
@@ -27,7 +27,6 @@ import org.b3log.latke.plugin.AbstractPlugin;
import
org.b3log.latke.plugin.PluginManager
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.solo.repository.PluginRepository
;
import
org.b3log.solo.repository.impl.PluginRepositoryImpl
;
import
org.b3log.solo.service.PluginMgmtService
;
import
java.util.List
;
...
...
@@ -55,7 +54,7 @@ public class PluginRefresher extends AbstractEventListener<List<AbstractPlugin>>
event
.
getType
(),
plugins
,
PluginRefresher
.
class
.
getName
());
final
BeanManager
beanManager
=
BeanManager
.
getInstance
();
final
PluginRepository
pluginRepository
=
beanManager
.
getReference
(
PluginRepository
Impl
.
class
);
final
PluginRepository
pluginRepository
=
beanManager
.
getReference
(
PluginRepository
.
class
);
final
Transaction
transaction
=
pluginRepository
.
beginTransaction
();
try
{
...
...
src/main/java/org/b3log/solo/filter/PermalinkFilter.java
View file @
d93e378b
...
...
@@ -33,8 +33,6 @@ import org.b3log.solo.model.Article;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.PageRepository
;
import
org.b3log.solo.repository.impl.ArticleRepositoryImpl
;
import
org.b3log.solo.repository.impl.PageRepositoryImpl
;
import
org.b3log.solo.service.ArticleQueryService
;
import
org.b3log.solo.service.PermalinkQueryService
;
import
org.json.JSONObject
;
...
...
@@ -98,10 +96,10 @@ public final class PermalinkFilter implements Filter {
final
BeanManager
beanManager
=
BeanManager
.
getInstance
();
try
{
final
ArticleRepository
articleRepository
=
beanManager
.
getReference
(
ArticleRepository
Impl
.
class
);
final
ArticleRepository
articleRepository
=
beanManager
.
getReference
(
ArticleRepository
.
class
);
article
=
articleRepository
.
getByPermalink
(
permalink
);
if
(
null
==
article
)
{
final
PageRepository
pageRepository
=
beanManager
.
getReference
(
PageRepository
Impl
.
class
);
final
PageRepository
pageRepository
=
beanManager
.
getReference
(
PageRepository
.
class
);
page
=
pageRepository
.
getByPermalink
(
permalink
);
}
...
...
src/main/java/org/b3log/solo/processor/SitemapProcessor.java
View file @
d93e378b
...
...
@@ -41,9 +41,9 @@ import org.b3log.solo.model.Tag;
import
org.b3log.solo.model.sitemap.Sitemap
;
import
org.b3log.solo.model.sitemap.URL
;
import
org.b3log.solo.repository.ArchiveDateRepository
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.PageRepository
;
import
org.b3log.solo.repository.TagRepository
;
import
org.b3log.solo.repository.impl.ArticleRepositoryImpl
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
...
...
@@ -76,7 +76,7 @@ public class SitemapProcessor {
* Article repository.
*/
@Inject
private
ArticleRepository
Impl
articleRepository
;
private
ArticleRepository
articleRepository
;
/**
* Page repository.
...
...
src/main/java/org/b3log/solo/repository/ArchiveDateArticleRepository.java
View file @
d93e378b
...
...
@@ -19,6 +19,7 @@ package org.b3log.solo.repository;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.ArchiveDate
;
import
org.b3log.solo.model.Article
;
import
org.json.JSONArray
;
...
...
@@ -31,6 +32,7 @@ import org.json.JSONObject;
* @version 1.0.0.3, Sep 30, 2018
* @since 0.3.1
*/
@Repository
public
class
ArchiveDateArticleRepository
extends
AbstractRepository
{
/**
...
...
src/main/java/org/b3log/solo/repository/ArchiveDateRepository.java
View file @
d93e378b
...
...
@@ -22,6 +22,7 @@ import org.b3log.latke.Keys;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.ArchiveDate
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
...
...
@@ -37,6 +38,7 @@ import java.util.List;
* @version 1.0.0.3, Sep 30, 2018
* @since 0.3.1
*/
@Repository
public
class
ArchiveDateRepository
extends
AbstractRepository
{
/**
...
...
src/main/java/org/b3log/solo/repository/ArticleRepository.java
View file @
d93e378b
...
...
@@ -22,6 +22,7 @@ import org.b3log.latke.ioc.Inject;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.cache.ArticleCache
;
import
org.b3log.solo.model.Article
;
import
org.json.JSONArray
;
...
...
@@ -38,6 +39,7 @@ import java.util.List;
* @version 1.1.1.11, Sep 30, 2018
* @since 0.3.1
*/
@Repository
public
class
ArticleRepository
extends
AbstractRepository
{
/**
...
...
src/main/java/org/b3log/solo/repository/CategoryRepository.java
View file @
d93e378b
...
...
@@ -17,20 +17,34 @@
*/
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Repository
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Category
;
import
org.b3log.solo.model.Tag
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.text.Collator
;
import
java.util.Collections
;
import
java.util.List
;
/**
* Category repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.
1, Apr 8, 2017
* @version 1.2.0.
2, Sep 30, 2018
* @since 2.0.0
*/
public
interface
CategoryRepository
extends
Repository
{
@Repository
public
class
CategoryRepository
extends
AbstractRepository
{
/**
* Public constructor.
*/
public
CategoryRepository
()
{
super
(
Category
.
CATEGORY
);
}
/**
* Gets a category by the specified category title.
...
...
@@ -39,7 +53,16 @@ public interface CategoryRepository extends Repository {
* @return a category, {@code null} if not found
* @throws RepositoryException repository exception
*/
JSONObject
getByTitle
(
final
String
categoryTitle
)
throws
RepositoryException
;
public
JSONObject
getByTitle
(
final
String
categoryTitle
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY_TITLE
,
FilterOperator
.
EQUAL
,
categoryTitle
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets a category by the specified category URI.
...
...
@@ -48,7 +71,16 @@ public interface CategoryRepository extends Repository {
* @return a category, {@code null} if not found
* @throws RepositoryException repository exception
*/
JSONObject
getByURI
(
final
String
categoryURI
)
throws
RepositoryException
;
public
JSONObject
getByURI
(
final
String
categoryURI
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY_URI
,
FilterOperator
.
EQUAL
,
categoryURI
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets the maximum order.
...
...
@@ -56,7 +88,16 @@ public interface CategoryRepository extends Repository {
* @return order number, returns {@code -1} if not found
* @throws RepositoryException repository exception
*/
int
getMaxOrder
()
throws
RepositoryException
;
public
int
getMaxOrder
()
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Category
.
CATEGORY_ORDER
,
SortDirection
.
DESCENDING
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
-
1
;
}
return
array
.
optJSONObject
(
0
).
optInt
(
Category
.
CATEGORY_ORDER
);
}
/**
* Gets the upper category of the category specified by the given id.
...
...
@@ -65,7 +106,22 @@ public interface CategoryRepository extends Repository {
* @return upper category, returns {@code null} if not found
* @throws RepositoryException repository exception
*/
JSONObject
getUpper
(
final
String
id
)
throws
RepositoryException
;
public
JSONObject
getUpper
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
category
=
get
(
id
);
if
(
null
==
category
)
{
return
null
;
}
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY_ORDER
,
FilterOperator
.
LESS_THAN
,
category
.
optInt
(
Category
.
CATEGORY_ORDER
))).
addSort
(
Category
.
CATEGORY_ORDER
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets the under category of the category specified by the given id.
...
...
@@ -74,7 +130,22 @@ public interface CategoryRepository extends Repository {
* @return under category, returns {@code null} if not found
* @throws RepositoryException repository exception
*/
JSONObject
getUnder
(
final
String
id
)
throws
RepositoryException
;
public
JSONObject
getUnder
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
category
=
get
(
id
);
if
(
null
==
category
)
{
return
null
;
}
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY_ORDER
,
FilterOperator
.
GREATER_THAN
,
category
.
optInt
(
Category
.
CATEGORY_ORDER
))).
addSort
(
Category
.
CATEGORY_ORDER
,
SortDirection
.
ASCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets a category by the specified order.
...
...
@@ -83,7 +154,16 @@ public interface CategoryRepository extends Repository {
* @return category, returns {@code null} if not found
* @throws RepositoryException repository exception
*/
JSONObject
getByOrder
(
final
int
order
)
throws
RepositoryException
;
public
JSONObject
getByOrder
(
final
int
order
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY_ORDER
,
FilterOperator
.
EQUAL
,
order
));
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets most used categories (contains the most tags) with the specified number.
...
...
@@ -92,5 +172,12 @@ public interface CategoryRepository extends Repository {
* @return a list of most used categories, returns an empty list if not found
* @throws RepositoryException repository exception
*/
List
<
JSONObject
>
getMostUsedCategories
(
final
int
num
)
throws
RepositoryException
;
public
List
<
JSONObject
>
getMostUsedCategories
(
final
int
num
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Category
.
CATEGORY_ORDER
,
SortDirection
.
ASCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
num
).
setPageCount
(
1
);
final
List
<
JSONObject
>
ret
=
getList
(
query
);
Collections
.
sort
(
ret
,
(
o1
,
o2
)
->
Collator
.
getInstance
(
java
.
util
.
Locale
.
CHINA
).
compare
(
o1
.
optString
(
Tag
.
TAG_TITLE
),
o2
.
optString
(
Tag
.
TAG_TITLE
)));
return
ret
;
}
}
src/main/java/org/b3log/solo/repository/CategoryTagRepository.java
View file @
d93e378b
...
...
@@ -17,18 +17,30 @@
*/
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Repository
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Category
;
import
org.b3log.solo.model.Tag
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
/**
* Category-Tag relation repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
1, Mar 31, 2017
* @version 1.1.0.
2, Sep 30, 2018
* @since 2.0.0
*/
public
interface
CategoryTagRepository
extends
Repository
{
@Repository
public
class
CategoryTagRepository
extends
AbstractRepository
{
/**
* Public constructor.
*/
public
CategoryTagRepository
()
{
super
(
Category
.
CATEGORY
+
"_"
+
Tag
.
TAG
);
}
/**
* Gets category-tag relations by the specified category id.
...
...
@@ -50,8 +62,12 @@ public interface CategoryTagRepository extends Repository {
* </pre>
* @throws RepositoryException repository exception
*/
JSONObject
getByCategoryId
(
final
String
categoryId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
;
public
JSONObject
getByCategoryId
(
final
String
categoryId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
categoryId
)).
setCurrentPageNum
(
currentPageNum
).
setPageSize
(
pageSize
).
setPageCount
(
1
);
return
get
(
query
);
}
/**
* Gets category-tag relations by the specified tag id.
...
...
@@ -73,8 +89,12 @@ public interface CategoryTagRepository extends Repository {
* </pre>
* @throws RepositoryException repository exception
*/
JSONObject
getByTagId
(
final
String
tagId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
;
public
JSONObject
getByTagId
(
final
String
tagId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Tag
.
TAG
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
tagId
)).
setCurrentPageNum
(
currentPageNum
).
setPageSize
(
pageSize
).
setPageCount
(
1
);
return
get
(
query
);
}
/**
* Removes category-tag relations by the specified category id.
...
...
@@ -82,7 +102,14 @@ public interface CategoryTagRepository extends Repository {
* @param categoryId the specified category id
* @throws RepositoryException repository exception
*/
void
removeByCategoryId
(
final
String
categoryId
)
throws
RepositoryException
;
public
void
removeByCategoryId
(
final
String
categoryId
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
categoryId
));
final
JSONArray
relations
=
get
(
query
).
optJSONArray
(
Keys
.
RESULTS
);
for
(
int
i
=
0
;
i
<
relations
.
length
();
i
++)
{
final
JSONObject
rel
=
relations
.
optJSONObject
(
i
);
remove
(
rel
.
optString
(
Keys
.
OBJECT_ID
));
}
}
/**
* Removes category-tag relations by the specified tag id.
...
...
@@ -90,5 +117,12 @@ public interface CategoryTagRepository extends Repository {
* @param tagId the specified tag id
* @throws RepositoryException repository exception
*/
void
removeByTagId
(
final
String
tagId
)
throws
RepositoryException
;
public
void
removeByTagId
(
final
String
tagId
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Tag
.
TAG
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
tagId
));
final
JSONArray
relations
=
get
(
query
).
optJSONArray
(
Keys
.
RESULTS
);
for
(
int
i
=
0
;
i
<
relations
.
length
();
i
++)
{
final
JSONObject
rel
=
relations
.
optJSONObject
(
i
);
remove
(
rel
.
optString
(
Keys
.
OBJECT_ID
));
}
}
}
src/main/java/org/b3log/solo/repository/CommentRepository.java
View file @
d93e378b
...
...
@@ -17,51 +17,165 @@
*/
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Repository
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.cache.CommentCache
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Comment
;
import
org.json.JSONObject
;
import
java.util.Iterator
;
import
java.util.List
;
/**
* Comment repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
4, Oct 26, 2011
* @version 1.0.0.
5, Sep 30, 2018
* @since 0.3.1
*/
public
interface
CommentRepository
extends
Repository
{
@Repository
public
class
CommentRepository
extends
AbstractRepository
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CommentRepository
.
class
);
/**
* Article repository.
*/
@Inject
private
ArticleRepository
articleRepository
;
/**
* Comment cache.
*/
@Inject
private
CommentCache
commentCache
;
/**
* Public constructor.
*/
public
CommentRepository
()
{
super
(
Comment
.
COMMENT
);
}
@Override
public
void
remove
(
final
String
id
)
throws
RepositoryException
{
super
.
remove
(
id
);
commentCache
.
removeComment
(
id
);
}
@Override
public
JSONObject
get
(
final
String
id
)
throws
RepositoryException
{
JSONObject
ret
=
commentCache
.
getComment
(
id
);
if
(
null
!=
ret
)
{
return
ret
;
}
ret
=
super
.
get
(
id
);
if
(
null
==
ret
)
{
return
null
;
}
commentCache
.
putComment
(
ret
);
return
ret
;
}
@Override
public
void
update
(
final
String
id
,
final
JSONObject
comment
)
throws
RepositoryException
{
super
.
update
(
id
,
comment
);
comment
.
put
(
Keys
.
OBJECT_ID
,
id
);
commentCache
.
putComment
(
comment
);
}
/**
* Gets post comments recently with the specified fetch.
*
* @param fetchSize the specified fetch size
* @return a list of comments recently, returns an empty list if not found
* @throws RepositoryException repository exception
* @throws RepositoryException repository exception
*/
List
<
JSONObject
>
getRecentComments
(
final
int
fetchSize
)
throws
RepositoryException
;
public
List
<
JSONObject
>
getRecentComments
(
final
int
fetchSize
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Keys
.
OBJECT_ID
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
fetchSize
).
setPageCount
(
1
);
final
List
<
JSONObject
>
ret
=
getList
(
query
);
// Removes unpublished article related comments
removeForUnpublishedArticles
(
ret
);
return
ret
;
}
/**
* Gets comments with the specified on id, current page number and
* Gets comments with the specified on id, current page number and
* page size.
*
* @param onId the specified on id
*
* @param onId
the specified on id
* @param currentPageNum the specified current page number
* @param pageSize the specified page size
* @param pageSize
the specified page size
* @return a list of comments, returns an empty list if not found
* @throws RepositoryException repository exception
* @throws RepositoryException repository exception
*/
List
<
JSONObject
>
getComments
(
final
String
onId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
;
public
List
<
JSONObject
>
getComments
(
final
String
onId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Keys
.
OBJECT_ID
,
SortDirection
.
DESCENDING
).
setFilter
(
new
PropertyFilter
(
Comment
.
COMMENT_ON_ID
,
FilterOperator
.
EQUAL
,
onId
)).
setCurrentPageNum
(
currentPageNum
).
setPageSize
(
pageSize
).
setPageCount
(
1
);
return
getList
(
query
);
}
/**
* Removes comments with the specified on id.
*
*
* @param onId the specified on id
* @return removed count
* @throws RepositoryException repository exception
* @throws RepositoryException repository exception
*/
int
removeComments
(
final
String
onId
)
throws
RepositoryException
;
public
int
removeComments
(
final
String
onId
)
throws
RepositoryException
{
final
List
<
JSONObject
>
comments
=
getComments
(
onId
,
1
,
Integer
.
MAX_VALUE
);
for
(
final
JSONObject
comment
:
comments
)
{
final
String
commentId
=
comment
.
optString
(
Keys
.
OBJECT_ID
);
remove
(
commentId
);
}
LOGGER
.
log
(
Level
.
DEBUG
,
"Removed comments[onId={0}, removedCnt={1}]"
,
onId
,
comments
.
size
());
return
comments
.
size
();
}
/**
* Removes comments of unpublished articles for the specified comments.
*
* @param comments the specified comments
* @throws RepositoryException repository exception
*/
private
void
removeForUnpublishedArticles
(
final
List
<
JSONObject
>
comments
)
throws
RepositoryException
{
LOGGER
.
debug
(
"Removing unpublished articles' comments...."
);
final
Iterator
<
JSONObject
>
iterator
=
comments
.
iterator
();
while
(
iterator
.
hasNext
())
{
final
JSONObject
comment
=
iterator
.
next
();
final
String
commentOnType
=
comment
.
optString
(
Comment
.
COMMENT_ON_TYPE
);
if
(
Article
.
ARTICLE
.
equals
(
commentOnType
))
{
final
String
articleId
=
comment
.
optString
(
Comment
.
COMMENT_ON_ID
);
if
(!
articleRepository
.
isPublished
(
articleId
))
{
iterator
.
remove
();
}
}
}
LOGGER
.
debug
(
"Removed unpublished articles' comments...."
);
}
}
src/main/java/org/b3log/solo/repository/LinkRepository.java
View file @
d93e378b
...
...
@@ -17,18 +17,29 @@
*/
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Repository
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Link
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
/**
* Link repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
3, Nov 2, 2011
* @version 1.0.0.
4, Sep 30, 2018
* @since 0.3.1
*/
public
interface
LinkRepository
extends
Repository
{
@Repository
public
class
LinkRepository
extends
AbstractRepository
{
/**
* Public constructor.
*/
public
LinkRepository
()
{
super
(
Link
.
LINK
);
}
/**
* Gets a link by the specified address.
...
...
@@ -37,40 +48,97 @@ public interface LinkRepository extends Repository {
* @return link, returns {@code null} if not found
* @throws RepositoryException repository exception
*/
JSONObject
getByAddress
(
final
String
address
)
throws
RepositoryException
;
public
JSONObject
getByAddress
(
final
String
address
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Link
.
LINK_ADDRESS
,
FilterOperator
.
EQUAL
,
address
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets the maximum order.
*
*
* @return order number, returns {@code -1} if not found
* @throws RepositoryException repository exception
*/
int
getMaxOrder
()
throws
RepositoryException
;
public
int
getMaxOrder
()
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Link
.
LINK_ORDER
,
SortDirection
.
DESCENDING
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
-
1
;
}
return
array
.
optJSONObject
(
0
).
optInt
(
Link
.
LINK_ORDER
);
}
/**
* Gets the upper link of the link specified by the given id.
*
*
* @param id the given id
* @return upper link, returns {@code null} if not found
* @throws RepositoryException repository exception
* @throws RepositoryException repository exception
*/
JSONObject
getUpper
(
final
String
id
)
throws
RepositoryException
;
public
JSONObject
getUpper
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
link
=
get
(
id
);
if
(
null
==
link
)
{
return
null
;
}
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Link
.
LINK_ORDER
,
FilterOperator
.
LESS_THAN
,
link
.
optInt
(
Link
.
LINK_ORDER
))).
addSort
(
Link
.
LINK_ORDER
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets the under link of the link specified by the given id.
*
*
* @param id the given id
* @return under link, returns {@code null} if not found
* @throws RepositoryException repository exception
* @throws RepositoryException repository exception
*/
JSONObject
getUnder
(
final
String
id
)
throws
RepositoryException
;
public
JSONObject
getUnder
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
link
=
get
(
id
);
if
(
null
==
link
)
{
return
null
;
}
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Link
.
LINK_ORDER
,
FilterOperator
.
GREATER_THAN
,
link
.
optInt
(
Link
.
LINK_ORDER
))).
addSort
(
Link
.
LINK_ORDER
,
SortDirection
.
ASCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets a link by the specified order.
*
* @param order the specified order
* @return link, returns {@code null} if not found
* @throws RepositoryException repository exception
* @throws RepositoryException repository exception
*/
JSONObject
getByOrder
(
final
int
order
)
throws
RepositoryException
;
public
JSONObject
getByOrder
(
final
int
order
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Link
.
LINK_ORDER
,
FilterOperator
.
EQUAL
,
order
));
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
}
src/main/java/org/b3log/solo/repository/OptionRepository.java
View file @
d93e378b
...
...
@@ -17,18 +17,77 @@
*/
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Repository
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.cache.OptionCache
;
import
org.b3log.solo.model.Option
;
import
org.json.JSONObject
;
import
java.util.List
;
/**
* Option repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
0, Sep 19
, 2018
* @version 1.1.0.
1, Sep 30
, 2018
* @since 0.6.0
*/
public
interface
OptionRepository
extends
Repository
{
@Repository
public
class
OptionRepository
extends
AbstractRepository
{
/**
* Option cache.
*/
@Inject
private
OptionCache
optionCache
;
/**
* Public constructor.
*/
public
OptionRepository
()
{
super
(
Option
.
OPTION
);
}
@Override
public
void
remove
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
option
=
get
(
id
);
if
(
null
==
option
)
{
return
;
}
super
.
remove
(
id
);
optionCache
.
removeOption
(
id
);
final
String
category
=
option
.
optString
(
Option
.
OPTION_CATEGORY
);
optionCache
.
removeCategory
(
category
);
}
@Override
public
JSONObject
get
(
final
String
id
)
throws
RepositoryException
{
JSONObject
ret
=
optionCache
.
getOption
(
id
);
if
(
null
!=
ret
)
{
return
ret
;
}
ret
=
super
.
get
(
id
);
if
(
null
==
ret
)
{
return
null
;
}
optionCache
.
putOption
(
ret
);
return
ret
;
}
@Override
public
void
update
(
final
String
id
,
final
JSONObject
option
)
throws
RepositoryException
{
super
.
update
(
id
,
option
);
option
.
put
(
Keys
.
OBJECT_ID
,
id
);
optionCache
.
putOption
(
option
);
}
/**
* Gets options with the specified category.
...
...
@@ -46,5 +105,25 @@ public interface OptionRepository extends Repository {
* </pre>, returns {@code null} if not found
* @throws RepositoryException repository exception
*/
JSONObject
getOptions
(
final
String
category
)
throws
RepositoryException
;
public
JSONObject
getOptions
(
final
String
category
)
throws
RepositoryException
{
final
JSONObject
cached
=
optionCache
.
getCategory
(
category
);
if
(
null
!=
cached
)
{
return
cached
;
}
final
JSONObject
ret
=
new
JSONObject
();
try
{
final
List
<
JSONObject
>
options
=
getList
(
new
Query
().
setFilter
(
new
PropertyFilter
(
Option
.
OPTION_CATEGORY
,
FilterOperator
.
EQUAL
,
category
)));
if
(
0
==
options
.
size
())
{
return
null
;
}
options
.
stream
().
forEach
(
option
->
ret
.
put
(
option
.
optString
(
Keys
.
OBJECT_ID
),
option
.
opt
(
Option
.
OPTION_VALUE
)));
optionCache
.
putCategory
(
category
,
ret
);
return
ret
;
}
catch
(
final
Exception
e
)
{
throw
new
RepositoryException
(
e
);
}
}
}
src/main/java/org/b3log/solo/repository/PageRepository.java
View file @
d93e378b
...
...
@@ -17,8 +17,13 @@
*/
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Repository
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.cache.PageCache
;
import
org.b3log.solo.model.Page
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.util.List
;
...
...
@@ -27,19 +32,74 @@ import java.util.List;
* Page repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
6, Dec 31, 2011
* @version 1.0.0.
7, Sep 30, 2018
* @since 0.3.1
*/
public
interface
PageRepository
extends
Repository
{
@Repository
public
class
PageRepository
extends
AbstractRepository
{
/**
* Page cache.
*/
@Inject
private
PageCache
pageCache
;
/**
* Public constructor.
*/
public
PageRepository
()
{
super
(
Page
.
PAGE
);
}
@Override
public
void
remove
(
final
String
id
)
throws
RepositoryException
{
super
.
remove
(
id
);
pageCache
.
removePage
(
id
);
}
@Override
public
JSONObject
get
(
final
String
id
)
throws
RepositoryException
{
JSONObject
ret
=
pageCache
.
getPage
(
id
);
if
(
null
!=
ret
)
{
return
ret
;
}
ret
=
super
.
get
(
id
);
if
(
null
==
ret
)
{
return
null
;
}
pageCache
.
putPage
(
ret
);
return
ret
;
}
@Override
public
void
update
(
final
String
id
,
final
JSONObject
page
)
throws
RepositoryException
{
super
.
update
(
id
,
page
);
page
.
put
(
Keys
.
OBJECT_ID
,
id
);
pageCache
.
putPage
(
page
);
}
/**
* Gets a page by the specified permalink.
*
* @param permalink the specified permalink
* @return page, returns {@code null} if not found
* @throws RepositoryException repository exception
* @throws RepositoryException repository exception
*/
JSONObject
getByPermalink
(
final
String
permalink
)
throws
RepositoryException
;
public
JSONObject
getByPermalink
(
final
String
permalink
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Page
.
PAGE_PERMALINK
,
FilterOperator
.
EQUAL
,
permalink
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets the maximum order.
...
...
@@ -47,34 +107,82 @@ public interface PageRepository extends Repository {
* @return order number, returns {@code -1} if not found
* @throws RepositoryException repository exception
*/
int
getMaxOrder
()
throws
RepositoryException
;
public
int
getMaxOrder
()
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Page
.
PAGE_ORDER
,
SortDirection
.
DESCENDING
).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
-
1
;
}
return
array
.
optJSONObject
(
0
).
optInt
(
Page
.
PAGE_ORDER
);
}
/**
* Gets the upper page of the page specified by the given id.
*
*
* @param id the given id
* @return upper page, returns {@code null} if not found
* @throws RepositoryException repository exception
* @throws RepositoryException repository exception
*/
JSONObject
getUpper
(
final
String
id
)
throws
RepositoryException
;
public
JSONObject
getUpper
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
page
=
get
(
id
);
if
(
null
==
page
)
{
return
null
;
}
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Page
.
PAGE_ORDER
,
FilterOperator
.
LESS_THAN
,
page
.
optInt
(
Page
.
PAGE_ORDER
))).
addSort
(
Page
.
PAGE_ORDER
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
1
).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets the under page of the page specified by the given id.
*
*
* @param id the given id
* @return under page, returns {@code null} if not found
* @throws RepositoryException repository exception
* @throws RepositoryException repository exception
*/
JSONObject
getUnder
(
final
String
id
)
throws
RepositoryException
;
public
JSONObject
getUnder
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
page
=
get
(
id
);
if
(
null
==
page
)
{
return
null
;
}
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Page
.
PAGE_ORDER
,
FilterOperator
.
GREATER_THAN
,
page
.
optInt
(
Page
.
PAGE_ORDER
))).
addSort
(
Page
.
PAGE_ORDER
,
SortDirection
.
ASCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
1
).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets a page by the specified order.
*
* @param order the specified order
* @return page, returns {@code null} if not found
* @throws RepositoryException repository exception
* @throws RepositoryException repository exception
*/
JSONObject
getByOrder
(
final
int
order
)
throws
RepositoryException
;
public
JSONObject
getByOrder
(
final
int
order
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Page
.
PAGE_ORDER
,
FilterOperator
.
EQUAL
,
order
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets pages.
...
...
@@ -82,5 +190,9 @@ public interface PageRepository extends Repository {
* @return a list of pages, returns an empty list if not found
* @throws RepositoryException repository exception
*/
List
<
JSONObject
>
getPages
()
throws
RepositoryException
;
public
List
<
JSONObject
>
getPages
()
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Page
.
PAGE_ORDER
,
SortDirection
.
ASCENDING
).
setPageCount
(
1
);
return
getList
(
query
);
}
}
src/main/java/org/b3log/solo/repository/PluginRepository.java
View file @
d93e378b
...
...
@@ -17,13 +17,24 @@
*/
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Repository
;
import
org.b3log.latke.model.Plugin
;
import
org.b3log.latke.repository.AbstractRepository
;
import
org.b3log.latke.repository.annotation.Repository
;
/**
* Plugin repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
0, Jan 24, 2013
* @version 1.0.0.
1, Sep 30, 2018
* @since 0.3.1
*/
public
interface
PluginRepository
extends
Repository
{}
@Repository
public
class
PluginRepository
extends
AbstractRepository
{
/**
* Public constructor.
*/
public
PluginRepository
()
{
super
(
Plugin
.
PLUGIN
);
}
}
src/main/java/org/b3log/solo/repository/TagArticleRepository.java
View file @
d93e378b
...
...
@@ -17,8 +17,11 @@
*/
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Repository
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Tag
;
import
org.json.JSONObject
;
import
java.util.List
;
...
...
@@ -27,10 +30,18 @@ import java.util.List;
* Tag-Article repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
3, Nov 8, 2011
* @version 1.0.0.
4, Sep 30, 2018
* @since 0.3.1
*/
public
interface
TagArticleRepository
extends
Repository
{
@Repository
public
class
TagArticleRepository
extends
AbstractRepository
{
/**
* Public constructor.
*/
public
TagArticleRepository
()
{
super
(
Tag
.
TAG
+
"_"
+
Article
.
ARTICLE
);
}
/**
* Gets tag-article relations by the specified article id.
...
...
@@ -46,17 +57,21 @@ public interface TagArticleRepository extends Repository {
* </pre>
* @throws RepositoryException repository exception
*/
List
<
JSONObject
>
getByArticleId
(
final
String
articleId
)
throws
RepositoryException
;
public
List
<
JSONObject
>
getByArticleId
(
final
String
articleId
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Article
.
ARTICLE
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
articleId
)).
setPageCount
(
1
);
return
getList
(
query
);
}
/**
* Gets tag-article relations by the specified tag id.
*
* @param tagId the specified tag id
* @param tagId
the specified tag id
* @param currentPageNum the specified current page number, MUST greater
* then {@code 0}
* @param pageSize the specified page size(count of a page contains objects),
* MUST greater then {@code 0}
*
then {@code 0}
* @param pageSize
the specified page size(count of a page contains objects),
*
MUST greater then {@code 0}
* @return for example
* <pre>
* {
...
...
@@ -72,7 +87,11 @@ public interface TagArticleRepository extends Repository {
* </pre>
* @throws RepositoryException repository exception
*/
JSONObject
getByTagId
(
final
String
tagId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
;
public
JSONObject
getByTagId
(
final
String
tagId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Tag
.
TAG
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
tagId
)).
addSort
(
Article
.
ARTICLE
+
"_"
+
Keys
.
OBJECT_ID
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
currentPageNum
).
setPageSize
(
pageSize
).
setPageCount
(
1
);
return
get
(
query
);
}
}
src/main/java/org/b3log/solo/repository/TagRepository.java
View file @
d93e378b
...
...
@@ -17,31 +17,63 @@
*/
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Repository
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Tag
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.text.Collator
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* Tag repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
1, Aug 12, 2010
* @version 1.0.0.
2, Sep 30, 2018
* @since 0.3.1
*/
public
interface
TagRepository
extends
Repository
{
@Repository
public
class
TagRepository
extends
AbstractRepository
{
/**
* Public constructor.
*/
public
TagRepository
()
{
super
(
Tag
.
TAG
);
}
/**
* Tag-Article relation repository.
*/
@Inject
private
TagArticleRepository
tagArticleRepository
;
/**
* Gets tags of an article specified by the article id.
*
*
* @param articleId the specified article id
* @return a list of tags of the specified article, returns an empty list
* if not found
* @throws RepositoryException repository exception
*/
List
<
JSONObject
>
getByArticleId
(
final
String
articleId
)
throws
RepositoryException
;
public
List
<
JSONObject
>
getByArticleId
(
final
String
articleId
)
throws
RepositoryException
{
final
List
<
JSONObject
>
ret
=
new
ArrayList
<>();
final
List
<
JSONObject
>
tagArticleRelations
=
tagArticleRepository
.
getByArticleId
(
articleId
);
for
(
final
JSONObject
tagArticleRelation
:
tagArticleRelations
)
{
final
String
tagId
=
tagArticleRelation
.
optString
(
Tag
.
TAG
+
"_"
+
Keys
.
OBJECT_ID
);
final
JSONObject
tag
=
get
(
tagId
);
ret
.
add
(
tag
);
}
return
ret
;
}
/**
* Gets a tag by the specified tag title.
...
...
@@ -50,7 +82,17 @@ public interface TagRepository extends Repository {
* @return a tag, {@code null} if not found
* @throws RepositoryException repository exception
*/
JSONObject
getByTitle
(
final
String
tagTitle
)
throws
RepositoryException
;
public
JSONObject
getByTitle
(
final
String
tagTitle
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Tag
.
TAG_TITLE
,
FilterOperator
.
EQUAL
,
tagTitle
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
/**
* Gets most used tags with the specified number.
...
...
@@ -59,5 +101,12 @@ public interface TagRepository extends Repository {
* @return a list of most used tags, returns an empty list if not found
* @throws RepositoryException repository exception
*/
List
<
JSONObject
>
getMostUsedTags
(
final
int
num
)
throws
RepositoryException
;
public
List
<
JSONObject
>
getMostUsedTags
(
final
int
num
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Tag
.
TAG_PUBLISHED_REFERENCE_COUNT
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
num
).
setPageCount
(
1
);
final
List
<
JSONObject
>
tagJoList
=
getList
(
query
);
Collections
.
sort
(
tagJoList
,
(
o1
,
o2
)
->
Collator
.
getInstance
(
java
.
util
.
Locale
.
CHINA
).
compare
(
o1
.
optString
(
Tag
.
TAG_TITLE
),
o2
.
optString
(
Tag
.
TAG_TITLE
)));
return
tagJoList
;
}
}
src/main/java/org/b3log/solo/repository/UserRepository.java
View file @
d93e378b
...
...
@@ -17,18 +17,76 @@
*/
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Repository
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.model.Role
;
import
org.b3log.latke.model.User
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.cache.UserCache
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.util.List
;
/**
* User repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
0, Sep 21
, 2018
* @version 1.1.0.
1, Sep 30
, 2018
* @since 0.3.1
*/
public
interface
UserRepository
extends
Repository
{
@Repository
public
class
UserRepository
extends
AbstractRepository
{
/**
* User cache.
*/
@Inject
private
UserCache
userCache
;
/**
* Public constructor.
*/
public
UserRepository
()
{
super
(
User
.
USER
);
}
@Override
public
void
remove
(
final
String
id
)
throws
RepositoryException
{
super
.
remove
(
id
);
userCache
.
removeUser
(
id
);
}
@Override
public
JSONObject
get
(
final
String
id
)
throws
RepositoryException
{
JSONObject
ret
=
userCache
.
getUser
(
id
);
if
(
null
!=
ret
)
{
return
ret
;
}
ret
=
super
.
get
(
id
);
if
(
null
==
ret
)
{
return
null
;
}
userCache
.
putUser
(
ret
);
return
ret
;
}
@Override
public
void
update
(
final
String
id
,
final
JSONObject
user
)
throws
RepositoryException
{
super
.
update
(
id
,
user
);
user
.
put
(
Keys
.
OBJECT_ID
,
id
);
userCache
.
putUser
(
user
);
if
(
Role
.
ADMIN_ROLE
.
equals
(
user
.
optString
(
User
.
USER_ROLE
)))
{
userCache
.
putAdmin
(
user
);
}
}
/**
* Gets a user by the specified username.
...
...
@@ -37,7 +95,16 @@ public interface UserRepository extends Repository {
* @return user, returns {@code null} if not found
* @throws RepositoryException repository exception
*/
JSONObject
getByUserName
(
final
String
userName
)
throws
RepositoryException
;
public
JSONObject
getByUserName
(
final
String
userName
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setPageCount
(
1
).
setFilter
(
new
PropertyFilter
(
User
.
USER_NAME
,
FilterOperator
.
EQUAL
,
userName
));
final
List
<
JSONObject
>
users
=
getList
(
query
);
if
(
users
.
isEmpty
())
{
return
null
;
}
return
users
.
get
(
0
);
}
/**
* Gets a user by the specified email.
...
...
@@ -46,7 +113,25 @@ public interface UserRepository extends Repository {
* @return user, returns {@code null} if not found
* @throws RepositoryException repository exception
*/
JSONObject
getByEmail
(
final
String
email
)
throws
RepositoryException
;
public
JSONObject
getByEmail
(
final
String
email
)
throws
RepositoryException
{
JSONObject
ret
=
userCache
.
getUserByEmail
(
email
);
if
(
null
!=
ret
)
{
return
ret
;
}
final
Query
query
=
new
Query
().
setPageCount
(
1
).
setFilter
(
new
PropertyFilter
(
User
.
USER_EMAIL
,
FilterOperator
.
EQUAL
,
email
.
toLowerCase
().
trim
()));
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
ret
=
array
.
optJSONObject
(
0
);
userCache
.
putUser
(
ret
);
return
ret
;
}
/**
* Gets the administrator user.
...
...
@@ -54,5 +139,22 @@ public interface UserRepository extends Repository {
* @return administrator user, returns {@code null} if not found or error
* @throws RepositoryException repository exception
*/
JSONObject
getAdmin
()
throws
RepositoryException
;
public
JSONObject
getAdmin
()
throws
RepositoryException
{
JSONObject
ret
=
userCache
.
getAdmin
();
if
(
null
!=
ret
)
{
return
ret
;
}
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
User
.
USER_ROLE
,
FilterOperator
.
EQUAL
,
Role
.
ADMIN_ROLE
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
ret
=
array
.
optJSONObject
(
0
);
userCache
.
putAdmin
(
ret
);
return
ret
;
}
}
src/main/java/org/b3log/solo/repository/impl/CategoryRepositoryImpl.java
deleted
100644 → 0
View file @
9e9a8ec9
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Category
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.repository.CategoryRepository
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.text.Collator
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
/**
* Category repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.2, Apr 19, 2017
* @since 2.0.0
*/
@Repository
public
class
CategoryRepositoryImpl
extends
AbstractRepository
implements
CategoryRepository
{
/**
* Public constructor.
*/
public
CategoryRepositoryImpl
()
{
super
(
Category
.
CATEGORY
);
}
@Override
public
JSONObject
getByTitle
(
final
String
categoryTitle
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY_TITLE
,
FilterOperator
.
EQUAL
,
categoryTitle
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
JSONObject
getByURI
(
final
String
categoryURI
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY_URI
,
FilterOperator
.
EQUAL
,
categoryURI
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
int
getMaxOrder
()
throws
RepositoryException
{
final
Query
query
=
new
Query
();
query
.
addSort
(
Category
.
CATEGORY_ORDER
,
SortDirection
.
DESCENDING
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
-
1
;
}
return
array
.
optJSONObject
(
0
).
optInt
(
Category
.
CATEGORY_ORDER
);
}
@Override
public
JSONObject
getByOrder
(
final
int
order
)
throws
RepositoryException
{
final
Query
query
=
new
Query
();
query
.
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY_ORDER
,
FilterOperator
.
EQUAL
,
order
));
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
List
<
JSONObject
>
getMostUsedCategories
(
final
int
num
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Category
.
CATEGORY_ORDER
,
SortDirection
.
ASCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
num
).
setPageCount
(
1
);
final
List
<
JSONObject
>
ret
=
getList
(
query
);
sortJSONCategoryList
(
ret
);
return
ret
;
}
@Override
public
JSONObject
getUpper
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
category
=
get
(
id
);
if
(
null
==
category
)
{
return
null
;
}
final
Query
query
=
new
Query
();
query
.
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY_ORDER
,
FilterOperator
.
LESS_THAN
,
category
.
optInt
(
Category
.
CATEGORY_ORDER
))).
addSort
(
Category
.
CATEGORY_ORDER
,
SortDirection
.
DESCENDING
);
query
.
setCurrentPageNum
(
1
);
query
.
setPageSize
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
JSONObject
getUnder
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
category
=
get
(
id
);
if
(
null
==
category
)
{
return
null
;
}
final
Query
query
=
new
Query
();
query
.
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY_ORDER
,
FilterOperator
.
GREATER_THAN
,
category
.
optInt
(
Category
.
CATEGORY_ORDER
))).
addSort
(
Category
.
CATEGORY_ORDER
,
SortDirection
.
ASCENDING
);
query
.
setCurrentPageNum
(
1
);
query
.
setPageSize
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
private
void
sortJSONCategoryList
(
final
List
<
JSONObject
>
tagJoList
)
{
Collections
.
sort
(
tagJoList
,
new
Comparator
<
JSONObject
>()
{
@Override
public
int
compare
(
final
JSONObject
o1
,
final
JSONObject
o2
)
{
return
Collator
.
getInstance
(
java
.
util
.
Locale
.
CHINA
).
compare
(
o1
.
optString
(
Tag
.
TAG_TITLE
),
o2
.
optString
(
Tag
.
TAG_TITLE
));
}
});
}
}
src/main/java/org/b3log/solo/repository/impl/CategoryTagRepositoryImpl.java
deleted
100644 → 0
View file @
9e9a8ec9
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Category
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.repository.CategoryTagRepository
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
/**
* Category-Tag relation repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.0, Mar 31, 2017
* @since 2.0.0
*/
@Repository
public
class
CategoryTagRepositoryImpl
extends
AbstractRepository
implements
CategoryTagRepository
{
/**
* Public constructor.
*/
public
CategoryTagRepositoryImpl
()
{
super
(
Category
.
CATEGORY
+
"_"
+
Tag
.
TAG
);
}
@Override
public
JSONObject
getByCategoryId
(
final
String
categoryId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
categoryId
)).
setCurrentPageNum
(
currentPageNum
).
setPageSize
(
pageSize
).
setPageCount
(
1
);
return
get
(
query
);
}
@Override
public
JSONObject
getByTagId
(
final
String
tagId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Tag
.
TAG
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
tagId
)).
setCurrentPageNum
(
currentPageNum
).
setPageSize
(
pageSize
).
setPageCount
(
1
);
return
get
(
query
);
}
@Override
public
void
removeByCategoryId
(
final
String
categoryId
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Category
.
CATEGORY
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
categoryId
));
final
JSONArray
relations
=
get
(
query
).
optJSONArray
(
Keys
.
RESULTS
);
for
(
int
i
=
0
;
i
<
relations
.
length
();
i
++)
{
final
JSONObject
rel
=
relations
.
optJSONObject
(
i
);
remove
(
rel
.
optString
(
Keys
.
OBJECT_ID
));
}
}
@Override
public
void
removeByTagId
(
final
String
tagId
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Tag
.
TAG
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
tagId
));
final
JSONArray
relations
=
get
(
query
).
optJSONArray
(
Keys
.
RESULTS
);
for
(
int
i
=
0
;
i
<
relations
.
length
();
i
++)
{
final
JSONObject
rel
=
relations
.
optJSONObject
(
i
);
remove
(
rel
.
optString
(
Keys
.
OBJECT_ID
));
}
}
}
src/main/java/org/b3log/solo/repository/impl/CommentRepositoryImpl.java
deleted
100644 → 0
View file @
9e9a8ec9
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.cache.CommentCache
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.json.JSONObject
;
import
java.util.Iterator
;
import
java.util.List
;
/**
* Comment repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.10, Aug 27, 2018
* @since 0.3.1
*/
@Repository
public
class
CommentRepositoryImpl
extends
AbstractRepository
implements
CommentRepository
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CommentRepositoryImpl
.
class
);
/**
* Article repository.
*/
@Inject
private
ArticleRepository
articleRepository
;
/**
* Comment cache.
*/
@Inject
private
CommentCache
commentCache
;
/**
* Public constructor.
*/
public
CommentRepositoryImpl
()
{
super
(
Comment
.
COMMENT
);
}
@Override
public
void
remove
(
final
String
id
)
throws
RepositoryException
{
super
.
remove
(
id
);
commentCache
.
removeComment
(
id
);
}
@Override
public
JSONObject
get
(
final
String
id
)
throws
RepositoryException
{
JSONObject
ret
=
commentCache
.
getComment
(
id
);
if
(
null
!=
ret
)
{
return
ret
;
}
ret
=
super
.
get
(
id
);
if
(
null
==
ret
)
{
return
null
;
}
commentCache
.
putComment
(
ret
);
return
ret
;
}
@Override
public
void
update
(
final
String
id
,
final
JSONObject
comment
)
throws
RepositoryException
{
super
.
update
(
id
,
comment
);
comment
.
put
(
Keys
.
OBJECT_ID
,
id
);
commentCache
.
putComment
(
comment
);
}
@Override
public
int
removeComments
(
final
String
onId
)
throws
RepositoryException
{
final
List
<
JSONObject
>
comments
=
getComments
(
onId
,
1
,
Integer
.
MAX_VALUE
);
for
(
final
JSONObject
comment
:
comments
)
{
final
String
commentId
=
comment
.
optString
(
Keys
.
OBJECT_ID
);
remove
(
commentId
);
}
LOGGER
.
log
(
Level
.
DEBUG
,
"Removed comments[onId={0}, removedCnt={1}]"
,
onId
,
comments
.
size
());
return
comments
.
size
();
}
@Override
public
List
<
JSONObject
>
getComments
(
final
String
onId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Keys
.
OBJECT_ID
,
SortDirection
.
DESCENDING
).
setFilter
(
new
PropertyFilter
(
Comment
.
COMMENT_ON_ID
,
FilterOperator
.
EQUAL
,
onId
)).
setCurrentPageNum
(
currentPageNum
).
setPageSize
(
pageSize
).
setPageCount
(
1
);
return
getList
(
query
);
}
@Override
public
List
<
JSONObject
>
getRecentComments
(
final
int
num
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Keys
.
OBJECT_ID
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
num
).
setPageCount
(
1
);
final
List
<
JSONObject
>
ret
=
getList
(
query
);
// Removes unpublished article related comments
removeForUnpublishedArticles
(
ret
);
return
ret
;
}
/**
* Removes comments of unpublished articles for the specified comments.
*
* @param comments the specified comments
* @throws RepositoryException repository exception
*/
private
void
removeForUnpublishedArticles
(
final
List
<
JSONObject
>
comments
)
throws
RepositoryException
{
LOGGER
.
debug
(
"Removing unpublished articles' comments...."
);
final
Iterator
<
JSONObject
>
iterator
=
comments
.
iterator
();
while
(
iterator
.
hasNext
())
{
final
JSONObject
comment
=
iterator
.
next
();
final
String
commentOnType
=
comment
.
optString
(
Comment
.
COMMENT_ON_TYPE
);
if
(
Article
.
ARTICLE
.
equals
(
commentOnType
))
{
final
String
articleId
=
comment
.
optString
(
Comment
.
COMMENT_ON_ID
);
if
(!
articleRepository
.
isPublished
(
articleId
))
{
iterator
.
remove
();
}
}
}
LOGGER
.
debug
(
"Removed unpublished articles' comments...."
);
}
/**
* Sets the article repository with the specified article repository.
*
* @param articleRepository the specified article repository
*/
public
void
setArticleRepository
(
final
ArticleRepository
articleRepository
)
{
this
.
articleRepository
=
articleRepository
;
}
}
src/main/java/org/b3log/solo/repository/impl/LinkRepositoryImpl.java
deleted
100644 → 0
View file @
9e9a8ec9
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Link
;
import
org.b3log.solo.repository.LinkRepository
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
/**
* Link repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.5, Nov 10, 2011
* @since 0.3.1
*/
@Repository
public
class
LinkRepositoryImpl
extends
AbstractRepository
implements
LinkRepository
{
/**
* Public constructor.
*/
public
LinkRepositoryImpl
()
{
super
(
Link
.
LINK
);
}
@Override
public
JSONObject
getByAddress
(
final
String
address
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Link
.
LINK_ADDRESS
,
FilterOperator
.
EQUAL
,
address
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
int
getMaxOrder
()
throws
RepositoryException
{
final
Query
query
=
new
Query
();
query
.
addSort
(
Link
.
LINK_ORDER
,
SortDirection
.
DESCENDING
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
-
1
;
}
return
array
.
optJSONObject
(
0
).
optInt
(
Link
.
LINK_ORDER
);
}
@Override
public
JSONObject
getByOrder
(
final
int
order
)
throws
RepositoryException
{
final
Query
query
=
new
Query
();
query
.
setFilter
(
new
PropertyFilter
(
Link
.
LINK_ORDER
,
FilterOperator
.
EQUAL
,
order
));
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
JSONObject
getUpper
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
link
=
get
(
id
);
if
(
null
==
link
)
{
return
null
;
}
final
Query
query
=
new
Query
();
query
.
setFilter
(
new
PropertyFilter
(
Link
.
LINK_ORDER
,
FilterOperator
.
LESS_THAN
,
link
.
optInt
(
Link
.
LINK_ORDER
))).
addSort
(
Link
.
LINK_ORDER
,
SortDirection
.
DESCENDING
);
query
.
setCurrentPageNum
(
1
);
query
.
setPageSize
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
JSONObject
getUnder
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
link
=
get
(
id
);
if
(
null
==
link
)
{
return
null
;
}
final
Query
query
=
new
Query
();
query
.
setFilter
(
new
PropertyFilter
(
Link
.
LINK_ORDER
,
FilterOperator
.
GREATER_THAN
,
link
.
optInt
(
Link
.
LINK_ORDER
))).
addSort
(
Link
.
LINK_ORDER
,
SortDirection
.
ASCENDING
);
query
.
setCurrentPageNum
(
1
);
query
.
setPageSize
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
}
src/main/java/org/b3log/solo/repository/impl/OptionRepositoryImpl.java
deleted
100644 → 0
View file @
9e9a8ec9
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.cache.OptionCache
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.repository.OptionRepository
;
import
org.json.JSONObject
;
import
java.util.List
;
/**
* Option repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.2, Sep 19, 2018
* @since 0.6.0
*/
@Repository
public
class
OptionRepositoryImpl
extends
AbstractRepository
implements
OptionRepository
{
/**
* Option cache.
*/
@Inject
private
OptionCache
optionCache
;
/**
* Public constructor.
*/
public
OptionRepositoryImpl
()
{
super
(
Option
.
OPTION
);
}
@Override
public
void
remove
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
option
=
get
(
id
);
if
(
null
==
option
)
{
return
;
}
super
.
remove
(
id
);
optionCache
.
removeOption
(
id
);
final
String
category
=
option
.
optString
(
Option
.
OPTION_CATEGORY
);
optionCache
.
removeCategory
(
category
);
}
@Override
public
JSONObject
get
(
final
String
id
)
throws
RepositoryException
{
JSONObject
ret
=
optionCache
.
getOption
(
id
);
if
(
null
!=
ret
)
{
return
ret
;
}
ret
=
super
.
get
(
id
);
if
(
null
==
ret
)
{
return
null
;
}
optionCache
.
putOption
(
ret
);
return
ret
;
}
@Override
public
void
update
(
final
String
id
,
final
JSONObject
option
)
throws
RepositoryException
{
super
.
update
(
id
,
option
);
option
.
put
(
Keys
.
OBJECT_ID
,
id
);
optionCache
.
putOption
(
option
);
}
@Override
public
JSONObject
getOptions
(
final
String
category
)
throws
RepositoryException
{
final
JSONObject
cached
=
optionCache
.
getCategory
(
category
);
if
(
null
!=
cached
)
{
return
cached
;
}
final
JSONObject
ret
=
new
JSONObject
();
try
{
final
List
<
JSONObject
>
options
=
getList
(
new
Query
().
setFilter
(
new
PropertyFilter
(
Option
.
OPTION_CATEGORY
,
FilterOperator
.
EQUAL
,
category
)));
if
(
0
==
options
.
size
())
{
return
null
;
}
options
.
stream
().
forEach
(
option
->
ret
.
put
(
option
.
optString
(
Keys
.
OBJECT_ID
),
option
.
opt
(
Option
.
OPTION_VALUE
)));
optionCache
.
putCategory
(
category
,
ret
);
return
ret
;
}
catch
(
final
Exception
e
)
{
throw
new
RepositoryException
(
e
);
}
}
}
src/main/java/org/b3log/solo/repository/impl/PageRepositoryImpl.java
deleted
100644 → 0
View file @
9e9a8ec9
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.cache.PageCache
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.repository.PageRepository
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.util.List
;
/**
* Page repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.10, Aug 27, 2018
* @since 0.3.1
*/
@Repository
public
class
PageRepositoryImpl
extends
AbstractRepository
implements
PageRepository
{
/**
* Page cache.
*/
@Inject
private
PageCache
pageCache
;
/**
* Public constructor.
*/
public
PageRepositoryImpl
()
{
super
(
Page
.
PAGE
);
}
@Override
public
void
remove
(
final
String
id
)
throws
RepositoryException
{
super
.
remove
(
id
);
pageCache
.
removePage
(
id
);
}
@Override
public
JSONObject
get
(
final
String
id
)
throws
RepositoryException
{
JSONObject
ret
=
pageCache
.
getPage
(
id
);
if
(
null
!=
ret
)
{
return
ret
;
}
ret
=
super
.
get
(
id
);
if
(
null
==
ret
)
{
return
null
;
}
pageCache
.
putPage
(
ret
);
return
ret
;
}
@Override
public
void
update
(
final
String
id
,
final
JSONObject
page
)
throws
RepositoryException
{
super
.
update
(
id
,
page
);
page
.
put
(
Keys
.
OBJECT_ID
,
id
);
pageCache
.
putPage
(
page
);
}
@Override
public
JSONObject
getByPermalink
(
final
String
permalink
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Page
.
PAGE_PERMALINK
,
FilterOperator
.
EQUAL
,
permalink
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
int
getMaxOrder
()
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Page
.
PAGE_ORDER
,
SortDirection
.
DESCENDING
).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
-
1
;
}
return
array
.
optJSONObject
(
0
).
optInt
(
Page
.
PAGE_ORDER
);
}
@Override
public
JSONObject
getUpper
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
page
=
get
(
id
);
if
(
null
==
page
)
{
return
null
;
}
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Page
.
PAGE_ORDER
,
FilterOperator
.
LESS_THAN
,
page
.
optInt
(
Page
.
PAGE_ORDER
))).
addSort
(
Page
.
PAGE_ORDER
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
1
).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
JSONObject
getUnder
(
final
String
id
)
throws
RepositoryException
{
final
JSONObject
page
=
get
(
id
);
if
(
null
==
page
)
{
return
null
;
}
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Page
.
PAGE_ORDER
,
FilterOperator
.
GREATER_THAN
,
page
.
optInt
(
Page
.
PAGE_ORDER
))).
addSort
(
Page
.
PAGE_ORDER
,
SortDirection
.
ASCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
1
).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
1
!=
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
JSONObject
getByOrder
(
final
int
order
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Page
.
PAGE_ORDER
,
FilterOperator
.
EQUAL
,
order
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
List
<
JSONObject
>
getPages
()
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Page
.
PAGE_ORDER
,
SortDirection
.
ASCENDING
).
setPageCount
(
1
);
return
getList
(
query
);
}
}
src/main/java/org/b3log/solo/repository/impl/PluginRepositoryImpl.java
deleted
100644 → 0
View file @
9e9a8ec9
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.model.Plugin
;
import
org.b3log.latke.repository.AbstractRepository
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.repository.PluginRepository
;
/**
* Plugin repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Jul 21, 2011
* @since 0.3.1
*/
@Repository
public
class
PluginRepositoryImpl
extends
AbstractRepository
implements
PluginRepository
{
/**
* Public constructor.
*/
public
PluginRepositoryImpl
()
{
super
(
Plugin
.
PLUGIN
);
}
}
src/main/java/org/b3log/solo/repository/impl/TagArticleRepositoryImpl.java
deleted
100644 → 0
View file @
9e9a8ec9
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.repository.TagArticleRepository
;
import
org.json.JSONObject
;
import
java.util.List
;
/**
* Tag-Article relation repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.10, Aug 27, 2018
* @since 0.3.1
*/
@Repository
public
class
TagArticleRepositoryImpl
extends
AbstractRepository
implements
TagArticleRepository
{
/**
* Public constructor.
*/
public
TagArticleRepositoryImpl
()
{
super
(
Tag
.
TAG
+
"_"
+
Article
.
ARTICLE
);
}
@Override
public
List
<
JSONObject
>
getByArticleId
(
final
String
articleId
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Article
.
ARTICLE
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
articleId
)).
setPageCount
(
1
);
return
getList
(
query
);
}
@Override
public
JSONObject
getByTagId
(
final
String
tagId
,
final
int
currentPageNum
,
final
int
pageSize
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Tag
.
TAG
+
"_"
+
Keys
.
OBJECT_ID
,
FilterOperator
.
EQUAL
,
tagId
)).
addSort
(
Article
.
ARTICLE
+
"_"
+
Keys
.
OBJECT_ID
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
currentPageNum
).
setPageSize
(
pageSize
).
setPageCount
(
1
);
return
get
(
query
);
}
}
src/main/java/org/b3log/solo/repository/impl/TagRepositoryImpl.java
deleted
100644 → 0
View file @
9e9a8ec9
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.repository.TagArticleRepository
;
import
org.b3log.solo.repository.TagRepository
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.text.Collator
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* Tag repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.2, Aug 27, 2018
* @since 0.3.1
*/
@Repository
public
class
TagRepositoryImpl
extends
AbstractRepository
implements
TagRepository
{
/**
* Tag-Article relation repository.
*/
@Inject
private
TagArticleRepository
tagArticleRepository
;
/**
* Public constructor.
*/
public
TagRepositoryImpl
()
{
super
(
Tag
.
TAG
);
}
@Override
public
JSONObject
getByTitle
(
final
String
tagTitle
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Tag
.
TAG_TITLE
,
FilterOperator
.
EQUAL
,
tagTitle
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
return
array
.
optJSONObject
(
0
);
}
@Override
public
List
<
JSONObject
>
getMostUsedTags
(
final
int
num
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
addSort
(
Tag
.
TAG_PUBLISHED_REFERENCE_COUNT
,
SortDirection
.
DESCENDING
).
setCurrentPageNum
(
1
).
setPageSize
(
num
).
setPageCount
(
1
);
final
List
<
JSONObject
>
tagJoList
=
getList
(
query
);
sortJSONTagList
(
tagJoList
);
return
tagJoList
;
}
@Override
public
List
<
JSONObject
>
getByArticleId
(
final
String
articleId
)
throws
RepositoryException
{
final
List
<
JSONObject
>
ret
=
new
ArrayList
<>();
final
List
<
JSONObject
>
tagArticleRelations
=
tagArticleRepository
.
getByArticleId
(
articleId
);
for
(
final
JSONObject
tagArticleRelation
:
tagArticleRelations
)
{
final
String
tagId
=
tagArticleRelation
.
optString
(
Tag
.
TAG
+
"_"
+
Keys
.
OBJECT_ID
);
final
JSONObject
tag
=
get
(
tagId
);
ret
.
add
(
tag
);
}
return
ret
;
}
/**
* Sets tag article repository with the specified tag article repository.
*
* @param tagArticleRepository the specified tag article repository
*/
public
void
setTagArticleRepository
(
final
TagArticleRepository
tagArticleRepository
)
{
this
.
tagArticleRepository
=
tagArticleRepository
;
}
private
void
sortJSONTagList
(
final
List
<
JSONObject
>
tagJoList
)
{
Collections
.
sort
(
tagJoList
,
(
o1
,
o2
)
->
{
try
{
return
Collator
.
getInstance
(
java
.
util
.
Locale
.
CHINA
)
.
compare
(
o1
.
getString
(
Tag
.
TAG_TITLE
),
o2
.
getString
(
Tag
.
TAG_TITLE
));
}
catch
(
final
JSONException
e
)
{
throw
new
RuntimeException
(
e
);
}
});
}
}
src/main/java/org/b3log/solo/repository/impl/UserRepositoryImpl.java
deleted
100644 → 0
View file @
9e9a8ec9
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.model.Role
;
import
org.b3log.latke.model.User
;
import
org.b3log.latke.repository.*
;
import
org.b3log.latke.repository.annotation.Repository
;
import
org.b3log.solo.cache.UserCache
;
import
org.b3log.solo.repository.UserRepository
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.util.List
;
/**
* User repository.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.10, Sep 21, 2018
* @since 0.3.1
*/
@Repository
public
class
UserRepositoryImpl
extends
AbstractRepository
implements
UserRepository
{
/**
* User cache.
*/
@Inject
private
UserCache
userCache
;
/**
* Public constructor.
*/
public
UserRepositoryImpl
()
{
super
(
User
.
USER
);
}
@Override
public
void
remove
(
final
String
id
)
throws
RepositoryException
{
super
.
remove
(
id
);
userCache
.
removeUser
(
id
);
}
@Override
public
JSONObject
get
(
final
String
id
)
throws
RepositoryException
{
JSONObject
ret
=
userCache
.
getUser
(
id
);
if
(
null
!=
ret
)
{
return
ret
;
}
ret
=
super
.
get
(
id
);
if
(
null
==
ret
)
{
return
null
;
}
userCache
.
putUser
(
ret
);
return
ret
;
}
@Override
public
void
update
(
final
String
id
,
final
JSONObject
user
)
throws
RepositoryException
{
super
.
update
(
id
,
user
);
user
.
put
(
Keys
.
OBJECT_ID
,
id
);
userCache
.
putUser
(
user
);
if
(
Role
.
ADMIN_ROLE
.
equals
(
user
.
optString
(
User
.
USER_ROLE
)))
{
userCache
.
putAdmin
(
user
);
}
}
@Override
public
JSONObject
getByUserName
(
final
String
userName
)
throws
RepositoryException
{
final
Query
query
=
new
Query
().
setPageCount
(
1
).
setFilter
(
new
PropertyFilter
(
User
.
USER_NAME
,
FilterOperator
.
EQUAL
,
userName
));
final
List
<
JSONObject
>
users
=
getList
(
query
);
if
(
users
.
isEmpty
())
{
return
null
;
}
return
users
.
get
(
0
);
}
@Override
public
JSONObject
getByEmail
(
final
String
email
)
throws
RepositoryException
{
JSONObject
ret
=
userCache
.
getUserByEmail
(
email
);
if
(
null
!=
ret
)
{
return
ret
;
}
final
Query
query
=
new
Query
().
setPageCount
(
1
).
setFilter
(
new
PropertyFilter
(
User
.
USER_EMAIL
,
FilterOperator
.
EQUAL
,
email
.
toLowerCase
().
trim
()));
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
ret
=
array
.
optJSONObject
(
0
);
userCache
.
putUser
(
ret
);
return
ret
;
}
@Override
public
JSONObject
getAdmin
()
throws
RepositoryException
{
JSONObject
ret
=
userCache
.
getAdmin
();
if
(
null
!=
ret
)
{
return
ret
;
}
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
User
.
USER_ROLE
,
FilterOperator
.
EQUAL
,
Role
.
ADMIN_ROLE
)).
setPageCount
(
1
);
final
JSONObject
result
=
get
(
query
);
final
JSONArray
array
=
result
.
optJSONArray
(
Keys
.
RESULTS
);
if
(
0
==
array
.
length
())
{
return
null
;
}
ret
=
array
.
optJSONObject
(
0
);
userCache
.
putAdmin
(
ret
);
return
ret
;
}
}
skins
@
4bd78b7c
Subproject commit
b1349979a6e5b1e12fe6b27d0324017506f44da
d
Subproject commit
4bd78b7cfa6e23403ee7383677f323fa137b230
d
src/test/java/org/b3log/solo/AbstractTestCase.java
View file @
d93e378b
...
...
@@ -25,7 +25,6 @@ import org.b3log.latke.repository.jdbc.util.JdbcRepositories;
import
org.b3log.solo.api.MetaWeblogAPI
;
import
org.b3log.solo.cache.*
;
import
org.b3log.solo.repository.*
;
import
org.b3log.solo.repository.impl.*
;
import
org.b3log.solo.service.*
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.BeforeClass
;
...
...
@@ -100,7 +99,7 @@ public abstract class AbstractTestCase {
* @return category-tag repository
*/
public
CategoryTagRepository
getCategoryTagRepository
()
{
return
beanManager
.
getReference
(
CategoryTagRepository
Impl
.
class
);
return
beanManager
.
getReference
(
CategoryTagRepository
.
class
);
}
/**
...
...
@@ -109,7 +108,7 @@ public abstract class AbstractTestCase {
* @return category repository
*/
public
CategoryRepository
getCategoryRepository
()
{
return
beanManager
.
getReference
(
CategoryRepository
Impl
.
class
);
return
beanManager
.
getReference
(
CategoryRepository
.
class
);
}
/**
...
...
@@ -118,7 +117,7 @@ public abstract class AbstractTestCase {
* @return user repository
*/
public
UserRepository
getUserRepository
()
{
return
beanManager
.
getReference
(
UserRepository
Impl
.
class
);
return
beanManager
.
getReference
(
UserRepository
.
class
);
}
/**
...
...
@@ -127,7 +126,7 @@ public abstract class AbstractTestCase {
* @return link repository
*/
public
LinkRepository
getLinkRepository
()
{
return
beanManager
.
getReference
(
LinkRepository
Impl
.
class
);
return
beanManager
.
getReference
(
LinkRepository
.
class
);
}
/**
...
...
@@ -145,7 +144,7 @@ public abstract class AbstractTestCase {
* @return tag repository
*/
public
TagRepository
getTagRepository
()
{
return
beanManager
.
getReference
(
TagRepository
Impl
.
class
);
return
beanManager
.
getReference
(
TagRepository
.
class
);
}
/**
...
...
@@ -154,7 +153,7 @@ public abstract class AbstractTestCase {
* @return tag-article repository
*/
public
TagArticleRepository
getTagArticleRepository
()
{
return
beanManager
.
getReference
(
TagArticleRepository
Impl
.
class
);
return
beanManager
.
getReference
(
TagArticleRepository
.
class
);
}
/**
...
...
@@ -163,7 +162,7 @@ public abstract class AbstractTestCase {
* @return page repository
*/
public
PageRepository
getPageRepository
()
{
return
beanManager
.
getReference
(
PageRepository
Impl
.
class
);
return
beanManager
.
getReference
(
PageRepository
.
class
);
}
/**
...
...
@@ -172,7 +171,7 @@ public abstract class AbstractTestCase {
* @return comment repository
*/
public
CommentRepository
getCommentRepository
()
{
return
beanManager
.
getReference
(
CommentRepository
Impl
.
class
);
return
beanManager
.
getReference
(
CommentRepository
.
class
);
}
/**
...
...
@@ -199,7 +198,7 @@ public abstract class AbstractTestCase {
* @return plugin repository
*/
public
PluginRepository
getPluginRepository
()
{
return
beanManager
.
getReference
(
PluginRepository
Impl
.
class
);
return
beanManager
.
getReference
(
PluginRepository
.
class
);
}
/**
...
...
@@ -208,7 +207,7 @@ public abstract class AbstractTestCase {
* @return option repository
*/
public
OptionRepository
getOptionRepository
()
{
return
beanManager
.
getReference
(
OptionRepository
Impl
.
class
);
return
beanManager
.
getReference
(
OptionRepository
.
class
);
}
/**
...
...
src/test/java/org/b3log/solo/repository/
impl/
ArchiveDateArticleRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/ArchiveDateArticleRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.Transaction
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
ArchiveDateRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/ArchiveDateRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
junit.framework.Assert
;
import
org.apache.commons.lang.time.DateUtils
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
ArticleRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/ArticleRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.Query
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
CategoryRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/CategoryRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.solo.AbstractTestCase
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
CommentRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/CommentRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.solo.AbstractTestCase
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
LinkRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/LinkRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.solo.AbstractTestCase
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
OptionRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/OptionRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.Transaction
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
PageRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/PageRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.repository.Transaction
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
PluginRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/PluginRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.repository.PluginRepository
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
TagArticleRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/TagArticleRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
java.util.List
;
import
junit.framework.Assert
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
TagRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/TagRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
java.util.List
;
import
junit.framework.Assert
;
...
...
src/test/java/org/b3log/solo/repository/
impl/
UserRepositoryImplTestCase.java
→
src/test/java/org/b3log/solo/repository/UserRepositoryImplTestCase.java
View file @
d93e378b
...
...
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
repository
.
impl
;
package
org
.
b3log
.
solo
.
repository
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.model.Role
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment