All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.anosite.gen.aswebdata.action.MultiOpDialogPagexsAction Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** MultiOpDialogPagexsAction.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.aswebdata.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.aswebdata.data.PagexFactory;
import net.anotheria.anosite.gen.aswebdata.data.Pagex;
import net.anotheria.anosite.gen.aswebdata.bean.EditPagexFB;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.asg.util.locking.helper.DocumentLockingHelper;
import net.anotheria.asg.data.MultilingualObject;
import net.anotheria.maf.bean.annotations.Form;


public class MultiOpDialogPagexsAction extends BasePagexAction{

	// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateMultiOpDialogAction


	@Override
	public ActionForward execute(ActionMapping mapping, @Form(EditPagexFB.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("aswebdataPagexDelete"))
			return aswebdataPagexDelete(mapping, af, req, res);
		if (path.equals("aswebdataPagexDuplicate"))
			return aswebdataPagexDuplicate(mapping, af, req, res);
		if (path.equals("aswebdataPagexUpdate"))
			return aswebdataPagexUpdate(mapping, af, req, res);
		if (path.equals("aswebdataPagexClose"))
			return aswebdataPagexClose(mapping, af, req, res);
		if (path.equals("aswebdataPagexCopyLang"))
			return aswebdataPagexCopyLang(mapping, af, req, res);
		if (path.equals("aswebdataPagexSwitchMultilang"))
			return aswebdataPagexSwitchMultilang(mapping, af, req, res);
		if (path.equals("aswebdataPagexLock"))
			return aswebdataPagexLock(mapping, af, req, res);
		if (path.equals("aswebdataPagexUnLock"))
			return aswebdataPagexUnLock(mapping, af, req, res);
		throw new IllegalArgumentException("Unknown path: "+path);
	}

	public ActionForward aswebdataPagexDelete(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){
		Pagex pagexCurr = getASWebDataService().getPagex(id);
		if (pagexCurr instanceof LockableObject){ 
		LockableObject lockable = (LockableObject)pagexCurr;
		DocumentLockingHelper.delete.checkExecutionPermission(lockable, false, getUserId(req));
		}
		getASWebDataService().deletePagex(id);
	}
	res.sendRedirect("aswebdataPagexShow?ts="+System.currentTimeMillis());
	return null;
}

public ActionForward aswebdataPagexDuplicate(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	Pagex pagexSrc = getASWebDataService().getPagex(id);
	Pagex pagexDest = PagexFactory.createPagex(pagexSrc);











	Pagex pagexCreated = getASWebDataService().createPagex(pagexDest);
	res.sendRedirect("aswebdataPagexEdit?ts="+System.currentTimeMillis()+"&"+PARAM_ID+"="+pagexCreated.getId());

	return null;
}

// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateUpdateActionMethod

public ActionForward aswebdataPagexUpdate(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	EditPagexFB form = (EditPagexFB) af;
	boolean create = false;
	Pagex pagex = null;
	if (form.getId()==null) {
	res.sendRedirect("asresourcedataLocalizationBundleShow?ts="+System.currentTimeMillis());
	return null;
}
if (form.getId().length()>0){
	pagex = (Pagex)getASWebDataService().getPagex(form.getId()).clone();
}else{
	pagex = PagexFactory.createPagex();
	create = true;
}

String nextAction = req.getParameter("nextAction");
if (nextAction == null || nextAction.length() == 0)
	nextAction = "close";

//skipped id because it's readonly.
pagex.setName(form.getName());
pagex.setLocalizedNameEN(form.getLocalizedNameEN());
pagex.setLocalizedNameDE(form.getLocalizedNameDE());
pagex.setTitleEN(form.getTitleEN());
pagex.setTitleDE(form.getTitleDE());
pagex.setKeywordsEN(form.getKeywordsEN());
pagex.setKeywordsDE(form.getKeywordsDE());
pagex.setDescriptionEN(form.getDescriptionEN());
pagex.setDescriptionDE(form.getDescriptionDE());
// skipped container mediaLinks
// skipped container scripts
// skipped container localizations
pagex.setTemplate(form.getTemplate());
// skipped container attributes
// skipped container c1
// skipped container c2
// skipped container c3
// skipped container header
// skipped container footer
pagex.setHttpsonly(form.isHttpsonly());
pagex.setAccessOperation(form.getAccessOperation());
pagex.setFeature(form.getFeature());

Pagex updatedCopy = null;
if (create){
	updatedCopy = getASWebDataService().createPagex(pagex);
}else{
	canUpdatePagexs(pagex, req);
	checkPagexs(pagex, req);
	updatedCopy = getASWebDataService().updatePagex(pagex);
}
if (nextAction.equalsIgnoreCase("stay")){
	res.sendRedirect("aswebdataPagexEdit?ts="+System.currentTimeMillis()+"&pId="+updatedCopy.getId());
}else{
	unlockAfterUpdate(pagex, req);
	res.sendRedirect("aswebdataPagexShow?ts="+System.currentTimeMillis());
}
return null;
}
/**
 * Simply unlocks document after updation.
 */
private void unlockAfterUpdate(Pagex pagex, HttpServletRequest req) throws Exception{
	if(((LockableObject)pagex).isLocked())
		unLockPagexs(pagex, req, false);
}

public ActionForward aswebdataPagexCopyLang(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String sourceLanguage = req.getParameter("pSrcLang");
	if (sourceLanguage==null || sourceLanguage.length()==0)
		throw new RuntimeException("No source language");

	String destLanguage = req.getParameter("pDestLang");
	if (destLanguage==null || destLanguage.length()==0)
		throw new RuntimeException("No destination language");

	String id = getStringParameter(req, PARAM_ID);
	Pagex pagex = getASWebDataService().getPagex(id);
	canUpdatePagexs(pagex, req);
	checkPagexs(pagex, req);
	pagex.copyLANG2LANG(sourceLanguage, destLanguage);
	getASWebDataService().updatePagex(pagex);
	res.sendRedirect("aswebdataPagexEdit?ts="+System.currentTimeMillis()+"&pId="+id);
	return null;
}

public ActionForward aswebdataPagexSwitchMultilang(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	String value = getStringParameter(req, "value");
	Pagex pagex = getASWebDataService().getPagex(id);
	canUpdatePagexs(pagex, req);
	checkPagexs(pagex, req);
	((MultilingualObject)pagex).setMultilingualDisabledInstance(Boolean.valueOf(value));
	getASWebDataService().updatePagex(pagex);
	res.sendRedirect("aswebdataPagexEdit?ts="+System.currentTimeMillis()+"&pId="+id);
	return null;
}

public ActionForward aswebdataPagexLock(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	Pagex pagexCurr = id != null && !id.equals("") ? getASWebDataService().getPagex(id) : null;
	if(pagexCurr != null && pagexCurr instanceof LockableObject){ 
		LockableObject lockable = (LockableObject)pagexCurr;
		DocumentLockingHelper.lock.checkExecutionPermission(lockable,false,getUserId(req));
		lockPagexs(pagexCurr, req);
	}
	res.sendRedirect(getRedirectUrl(req, pagexCurr));
	return null;
}

public ActionForward aswebdataPagexUnLock(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	Pagex pagexCurr = id != null && !id.equals("") ? getASWebDataService().getPagex(id) : null;
	if(pagexCurr != null && pagexCurr instanceof LockableObject){ 
		LockableObject lockable = (LockableObject)pagexCurr;
		DocumentLockingHelper.unLock.checkExecutionPermission(lockable,isUserInRole(req, "admin"),getUserId(req));
		unLockPagexs(pagexCurr, req, false);
	}
	res.sendRedirect(getRedirectUrl(req, pagexCurr));
	return null;
}

/**
 * Simplest method for redirect url creation. nextAction == showEdit - going to 'editView', to 'listView' otherwise. 
 */
private String getRedirectUrl(HttpServletRequest req, Pagex item){
	String nextAction = req.getParameter("nextAction");
	if (item==null || nextAction == null || nextAction.length() == 0)
		return "aswebdataPagexShow?ts="+System.currentTimeMillis();
	else
		return nextAction.equals("showEdit") ? "aswebdataPagexEdit?ts="+System.currentTimeMillis()+"&pId="+item.getId()
		       : "aswebdataPagexShow?ts="+System.currentTimeMillis();
}

public ActionForward aswebdataPagexClose(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
	String id = getStringParameter(req, PARAM_ID);
	Pagex pagexCurr = id != null && !id.equals("") ? getASWebDataService().getPagex(id) : null;
	if(pagexCurr != null && pagexCurr instanceof LockableObject && ((LockableObject)pagexCurr).isLocked()) 
		unLockPagexs(pagexCurr, req, false);
	res.sendRedirect("aswebdataPagexShow?ts="+System.currentTimeMillis());
	return null;
}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy