net.anotheria.anosite.gen.assitedata.action.EditMediaLinkAction Maven / Gradle / Ivy
/**
********************************************************************************
*** EditMediaLinkAction.java ***
*** generated by AnoSiteGenerator (ASG), Version: 3.2.2 ***
*** Copyright (C) 2005 - 2023 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.assitedata.action;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionCommand;
import net.anotheria.maf.action.ActionMapping;
import java.util.List;
import java.util.ArrayList;
import net.anotheria.anosite.gen.assitedata.bean.EditMediaLinkFB;
import net.anotheria.anosite.gen.assitedata.data.MediaLink;
import net.anotheria.webutils.bean.LabelValueBean;
import net.anotheria.anosite.gen.shared.data.MediaDescEnum;
import net.anotheria.anosite.gen.shared.data.LinkTypesEnum;
import net.anotheria.asg.data.LockableObject;
import net.anotheria.anosite.gen.asresourcedata.data.FileLink;
import net.anotheria.asg.exception.ConstantNotFoundException;
public class EditMediaLinkAction extends ShowMediaLinksAction{
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEditAction
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEditActionMethod
public ActionCommand anoDocExecute(ActionMapping mapping, HttpServletRequest req, HttpServletResponse res) throws Exception{
String id = getStringParameter(req, PARAM_ID);
EditMediaLinkFB form = new EditMediaLinkFB() ;
MediaLink medialink = getASSiteDataService().getMediaLink(id);
checkMediaLinks(medialink, req);
if(medialink instanceof LockableObject && !((LockableObject)medialink).isLocked() && isAutoLockingEnabled())
lockMediaLinks(medialink, req);
form.setId(medialink.getId());
form.setName(medialink.getName());
form.setFile(medialink.getFile());
form.setHref(medialink.getHref());
form.setType(medialink.getType());
form.setMedia(medialink.getMedia());
form.setRel(medialink.getRel());
form.setRev(medialink.getRev());
form.setHreflang(medialink.getHreflang());
form.setCharset(medialink.getCharset());
form.setBrowserFiltering(medialink.getBrowserFiltering());
form.setOnload(medialink.getOnload());
// guards is a table, storing size only
form.setGuards(medialink.getGuardsSize());
form.setLocked(((LockableObject)medialink).isLocked());
form.setLockerId(((LockableObject)medialink).getLockerId());
form.setLockingTime(net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)medialink).getLockingTime()) + " automatic unlock expected AT : " + net.anotheria.util.NumberUtils.makeISO8601TimestampString(((LockableObject)medialink).getLockingTime() + getLockingTimeout()));
//link file to ASResourceData.FileLink
List filelinks = getASResourceDataService().getFileLinks();
List filelinksValues = new ArrayList(filelinks.size()+1);
filelinksValues.add(new LabelValueBean("", "-----"));
for (net.anotheria.anosite.gen.asresourcedata.data.FileLink filelinkTemp : filelinks){
LabelValueBean bean = new LabelValueBean(filelinkTemp.getId(), filelinkTemp.getName() + " [" + filelinkTemp.getId() + "]" );
filelinksValues.add(bean);
}
form.setFileCollection(filelinksValues);
try{
form.setFileCurrentValue(getASResourceDataService().getFileLink(medialink.getFile()).getName());
}catch(Exception e){
form.setFileCurrentValue("none");
form.setFileIdOfCurrentValue("none");
}
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEnumerationPropertyHandling
//enumeration MediaDesc
MediaDescEnum[] MediaDesc_values = MediaDescEnum.values();
List MediaDesc_valuesListValues = new ArrayList(MediaDesc_values.length);
for (MediaDescEnum element : MediaDesc_values) {
LabelValueBean bean = new LabelValueBean(""+element.getValue(), element.name());
MediaDesc_valuesListValues.add(bean);
}
form.setMediaCollection(MediaDesc_valuesListValues);
try {
form.setMediaCurrentValue(MediaDescEnum.getConstantByValue(medialink.getMedia()).name());
}catch(net.anotheria.asg.exception.ConstantNotFoundException e){
} //try
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEnumerationPropertyHandling
//enumeration LinkTypes
LinkTypesEnum[] LinkTypes_values = LinkTypesEnum.values();
List LinkTypes_valuesListValues = new ArrayList(LinkTypes_values.length);
for (LinkTypesEnum element : LinkTypes_values) {
LabelValueBean bean = new LabelValueBean(""+element.getValue(), element.name());
LinkTypes_valuesListValues.add(bean);
}
form.setRelCollection(LinkTypes_valuesListValues);
try {
form.setRelCurrentValue(LinkTypesEnum.getConstantByValue(medialink.getRel()).name());
}catch(net.anotheria.asg.exception.ConstantNotFoundException e){
} //try
// Generated by: class net.anotheria.asg.generator.view.action.ModuleActionsGenerator.generateEnumerationPropertyHandling
//enumeration LinkTypes already prepared.
form.setRevCollection(LinkTypes_valuesListValues);
try {
form.setRevCurrentValue(LinkTypesEnum.getConstantByValue(medialink.getRev()).name());
}catch(net.anotheria.asg.exception.ConstantNotFoundException e){
} //try
addBeanToRequest(req, "objectId" , medialink.getId());
addBeanToRequest(req, "EditASSiteDataMediaLinkForm" , form);
addBeanToRequest(req, "objectInfoString" , medialink.getObjectInfo().toString());
addBeanToRequest(req, "apply.label.prefix", "Apply");
addBeanToRequest(req, "save.label.prefix", "Save");
addBeanToRequest(req, "transfer.label.prefix", "Transfer");
addFieldExplanations(req, medialink);
return mapping.success();
}
}