[jboss-svn-commits] JBL Code SVN: r6899 - in labs/jbosslabs/trunk/portal-extensions/forge-contributor/src: etc java/org/jboss/forge/contributor

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 18 15:47:10 EDT 2006


Author: dejp
Date: 2006-10-18 15:47:04 -0400 (Wed, 18 Oct 2006)
New Revision: 6899

Modified:
   labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/etc/Messages.properties
   labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConDataBean.java
   labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConDescriptor.java
   labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConMainBean.java
   labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java
Log:
contributors portlet

Modified: labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/etc/Messages.properties
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/etc/Messages.properties	2006-10-18 19:30:09 UTC (rev 6898)
+++ labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/etc/Messages.properties	2006-10-18 19:47:04 UTC (rev 6899)
@@ -1,62 +1,28 @@
-applicationAdded = Success! Your application has been added. Soon you will get an e-mail with a confirmation code.
-unableToAdd = We are unable to add your application right now. Please try again later.
-unableToConfirm = We are unable to confirm your application right now. Please try again later.
-confirmationCodeInvalid = The confirmation code is invalid.
-confirmationSucceeded = Your application has been successfully confirmed. \
-	You will receive an email when your application will be accepted or rejected.
+applicationAdded Success\! Your application has been added. Soon you will get an e-mail with a confirmation code.
+unableToAdd We are unable to add your application right now. Please try again later.
+unableToConfirm We are unable to confirm your application right now. Please try again later.
+confirmationCodeInvalid The confirmation code is invalid.
+confirmationSucceeded Your application has been successfully confirmed. You will receive an email when your application will be accepted or rejected.
 
-adminMailSubject = New contributors application
-adminMailText = New application added to agreements.xml; please accept it \
-	or delete: \n {0} \
-	\n\
-	To accept/delete the application go to the following website and \
-	click the "Administer applications" link: \n\
-	{1}
+adminMailSubject New contributors application
+adminMailText New application added to agreements.xml; please accept it or delete\: \n {0} \nTo accept/delete the application go to the following website and click the "Administer applications" link\: \n{1}
 
-deletedMailSubject = Application deletion
-deletedMailText = \
-	Dear {0}, \n\
-	\n\
-	I am sorry to inform you that your application to become \n\
-	a contributor to JBoss has been rejected. \n\
-	\n\
-	The JBoss Labs team.
+deletedMailSubject Application deletion
+deletedMailText Dear {0}, \n\nI am sorry to inform you that your application to become \na contributor to JBoss has been rejected. \n\nThe JBoss Labs team.
 	
-acceptedMailSubject = Application acceptation
-acceptedMailText = \
-	Dear {0}, \n\
-	\n\
-	I am happy to inform you that your application to become \n\
-	a contributor to JBoss has been accepted. Your name should \n\
-	now be visible on the contributor's list on labs.jboss.com. \n\
-	\n\
-	The JBoss Labs team.
-acceptedMailTextAdmin = \
-	A new contributor has been accepted. \n\
-	Name: {0} \n\
-    Projects: {4} \n\
-	Email: {1} \n\
-	Type: {2} \n\
-	Login: {3}
+acceptedMailSubject Application acceptation
+acceptedMailText Dear {0}, \n\nI am happy to inform you that your application to become \na contributor to JBoss has been accepted. Your name should \nnow be visible on the contributor's list on labs.jboss.com. \n\nThe JBoss Labs team.
+acceptedMailTextAdmin A new contributor has been accepted. \nName\: {0} \nProjects\: {4} \nEmail\: {1} \nType\: {2} \nLogin\: {3}
 
-confirmMailSubject = Application confirmation
-confirmMailText = \
-	Dear {0}, \n\
-	\n\
-	You have applied to become a contributor to JBoss. \n\
-	This e-mail was sent to you to confirm your application. \n\
-	If you have not applied using the labs.jboss.com website, \n\
-	please accept our apologies. \n\
-	\n\
-	To confirm your application please click this link, or \n\
-	copy-paste it into your web browser: \n\
-	{1}\n\
-	\n\
-	The JBoss Labs team.
+confirmMailSubject Application confirmation
+confirmMailText Dear {0}, \n\nYou have applied to become a contributor to JBoss. \nThis e-mail was sent to you to confirm your application. \nIf you have not applied using the labs.jboss.com website, \nplease accept our apologies. \n\nTo confirm your application please click this link, or \ncopy-paste it into your web browser\: \n{1}\n\nThe JBoss Labs team.
 
-notAllFieldsFilledError = Error: not all fields have been filled.
-nameAlreadyExistsError = Error: the name you gave already exists.
+notAllFieldsFilledError Error\: not all fields have been filled.
+nameAlreadyExistsError Error\: the name you gave already exists.
 
-applicationAccepted = Success! Application accepted.
-applicationDeleted = Success! Application deleted.
-commitError = Error! Please check the xml descriptor.
\ No newline at end of file
+applicationAccepted Success\! Application accepted.
+applicationDeleted Success\! Application deleted.
+commitError Error\! Please check the xml descriptor.
+
+committerAccessMailSubject Committer access for
+committerAccessMailText A new contributor requested committer access. \nName\: {0} \nProjects\: {4} \nEmail\: {1} \nType\: {2} \nLogin\: {3}
\ No newline at end of file

Modified: labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConDataBean.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConDataBean.java	2006-10-18 19:30:09 UTC (rev 6898)
+++ labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConDataBean.java	2006-10-18 19:47:04 UTC (rev 6899)
@@ -47,6 +47,7 @@
 	private String login;
 	private Date sinceDate;
 	private Map<String, String> projectsInfo;
+	private String committer;
 	
 	public ConDataBean() {
 		
@@ -54,7 +55,7 @@
 	
 	public ConDataBean(String accepted, String email, 
 			String name, List<String> projectsIds, String since, String type,
-			String login) {
+			String login, String committer) {
 		
 		this.accepted = accepted;
 		this.email = email;
@@ -62,6 +63,7 @@
 		this.since = since;
 		this.type = type;
 		this.login = login;
+		this.committer = committer;
 
 		this.projectsInfo = new LinkedHashMap<String, String>();
 		for (String projectId : projectsIds) {
@@ -80,7 +82,7 @@
 
 	public ConDataBean(String accepted, String email, 
 			String name, Map <String, String> projectsInfo, String since, String type,
-			String login) {
+			String login, String committer) {
 		
 		this.accepted = accepted;
 		this.email = email;
@@ -88,11 +90,10 @@
 		this.since = since;
 		this.type = type;
 		this.login = login;
+		this.committer = committer;
 
 		this.projectsInfo = projectsInfo;
 		
-		setProjectsInfo(projectsInfo);
-		
 		try {
 			sinceDate = new SimpleDateFormat("MM/dd/yy").parse(since);
 		} catch (ParseException e) {
@@ -103,33 +104,8 @@
 	
 	/**
 	 * Creates a string with information held in this bean in XML form.
-	 * Format:
-	 * 		<aggreement>
-	 * 			<id>contributor name</id>
-	 * 			<name>projects</name>
-	 * 			<login>contributor login</login>
-	 * 			<e-mail>contributor e-mail</e-mail>
-	 * 			<since>date of application</since>
-	 * 			<type>type of agreement (Individual or Corporate)</type>
-	 * 			<accepted>1/0 - if project is accepted/not</accepted>
-	 * 		</agreement>
 	 * @return A string with information held in this bean in XML form.
 	 */
-	/*public String getXml() {
-		return
-			  "\t<"+ConDescriptor.AGREEMENT_TAG+">\n"
-			+ "\t\t<id>" + name + "</id>\n"
-			+ "\t\t<name>" + projects + "</name>\n"
-			+ "\t\t<login>" + login + "</login>\n"
-			+ "\t\t<e-mail>" + email + "</e-mail>\n"
-			+ "\t\t<since>" + since + "</since>\n"
-			+ "\t\t<type>" + type + "</type>\n"
-			//+ "\t\t<acceptedBySponsor>" + acceptedBySponsor + "</acceptedBySponsor>\n"
-			+ "\t\t<accepted>" + accepted + "</accepted>\n"
-			//+ "\t\t<committer>" + committer + "</committer>\n"
-			+ "\t</"+ConDescriptor.AGREEMENT_TAG+">\n";
-	}*/
-
 	public String getXml() {
 		StringBuilder xml = new StringBuilder();
 		xml.append("\t<"+ConDescriptor.AGREEMENT_TAG+">\n");
@@ -149,6 +125,7 @@
 		xml.append("\t\t<since>" + since + "</since>\n");
 		xml.append("\t\t<type>" + type + "</type>\n");
 		xml.append("\t\t<accepted>" + accepted + "</accepted>\n");
+		xml.append("\t\t<committer>" + committer + "</committer>\n");
 		xml.append("\t</"+ConDescriptor.AGREEMENT_TAG+">\n");
 		return xml.toString();
 	}
@@ -167,8 +144,6 @@
 			Projects prjs = ProjectsHelper.getProjects(ConTools.getPortalName());
 		
 			for (String projectId : projectsInfo.keySet()) {
-				projectsInfo.put(projectId, "0");
-			
 				if (projects.length() > 0)			
 					projects = projects + ", " + prjs.getProjectName(projectId);
 				else 
@@ -179,21 +154,6 @@
 		return projects;
 	}
 
-	/*public void setProjects(Map<String, String> projectsInfo) {
-		Projects prjs = ProjectsHelper.getProjects(ConTools.getPortalName());
-		String projects = new String();
-		
-		for (String projectId : projectsInfo.keySet()) {
-			projectsInfo.put(projectId, "0");
-			
-			if (projects.length() > 0)			
-				projects = projects + ", " + prjs.getProjectName(projectId);
-			else 
-				projects = prjs.getProjectName(projectId);
-		}
-		this.projects = projects;
-	}*/
-	
 	public String getSince() {
 		return since;
 	}
@@ -251,8 +211,15 @@
 	}
 	
 	public boolean isAcceptedByProjectLeads() {
-
 		return !projectsInfo.containsValue("0");
 	}
+
+	public String getCommitter() {
+		return committer;
+	}
+
+	public void setCommitter(String committer) {
+		this.committer = committer;
+	}
 	
 }

Modified: labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConDescriptor.java	2006-10-18 19:30:09 UTC (rev 6898)
+++ labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConDescriptor.java	2006-10-18 19:47:04 UTC (rev 6899)
@@ -60,6 +60,7 @@
 	public static final String PROJECT_TAG = "project";
 	public static final String PROJECT_ID_TAG = "projectId";
 	public static final String ACCEPTED_BY_PROJECT_LEAD_TAG = "acceptedByProjectLead";
+	public static final String COMMITTER_TAG = "committer";
 	
 	private List<ConDataBean> data;
 	private List<ConDataBean> notAcceptedData;
@@ -269,8 +270,9 @@
 					contributor.setType(XmlTools.unmarshallText(n));
 				} else if (ACCEPTED_TAG.equals(nodeName)) {
 					contributor.setAccepted(XmlTools.unmarshallText(n));
+				} else if (COMMITTER_TAG.equals(nodeName)) {
+					contributor.setCommitter(XmlTools.unmarshallText(n));
 				}
-				
 			}
 		}
 		

Modified: labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConMainBean.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConMainBean.java	2006-10-18 19:30:09 UTC (rev 6898)
+++ labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConMainBean.java	2006-10-18 19:47:04 UTC (rev 6899)
@@ -76,7 +76,6 @@
 	public String acceptByProjectLead() {
 		ConDataBean conDataBean = (ConDataBean) leadDataTable.getRowData();
 		if (getServer().acceptByProjectLead(conDataBean)) {
-			//getServer().getDesc(ConTools.getPortalName()).getNotAcceptedByLeadsData().remove(conDataBean);
 			addMessage(getServer().getMessages().getString("applicationAccepted"));
 		} else {
 			addMessage(getServer().getMessages().getString("commitError"));
@@ -88,7 +87,6 @@
 	public String accept() {
 		ConDataBean conDataBean = (ConDataBean) adminDataTable.getRowData();
 		if (getServer().accept(conDataBean)) {
-			getServer().getDesc(ConTools.getPortalName()).getNotAcceptedData().remove(conDataBean);
 			addMessage(getServer().getMessages().getString("applicationAccepted"));
 		} else {
 			addMessage(getServer().getMessages().getString("commitError"));
@@ -100,7 +98,6 @@
 	public String delete() {
 		ConDataBean conDataBean = (ConDataBean) adminDataTable.getRowData();
 		if (getServer().delete(conDataBean)) {
-			getServer().getDesc(ConTools.getPortalName()).getNotAcceptedData().remove(conDataBean);
 			addMessage(getServer().getMessages().getString("applicationDeleted"));
 		} else {
 			addMessage(getServer().getMessages().getString("commitError"));
@@ -109,12 +106,28 @@
 		return null;
 	}
 	
+	public String deleteByLead() {
+		ConDataBean conDataBean = (ConDataBean) leadDataTable.getRowData();
+		if (getServer().delete(conDataBean)) {
+			addMessage(getServer().getMessages().getString("applicationDeleted"));
+		} else {
+			addMessage(getServer().getMessages().getString("commitError"));
+		}
+		getServer().resetDesc(ConTools.getPortalName());
+		return null;
+	}
+	
 	public String processApplication() {
 		String error = null;
-
-		error = getServer().processApplication(name, email, type,
-			projects, ConTools.getRemoteUser());
 		
+		if (committer) {
+			error = getServer().processApplication(name, email, type,
+					projects, ConTools.getRemoteUser(), "1");
+		} else {
+			error = getServer().processApplication(name, email, type,
+					projects, ConTools.getRemoteUser(), "0");			
+		}
+		
 		if (error == null) {
 			addMessage(getServer().getMessages().getString("applicationAdded"));
 		

Modified: labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java	2006-10-18 19:30:09 UTC (rev 6898)
+++ labs/jbosslabs/trunk/portal-extensions/forge-contributor/src/java/org/jboss/forge/contributor/ConServer.java	2006-10-18 19:47:04 UTC (rev 6899)
@@ -44,6 +44,7 @@
 
 /**
  * @author adamw
+ * @author dejp
  * A "server" bean for the contributors portlet, which handles reading
  * and writing the xml file with agreements.
  */
@@ -145,12 +146,14 @@
 			
 			confirmed.setContent(newContent);
 			confirmed.save("New application accepted");
-			 
+			
+			getDesc(ConTools.getPortalName()).getNotAcceptedByLeadsData().remove(contributor);
+			
 			if (!projectsInfo.containsValue("0")) {
 				PortalNodeURL url = ConTools.createRenderURL();
 				String adminURL = ConTools.getBaseServerAddress() + 
 					url.toString();
-			
+
 				// sending email to admin
 				ForgeHelper.postMail(
 						ForgeHelper.getProperties().getProperty("contribadmin"),
@@ -161,17 +164,17 @@
 			}
 			
 			org.jboss.portal.identity.User projectLead = ConTools.getUser();
-			String projectLeadEmail = projectLead.getRealEmail(); 
+			String projectLeadEmail = projectLead.getRealEmail();
 			
 			// email to project lead
-			/*ForgeHelper.postMail(
+			ForgeHelper.postMail(
 					projectLeadEmail,
 					messages.getString("acceptedMailSubject"),
 					getFormattedMessage("acceptedMailTextAdmin", 
 							new Object[] { contributor.getName(),
 							contributor.getEmail(), contributor.getType(),
 							contributor.getLogin(), contributor.getProjects() }),
-					"labs-robot at labs.jboss.com");*/
+					"labs-robot at labs.jboss.com");
 			
 			return true;
 		} catch (Exception e) {
@@ -201,6 +204,8 @@
 			confirmed.setContent(newContent);
 			confirmed.save("New application accepted");
 			
+			getDesc(ConTools.getPortalName()).getNotAcceptedData().remove(dataBean);
+			
 			// Posting a notification to the contributor
 			ForgeHelper.postMail(dataBean.getEmail(),
 					messages.getString("acceptedMailSubject"),
@@ -218,6 +223,17 @@
 							dataBean.getLogin(), dataBean.getProjects() }),
 					"labs-robot at labs.jboss.com");
 			
+			if ("1".equals(dataBean.getCommitter())) {
+				ForgeHelper.postMail(
+						ForgeHelper.getProperties().getProperty("jira"),
+						messages.getString("committerAccessMailSubject") + " " + dataBean.getName(),
+						getFormattedMessage("committerAccessMailText", 
+								new Object[] { dataBean.getName(),
+								dataBean.getEmail(), dataBean.getType(),
+								dataBean.getLogin(), dataBean.getProjects() }),
+						"labs-robot at labs.jboss.com");				
+			}
+			
 			return true;
 		} catch (Exception e) {
 			return false;
@@ -254,6 +270,8 @@
 				throw new RuntimeException(e);
 			}
 			
+			getDesc(ConTools.getPortalName()).getNotAcceptedData().remove(dataBean);
+			
 			return true;
 		} finally {
 			// Sending the "you-are-reject" email no matter exception or not.
@@ -268,6 +286,53 @@
 			}
 		}
 	}
+
+	/**
+	 * Deletes the given application.
+	 * @param dataBean Application to delete.
+	 * @return True iff deleting was successfull.
+	 */
+	synchronized boolean deleteByLead(ConDataBean dataBean) {
+		String oldXml = dataBean.getXml();
+		
+		try {
+			// Values ok, adding application.
+			Node confirmed;
+			try {
+				confirmed = cm.getNode(getConfirmedFilePath());
+			} catch (ResourceDoesNotExist e) {
+				// Nothing to do here ...
+				throw new RuntimeException(e);
+			}
+			String content = confirmed.getContent();
+			
+			String newContent = ForgeHelper.replace(content, 
+				oldXml, "");
+			
+			confirmed.setContent(newContent);
+			try {
+				confirmed.save("New application deleted");
+			} catch (SaveException e) {
+				// TODO 
+				throw new RuntimeException(e);
+			}
+			
+			getDesc(ConTools.getPortalName()).getNotAcceptedByLeadsData().remove(dataBean);
+			
+			return true;
+		} finally {
+			// Sending the "you-are-reject" email no matter exception or not.
+			try {
+				ForgeHelper.postMail(dataBean.getEmail(),
+						messages.getString("deletedMailSubject"),
+						getFormattedMessage("deletedMailText", 
+								new Object[] { dataBean.getName() }),
+						"forge-robot at labs.jboss.com");
+			} catch (Exception e) {
+				// Nothing to do here. No mail... well.
+			}
+		}
+	}
 	
 	/**
 	 * Confirms the given agreement.
@@ -309,7 +374,8 @@
 				toConfirm.getProjectsInfo(),
 				toConfirm.getSince(),
 				toConfirm.getType(), 
-				toConfirm.getLogin()).getXml();
+				toConfirm.getLogin(),
+				toConfirm.getCommitter()).getXml();
 		
 		// Writing changes to xml files.
 		try {
@@ -383,7 +449,7 @@
 	 * @return An error string or null, if no error occured.
 	 */
 	synchronized String processApplication(String name, String email, String type,
-			List<String> projects, String username) {
+			List<String> projects, String username, String committer) {
 		
 		if ((!checkString(name)) || (!checkString(email)) ||
 				(!checkString(type)) || (projects.isEmpty()))
@@ -406,7 +472,7 @@
 		// the agreement during confimation.
 		String newAgreement =
 			new ConDataBean(name, email, confirmationCode, 
-					projects, since, type, username).getXml();
+					projects, since, type, username, committer).getXml();
 		
 		try {
 			// Values ok, adding application.




More information about the jboss-svn-commits mailing list