I'm trying to parse lint-result.xml produced by Jenkins. I created stand-alone project that takes lint result file and parse it with XStream 1.4.1 (version that is currently used by Jenkins from what I seen in documentation) this works absolutely fine. However when I move code to Jenkins plugin (it is post-build plugin) I'm getting following error
com.thoughtworks.xstream.mapper.CannotResolveClassException: com.peter.android_lint.parser.LintIssues : com.peter.android_lint.parser.LintIssues
at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:68)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:71)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:86)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:96)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:56)
at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:136)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:926)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:912)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:864)
at com.peter.android_lint.parser.LintParser.parse(LintParser.java:25)
at com.peter.ReportPublisher.findFiles(ReportPublisher.java:61)
at com.peter.ReportPublisher.perform(ReportPublisher.java:48)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:786)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:733)
at hudson.model.Run.execute(Run.java:1592)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)
Parser class
public class LintParser {
private File lintResult;
public void parse(String fileName) {
lintResult = new File(fileName);
XStream xstream = new XStream();
xstream.alias("issues", LintIssues.class);
xstream.alias("issue", LintIssue.class);
xstream.alias("location", Location.class);
//xstream.processAnnotations(new Class[]{LintIssues.class, LintIssue.class, Location.class});
LintIssues lintIssues = null;
FileInputStream fis = null;
BufferedInputStream bis = null;
try {
fis = new FileInputStream(lintResult);
bis = new BufferedInputStream(fis);
lintIssues = (LintIssues) xstream.fromXML(bis);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
List<LintIssue> issueList = lintIssues.getIssueList();
for (LintIssue issue : issueList) {
printIssue(issue);
}
if(bis != null){
try{
bis.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private void printIssue(LintIssue issue) {
System.out.println("ID= " + issue.getId() + " , severity= " + issue.getSeverity() + " , priority= " + issue.getPriority());
for (Location location : issue.getLocations()) {
printLocation(location);
}
}
private void printLocation(Location location) {
System.out.println("\t Location file=" + location.getFilename());
}
}
LintIssues class
//#XStreamAlias("issues")
public class LintIssues {
#XStreamImplicit(itemFieldName = "issue")
private List<LintIssue> issueList = new ArrayList<LintIssue>();
public LintIssues(List<LintIssue> issueList) {
this.issueList = issueList;
}
public List<LintIssue> getIssueList() {
return issueList;
}
}
LintIssue class
//#XStreamAlias("issue")
public class LintIssue {
#XStreamAlias("id")
#XStreamAsAttribute
private String id;
#XStreamAlias("severity")
#XStreamAsAttribute
private String severity;
#XStreamAlias("category")
#XStreamAsAttribute
private String category;
#XStreamAlias("priority")
#XStreamAsAttribute
private int priority;
#XStreamAlias("summary")
#XStreamAsAttribute
private String summary;
#XStreamAlias("explanation")
#XStreamAsAttribute
private String explanation;
#XStreamAlias("message")
#XStreamAsAttribute
private String message;
#XStreamAlias("errorLine1")
#XStreamAsAttribute
private String errorLine1;
#XStreamAlias("errorLine2")
#XStreamAsAttribute
private String errorLine2;
#XStreamImplicit(itemFieldName = "location")
private List<Location> locations = new ArrayList<Location>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getSeverity() {
return severity;
}
public void setSeverity(String severity) {
this.severity = severity;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getExplanation() {
return explanation;
}
public void setExplanation(String explanation) {
this.explanation = explanation;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getErrorLine1() {
return errorLine1;
}
public void setErrorLine1(String errorLine1) {
this.errorLine1 = errorLine1;
}
public String getErrorLine2() {
return errorLine2;
}
public void setErrorLine2(String errorLine2) {
this.errorLine2 = errorLine2;
}
public List<Location> getLocations() {
return locations == null ? new ArrayList<Location>() : locations;
}
public void setLocations(List<Location> locations) {
this.locations = locations;
}
}
Location class
//#XStreamAlias("location")
public class Location implements Serializable {
private static final long serialVersionUID = 1128640353127613495L;
#XStreamAlias("file")
#XStreamAsAttribute
private String filename;
#XStreamAlias("line")
#XStreamAsAttribute
private int lineNumber;
#XStreamAlias("column")
#XStreamAsAttribute
private int column;
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public int getLineNumber() {
return lineNumber;
}
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
}
public int getColumn() {
return column;
}
public void setColumn(int column) {
this.column = column;
}
}
You might have better luck getting a good answer to this question by participating in the jenkinsci-dev mailing list.
Related
I have one question. I am using neo4j-ogm snapshot 1.5 .
I have the following classes:
#NodeEntity
public abstract class Entity {
#GraphId
protected Long id;
#Expose
protected String code = null;
#Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || id == null || getClass() != o.getClass())
return false;
Entity entity = (Entity) o;
if (!id.equals(entity.id))
return false;
return true;
}
#Override
public int hashCode() {
return (id == null) ? -1 : id.hashCode();
}
public Long getId(){
return id;
}
public void setId(Long neo4jId){
this.id = neo4jId;
}
public String getCode(){
return code;
}
public void setCode(String code){
this.code = code;
}
}
public class PropertyGroup extends Entity{
#Expose
private String name;
public PropertyGroup(){
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class User extends Entity {
private Long registration_date;
private Long last_login_date;
private Boolean is_admin = false;
private String push_dev;
private String push_id;
private Boolean push_enabled = false;
#Expose
private String avatar;
#Expose
private String avatarUrl;
#Expose
private String name;
#Expose
private volatile String password;
#Expose
private int likes = 0;
#Expose
private int questionCount = 0;
#Expose
private int followersCount = 0;
#Expose
private boolean isFollowing = false;
// public Set<UserPropertyRelation> properties;
// #Relationship(type = ModelRelType.ANSWERED)
// public Set<UserAnsweredRelation> userAnswers;
//
// #Relationship(type = ModelRelType.LIKES)
// private Set<LikesQuestionRelation> questionsLiked;
#Expose
#Relationship(type = ModelRelType.HAS_PROPERTY)
private Set<PropertyGroup> properties;
// private Profile userProfile;
// private List<Fact> facts;
// #Expose
// #Relationship(type = ModelRelType.OWNS)
// private List<Question> questions;
public User(){
// this.properties = new LinkedHashSet<UserPropertyRelation>();
// this.userAnswers = new LinkedHashSet<UserAnsweredRelation>();
// this.userProperties = new HashSet<PropertyGroup>();
// this.setFacts(new ArrayList<Fact>());
this.properties = new HashSet<PropertyGroup>();
}
public User(long regDate, long lastLoginDate, boolean isAdmin,
String pushDev, String pushId, boolean pushEnabled){
this();
this.registration_date = regDate;
this.last_login_date = lastLoginDate;
this.is_admin = isAdmin;
this.push_dev = pushDev;
this.push_id = pushId;
this.push_enabled = pushEnabled;
}
// public void addUserAnsweredRelation(UserAnsweredRelation answer){
// answer.setStartNode(this);
// this.userAnswers.add(answer);
// }
//
// public Set<UserAnsweredRelation> getUserAnsweredRelations() {
// return this.userAnswers;
// }
// public void setUserAnsweredRelations(Set<UserAnsweredRelation> userAnswers){
// for(UserAnsweredRelation a : userAnswers){
// a.setStartNode(this);
// }
//
// this.userAnswers = userAnswers;
// }
//
// public void addUserPropertyRelation(UserPropertyRelation rel){
// rel.setUser(this);
// properties.add(rel);
// }
//
// public void setUserPropertyRelations(Set<UserPropertyRelation> properties){
// for(UserPropertyRelation r: properties){
// r.setUser(this);
// }
//
// this.properties = properties;
// }
// public Set<UserPropertyRelation> getUserPropertyRelations(){
// return this.properties;
// }
public long getRegistrationDate() {
return registration_date;
}
public void setRegistrationDate(long registrationDate) {
this.registration_date = registrationDate;
}
public long getLastLoginDate() {
return last_login_date;
}
public void setLastLoginDate(long lastLoginDate) {
this.last_login_date = lastLoginDate;
}
public boolean isAdmin() {
return is_admin;
}
public void setAdmin(boolean isAdmin) {
this.is_admin = isAdmin;
}
public String getPushDev() {
return push_dev;
}
public void setPushDev(String pushDev) {
this.push_dev = pushDev;
}
public String getPushId() {
return push_id;
}
public void setPushId(String pushId) {
this.push_id = pushId;
}
public boolean isPushEnabled() {
return push_enabled;
}
public void setPushEnabled(boolean pushEnabled) {
this.push_enabled = pushEnabled;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<PropertyGroup> getProperties() {
return properties;
}
public void setProperties(Set<PropertyGroup> properties) {
this.properties = properties;
}
// public Profile getUserProfile() {
// return userProfile;
// }
//
// public void setUserProfile(Profile userProfile) {
// this.userProfile = userProfile;
// }
// public Set<LikesQuestionRelation> getQuestionsLiked() {
// return questionsLiked;
// }
//
// public void setQuestionsLiked(Set<LikesQuestionRelation> likes) {
// this.questionsLiked = likes;
// }
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
// public List<Fact> getFacts() {
// return facts;
// }
//
// public void setFacts(List<Fact> facts) {
// this.facts = facts;
// }
public String getAvatarUrl() {
return avatarUrl;
}
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
public int getLikes() {
return likes;
}
public void setLikes(int likes) {
this.likes = likes;
}
public int getQuestionCount() {
return questionCount;
}
public void setQuestionCount(int questionCount) {
this.questionCount = questionCount;
}
public int getFollowersCount() {
return followersCount;
}
public void setFollowersCount(int followersCount) {
this.followersCount = followersCount;
}
public boolean isFollowing() {
return isFollowing;
}
public void setFollowing(boolean isFollowing) {
this.isFollowing = isFollowing;
}
// public List<Question> getQuestions() {
// return questions;
// }
//
// public void setQuestions(List<Question> questions) {
// this.questions = questions;
// }
When I am trying to do the following:
SessionFactory sessionFactory = new SessionFactory(modelsPackageName);
Session session = sessionFactory.openSession(url);
String cypher = "MATCH (u:User {code: {CODE}})-[h:HAS_PROPERTY]->(pg:PropertyGroup) " +
"RETURN u, h, pg";
Map<String, Object> params = new HashMap<String, Object>();
params.put("CODE", "fc48b19ba6f8427a03d6e5990bcef99a28f55592b80fe38731cf805ed188cabf");
// System.out.println(Util.mergeParamsWithCypher(cypher, params));
User u = session.queryForObject(User.class, cypher, params);
The user Object (u) never contains any properties (PropertyGroup entity is not mapped).
What am I doing wrong?
Any help would be appreciated.
Regards,
Alex
If you're using queryForObject return just one column- the object, in your case u.
Neo4j OGM 1.x does not support mapping of custom query results to domain entities, so you will have to return the entity ID, and then do an additional load-by-id specifying a custom depth.
OGM 2.0 (currently 2.0.0-M01) does support mapping custom query results to entities. Your query will remain the same (i.e. return u,h,pg) but instead you'll use the query() method that returns a Result. From the result, you'll be able to get your User entity by column-name u and it'll be hydrated with the PropertyGroups it is related to.
Update:
The dependencies for OGM 2.0.0-M01 are
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-api</artifactId>
<version>2.0.0-M01</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-core</artifactId>
<version>2.0.0-M01</version>
</dependency>
Be sure to read the about the configuration changes since you're upgrading from OGM 1.x http://neo4j.com/docs/ogm/java/2.0.0-M01/#reference_setup
A summary of new features: http://neo4j.com/blog/neo4j-ogm-2-0-milestone-1/
Hi I am new to richfaces picklist , My scenario is to load hashmap and by selecting the key value i need to load it in picklist. After getting the key i need to generate dynamic jasper report. My problem is while try to load the map value i end up with Typecast exception with the examples i came accross.
<rich:pickList id="pickList1" value="#{xxx.selectionBean.fieldNameList}" sourceCaption="Fields to be Selected for Report"
targetCaption="Selected Fields for Report" listWidth="165px" listHeight="100px" orderable="true" converter="pickListConvertor">
<f:selectItems value="#{xxx.commencementworkBean.commencementList}" var="s"
itemLabel="#{s.key}" itemValue="#{s.value}" />
<f:converter converterId="pickListConvertor" />
</rich:pickList>
SelectionBean
package xxx.xxx.xxx.bean;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class SelectionBean implements Serializable{
/**
vs00324258
*/
private static final long serialVersionUID = -1597587007448113972L;
private String key;
private String value;
List<SelectionBean> fieldNameList = new ArrayList<SelectionBean>();
List<SelectionBean> dynamicList = new ArrayList<SelectionBean>();
List<Object> fieldList = new ArrayList<Object>();
public List<SelectionBean> getFieldNameList() {
return fieldNameList;
}
public void setFieldNameList(List<SelectionBean> fieldNameList) {
this.fieldNameList = fieldNameList;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public List<SelectionBean> getDynamicList() {
return dynamicList;
}
public void setDynamicList(List<SelectionBean> dynamicList) {
this.dynamicList = dynamicList;
}
public List<Object> getFieldList() {
return fieldList;
}
public void setFieldList(List<Object> fieldList) {
this.fieldList = fieldList;
}
}
PicklistConvertor
#FacesConverter(value = "pickListConvertor")
public class PickListConvertor implements Converter{
#Override
public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
if(submittedValue.trim().equals("")){
return null;
}else{
return submittedValue.toString();
}
}
#Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (value == null || value.equals("")) {
return "";
} else {
return String.valueOf(((SelectionBean) value));
}
}
}
CommencementWorkBean
public class CommencementworkBean implements Serializable{
/**
vs00324258
*/
private static final long serialVersionUID = -5020735931910106047L;
private String agreementnum;
private String agreementtype;
private String authorityentering;
private String contractorname;
private String tendercalledbyoffice;
private Date dateofagreemtn;
private Date dateofcommofwork;
private Date dateofintendedcompl;
private Date tenderdate;
private Date duedateofmeterialworks;
private Date regdateofcontract;
private String detailsofsecurdeposit;
private String estamtsanctionno;
private String estimateamt;
private String isitlowest;
private String nameofwork;
private String orignalorsupplemental;
private String pricevariationapplicable;
private String reasonforlowest;
private String regnumberofvendor;
private String remarks;
private String taxes;
private String statusCode;
private String tenderauthority;
private String tenderpremium;
private String validityofsecurdeposit;
private String valueofcontract;
private String worldbankapproval;
private boolean searchCommTableEnabled = false;
private String fieldName;
private Map<String,Object> commencementList = new TreeMap<String, Object>();
private String headerName;
private String valueName;
private List<CommencementworkBean>searchCommencementBeanList = new ArrayList<CommencementworkBean>();
public String getAgreementnum() {
return agreementnum;
}
public void setAgreementnum(String agreementnum) {
this.agreementnum = agreementnum;
}
public String getAgreementtype() {
return agreementtype;
}
public void setAgreementtype(String agreementtype) {
this.agreementtype = agreementtype;
}
public String getAuthorityentering() {
return authorityentering;
}
public void setAuthorityentering(String authorityentering) {
this.authorityentering = authorityentering;
}
public String getContractorname() {
return contractorname;
}
public void setContractorname(String contractorname) {
this.contractorname = contractorname;
}
public String getTendercalledbyoffice() {
return tendercalledbyoffice;
}
public void setTendercalledbyoffice(String tendercalledbyoffice) {
this.tendercalledbyoffice = tendercalledbyoffice;
}
public Date getDateofagreemtn() {
return dateofagreemtn;
}
public void setDateofagreemtn(Date dateofagreemtn) {
this.dateofagreemtn = dateofagreemtn;
}
public Date getDateofcommofwork() {
return dateofcommofwork;
}
public void setDateofcommofwork(Date dateofcommofwork) {
this.dateofcommofwork = dateofcommofwork;
}
public Date getDateofintendedcompl() {
return dateofintendedcompl;
}
public void setDateofintendedcompl(Date dateofintendedcompl) {
this.dateofintendedcompl = dateofintendedcompl;
}
public Date getTenderdate() {
return tenderdate;
}
public void setTenderdate(Date tenderdate) {
this.tenderdate = tenderdate;
}
public Date getRegdateofcontract() {
return regdateofcontract;
}
public void setRegdateofcontract(Date regdateofcontract) {
this.regdateofcontract = regdateofcontract;
}
public String getDetailsofsecurdeposit() {
return detailsofsecurdeposit;
}
public void setDetailsofsecurdeposit(String detailsofsecurdeposit) {
this.detailsofsecurdeposit = detailsofsecurdeposit;
}
public String getEstamtsanctionno() {
return estamtsanctionno;
}
public void setEstamtsanctionno(String estamtsanctionno) {
this.estamtsanctionno = estamtsanctionno;
}
public String getEstimateamt() {
return estimateamt;
}
public void setEstimateamt(String estimateamt) {
this.estimateamt = estimateamt;
}
public String getIsitlowest() {
return isitlowest;
}
public void setIsitlowest(String isitlowest) {
this.isitlowest = isitlowest;
}
public String getNameofwork() {
return nameofwork;
}
public void setNameofwork(String nameofwork) {
this.nameofwork = nameofwork;
}
public String getOrignalorsupplemental() {
return orignalorsupplemental;
}
public void setOrignalorsupplemental(String orignalorsupplemental) {
this.orignalorsupplemental = orignalorsupplemental;
}
public String getPricevariationapplicable() {
return pricevariationapplicable;
}
public void setPricevariationapplicable(String pricevariationapplicable) {
this.pricevariationapplicable = pricevariationapplicable;
}
public String getReasonforlowest() {
return reasonforlowest;
}
public void setReasonforlowest(String reasonforlowest) {
this.reasonforlowest = reasonforlowest;
}
public String getRegnumberofvendor() {
return regnumberofvendor;
}
public void setRegnumberofvendor(String regnumberofvendor) {
this.regnumberofvendor = regnumberofvendor;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getTaxes() {
return taxes;
}
public void setTaxes(String taxes) {
this.taxes = taxes;
}
public String getTenderauthority() {
return tenderauthority;
}
public void setTenderauthority(String tenderauthority) {
this.tenderauthority = tenderauthority;
}
public String getTenderpremium() {
return tenderpremium;
}
public void setTenderpremium(String tenderpremium) {
this.tenderpremium = tenderpremium;
}
public String getValidityofsecurdeposit() {
return validityofsecurdeposit;
}
public void setValidityofsecurdeposit(String validityofsecurdeposit) {
this.validityofsecurdeposit = validityofsecurdeposit;
}
public String getValueofcontract() {
return valueofcontract;
}
public void setValueofcontract(String valueofcontract) {
this.valueofcontract = valueofcontract;
}
public String getWorldbankapproval() {
return worldbankapproval;
}
public void setWorldbankapproval(String worldbankapproval) {
this.worldbankapproval = worldbankapproval;
}
public Date getDuedateofmeterialworks() {
return duedateofmeterialworks;
}
public void setDuedateofmeterialworks(Date duedateofmeterialworks) {
this.duedateofmeterialworks = duedateofmeterialworks;
}
public boolean isSearchCommTableEnabled() {
return searchCommTableEnabled;
}
public void setSearchCommTableEnabled(boolean searchCommTableEnabled) {
this.searchCommTableEnabled = searchCommTableEnabled;
}
public List<CommencementworkBean> getSearchCommencementBeanList() {
return searchCommencementBeanList;
}
public void setSearchCommencementBeanList(
List<CommencementworkBean> searchCommencementBeanList) {
this.searchCommencementBeanList = searchCommencementBeanList;
}
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public String getHeaderName() {
return headerName;
}
public void setHeaderName(String headerName) {
this.headerName = headerName;
}
public String getValueName() {
return valueName;
}
public void setValueName(String valueName) {
this.valueName = valueName;
}
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public Map<String, Object> getCommencementList() {
return commencementList;
}
public void setCommencementList(Map<String, Object> commencementList) {
this.commencementList = commencementList;
}
}
What should i do to get key and value from the selection list.
Exception
java.lang.String cannot be cast to xxx.xxx.xxx.bean.SelectionBean
java.lang.ClassCastException: java.lang.String cannot be cast to xxx.xxx.xxx.bean.SelectionBean
at org.gov.tnwrd.utils.PickListConvertor.getAsString(PickListConvertor.java:26)
at org.richfaces.component.util.InputUtils.getConvertedStringValue(InputUtils.java:96)
at org.richfaces.component.util.InputUtils.getConvertedStringValue(InputUtils.java:88)
at org.richfaces.renderkit.SelectHelper.generateClientSelectItem(SelectHelper.java:80)
at org.richfaces.renderkit.SelectManyHelper.getClientSelectItems(SelectManyHelper.java:254)
at org.richfaces.renderkit.SelectManyRendererBase.getClientSelectItems(SelectManyRendererBase.java:60)
at org.richfaces.renderkit.html.PickListRenderer.encodeEnd(PickListRenderer.java:202)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:276)
at org.richfaces.renderkit.html.PanelRenderer.encodeEnd(PanelRenderer.java:181)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:276)
at org.richfaces.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:57)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at org.richfaces.context.ExtendedPartialViewContextImpl$RenderVisitCallback.visit(ExtendedPartialViewContextImpl.java:504)
at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:321)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1612)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at org.richfaces.component.AbstractTogglePanel.visitTree(AbstractTogglePanel.java:743)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIForm.visitTree(UIForm.java:371)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialRenderPhase(ExtendedPartialViewContextImpl.java:272)
at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:194)
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:981)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:409)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
I am new to Struts2. I am unable to get file name and path. Kindly help any one.
import java.io.File;
import java.util.ResourceBundle;
import org.apache.commons.io.FileUtils;
import nre.dao.DBconnection;
import com.mysql.jdbc.Connection;
import com.opensymphony.xwork2.ActionSupport;
public class AddProperty extends ActionSupport
{
private String propertyid;
private String propertyname;
private String country;
private String state;
private String city;
private String description;
private File uploadphoto;
private String photofiletype;
private String photoname;
public String getPropertyid()
{
return propertyid;
}
public void setPropertyid(String propertyid)
{
this.propertyid = propertyid;
}
public String getPropertyname()
{
return propertyname;
}
public void setPropertyname(String propertyname)
{
this.propertyname = propertyname;
}
public String getCountry()
{
return country;
}
public void setCountry(String country)
{
this.country = country;
}
public String getState()
{
return state;
}
public void setState(String state)
{
this.state = state;
}
public String getCity()
{
return city;
}
public void setCity(String city)
{
this.city = city;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public File getUploadphoto()
{
return uploadphoto;
}
public void setUploadphoto(File uploadphoto)
{
this.uploadphoto = uploadphoto;
}
public String getPhotofiletype() {
return photofiletype;
}
public void setPhotofiletype(String photofiletype) {
this.photofiletype = photofiletype;
}
public String getPhotoname() {
return photoname;
}
public void setPhotoname(String photoname) {
this.photoname = photoname;
}
public String execute(){
DBconnection connection=new DBconnection();
connection.getConnection();
try{
String filepath=connection.filepath;
System.out.println("filepath : : "+filepath);
System.out.println("photoname : : "+photoname);
if(filepath!=null && photoname!=null){
File filetocreate=new File(filepath,photoname);
FileUtils.copyFile(uploadphoto, filetocreate);
}
}catch(Exception e){
e.printStackTrace();
addActionError(e.getMessage());
return INPUT;
}
String query ="insert into addproperty(propertyid,propertyname,propertycity,propertystate,propertycountry,addedby,addeddate,removeddate) values ('"+propertyid+"','"+propertyname+"','"+city+"','"+state+"','"+country+"','Parthi',now(),NULL)";
connection.executeUpdate(query);
System.out.println("Completed Inserting");
return SUCCESS;
//System.out.println("Class completed");
}
}
Action class should have the following three properties.
• [inputName]File
• [inputName]FileName
• [inputName]ContentType
[inputName] is the name of the file tag(s) on the JSP. For example, if the file tag's name is uploadphoto, the properties will be as follows:
• File uploadphotoFile
• String uploadphotoFileName
• String uploadphotoContentType
String filePath = servletRequest.getRealPath("/");
File fileToCreate = new File(filePath, this.uploadphotoFileName);
FileUtils.copyFile(this.uploadphotoFile, fileToCreate);
I use this code:
JSF:
<p:treeTable id="treeSkill" value="#{skillManager.rootSkill}"
var="skill" selectionMode="single" widgetVar="skillsTreeTable"
style="border: 0;">
<p:ajax event="expand"
listener="#{skillManager.expandNodeListener}" />
<p:column> ..... </p:column>
<p/treeTable>
SkillManager:
#Named
#SessionScoped
public class SkillManager implements Serializable {
private static final long serialVersionUID = 1L;
private TreeNode rootSkill;
public SkillManager() {
initSkillTree();
}
public void expandNodeListener(NodeExpandEvent nee) {
TreeNode treeNode = nee.getTreeNode();
if (treeNode instanceof FetchChildren)
((FetchChildren) treeNode).fetchChildren();
if (treeNode instanceof LazySkillTreeNode)
((LazySkillTreeNode) treeNode).fetchSubchildren();
}
private void initSkillTree() {
rootSkill = new DefaultTreeNode("Root", null);
Skill realRootSkill = HrDaoFactory.getInstance().getSkillDAO().getRootSkill();
TreeNode realRootNode = new LazySkillTreeNode(realRootSkill, rootSkill);
for (Skill skill : realRootSkill.getChildrensSkills()) {
LazySkillTreeNode node = new LazySkillTreeNode(skill, realRootNode);
node.fetchChildren();
}
RequestContext.getCurrentInstance().update("woCatalogTabView:skillTreeForm");
}
}
LazySkillTreeNode:
public class LazySkillTreeNode extends LazyTreeNode implements FetchChildren {
private static final long serialVersionUID = 8856168173751148652L;
private boolean childrenFetched;
public LazySkillTreeNode(Object data, TreeNode parent) {
super(data, parent);
}
#Override
public void fetchChildren() {
if (childrenFetched)
return;
for (Skill skill : ((Skill) super.getData()).getChildrensSkills())
new LazySkillTreeNode(skill, this);
childrenFetched = true;
}
}
LazyTreeNode:
public abstract class LazyTreeNode extends DefaultTreeNode {
private static final long serialVersionUID = 8839307424434170537L;
private boolean subChildrenFetched;
public LazyTreeNode(Object data, TreeNode parent) {
super(data, parent);
}
public void fetchSubchildren() {
if (subChildrenFetched || isLeaf())
return;
List<TreeNode> treeNodeList = getChildren();
for (TreeNode node : treeNodeList) {
if (node instanceof FetchChildren)
((FetchChildren) node).fetchChildren();
}
subChildrenFetched = true;
}
}
Everything works fine, but if add/delete elements (after all this operations we call method initSkillTree() for rebuild tree) a lot of times, or if 2 or more users start to do it, we beginning to recieve in response from server this string:
<?xml version='1.0' encoding='UTF-8'?>
<partial-response><error><error-name>class java.lang.StackOverflowError</error-name><error-message><![CDATA[]]></error-message></error></partial-response>
Other problem that i don't have any information about error. No information in log files. In server.log nothing to.
We use: JSF (Mojarra 2.14), Primefaces 3.41, JBOSS 7.
And in the end error was in Controller class where method:
public void addOrUpdateSkill(Skill skill) {
Session session = null;
try {
session = HibernateUtil.getCurrentSession();
session.beginTransaction();
session.saveOrUpdate(skill);
session.getTransaction().commit();
evictAllSkillsFromSession();
} catch (Throwable e) {
logger.fatal(skill, e);
if (session.getTransaction() != null && session.getTransaction().isActive())
session.getTransaction().rollback();
throw new RuntimeException(e);
}
}
and stack trace was appeared in the row "logger.fatal(skill, e);"
you must pass the error message by first argument instead of Entity object.
Error appear because of it's toString() method implementation of Skill class:
#Entity
#Table(name = "SKILLS", schema = AppData.HR_SCHEMA)
public class Skill implements Serializable {
private static final long serialVersionUID = -2728239519286686549L;
#Id
#SequenceGenerator(name = "SKILLS_ID_GENERATOR", sequenceName = AppData.HR_SCHEMA + ".SKILLS_ID_SEQ")
#GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SKILLS_ID_GENERATOR")
private BigDecimal id;
#Column(name = "NAME_ENG")
private String nameEng;
#Temporal(TemporalType.TIMESTAMP)
#Column(name = "UPDATED_AT")
private Date updatedAt;
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "UPDATED_BY", referencedColumnName = "USER_ID")
private User updatedBy;
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "PARENT_ID")
private Skill parentSkill;
#OneToMany(mappedBy = "parentSkill", fetch = FetchType.LAZY, orphanRemoval = true)
private List<Skill> childrensSkills;
#Column(name = "DESCRIPTION")
private String description;
#OneToMany(orphanRemoval = true, mappedBy = "skill")
private List<SkillJoinedAction> skillJoinedActions;
#OneToMany(orphanRemoval = true, mappedBy = "skill")
private List<SkillJoinedEmployee> skillJoinedEmployees;
public Skill() {
}
public Skill(String nameEng, User updateBy, String description) {
this.nameEng = nameEng;
this.updatedBy = updateBy;
this.updatedAt = new Date();
this.setDescription(description);
}
public BigDecimal getId() {
return id;
}
public void setId(BigDecimal id) {
this.id = id;
}
public String getNameEng() {
return this.nameEng;
}
public void setNameEng(String nameEng) {
this.nameEng = nameEng;
}
public Date getUpdatedAt() {
return this.updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public User getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(User updatedBy) {
this.updatedBy = updatedBy;
}
public List<Skill> getChildrensSkills() {
return childrensSkills;
}
public void setChildrensSkills(List<Skill> childrensSkills) {
this.childrensSkills = childrensSkills;
}
public Skill getParentSkill() {
return parentSkill;
}
public void setParentSkill(Skill parentSkill) {
this.parentSkill = parentSkill;
}
#Override
public String toString() {
return "Skill [id=" + id + ", nameEng=" + nameEng + ", updatedAt=" + updatedAt + ", updatedBy=" + updatedBy + ", parentSkill="
+ parentSkill + ", childrensSkills=" + childrensSkills + "]";
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<SkillJoinedAction> getSkillJoinedActions() {
return skillJoinedActions;
}
public void setSkillJoinedActions(List<SkillJoinedAction> skillJoinedActions) {
this.skillJoinedActions = skillJoinedActions;
}
public List<SkillJoinedEmployee> getSkillJoinedEmployees() {
return skillJoinedEmployees;
}
public void setSkillJoinedEmployees(List<SkillJoinedEmployee> skillJoinedEmployees) {
this.skillJoinedEmployees = skillJoinedEmployees;
}
}
as you can see in method:
#Override
public String toString() {
return "Skill [id=" + id + ", nameEng=" + nameEng + ", updatedAt=" + updatedAt + ", updatedBy=" + updatedBy + ", parentSkill="
+ parentSkill + ", childrensSkills=" + childrensSkills + "]";
}
was called method toString() on parentSkill who in his turn call toString() on childrensSkills... infinite recursion.
The problem I have is that I am trying to have a multi select data grid column which will have a List objects (productsEntitled).
I've got the products to display properly by providing a buildSelect custom function to populate my Edit Dialog Box when a user click edit on a record.
When I have the column with the multi select <sjg:gridColumn name="productsEntitledListModel on my grid, the save functionality does not work and does not save. I don't see any errors on the browser console nor on the java console.
Any help will be appreciated as I am unable to find out what the problem is, I de-compiled the entire show case jar and nothing that helps with this issue.
My model look like this:
#Entity
#Table ( name = "USERS")
public class User {
private Long id;
private String name;
private String username;
private String password;
private String sourceIp;
private Device device;
private List<Product> productsEntitled;
This is my grid on a jsp page:
<s:url id="remoteurl" action="loadUsersJson"/>
<s:url id="editurl" action="editGridUserEntry"/>
<s:url id="selectproductsurl" action="loadProductsJson"/>
<sjg:grid gridModel="users"
id="gridUsers"
dataType="json"
width="1150"
href="%{remoteurl}"
draggable="true"
pager="true"
resizable="true"
navigatorAddOptions="{height:525, width:425, readAfterSubmit:true, draggable:true, resizable:true}"
navigatorEditOptions="{height:525, width:425, reloadAfterSubmit:true, draggable:true, resizable:true}"
navigatorDeleteOptions="{height:200, width:200, reloadAfterSubmit:true, draggable:true, resizable:true}"
editurl="%{editurl}"
navigator="true"
navigatorEdit="true"
navigatorAdd="true"
navigatorView="true"
navigatorDelete="true"
rowList="10,15,20"
rowNum="15"
multiselect="false"
onSelectRowTopics="rowselect">
<sjg:gridColumn name="id" editable="true" index="id" hidden="true" key="true" title="ID"/>
<sjg:gridColumn name="name" index="name" editable="true" edittype="text" title="NAME"/>
<sjg:gridColumn name="sourceIp" index="sourceIp" editable="true" edittype="text" title="SOURCE IP"/>
<sjg:gridColumn name="username" index="username" editable="true" edittype="text" title="USERNAME"/>
<sjg:gridColumn name="password" index="password" editable="true" edittype="password" title="PASSWORD"/>
<sjg:gridColumn name="role" index="role" editable="true" edittype="select" editoptions="{value:'Admin:Admin;User:User;'}" title="ROLE"/>
<sjg:gridColumn name="deviceId" jsonmap="device.id" key="true" hidden="true" editable="text" title="DEVICE ID"/>
<sjg:gridColumn name="deviceIp" jsonmap="device.ip" editable="true" edittype="text" title="DEVICE IP"/>
<sjg:gridColumn name="productsEntitledListModel"
width="300"
editable="true"
edittype="select"
editoptions="{dataUrl: '%{selectproductsurl}', multiple:true, buildSelect:customBuildSelect}"
title="PRODUCTS"/>
</sjg:grid>
These are my action classes:
Show the grid:
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.opensymphony.xwork2.ActionSupport;
public class AdminAction extends ActionSupport implements ServletRequestAware {
private static final long serialVersionUID = -1090720652366248768L;
private static final Log logger = LogFactory.getLog(AdminAction.class);
private HttpServletRequest request;
private AuthenticationTicket ticket;
private AdminService adminService;
private List<User> users;
private List<Product> products;
//private List<String>productsAllList;
private String userId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
public AuthenticationTicket getTicket() {
return ticket;
}
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public void setTicket(AuthenticationTicket ticket) {
this.ticket = ticket;
}
#Override
public void setServletRequest(HttpServletRequest request) {
this.request = request;
}
public String redirectUsersTab() {
return "users";
}
public String redirectProductsTab() {
return "products";
}
private void initAdminService () {
logger.debug("initAdminService()...");
if (adminService == null) {
adminService = (AdminService)ServiceFinder.getContext(request).getBean("adminService");
}
}
public String loadUsersJson() {
initAdminService();
this.users = adminService.getUsersAll();
return "success";
}
public String loadProductsJson() {
initAdminService();
this.products = adminService.getProductsAll();
return "success";
}
//TODO: clean up
public String getAllProductsList() {
logger.debug("testParam, userId: " + this.userId);
initAdminService();
List<Product> temp = adminService.getProductsAll();
if (userId != null) {
User userTemp = new User();
userTemp.setId(new Long(userId));
List<Product> prodEntitled = adminService.getProductsByUser(userTemp);
logger.debug("Products entitled: " + prodEntitled);
}
//TODO: merge prod and prod entitled to Model to populate the grid
products = temp;
/*
if (temp != null && temp.size() > 0) {
this.productsAllList = new ArrayList<String>();
for (Product p : temp) {
this.productsAllList.add(p.getName());
}
}
*/
//logger.debug("this.productsAllList: " + this.productsAllList);
return "success";
}
}
Class to edit the grid:
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.opensymphony.xwork2.ActionSupport;
public class EditUsersGridAction extends ActionSupport implements ServletRequestAware {
private static final Log logger = LogFactory.getLog(EditUsersGridAction.class);
private static final long serialVersionUID = -5485382508029951644L;
private HttpServletRequest request;
private AdminService adminService;
private String oper = "";
private Long id;
private String name;
private String sourceIp;
private String password;
private String username;
private Long deviceId;
private String deviceIp;
private String devicePortDescription;
private String devicePortLayer;
private String deviceType;
private List<Product>productsEntitled;
private List<GridColumnListModel> productsEntitledListModel;
private List<Product>productsAvailable;
public List<GridColumnListModel> getProductsEntitledListModel() {
try {
if (productsEntitled != null && productsEntitled.size() > 0) {
productsEntitledListModel = new ArrayList<EditUsersGridAction.GridColumnListModel>();
for (Product p : productsEntitled) {
GridColumnListModel tmp = new GridColumnListModel();
tmp.setName(p.getName());
tmp.setValue(p);
productsEntitledListModel.add(tmp);
}
return this.productsEntitledListModel;
}else {
return null;
}
} catch (Exception ex) {
logger.error("Exception in getProductsEntitledString", ex);
return null;
}
}
public void setProductsEntitledListModel(List<GridColumnListModel> productsEntitledListModel) {
this.productsEntitledListModel = productsEntitledListModel;
}
public Long getDeviceId() {
return deviceId;
}
public void setDeviceId(Long deviceId) {
this.deviceId = deviceId;
}
public String getDeviceIp() {
return deviceIp;
}
public void setDeviceIp(String deviceIp) {
this.deviceIp = deviceIp;
}
public String getDevicePortDescription() {
return devicePortDescription;
}
public void setDevicePortDescription(String devicePortDescription) {
this.devicePortDescription = devicePortDescription;
}
public String getDevicePortLayer() {
return devicePortLayer;
}
public void setDevicePortLayer(String devicePortLayer) {
this.devicePortLayer = devicePortLayer;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public String getOper() {
return oper;
}
public void setOper(String oper) {
this.oper = oper;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSourceIp() {
return sourceIp;
}
public void setSourceIp(String sourceIp) {
this.sourceIp = sourceIp;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public List<Product> getProductsEntitled() {
return productsEntitled;
}
public void setProductsEntitled(List<Product> productsEntitled) {
this.productsEntitled = productsEntitled;
}
public List<Product> getProductsAvailable() {
return productsAvailable;
}
public void setProductsAvailable(List<Product> productsAvailable) {
this.productsAvailable = productsAvailable;
}
public HttpServletRequest getRequest() {
return request;
}
public void setRequest(HttpServletRequest request) {
this.request = request;
}
#Override
public void setServletRequest(HttpServletRequest request) {
this.request = request;
}
private void initAdminService () {
logger.debug("initAdminService()...");
if (adminService == null) {
adminService = (AdminService)ServiceFinder.getContext(request).getBean("adminService");
}
}
public String execute() throws Exception {
logger.debug("#### IN EditGridUsersAction ###");
initAdminService();
productsAvailable = adminService.getProductsAll();
User user = new User();
user.setName(name);
user.setPassword(password);
user.setUsername(username);
user.setSourceIp(sourceIp);
Device device = new Device();
device.setId(deviceId);
device.setIp(deviceIp);
device.setPortDescription(devicePortDescription);
device.setType(deviceType);
user.setDevice(device);
if (id != null) {
user.setId(id);
}
if (oper.equalsIgnoreCase("add")) {
logger.debug("products selected");
//user.setProductsEntitled(adminService.getProductsAll());
adminService.addUser(user);
} else if ( oper.equalsIgnoreCase("edit")) {
//TODO: convert model to products and add to user
logger.debug("now in edit");
List<Product> tempProd = new ArrayList<Product>();
for (GridColumnListModel gridColModel : productsEntitledListModel) {
tempProd.add(gridColModel.getValue());
}
user.setProductsEntitled(tempProd);
adminService.updateUser(user);
//return "input";
}else if (oper.equalsIgnoreCase("del")) {
logger.debug("in delete");
adminService.deleteUser(user);
}
return "success";
}
public class GridColumnListModel {
private String name;
private Product value;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Product getValue() {
return value;
}
public void setValue(Product value) {
this.value = value;
}
}
}