Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
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
Commits
ae4e39f0
Commit
ae4e39f0
authored
Jan 17, 2013
by
wmainlove@gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用advice简化一些代码
parent
989c6df0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
9 deletions
+63
-9
core/src/main/java/org/b3log/solo/processor/console/PluginConsole.java
.../java/org/b3log/solo/processor/console/PluginConsole.java
+5
-9
core/src/main/java/org/b3log/solo/processor/console/common/ProcessAuthAdvice.java
...3log/solo/processor/console/common/ProcessAuthAdvice.java
+58
-0
No files found.
core/src/main/java/org/b3log/solo/processor/console/PluginConsole.java
View file @
ae4e39f0
...
...
@@ -26,10 +26,12 @@ import org.b3log.latke.model.Plugin;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.annotation.Before
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.JSONRenderer
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.solo.processor.console.common.ProcessAuthAdvice
;
import
org.b3log.solo.service.PluginMgmtService
;
import
org.b3log.solo.service.PluginQueryService
;
import
org.b3log.solo.util.QueryResults
;
...
...
@@ -41,10 +43,12 @@ import org.json.JSONObject;
* Plugin console request processing.
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.1, Aug 9, 2012
* @author <a href="mailto:wmainlove@gmail.com">Love Yao</a>
* @version 1.1.0.0, Jan 17, 2013
* @since 0.4.0
*/
@RequestProcessor
@Before
(
adviceClass
=
ProcessAuthAdvice
.
class
)
public
final
class
PluginConsole
{
/**
...
...
@@ -93,10 +97,6 @@ public final class PluginConsole {
@RequestProcessing
(
value
=
"/console/plugin/status/"
,
method
=
HTTPRequestMethod
.
PUT
)
public
void
setPluginStatus
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
,
final
HTTPRequestContext
context
)
throws
Exception
{
if
(!
userUtils
.
isLoggedIn
(
request
,
response
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
}
final
JSONRenderer
renderer
=
new
JSONRenderer
();
...
...
@@ -150,10 +150,6 @@ public final class PluginConsole {
method
=
HTTPRequestMethod
.
GET
)
public
void
getPlugins
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
,
final
HTTPRequestContext
context
)
throws
Exception
{
if
(!
userUtils
.
isLoggedIn
(
request
,
response
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
}
final
JSONRenderer
renderer
=
new
JSONRenderer
();
...
...
core/src/main/java/org/b3log/solo/processor/console/common/ProcessAuthAdvice.java
0 → 100644
View file @
ae4e39f0
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
b3log
.
solo
.
processor
.
console
.
common
;
import
java.io.IOException
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.advice.BeforeRequestProcessAdvice
;
import
org.b3log.latke.servlet.advice.RequestProcessAdviceException
;
import
org.b3log.latke.servlet.advice.RequestReturnAdviceException
;
import
org.b3log.solo.util.Users
;
/**
* the common auth check before advice for admin console.
*
* @author <a href="mailto:wmainlove@gmail.com">Love Yao</a>
* @version 1.0.0.0, Jan 17, 2013
*/
public
class
ProcessAuthAdvice
extends
BeforeRequestProcessAdvice
{
/**
* User utilities.
*/
private
Users
userUtils
=
Users
.
getInstance
();
@Override
public
void
doAdvice
(
final
HTTPRequestContext
context
,
final
Map
<
String
,
Object
>
args
)
throws
RequestProcessAdviceException
{
if
(!
userUtils
.
isLoggedIn
(
context
.
getRequest
(),
context
.
getResponse
()))
{
try
{
context
.
getResponse
().
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
}
catch
(
final
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
throw
new
RequestReturnAdviceException
(
null
);
}
}
}
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