Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
net.anotheria.anosite.gen.asblogdata.action.MultiOpDialogPostsAction Maven / Gradle / Ivy
/**
********************************************************************************
*** MultiOpDialogPostsAction.java ***
*** generated by AnoSiteGenerator (ASG), Version: 2.6.3 ***
*** Copyright (C) 2005 - 2010 Anotheria.net, www.anotheria.net ***
*** All Rights Reserved. ***
********************************************************************************
*** Don't edit this code, if you aren't sure ***
*** that you do exactly know what you are doing! ***
*** It's better to invest time in the generator, as into the generated code. ***
********************************************************************************
*/
package net.anotheria.anosite.gen.asblogdata.action;
import net.anotheria.util.NumberUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionForward;
import net.anotheria.maf.action.ActionMapping;
import net.anotheria.maf.bean.FormBean;
import java.util.List;
import java.util.ArrayList;
import net.anotheria.anosite.gen.asblogdata.data.PostFactory;
import net.anotheria.anosite.gen.asblogdata.data.Post;
import net.anotheria.anosite.gen.asblogdata.bean.EditPostFB;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.asg.util.locking.helper.DocumentLockingHelper;
import net.anotheria.maf.bean.annotations.Form;
public class MultiOpDialogPostsAction extends BasePostAction{
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateMultiOpDialogAction
@Override
public ActionForward execute(ActionMapping mapping, @Form(EditPostFB.class) FormBean formBean, HttpServletRequest req, HttpServletResponse res) throws Exception{
return super.execute(mapping, formBean, req, res);
} //execute
public ActionForward anoDocExecute(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String path = stripPath(mapping.getPath());
if (path.equals("asblogdataPostDelete"))
return asblogdataPostDelete(mapping, af, req, res);
if (path.equals("asblogdataPostDuplicate"))
return asblogdataPostDuplicate(mapping, af, req, res);
if (path.equals("asblogdataPostUpdate"))
return asblogdataPostUpdate(mapping, af, req, res);
if (path.equals("asblogdataPostClose"))
return asblogdataPostClose(mapping, af, req, res);
if (path.equals("asblogdataPostLock"))
return asblogdataPostLock(mapping, af, req, res);
if (path.equals("asblogdataPostUnLock"))
return asblogdataPostUnLock(mapping, af, req, res);
throw new IllegalArgumentException("Unknown path: "+path);
}
public ActionForward asblogdataPostDelete(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String[] iDs = req.getParameterValues(PARAM_ID);
if (iDs == null){
throw new RuntimeException("Parameter " + PARAM_ID + " is not set.");
}
for (String id : iDs){
Post postCurr = getASBlogDataService().getPost(id);
if (postCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)postCurr;
DocumentLockingHelper.delete.checkExecutionPermission(lockable, false, getUserId(req));
}
getASBlogDataService().deletePost(id);
}
res.sendRedirect("asblogdataPostShow?ts="+System.currentTimeMillis());
return null;
}
public ActionForward asblogdataPostDuplicate(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
Post postSrc = getASBlogDataService().getPost(id);
Post postDest = PostFactory.createPost(postSrc);
Post postCreated = getASBlogDataService().createPost(postDest);
res.sendRedirect("asblogdataPostEdit?ts="+System.currentTimeMillis()+"&"+PARAM_ID+"="+postCreated.getId());
return null;
}
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateUpdateActionMethod
public ActionForward asblogdataPostUpdate(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
EditPostFB form = (EditPostFB) af;
boolean create = false;
Post post = null;
if (form.getId()==null) {
res.sendRedirect("asresourcedataLocalizationBundleShow?ts="+System.currentTimeMillis());
return null;
}
if (form.getId().length()>0){
post = (Post)getASBlogDataService().getPost(form.getId()).clone();
}else{
post = PostFactory.createPost();
create = true;
}
String nextAction = req.getParameter("nextAction");
if (nextAction == null || nextAction.length() == 0)
nextAction = "close";
//skipped id because it's readonly.
post.setName(form.getName());
post.setContent(form.getContent());
// skipped container tags
// skipped container comments
Post updatedCopy = null;
if (create){
updatedCopy = getASBlogDataService().createPost(post);
}else{
canUpdatePosts(post, req);
checkPosts(post, req);
updatedCopy = getASBlogDataService().updatePost(post);
}
if (nextAction.equalsIgnoreCase("stay")){
res.sendRedirect("asblogdataPostEdit?ts="+System.currentTimeMillis()+"&pId="+updatedCopy.getId());
}else{
unlockAfterUpdate(post, req);
res.sendRedirect("asblogdataPostShow?ts="+System.currentTimeMillis());
}
return null;
}
/**
* Simply unlocks document after updation.
*/
private void unlockAfterUpdate(Post post, HttpServletRequest req) throws Exception{
if(((LockableObject)post).isLocked())
unLockPosts(post, req, false);
}
public ActionForward asblogdataPostLock(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
Post postCurr = id != null && !id.equals("") ? getASBlogDataService().getPost(id) : null;
if(postCurr != null && postCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)postCurr;
DocumentLockingHelper.lock.checkExecutionPermission(lockable,false,getUserId(req));
lockPosts(postCurr, req);
}
res.sendRedirect(getRedirectUrl(req, postCurr));
return null;
}
public ActionForward asblogdataPostUnLock(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
Post postCurr = id != null && !id.equals("") ? getASBlogDataService().getPost(id) : null;
if(postCurr != null && postCurr instanceof LockableObject){
LockableObject lockable = (LockableObject)postCurr;
DocumentLockingHelper.unLock.checkExecutionPermission(lockable,isUserInRole(req, "admin"),getUserId(req));
unLockPosts(postCurr, req, false);
}
res.sendRedirect(getRedirectUrl(req, postCurr));
return null;
}
/**
* Simplest method for redirect url creation. nextAction == showEdit - going to 'editView', to 'listView' otherwise.
*/
private String getRedirectUrl(HttpServletRequest req, Post item){
String nextAction = req.getParameter("nextAction");
if (item==null || nextAction == null || nextAction.length() == 0)
return "asblogdataPostShow?ts="+System.currentTimeMillis();
else
return nextAction.equals("showEdit") ? "asblogdataPostEdit?ts="+System.currentTimeMillis()+"&pId="+item.getId()
: "asblogdataPostShow?ts="+System.currentTimeMillis();
}
public ActionForward asblogdataPostClose(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
Post postCurr = id != null && !id.equals("") ? getASBlogDataService().getPost(id) : null;
if(postCurr != null && postCurr instanceof LockableObject && ((LockableObject)postCurr).isLocked())
unLockPosts(postCurr, req, false);
res.sendRedirect("asblogdataPostShow?ts="+System.currentTimeMillis());
return null;
}
}