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

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

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** EditPagexAction.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 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.bean.EditPagexFB;
import net.anotheria.anosite.gen.aswebdata.data.Pagex;
import net.anotheria.asg.util.helper.cmsview.CMSViewHelperUtil;
import net.anotheria.asg.util.helper.cmsview.CMSViewHelperRegistry;
import net.anotheria.asg.data.MultilingualObject;
import net.anotheria.webutils.bean.LabelValueBean;
import net.anotheria.anodoc.query2.QueryProperty;
import net.anotheria.asg.util.bean.LinkToMeBean;
import net.anotheria.anosite.gen.assitedata.data.Site;
import net.anotheria.anosite.gen.assitedata.data.NaviItem;
import net.anotheria.anosite.gen.assitedata.data.EntryPoint;
import net.anotheria.anosite.gen.assitedata.data.PageAlias;
import net.anotheria.anosite.gen.ascustomaction.data.ActionMappingDef;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.anosite.gen.assitedata.data.PageTemplate;
import net.anotheria.anosite.gen.anoaccessconfiguration.data.AccessOperation;
import net.anotheria.anosite.gen.asfeature.data.Feature;


public class EditPagexAction extends ShowPagexsAction{

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

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

	public ActionForward anoDocExecute(ActionMapping mapping, FormBean af, HttpServletRequest req, HttpServletResponse res) throws Exception{
		String id = getStringParameter(req, PARAM_ID);
		EditPagexFB form = new EditPagexFB() ;
		Pagex pagex = getASWebDataService().getPagex(id);
		checkPagexs(pagex, req);
		if(pagex instanceof LockableObject && !((LockableObject)pagex).isLocked() && isAutoLockingEnabled())
			lockPagexs(pagex, req);
		form.setId(pagex.getId());
		form.setName(pagex.getName());
		form.setLocalizedNameEN(pagex.getLocalizedNameEN());
		form.setLocalizedNameDE(pagex.getLocalizedNameDE());
		form.setTitleEN(pagex.getTitleEN());
		form.setTitleDE(pagex.getTitleDE());
		form.setKeywordsEN(pagex.getKeywordsEN());
		form.setKeywordsDE(pagex.getKeywordsDE());
		form.setDescriptionEN(pagex.getDescriptionEN());
		form.setDescriptionDE(pagex.getDescriptionDE());
		// mediaLinks is a table, storing size only
		form.setMediaLinks(pagex.getMediaLinksSize());
		// scripts is a table, storing size only
		form.setScripts(pagex.getScriptsSize());
		// localizations is a table, storing size only
		form.setLocalizations(pagex.getLocalizationsSize());
		form.setTemplate(pagex.getTemplate());
		form.setTemplatelink("assitedataPageTemplateEdit?pId="+pagex.getTemplate());
		// attributes is a table, storing size only
		form.setAttributes(pagex.getAttributesSize());
		// c1 is a table, storing size only
		form.setC1(pagex.getC1Size());
		// c2 is a table, storing size only
		form.setC2(pagex.getC2Size());
		// c3 is a table, storing size only
		form.setC3(pagex.getC3Size());
		// header is a table, storing size only
		form.setHeader(pagex.getHeaderSize());
		// footer is a table, storing size only
		form.setFooter(pagex.getFooterSize());
		form.setHttpsonly(pagex.getHttpsonly());
		form.setAccessOperation(pagex.getAccessOperation());
		form.setFeature(pagex.getFeature());
		form.setMultilingualInstanceDisabled(((MultilingualObject)pagex).isMultilingualDisabledInstance());
		form.setLocked(((LockableObject)pagex).isLocked());
		form.setLockerId(((LockableObject)pagex).getLockerId());
		form.setLockingTime(net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)pagex).getLockingTime()) + " automatic unlock expected AT : " + net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)pagex).getLockingTime() + getLockingTimeout()));


		//link template to ASSiteData.PageTemplate
		List pagetemplates = getASSiteDataService().getPageTemplates();
		List pagetemplatesValues = new ArrayList(pagetemplates.size()+1);
		pagetemplatesValues.add(new LabelValueBean("", "-----"));
		for (net.anotheria.anosite.gen.assitedata.data.PageTemplate pagetemplateTemp : pagetemplates){
			LabelValueBean bean = new LabelValueBean(pagetemplateTemp.getId(), pagetemplateTemp.getName() + " [" + pagetemplateTemp.getId() + "]" );
			pagetemplatesValues.add(bean);
		}
		form.setTemplateCollection(pagetemplatesValues);
		try{
			form.setTemplateCurrentValue(getASSiteDataService().getPageTemplate(pagex.getTemplate()).getName());
		}catch(Exception e){
			form.setTemplateCurrentValue("none");
			form.setTemplateIdOfCurrentValue("none");
		}

		//link accessOperation to AnoAccessConfiguration.AccessOperation
		List accessoperations = getAnoAccessConfigurationService().getAccessOperations();
		List accessoperationsValues = new ArrayList(accessoperations.size()+1);
		accessoperationsValues.add(new LabelValueBean("", "-----"));
		for (net.anotheria.anosite.gen.anoaccessconfiguration.data.AccessOperation accessoperationTemp : accessoperations){
			LabelValueBean bean = new LabelValueBean(accessoperationTemp.getId(), accessoperationTemp.getName() + " [" + accessoperationTemp.getId() + "]" );
			accessoperationsValues.add(bean);
		}
		form.setAccessOperationCollection(accessoperationsValues);
		try{
			form.setAccessOperationCurrentValue(getAnoAccessConfigurationService().getAccessOperation(pagex.getAccessOperation()).getName());
		}catch(Exception e){
			form.setAccessOperationCurrentValue("none");
			form.setAccessOperationIdOfCurrentValue("none");
		}

		//link feature to ASFeature.Feature
		List features = getASFeatureService().getFeatures();
		List featuresValues = new ArrayList(features.size()+1);
		featuresValues.add(new LabelValueBean("", "-----"));
		for (net.anotheria.anosite.gen.asfeature.data.Feature featureTemp : features){
			LabelValueBean bean = new LabelValueBean(featureTemp.getId(), featureTemp.getName() + " [" + featureTemp.getId() + "]" );
			featuresValues.add(bean);
		}
		form.setFeatureCollection(featuresValues);
		try{
			form.setFeatureCurrentValue(getASFeatureService().getFeature(pagex.getFeature()).getName());
		}catch(Exception e){
			form.setFeatureCurrentValue("none");
			form.setFeatureIdOfCurrentValue("none");
		}
		addBeanToRequest(req, "objectId" , pagex.getId());
		addBeanToRequest(req, "EditASWebDataPagexForm" , form);
		addBeanToRequest(req, "objectInfoString" , pagex.getObjectInfo().toString());
		addBeanToRequest(req, "apply.label.prefix", "Apply");
		addBeanToRequest(req, "save.label.prefix", "Save");

		addFieldExplanations(req, pagex);


		// Generating back link handling...
		List linksToMe = findLinksToCurrentDocument(pagex.getId());
		if (linksToMe.size()>0)
			req.setAttribute("linksToMe", linksToMe);
		return mapping.findForward("success");
	}

	private void addFieldExplanations(HttpServletRequest req, Pagex pagex) {
		if (!CMSViewHelperRegistry.getCMSViewHelpers("ASWebData.Pagex").isEmpty()) {
			String fieldDescription = null;
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "name");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.name", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "localizedName");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.localizedName", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "title");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.title", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "keywords");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.keywords", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "description");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.description", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "mediaLinks");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.mediaLinks", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "scripts");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.scripts", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "attributes");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.attributes", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "c1");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.c1", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "c2");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.c2", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "c3");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.c3", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "header");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.header", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "footer");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.footer", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "localizations");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.localizations", fieldDescription);
			fieldDescription = CMSViewHelperUtil.getFieldExplanation("ASWebData.Pagex", pagex, "httpsonly");
			if (fieldDescription!=null && fieldDescription.length()>0)
				req.setAttribute("description.httpsonly", fieldDescription);
		} //
	} //addFieldExplanations END


	private List findLinksToCurrentDocument(String documentId){
		List ret = new ArrayList();
		try{
			ret.addAll(findLinkToCurrentDocumentInASSiteDataSiteStartpage(documentId));
		}catch(Exception ignored){
		}
		try{
			ret.addAll(findLinkToCurrentDocumentInASSiteDataSiteSearchpage(documentId));
		}catch(Exception ignored){
		}
		try{
			ret.addAll(findLinkToCurrentDocumentInASSiteDataNaviItemInternalLink(documentId));
		}catch(Exception ignored){
		}
		try{
			ret.addAll(findLinkToCurrentDocumentInASSiteDataEntryPointStartPage(documentId));
		}catch(Exception ignored){
		}
		try{
			ret.addAll(findLinkToCurrentDocumentInASSiteDataPageAliasTargetPage(documentId));
		}catch(Exception ignored){
		}
		try{
			ret.addAll(findLinkToCurrentDocumentInASCustomActionActionMappingDefPage(documentId));
		}catch(Exception ignored){
		}
		return ret;
	}
	private List findLinkToCurrentDocumentInASSiteDataSiteStartpage(String documentId) throws net.anotheria.anosite.gen.assitedata.service.ASSiteDataServiceException{
		List ret = new ArrayList();
		QueryProperty p = new QueryProperty(Site.LINK_PROP_STARTPAGE, documentId);
		// temporarly - replacy with query property
		List list = getASSiteDataService().getSitesByProperty(p.getName(), p.getValue());
		for (Site doc : list ){
			ret.add(new LinkToMeBean(doc, "startpage"));
		}
		return ret;
	}
	private List findLinkToCurrentDocumentInASSiteDataSiteSearchpage(String documentId) throws net.anotheria.anosite.gen.assitedata.service.ASSiteDataServiceException{
		List ret = new ArrayList();
		QueryProperty p = new QueryProperty(Site.LINK_PROP_SEARCHPAGE, documentId);
		// temporarly - replacy with query property
		List list = getASSiteDataService().getSitesByProperty(p.getName(), p.getValue());
		for (Site doc : list ){
			ret.add(new LinkToMeBean(doc, "searchpage"));
		}
		return ret;
	}
	private List findLinkToCurrentDocumentInASSiteDataNaviItemInternalLink(String documentId) throws net.anotheria.anosite.gen.assitedata.service.ASSiteDataServiceException{
		List ret = new ArrayList();
		QueryProperty p = new QueryProperty(NaviItem.LINK_PROP_INTERNAL_LINK, documentId);
		// temporarly - replacy with query property
		List list = getASSiteDataService().getNaviItemsByProperty(p.getName(), p.getValue());
		for (NaviItem doc : list ){
			ret.add(new LinkToMeBean(doc, "internalLink"));
		}
		return ret;
	}
	private List findLinkToCurrentDocumentInASSiteDataEntryPointStartPage(String documentId) throws net.anotheria.anosite.gen.assitedata.service.ASSiteDataServiceException{
		List ret = new ArrayList();
		QueryProperty p = new QueryProperty(EntryPoint.LINK_PROP_START_PAGE, documentId);
		// temporarly - replacy with query property
		List list = getASSiteDataService().getEntryPointsByProperty(p.getName(), p.getValue());
		for (EntryPoint doc : list ){
			ret.add(new LinkToMeBean(doc, "startPage"));
		}
		return ret;
	}
	private List findLinkToCurrentDocumentInASSiteDataPageAliasTargetPage(String documentId) throws net.anotheria.anosite.gen.assitedata.service.ASSiteDataServiceException{
		List ret = new ArrayList();
		QueryProperty p = new QueryProperty(PageAlias.LINK_PROP_TARGET_PAGE, documentId);
		// temporarly - replacy with query property
		List list = getASSiteDataService().getPageAliassByProperty(p.getName(), p.getValue());
		for (PageAlias doc : list ){
			ret.add(new LinkToMeBean(doc, "targetPage"));
		}
		return ret;
	}
	private List findLinkToCurrentDocumentInASCustomActionActionMappingDefPage(String documentId) throws net.anotheria.anosite.gen.ascustomaction.service.ASCustomActionServiceException{
		List ret = new ArrayList();
		QueryProperty p = new QueryProperty(ActionMappingDef.LINK_PROP_PAGE, documentId);
		// temporarly - replacy with query property
		List list = getASCustomActionService().getActionMappingDefsByProperty(p.getName(), p.getValue());
		for (ActionMappingDef doc : list ){
			ret.add(new LinkToMeBean(doc, "page"));
		}
		return ret;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy