JBoss Portal SVN: r11593 - in branches/JBoss_Portal_Branch_2_7/core-samples/src: resources/portal-weather-samples-war/WEB-INF and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-07-27 08:38:45 -0400 (Sun, 27 Jul 2008)
New Revision: 11593
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/weather/WeatherPortlet.java
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-weather-samples-war/WEB-INF/jsp/weather/edit.jsp
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-weather-samples-war/WEB-INF/portlet.xml
Log:
rewrote a part of the weathe portlet so that
- it does not use a mix of render parameter and preferences for zip state
- does not store the entire feed URL in the preferences but rather the zip
- display the current zip when the preferences is edited
Modified: branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/weather/WeatherPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/weather/WeatherPortlet.java 2008-07-26 08:48:26 UTC (rev 11592)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/weather/WeatherPortlet.java 2008-07-27 12:38:45 UTC (rev 11593)
@@ -24,6 +24,7 @@
import org.apache.log4j.Logger;
import org.jboss.portal.common.net.URLTools;
+import org.jboss.portal.common.io.IOTools;
import org.w3c.dom.Document;
import javax.portlet.ActionRequest;
@@ -58,7 +59,7 @@
public class WeatherPortlet extends GenericPortlet
{
/** Logger */
- public static Logger log = Logger.getLogger(WeatherPortlet.class);
+ public static final Logger log = Logger.getLogger(WeatherPortlet.class);
/** Edit page */
private static final String JSP_EDIT = "/WEB-INF/jsp/weather/edit.jsp";
@@ -66,22 +67,27 @@
/** Help page */
private static final String JSP_HELP = "/WEB-INF/jsp/weather/help.jsp";
+ /** RSS 2.0 XSL page for output */
+ private static final String RSS_XSL = "/WEB-INF/xsl/weather/Rss.xsl";
+
+ /** . */
+ private static final String E_XSL_UNREADABLE = "Unable to prepare XSL files.";
+
+ /** . */
+ private static final String E_UNREADABLE = "Unable to read XML Source.";
+
+ /** . */
+ private static final String E_UNPARSEABLE = "Unable to parse XML Source.";
+
/** Default zip set in init param. */
private String DEFAULT_ZIP;
- /** RSS 2.0 XSL page for output */
- private static final String RSS_XSL = "/WEB-INF/xsl/weather/Rss.xsl";
-
/** Compiled Template for output */
private Templates template_2_0;
/** Base URL of Weather RSS */
private String RSS_URL_PREFIX;
- private static final String E_XSL_UNREADABLE = "Unable to prepare XSL files.";
- private static final String E_UNREADABLE = "Unable to read XML Source.";
- private static final String E_UNPARSEABLE = "Unable to parse XML Source.";
-
/** Compile the XSL File. */
public void init()
{
@@ -91,7 +97,6 @@
StreamSource xslSource = new StreamSource(inputstream);
TransformerFactory tFactory = TransformerFactory.newInstance();
this.template_2_0 = tFactory.newTemplates(xslSource);
-
this.DEFAULT_ZIP = getInitParameter("default_zipcode");
this.RSS_URL_PREFIX = getInitParameter("base_url");
}
@@ -103,23 +108,21 @@
protected void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException
{
- response.setProperty("expiration-cache", request.getPreferences().getValue("expires", "180"));
+// response.setProperty("expiration-cache", request.getPreferences().getValue("expires", "180"));
InputStream xmlInputStream = null;
InputStream xslInputStream = null;
- String newZip = null;
+ //
try
{
- newZip = request.getParameter("newzip");
- response.setContentType("text/html");
+ String zip = getZip(request);
- if (null == newZip)
- {
- newZip = request.getPreferences().getValue("RssXml", RSS_URL_PREFIX + DEFAULT_ZIP);
- }
+ //
+ String feedURL = buildFeedURL(zip);
- xmlInputStream = URLTools.getContentAsInputStream(new URL(newZip), 5000, 5000);
+ //
+ xmlInputStream = URLTools.getContentAsInputStream(new URL(feedURL), 5000, 5000);
if (xmlInputStream == null)
{
log.error(E_UNREADABLE);
@@ -129,9 +132,10 @@
// Ready the parsers
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
- Transformer transformer = this.template_2_0.newTransformer();
- Source xmlSource = null;
+ //
+ Transformer transformer;
+ Source xmlSource;
try
{
Document document = docBuilder.parse(xmlInputStream);
@@ -158,15 +162,8 @@
}
finally // close all streams
{
- if (xmlInputStream != null)
- {
- xmlInputStream.close();
- }
-
- if (xslInputStream != null)
- {
- xslInputStream.close();
- }
+ IOTools.safeClose(xmlInputStream);
+ IOTools.safeClose(xslInputStream);
}
}
@@ -181,6 +178,7 @@
protected void doEdit(RenderRequest request, RenderResponse response) throws IOException, PortletException
{
response.setContentType("text/html");
+ request.setAttribute("zip", getZip(request));
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(JSP_EDIT);
dispatcher.include(request, response);
}
@@ -208,7 +206,7 @@
PortletPreferences prefs = request.getPreferences();
try
{
- prefs.setValue("RssXml", RSS_URL_PREFIX + newZip);
+ prefs.setValue("zip", newZip);
prefs.store();
}
catch (Exception e)
@@ -219,10 +217,17 @@
// TODO: error checking for URL + NewZIP
- //store as the selected xml so that it shows up selected as displays
- response.setRenderParameter("newzip", RSS_URL_PREFIX + newZip);
-
//set the portlet mode back to view
response.setPortletMode(PortletMode.VIEW);
}
+
+ private String getZip(RenderRequest request)
+ {
+ return request.getPreferences().getValue("zip", DEFAULT_ZIP);
+ }
+
+ private String buildFeedURL(String zip)
+ {
+ return RSS_URL_PREFIX + zip;
+ }
}
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-weather-samples-war/WEB-INF/jsp/weather/edit.jsp
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-weather-samples-war/WEB-INF/jsp/weather/edit.jsp 2008-07-26 08:48:26 UTC (rev 11592)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-weather-samples-war/WEB-INF/jsp/weather/edit.jsp 2008-07-27 12:38:45 UTC (rev 11593)
@@ -31,9 +31,10 @@
<font class="portlet-font">Change Weather Location:</font>
<form method="post" action=" <portlet:actionURL></portlet:actionURL>">
- <font class="portlet-font">Zip Code:</font><br/>
- <input class="portlet-form-input-field" type="text" value="" size="12" name="newzip">
- <br/>
+ <div class="portlet-font">Zip Code:</div>
+ <div>
+ <input class="portlet-form-input-field" type="text" value="<%= renderRequest.getAttribute("zip") %>" size="12" name="newzip">
+ </div>
<input class="portlet-form-input-field" type="submit" name="submit" value="submit">
</form>
</div>
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-weather-samples-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-weather-samples-war/WEB-INF/portlet.xml 2008-07-26 08:48:26 UTC (rev 11592)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-weather-samples-war/WEB-INF/portlet.xml 2008-07-27 12:38:45 UTC (rev 11593)
@@ -44,7 +44,7 @@
<name>base_url</name>
<value>http://xml.weather.yahoo.com/forecastrss?p=</value>
</init-param>
- <expiration-cache>180</expiration-cache>
+ <!--<expiration-cache>180</expiration-cache>-->
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
@@ -66,8 +66,8 @@
<value>180</value>
</preference>
<preference>
- <name>RssXml</name>
- <value>http://xml.weather.yahoo.com/forecastrss?p=33145</value>
+ <name>zip</name>
+ <value>33145</value>
<read-only>false</read-only>
</preference>
</portlet-preferences>
15 years, 11 months
JBoss Portal SVN: r11592 - branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-07-26 04:48:26 -0400 (Sat, 26 Jul 2008)
New Revision: 11592
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java
Log:
rewrote ControllerPageNavigationalState#initiateWindowPublicNavigationalStateUpdate() which was bugged
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2008-07-25 20:13:04 UTC (rev 11591)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2008-07-26 08:48:26 UTC (rev 11592)
@@ -31,8 +31,6 @@
import org.jboss.portal.core.CoreConstants;
import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.controller.coordination.CoordinationManager;
import javax.xml.namespace.QName;
@@ -285,14 +283,16 @@
//
if (windowPublicNavigationalStateUpdate == null)
{
- initiateWindowPublicNavigationalStateUpdate(windowName);
+ initiateWindowPublicNavigationalStateUpdate();
}
+ //
if (windowPublicNavigationalStateUpdate.get(windowName) == null)
{
windowPublicNavigationalStateUpdate.put(windowName, new HashMap<QName, String[]>());
}
-
+
+ //
windowPublicNavigationalStateUpdate.get(windowName).put(name, value);
}
@@ -344,7 +344,7 @@
// For explicit initiate windowPublicNavigationStateUpdate with previous state
if (windowPublicNavigationalStateUpdate == null)
{
- initiateWindowPublicNavigationalStateUpdate(windowName);
+ initiateWindowPublicNavigationalStateUpdate();
}
//
@@ -598,8 +598,12 @@
{
HashMap<QName, String[]> params = new HashMap<QName, String[]>();
- org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns = navigationalStateContext.getWindowNavigationalState(getWindow(windowName).getId().toString());
+ //
+ Window window = getWindow(windowName);
+ //
+ org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns = navigationalStateContext.getWindowNavigationalState(window.getId().toString());
+
if (wns != null)
{
@@ -618,28 +622,26 @@
}
/**
- *
+ * @throws IllegalStateException if the public navigational state of the window is already initialized
*/
- public void initiateWindowPublicNavigationalStateUpdate(String windowName)
+ private void initiateWindowPublicNavigationalStateUpdate() throws IllegalStateException
{
+ if (windowPublicNavigationalStateUpdate != null)
+ {
+ throw new IllegalStateException("Was called with a non null windowPublicNavigationalStateUpdate field");
+ }
- Page page = getWindow(windowName).getPage();
-
+ //
windowPublicNavigationalStateUpdate = new HashMap<String, HashMap<QName, String[]>>();
// Initial state for all windows on this page
- for (PortalObject portalObject : page.getChildren())
+ for (String windowName : controllerContext.getWindowNames())
{
- if (portalObject instanceof Window)
- {
- Window window = (Window)portalObject;
- windowPublicNavigationalStateUpdate.put(window.getName(), getWindowPublicContentStateParameters(window.getName()));
- }
+ HashMap<QName, String[]> publicContentStateParams = getWindowPublicContentStateParameters(windowName);
+ windowPublicNavigationalStateUpdate.put(windowName, publicContentStateParams);
}
-
}
-
public Window getWindow(String windowName)
{
return controllerContext.getWindow(windowName);
15 years, 11 months
JBoss Portal SVN: r11591 - in branches/JBoss_Portal_Branch_2_7: cms/src/main/org/jboss/portal/test/cms/workflow and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-07-25 16:13:04 -0400 (Fri, 25 Jul 2008)
New Revision: 11591
Modified:
branches/JBoss_Portal_Branch_2_7/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java
branches/JBoss_Portal_Branch_2_7/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
Log:
JBPORTAL-2088 - uploading a file shows up in list when it's not approved
Modified: branches/JBoss_Portal_Branch_2_7/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java 2008-07-25 20:12:03 UTC (rev 11590)
+++ branches/JBoss_Portal_Branch_2_7/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java 2008-07-25 20:13:04 UTC (rev 11591)
@@ -34,6 +34,7 @@
import javax.naming.InitialContext;
import java.util.List;
import java.util.Locale;
+import java.util.ArrayList;
/**
* Created on : Dec 20, 2006
@@ -58,16 +59,15 @@
long processId = executionContext.getProcessInstance().getId();
CMS cms = this.getCMSService();
+ int lastIndex = content.getPath().lastIndexOf('/');
+ String path = content.getPath().substring(0, lastIndex);
+ String language = content.getPath().substring(lastIndex + 1);
if (approved)
{
ACLInterceptor.turnOff();
JCRCMS.turnOffWorkflow();
//create this content in the CMS and make it live
- int lastIndex = content.getPath().lastIndexOf('/');
- String path = content.getPath().substring(0, lastIndex);
- String language = content.getPath().substring(lastIndex + 1);
-
Command command = cms.getCommandFactory().createContentGetVersionsCommand(content.getPath());
List versions = (List)cms.execute(command);
org.jboss.portal.cms.model.Content processContent = this.findProcessContent(processId, versions);
@@ -100,6 +100,27 @@
JCRCMS.turnOnWorkflow();
ACLInterceptor.turnOn();
}
+ else
+ {
+ ACLInterceptor.turnOff();
+ JCRCMS.turnOffWorkflow();
+
+ //Check if there are any published versions of this file. If not, this is a new file that was denied publishing
+ //hence delete the file itself
+ Command command = cms.getCommandFactory().createContentGetVersionsCommand(content.getPath());
+ List versions = (List)cms.execute(command);
+ List filtered = this.filterPending(versions);
+ if(filtered == null || filtered.isEmpty())
+ {
+ //Delete this file
+ Command deleteCommand = cms.getCommandFactory().createDeleteCommand(path);
+ cms.execute(deleteCommand);
+ }
+
+
+ JCRCMS.turnOnWorkflow();
+ ACLInterceptor.turnOn();
+ }
}
/**
@@ -130,6 +151,30 @@
return content;
}
+
+ /**
+ *
+ * @param versions
+ * @return
+ */
+ private List filterPending(List versions)
+ {
+ List filtered = new ArrayList();
+
+ if(versions != null)
+ {
+ for(int i=0; i<versions.size(); i++)
+ {
+ org.jboss.portal.cms.model.Content content = (org.jboss.portal.cms.model.Content)versions.get(i);
+ if(!content.isWaitingForPublishApproval())
+ {
+ filtered.add(content);
+ }
+ }
+ }
+
+ return filtered;
+ }
/** @return */
private CMS getCMSService()
Modified: branches/JBoss_Portal_Branch_2_7/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java 2008-07-25 20:12:03 UTC (rev 11590)
+++ branches/JBoss_Portal_Branch_2_7/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java 2008-07-25 20:13:04 UTC (rev 11591)
@@ -91,60 +91,22 @@
/** @throws Exception */
- public void test() throws Exception
+ public void testPublishExistingFile() throws Exception
{
- //Execute file creation as a regular user/non-manager
- this.runAs("user");
-
- //Add a new file to the CMS
- File file = new FileImpl();
- file.setBasePath(this.newFile);
-
- Content content = new ContentImpl();
- content.setEncoding("UTF-8");
- content.setTitle("English Title");
- content.setDescription("English Description");
- content.setBasePath(this.newFile + "/" + Locale.ENGLISH.getLanguage());
- content.setBytes("newdata".getBytes());
- content.setMimeType("text/html");
- file.setContent(Locale.ENGLISH, content);
-
- Command newFileCommand = this.service.getCommandFactory().createNewFileCommand(file, content);
- this.service.execute(newFileCommand);
-
- //Make sure this resource is not published into the CMS yet
- Command fileGet = this.service.getCommandFactory().createFileGetCommand(this.newFile, Locale.ENGLISH);
- File assertFile = (File)this.service.execute(fileGet);
- assertNull(assertFile.getContent());
-
- //Check the pending queue for this file
ApprovePublish approvePublish = this.service.getApprovePublishWorkflow();
- Collection queueItems = approvePublish.getPendingQueue(this.newFile);
- assertNotNull(queueItems);
- assertEquals(1, queueItems.size());
-
- //Deny the publish of this file into the CMS
Set managers = approvePublish.getManagers();
String manager = (String)managers.iterator().next();
- org.jboss.portal.cms.workflow.Content pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
- approvePublish.processManagerResponse(Long.parseLong(pendingItem.getProcessId()), manager.toLowerCase(), false);
-
- //Make sure this resource is not published into the CMS, and removed from the pending queue
- assertFile = (File)this.service.execute(fileGet);
- assertNull(assertFile.getContent());
- queueItems = approvePublish.getPendingQueue(this.newFile);
- if (queueItems != null)
- {
- assertTrue(queueItems.isEmpty());
- }
-
+
+ //Execute file creation as a regular user/non-manager
+ this.createNewFile();
+
//Check for the existence of a file to be updated first
Command existsCommand = this.service.getCommandFactory().createItemExistsCommand(this.updateFile);
Boolean exists = (Boolean)this.service.execute(existsCommand);
assertTrue(exists.booleanValue());
//Get the file to be updated
- fileGet = this.service.getCommandFactory().createFileGetCommand(this.updateFile, new Locale(this.service.getDefaultLocale()));
+ Command fileGet = this.service.getCommandFactory().createFileGetCommand(this.updateFile, new Locale(this.service.getDefaultLocale()));
File updateFile = (File)this.service.execute(fileGet);
assertNotNull(updateFile);
assertNotNull(updateFile.getContent());
@@ -163,19 +125,19 @@
this.service.execute(updateFileCommand);
//Make sure a new LIVE version of this resource is not published into the CMS
- assertFile = (File)this.service.execute(fileGet);
+ File assertFile = (File)this.service.execute(fileGet);
versions = (List)this.service.execute(getVersions);
assertEquals(new String(assertFile.getContent().getBytes()), oldContent);
assertEquals(assertFile.getContent().getVersionNumber(), oldLiveVersion);
assertEquals(2, versions.size());
//Checking pending queue for a version of this file to be approved
- queueItems = approvePublish.getPendingQueue(this.updateFile);
+ Collection queueItems = approvePublish.getPendingQueue(this.updateFile);
assertNotNull(queueItems);
assertEquals(1, queueItems.size());
//Deny publishing of this new version into the CMS
- pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
+ org.jboss.portal.cms.workflow.Content pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
approvePublish.processManagerResponse(Long.parseLong(pendingItem.getProcessId()), manager.toLowerCase(), false);
//Check for the success of this denial, and removal from the pending queue
@@ -189,5 +151,87 @@
{
assertTrue(queueItems.isEmpty());
}
- }
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ public void testPublishNewFile() throws Exception
+ {
+ //Execute file creation as a regular user/non-manager
+ this.runAs("user");
+
+ //Add a new file to the CMS
+ File file = new FileImpl();
+ file.setBasePath(this.newFile);
+
+ Content content = new ContentImpl();
+ content.setEncoding("UTF-8");
+ content.setTitle("English Title");
+ content.setDescription("English Description");
+ content.setBasePath(this.newFile + "/" + Locale.ENGLISH.getLanguage());
+ content.setBytes("newdata".getBytes());
+ content.setMimeType("text/html");
+ file.setContent(Locale.ENGLISH, content);
+
+ Command newFileCommand = this.service.getCommandFactory().createNewFileCommand(file, content);
+ this.service.execute(newFileCommand);
+
+ //Make sure this resource is not published into the CMS yet
+ Command fileGet = this.service.getCommandFactory().createFileGetCommand(this.newFile, Locale.ENGLISH);
+ File assertFile = (File)this.service.execute(fileGet);
+ assertNull(assertFile.getContent());
+
+ //Check the pending queue for this file
+ ApprovePublish approvePublish = this.service.getApprovePublishWorkflow();
+ Collection queueItems = approvePublish.getPendingQueue(this.newFile);
+ assertNotNull(queueItems);
+ assertEquals(1, queueItems.size());
+
+ //Deny the publish of this file into the CMS
+ Set managers = approvePublish.getManagers();
+ String manager = (String)managers.iterator().next();
+ org.jboss.portal.cms.workflow.Content pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
+ approvePublish.processManagerResponse(Long.parseLong(pendingItem.getProcessId()), manager.toLowerCase(), false);
+
+ //Make sure the file/content does not exist in the CMS, and removed from the pending queue
+ assertFile = (File)this.service.execute(fileGet);
+ assertNull(assertFile);
+ queueItems = approvePublish.getPendingQueue(this.newFile);
+ if (queueItems != null)
+ {
+ assertTrue(queueItems.isEmpty());
+ }
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ private void createNewFile() throws Exception
+ {
+ JCRCMS.turnOffWorkflow();
+
+ //Execute file creation as a regular user/non-manager
+ this.runAs("user");
+
+ //Add a new file to the CMS
+ File file = new FileImpl();
+ file.setBasePath(this.newFile);
+
+ Content content = new ContentImpl();
+ content.setEncoding("UTF-8");
+ content.setTitle("English Title");
+ content.setDescription("English Description");
+ content.setBasePath(this.newFile + "/" + Locale.ENGLISH.getLanguage());
+ content.setBytes("newdata".getBytes());
+ content.setMimeType("text/html");
+ file.setContent(Locale.ENGLISH, content);
+
+ Command newFileCommand = this.service.getCommandFactory().createNewFileCommand(file, content);
+ this.service.execute(newFileCommand);
+
+ JCRCMS.turnOnWorkflow();
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-07-25 20:12:03 UTC (rev 11590)
+++ branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-07-25 20:13:04 UTC (rev 11591)
@@ -1421,8 +1421,31 @@
}
return;
}
- aRes.setRenderParameter("path", aReq.getParameter("path"));
- aRes.setRenderParameter("op", CMSAdminConstants.OP_VIEWFILE);
+
+ String filePath = aReq.getParameter("path");
+ String parentPath = null;
+ try
+ {
+ parentPath = NodeUtil.getParentPath(filePath);
+ }
+ catch(Exception e)
+ {
+ parentPath = "/";
+ }
+
+ //Check if this file still exists
+ Command existsCmd = this.CMSService.getCommandFactory().createItemExistsCommand(filePath);
+ boolean exists = ((Boolean)this.CMSService.execute(existsCmd)).booleanValue();
+ if(exists)
+ {
+ aRes.setRenderParameter("path", filePath);
+ aRes.setRenderParameter("op", CMSAdminConstants.OP_VIEWFILE);
+ }
+ else
+ {
+ aRes.setRenderParameter("path", parentPath);
+ aRes.setRenderParameter("op", CMSAdminConstants.OP_MAIN);
+ }
}
else if(CMSAdminConstants.OP_MODIFYANDAPPROVE.equals(op))
{
15 years, 11 months
JBoss Portal SVN: r11590 - in tags/JBoss_Portal_2_6_6: cms/src/main/org/jboss/portal/test/cms/workflow and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-07-25 16:12:03 -0400 (Fri, 25 Jul 2008)
New Revision: 11590
Modified:
tags/JBoss_Portal_2_6_6/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java
tags/JBoss_Portal_2_6_6/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java
tags/JBoss_Portal_2_6_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
Log:
JBPORTAL-2088 - uploading a file shows up in list when it's not approved
Modified: tags/JBoss_Portal_2_6_6/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java
===================================================================
--- tags/JBoss_Portal_2_6_6/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java 2008-07-25 20:11:07 UTC (rev 11589)
+++ tags/JBoss_Portal_2_6_6/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java 2008-07-25 20:12:03 UTC (rev 11590)
@@ -34,6 +34,7 @@
import javax.naming.InitialContext;
import java.util.List;
import java.util.Locale;
+import java.util.ArrayList;
/**
* Created on : Dec 20, 2006
@@ -58,16 +59,15 @@
long processId = executionContext.getProcessInstance().getId();
CMS cms = this.getCMSService();
+ int lastIndex = content.getPath().lastIndexOf('/');
+ String path = content.getPath().substring(0, lastIndex);
+ String language = content.getPath().substring(lastIndex + 1);
if (approved)
{
ACLInterceptor.turnOff();
JCRCMS.turnOffWorkflow();
//create this content in the CMS and make it live
- int lastIndex = content.getPath().lastIndexOf('/');
- String path = content.getPath().substring(0, lastIndex);
- String language = content.getPath().substring(lastIndex + 1);
-
Command command = cms.getCommandFactory().createContentGetVersionsCommand(content.getPath());
List versions = (List)cms.execute(command);
org.jboss.portal.cms.model.Content processContent = this.findProcessContent(processId, versions);
@@ -100,6 +100,27 @@
JCRCMS.turnOnWorkflow();
ACLInterceptor.turnOn();
}
+ else
+ {
+ ACLInterceptor.turnOff();
+ JCRCMS.turnOffWorkflow();
+
+ //Check if there are any published versions of this file. If not, this is a new file that was denied publishing
+ //hence delete the file itself
+ Command command = cms.getCommandFactory().createContentGetVersionsCommand(content.getPath());
+ List versions = (List)cms.execute(command);
+ List filtered = this.filterPending(versions);
+ if(filtered == null || filtered.isEmpty())
+ {
+ //Delete this file
+ Command deleteCommand = cms.getCommandFactory().createDeleteCommand(path);
+ cms.execute(deleteCommand);
+ }
+
+
+ JCRCMS.turnOnWorkflow();
+ ACLInterceptor.turnOn();
+ }
}
/**
@@ -130,6 +151,30 @@
return content;
}
+
+ /**
+ *
+ * @param versions
+ * @return
+ */
+ private List filterPending(List versions)
+ {
+ List filtered = new ArrayList();
+
+ if(versions != null)
+ {
+ for(int i=0; i<versions.size(); i++)
+ {
+ org.jboss.portal.cms.model.Content content = (org.jboss.portal.cms.model.Content)versions.get(i);
+ if(!content.isWaitingForPublishApproval())
+ {
+ filtered.add(content);
+ }
+ }
+ }
+
+ return filtered;
+ }
/** @return */
private CMS getCMSService()
Modified: tags/JBoss_Portal_2_6_6/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java
===================================================================
--- tags/JBoss_Portal_2_6_6/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java 2008-07-25 20:11:07 UTC (rev 11589)
+++ tags/JBoss_Portal_2_6_6/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java 2008-07-25 20:12:03 UTC (rev 11590)
@@ -91,60 +91,22 @@
/** @throws Exception */
- public void test() throws Exception
+ public void testPublishExistingFile() throws Exception
{
- //Execute file creation as a regular user/non-manager
- this.runAs("user");
-
- //Add a new file to the CMS
- File file = new FileImpl();
- file.setBasePath(this.newFile);
-
- Content content = new ContentImpl();
- content.setEncoding("UTF-8");
- content.setTitle("English Title");
- content.setDescription("English Description");
- content.setBasePath(this.newFile + "/" + Locale.ENGLISH.getLanguage());
- content.setBytes("newdata".getBytes());
- content.setMimeType("text/html");
- file.setContent(Locale.ENGLISH, content);
-
- Command newFileCommand = this.service.getCommandFactory().createNewFileCommand(file, content);
- this.service.execute(newFileCommand);
-
- //Make sure this resource is not published into the CMS yet
- Command fileGet = this.service.getCommandFactory().createFileGetCommand(this.newFile, Locale.ENGLISH);
- File assertFile = (File)this.service.execute(fileGet);
- assertNull(assertFile.getContent());
-
- //Check the pending queue for this file
ApprovePublish approvePublish = this.service.getApprovePublishWorkflow();
- Collection queueItems = approvePublish.getPendingQueue(this.newFile);
- assertNotNull(queueItems);
- assertEquals(1, queueItems.size());
-
- //Deny the publish of this file into the CMS
Set managers = approvePublish.getManagers();
String manager = (String)managers.iterator().next();
- org.jboss.portal.cms.workflow.Content pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
- approvePublish.processManagerResponse(Long.parseLong(pendingItem.getProcessId()), manager.toLowerCase(), false);
-
- //Make sure this resource is not published into the CMS, and removed from the pending queue
- assertFile = (File)this.service.execute(fileGet);
- assertNull(assertFile.getContent());
- queueItems = approvePublish.getPendingQueue(this.newFile);
- if (queueItems != null)
- {
- assertTrue(queueItems.isEmpty());
- }
-
+
+ //Execute file creation as a regular user/non-manager
+ this.createNewFile();
+
//Check for the existence of a file to be updated first
Command existsCommand = this.service.getCommandFactory().createItemExistsCommand(this.updateFile);
Boolean exists = (Boolean)this.service.execute(existsCommand);
assertTrue(exists.booleanValue());
//Get the file to be updated
- fileGet = this.service.getCommandFactory().createFileGetCommand(this.updateFile, new Locale(this.service.getDefaultLocale()));
+ Command fileGet = this.service.getCommandFactory().createFileGetCommand(this.updateFile, new Locale(this.service.getDefaultLocale()));
File updateFile = (File)this.service.execute(fileGet);
assertNotNull(updateFile);
assertNotNull(updateFile.getContent());
@@ -163,19 +125,19 @@
this.service.execute(updateFileCommand);
//Make sure a new LIVE version of this resource is not published into the CMS
- assertFile = (File)this.service.execute(fileGet);
+ File assertFile = (File)this.service.execute(fileGet);
versions = (List)this.service.execute(getVersions);
assertEquals(new String(assertFile.getContent().getBytes()), oldContent);
assertEquals(assertFile.getContent().getVersionNumber(), oldLiveVersion);
assertEquals(2, versions.size());
//Checking pending queue for a version of this file to be approved
- queueItems = approvePublish.getPendingQueue(this.updateFile);
+ Collection queueItems = approvePublish.getPendingQueue(this.updateFile);
assertNotNull(queueItems);
assertEquals(1, queueItems.size());
//Deny publishing of this new version into the CMS
- pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
+ org.jboss.portal.cms.workflow.Content pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
approvePublish.processManagerResponse(Long.parseLong(pendingItem.getProcessId()), manager.toLowerCase(), false);
//Check for the success of this denial, and removal from the pending queue
@@ -189,5 +151,87 @@
{
assertTrue(queueItems.isEmpty());
}
- }
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ public void testPublishNewFile() throws Exception
+ {
+ //Execute file creation as a regular user/non-manager
+ this.runAs("user");
+
+ //Add a new file to the CMS
+ File file = new FileImpl();
+ file.setBasePath(this.newFile);
+
+ Content content = new ContentImpl();
+ content.setEncoding("UTF-8");
+ content.setTitle("English Title");
+ content.setDescription("English Description");
+ content.setBasePath(this.newFile + "/" + Locale.ENGLISH.getLanguage());
+ content.setBytes("newdata".getBytes());
+ content.setMimeType("text/html");
+ file.setContent(Locale.ENGLISH, content);
+
+ Command newFileCommand = this.service.getCommandFactory().createNewFileCommand(file, content);
+ this.service.execute(newFileCommand);
+
+ //Make sure this resource is not published into the CMS yet
+ Command fileGet = this.service.getCommandFactory().createFileGetCommand(this.newFile, Locale.ENGLISH);
+ File assertFile = (File)this.service.execute(fileGet);
+ assertNull(assertFile.getContent());
+
+ //Check the pending queue for this file
+ ApprovePublish approvePublish = this.service.getApprovePublishWorkflow();
+ Collection queueItems = approvePublish.getPendingQueue(this.newFile);
+ assertNotNull(queueItems);
+ assertEquals(1, queueItems.size());
+
+ //Deny the publish of this file into the CMS
+ Set managers = approvePublish.getManagers();
+ String manager = (String)managers.iterator().next();
+ org.jboss.portal.cms.workflow.Content pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
+ approvePublish.processManagerResponse(Long.parseLong(pendingItem.getProcessId()), manager.toLowerCase(), false);
+
+ //Make sure the file/content does not exist in the CMS, and removed from the pending queue
+ assertFile = (File)this.service.execute(fileGet);
+ assertNull(assertFile);
+ queueItems = approvePublish.getPendingQueue(this.newFile);
+ if (queueItems != null)
+ {
+ assertTrue(queueItems.isEmpty());
+ }
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ private void createNewFile() throws Exception
+ {
+ JCRCMS.turnOffWorkflow();
+
+ //Execute file creation as a regular user/non-manager
+ this.runAs("user");
+
+ //Add a new file to the CMS
+ File file = new FileImpl();
+ file.setBasePath(this.newFile);
+
+ Content content = new ContentImpl();
+ content.setEncoding("UTF-8");
+ content.setTitle("English Title");
+ content.setDescription("English Description");
+ content.setBasePath(this.newFile + "/" + Locale.ENGLISH.getLanguage());
+ content.setBytes("newdata".getBytes());
+ content.setMimeType("text/html");
+ file.setContent(Locale.ENGLISH, content);
+
+ Command newFileCommand = this.service.getCommandFactory().createNewFileCommand(file, content);
+ this.service.execute(newFileCommand);
+
+ JCRCMS.turnOnWorkflow();
+ }
}
Modified: tags/JBoss_Portal_2_6_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
--- tags/JBoss_Portal_2_6_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-07-25 20:11:07 UTC (rev 11589)
+++ tags/JBoss_Portal_2_6_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-07-25 20:12:03 UTC (rev 11590)
@@ -1421,8 +1421,31 @@
}
return;
}
- aRes.setRenderParameter("path", aReq.getParameter("path"));
- aRes.setRenderParameter("op", CMSAdminConstants.OP_VIEWFILE);
+
+ String filePath = aReq.getParameter("path");
+ String parentPath = null;
+ try
+ {
+ parentPath = NodeUtil.getParentPath(filePath);
+ }
+ catch(Exception e)
+ {
+ parentPath = "/";
+ }
+
+ //Check if this file still exists
+ Command existsCmd = this.CMSService.getCommandFactory().createItemExistsCommand(filePath);
+ boolean exists = ((Boolean)this.CMSService.execute(existsCmd)).booleanValue();
+ if(exists)
+ {
+ aRes.setRenderParameter("path", filePath);
+ aRes.setRenderParameter("op", CMSAdminConstants.OP_VIEWFILE);
+ }
+ else
+ {
+ aRes.setRenderParameter("path", parentPath);
+ aRes.setRenderParameter("op", CMSAdminConstants.OP_MAIN);
+ }
}
else if(CMSAdminConstants.OP_MODIFYANDAPPROVE.equals(op))
{
15 years, 11 months
JBoss Portal SVN: r11589 - in branches/JBoss_Portal_Branch_2_6: cms/src/main/org/jboss/portal/test/cms/workflow and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-07-25 16:11:07 -0400 (Fri, 25 Jul 2008)
New Revision: 11589
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
Log:
JBPORTAL-2088 - uploading a file shows up in list when it's not approved
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java 2008-07-25 09:37:07 UTC (rev 11588)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java 2008-07-25 20:11:07 UTC (rev 11589)
@@ -34,6 +34,7 @@
import javax.naming.InitialContext;
import java.util.List;
import java.util.Locale;
+import java.util.ArrayList;
/**
* Created on : Dec 20, 2006
@@ -58,16 +59,15 @@
long processId = executionContext.getProcessInstance().getId();
CMS cms = this.getCMSService();
+ int lastIndex = content.getPath().lastIndexOf('/');
+ String path = content.getPath().substring(0, lastIndex);
+ String language = content.getPath().substring(lastIndex + 1);
if (approved)
{
ACLInterceptor.turnOff();
JCRCMS.turnOffWorkflow();
//create this content in the CMS and make it live
- int lastIndex = content.getPath().lastIndexOf('/');
- String path = content.getPath().substring(0, lastIndex);
- String language = content.getPath().substring(lastIndex + 1);
-
Command command = cms.getCommandFactory().createContentGetVersionsCommand(content.getPath());
List versions = (List)cms.execute(command);
org.jboss.portal.cms.model.Content processContent = this.findProcessContent(processId, versions);
@@ -100,6 +100,27 @@
JCRCMS.turnOnWorkflow();
ACLInterceptor.turnOn();
}
+ else
+ {
+ ACLInterceptor.turnOff();
+ JCRCMS.turnOffWorkflow();
+
+ //Check if there are any published versions of this file. If not, this is a new file that was denied publishing
+ //hence delete the file itself
+ Command command = cms.getCommandFactory().createContentGetVersionsCommand(content.getPath());
+ List versions = (List)cms.execute(command);
+ List filtered = this.filterPending(versions);
+ if(filtered == null || filtered.isEmpty())
+ {
+ //Delete this file
+ Command deleteCommand = cms.getCommandFactory().createDeleteCommand(path);
+ cms.execute(deleteCommand);
+ }
+
+
+ JCRCMS.turnOnWorkflow();
+ ACLInterceptor.turnOn();
+ }
}
/**
@@ -130,6 +151,30 @@
return content;
}
+
+ /**
+ *
+ * @param versions
+ * @return
+ */
+ private List filterPending(List versions)
+ {
+ List filtered = new ArrayList();
+
+ if(versions != null)
+ {
+ for(int i=0; i<versions.size(); i++)
+ {
+ org.jboss.portal.cms.model.Content content = (org.jboss.portal.cms.model.Content)versions.get(i);
+ if(!content.isWaitingForPublishApproval())
+ {
+ filtered.add(content);
+ }
+ }
+ }
+
+ return filtered;
+ }
/** @return */
private CMS getCMSService()
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java 2008-07-25 09:37:07 UTC (rev 11588)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/workflow/TestDeniedPublish.java 2008-07-25 20:11:07 UTC (rev 11589)
@@ -91,60 +91,22 @@
/** @throws Exception */
- public void test() throws Exception
+ public void testPublishExistingFile() throws Exception
{
- //Execute file creation as a regular user/non-manager
- this.runAs("user");
-
- //Add a new file to the CMS
- File file = new FileImpl();
- file.setBasePath(this.newFile);
-
- Content content = new ContentImpl();
- content.setEncoding("UTF-8");
- content.setTitle("English Title");
- content.setDescription("English Description");
- content.setBasePath(this.newFile + "/" + Locale.ENGLISH.getLanguage());
- content.setBytes("newdata".getBytes());
- content.setMimeType("text/html");
- file.setContent(Locale.ENGLISH, content);
-
- Command newFileCommand = this.service.getCommandFactory().createNewFileCommand(file, content);
- this.service.execute(newFileCommand);
-
- //Make sure this resource is not published into the CMS yet
- Command fileGet = this.service.getCommandFactory().createFileGetCommand(this.newFile, Locale.ENGLISH);
- File assertFile = (File)this.service.execute(fileGet);
- assertNull(assertFile.getContent());
-
- //Check the pending queue for this file
ApprovePublish approvePublish = this.service.getApprovePublishWorkflow();
- Collection queueItems = approvePublish.getPendingQueue(this.newFile);
- assertNotNull(queueItems);
- assertEquals(1, queueItems.size());
-
- //Deny the publish of this file into the CMS
Set managers = approvePublish.getManagers();
String manager = (String)managers.iterator().next();
- org.jboss.portal.cms.workflow.Content pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
- approvePublish.processManagerResponse(Long.parseLong(pendingItem.getProcessId()), manager.toLowerCase(), false);
-
- //Make sure this resource is not published into the CMS, and removed from the pending queue
- assertFile = (File)this.service.execute(fileGet);
- assertNull(assertFile.getContent());
- queueItems = approvePublish.getPendingQueue(this.newFile);
- if (queueItems != null)
- {
- assertTrue(queueItems.isEmpty());
- }
-
+
+ //Execute file creation as a regular user/non-manager
+ this.createNewFile();
+
//Check for the existence of a file to be updated first
Command existsCommand = this.service.getCommandFactory().createItemExistsCommand(this.updateFile);
Boolean exists = (Boolean)this.service.execute(existsCommand);
assertTrue(exists.booleanValue());
//Get the file to be updated
- fileGet = this.service.getCommandFactory().createFileGetCommand(this.updateFile, new Locale(this.service.getDefaultLocale()));
+ Command fileGet = this.service.getCommandFactory().createFileGetCommand(this.updateFile, new Locale(this.service.getDefaultLocale()));
File updateFile = (File)this.service.execute(fileGet);
assertNotNull(updateFile);
assertNotNull(updateFile.getContent());
@@ -163,19 +125,19 @@
this.service.execute(updateFileCommand);
//Make sure a new LIVE version of this resource is not published into the CMS
- assertFile = (File)this.service.execute(fileGet);
+ File assertFile = (File)this.service.execute(fileGet);
versions = (List)this.service.execute(getVersions);
assertEquals(new String(assertFile.getContent().getBytes()), oldContent);
assertEquals(assertFile.getContent().getVersionNumber(), oldLiveVersion);
assertEquals(2, versions.size());
//Checking pending queue for a version of this file to be approved
- queueItems = approvePublish.getPendingQueue(this.updateFile);
+ Collection queueItems = approvePublish.getPendingQueue(this.updateFile);
assertNotNull(queueItems);
assertEquals(1, queueItems.size());
//Deny publishing of this new version into the CMS
- pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
+ org.jboss.portal.cms.workflow.Content pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
approvePublish.processManagerResponse(Long.parseLong(pendingItem.getProcessId()), manager.toLowerCase(), false);
//Check for the success of this denial, and removal from the pending queue
@@ -189,5 +151,87 @@
{
assertTrue(queueItems.isEmpty());
}
- }
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ public void testPublishNewFile() throws Exception
+ {
+ //Execute file creation as a regular user/non-manager
+ this.runAs("user");
+
+ //Add a new file to the CMS
+ File file = new FileImpl();
+ file.setBasePath(this.newFile);
+
+ Content content = new ContentImpl();
+ content.setEncoding("UTF-8");
+ content.setTitle("English Title");
+ content.setDescription("English Description");
+ content.setBasePath(this.newFile + "/" + Locale.ENGLISH.getLanguage());
+ content.setBytes("newdata".getBytes());
+ content.setMimeType("text/html");
+ file.setContent(Locale.ENGLISH, content);
+
+ Command newFileCommand = this.service.getCommandFactory().createNewFileCommand(file, content);
+ this.service.execute(newFileCommand);
+
+ //Make sure this resource is not published into the CMS yet
+ Command fileGet = this.service.getCommandFactory().createFileGetCommand(this.newFile, Locale.ENGLISH);
+ File assertFile = (File)this.service.execute(fileGet);
+ assertNull(assertFile.getContent());
+
+ //Check the pending queue for this file
+ ApprovePublish approvePublish = this.service.getApprovePublishWorkflow();
+ Collection queueItems = approvePublish.getPendingQueue(this.newFile);
+ assertNotNull(queueItems);
+ assertEquals(1, queueItems.size());
+
+ //Deny the publish of this file into the CMS
+ Set managers = approvePublish.getManagers();
+ String manager = (String)managers.iterator().next();
+ org.jboss.portal.cms.workflow.Content pendingItem = (org.jboss.portal.cms.workflow.Content)queueItems.iterator().next();
+ approvePublish.processManagerResponse(Long.parseLong(pendingItem.getProcessId()), manager.toLowerCase(), false);
+
+ //Make sure the file/content does not exist in the CMS, and removed from the pending queue
+ assertFile = (File)this.service.execute(fileGet);
+ assertNull(assertFile);
+ queueItems = approvePublish.getPendingQueue(this.newFile);
+ if (queueItems != null)
+ {
+ assertTrue(queueItems.isEmpty());
+ }
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ private void createNewFile() throws Exception
+ {
+ JCRCMS.turnOffWorkflow();
+
+ //Execute file creation as a regular user/non-manager
+ this.runAs("user");
+
+ //Add a new file to the CMS
+ File file = new FileImpl();
+ file.setBasePath(this.newFile);
+
+ Content content = new ContentImpl();
+ content.setEncoding("UTF-8");
+ content.setTitle("English Title");
+ content.setDescription("English Description");
+ content.setBasePath(this.newFile + "/" + Locale.ENGLISH.getLanguage());
+ content.setBytes("newdata".getBytes());
+ content.setMimeType("text/html");
+ file.setContent(Locale.ENGLISH, content);
+
+ Command newFileCommand = this.service.getCommandFactory().createNewFileCommand(file, content);
+ this.service.execute(newFileCommand);
+
+ JCRCMS.turnOnWorkflow();
+ }
}
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-07-25 09:37:07 UTC (rev 11588)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-07-25 20:11:07 UTC (rev 11589)
@@ -1421,8 +1421,31 @@
}
return;
}
- aRes.setRenderParameter("path", aReq.getParameter("path"));
- aRes.setRenderParameter("op", CMSAdminConstants.OP_VIEWFILE);
+
+ String filePath = aReq.getParameter("path");
+ String parentPath = null;
+ try
+ {
+ parentPath = NodeUtil.getParentPath(filePath);
+ }
+ catch(Exception e)
+ {
+ parentPath = "/";
+ }
+
+ //Check if this file still exists
+ Command existsCmd = this.CMSService.getCommandFactory().createItemExistsCommand(filePath);
+ boolean exists = ((Boolean)this.CMSService.execute(existsCmd)).booleanValue();
+ if(exists)
+ {
+ aRes.setRenderParameter("path", filePath);
+ aRes.setRenderParameter("op", CMSAdminConstants.OP_VIEWFILE);
+ }
+ else
+ {
+ aRes.setRenderParameter("path", parentPath);
+ aRes.setRenderParameter("op", CMSAdminConstants.OP_MAIN);
+ }
}
else if(CMSAdminConstants.OP_MODIFYANDAPPROVE.equals(op))
{
15 years, 11 months
JBoss Portal SVN: r11588 - modules/identity/tags/JBP_IDENTITY_1_0_4/identity/src/main/org/jboss/portal/identity/db.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-07-25 05:37:07 -0400 (Fri, 25 Jul 2008)
New Revision: 11588
Modified:
modules/identity/tags/JBP_IDENTITY_1_0_4/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java
Log:
JBPORTAL-2090: role creation gives an NPE
Modified: modules/identity/tags/JBP_IDENTITY_1_0_4/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java
===================================================================
--- modules/identity/tags/JBP_IDENTITY_1_0_4/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java 2008-07-25 08:03:26 UTC (rev 11587)
+++ modules/identity/tags/JBP_IDENTITY_1_0_4/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java 2008-07-25 09:37:07 UTC (rev 11588)
@@ -151,8 +151,13 @@
if (broadcaster != null)
{
- RoleUpdatedEvent event = new RoleUpdatedEvent(getId(), getName(), displayName);
- broadcaster.fireEvent(event);
+ // This can be called on object creation by hibernate so make sure that all fields are populated first
+ if (getId() != null && getName() != null && getDisplayName() != null)
+ {
+ RoleUpdatedEvent event = new RoleUpdatedEvent(getId(), getName(), displayName);
+ broadcaster.fireEvent(event);
+ }
+
}
}
15 years, 11 months
JBoss Portal SVN: r11587 - modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/db.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-07-25 04:03:26 -0400 (Fri, 25 Jul 2008)
New Revision: 11587
Modified:
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java
Log:
- stupid bug...
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java 2008-07-24 20:44:01 UTC (rev 11586)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java 2008-07-25 08:03:26 UTC (rev 11587)
@@ -151,8 +151,13 @@
if (broadcaster != null)
{
- RoleUpdatedEvent event = new RoleUpdatedEvent(getId(), getName(), displayName);
- broadcaster.fireEvent(event);
+ // This can be called on object creation by hibernate so make sure that all fields are populated first
+ if (getId() != null && getName() != null && getDisplayName() != null)
+ {
+ RoleUpdatedEvent event = new RoleUpdatedEvent(getId(), getName(), displayName);
+ broadcaster.fireEvent(event);
+ }
+
}
}
15 years, 11 months
JBoss Portal SVN: r11585 - in tags/JBoss_Portal_2_6_6/core-wsrp/src: resources/portal-wsrp-admin-war/WEB-INF/classes and 1 other directory.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-07-24 15:39:08 -0400 (Thu, 24 Jul 2008)
New Revision: 11585
Modified:
tags/JBoss_Portal_2_6_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
tags/JBoss_Portal_2_6_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
tags/JBoss_Portal_2_6_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties
tags/JBoss_Portal_2_6_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties
Log:
- JBPORTAL-2084: fixed detection of need to call modifyRegistration.
- Now perform value normalization to consider empty String as null since we can get both from JSF.
- Improved status reporting.
Modified: tags/JBoss_Portal_2_6_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- tags/JBoss_Portal_2_6_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2008-07-24 19:30:06 UTC (rev 11584)
+++ tags/JBoss_Portal_2_6_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2008-07-24 19:39:08 UTC (rev 11585)
@@ -64,6 +64,7 @@
private static final String CANNOT_MODIFY_REG = "bean_consumer_cannot_modify_reg";
private static final String CANNOT_ERASE_REG = "bean_consumer_cannot_erase_reg";
private static final String MALFORMED_URL = "bean_consumer_malformed_url";
+ private static final String UPDATE_SUCCESS = "bean_consumer_update_success";
public ConsumerBean()
{
@@ -297,6 +298,11 @@
public String update()
{
+ return internalUpdate(true);
+ }
+
+ private String internalUpdate(boolean showMessage)
+ {
if (consumer != null)
{
if (isModified())
@@ -324,6 +330,10 @@
}
}
+ if (showMessage)
+ {
+ beanContext.createInfoMessage(UPDATE_SUCCESS);
+ }
return ConsumerManagerBean.CONFIGURE_CONSUMER;
}
@@ -343,14 +353,22 @@
{
if (isModified())
{
- String updateResult = update();
+ String updateResult = internalUpdate(false);
if (updateResult == null)
{
return null;
}
}
- manager.refresh(consumer);
+ // if the registration is locally modified, bypassed the refresh as it will not yield a proper result
+ if (!isRegistrationLocallyModified())
+ {
+ manager.refresh(consumer);
+ }
+ else
+ {
+ beanContext.createInfoMessage(ConsumerManagerBean.REFRESH_MODIFY);
+ }
return ConsumerManagerBean.CONFIGURE_CONSUMER;
}
@@ -464,9 +482,23 @@
private boolean isOldAndNewEqual(Object oldValue, Object newValue)
{
+ oldValue = normalizeStringIfNeeded(oldValue);
+ newValue = normalizeStringIfNeeded(newValue);
+
return (oldValue != null && !oldValue.equals(newValue)) || (oldValue == null && newValue != null);
}
+ /**
+ * Normalizes Strings by considering empty String as null as JSF would give either
+ *
+ * @param value
+ * @return
+ */
+ private Object normalizeStringIfNeeded(Object value)
+ {
+ return (value instanceof String && ((String)value).length() == 0) ? null : value;
+ }
+
// Listeners
public void useWSDLListener(ValueChangeEvent event)
@@ -481,12 +513,12 @@
{
if (!registrationLocallyModified)
{
- registrationLocallyModified = isOldAndNewEqual(event.getOldValue(), event.getNewValue());
-
- // FIX-ME: this should be handled better
- // if we modified locally, mark the registration info as modified as well
- getProducerInfo().getRegistrationInfo().setModified(registrationLocallyModified);
- getProducerInfo().setModifyRegistrationRequired(true);
+ // only mark as locally modified if we had a previous value
+ Object oldValue = normalizeStringIfNeeded(event.getOldValue());
+ if (oldValue != null)
+ {
+ registrationLocallyModified = isOldAndNewEqual(oldValue, event.getNewValue());
+ }
}
}
}
Modified: tags/JBoss_Portal_2_6_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- tags/JBoss_Portal_2_6_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2008-07-24 19:30:06 UTC (rev 11584)
+++ tags/JBoss_Portal_2_6_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2008-07-24 19:39:08 UTC (rev 11585)
@@ -55,7 +55,7 @@
private static final String REFRESH_SUCCESS = "bean_consumermanager_refresh_success";
private static final String REFRESH_FAILURE = "bean_consumermanager_refresh_failure";
private static final String REFRESH_EXCEPTION = "bean_consumermanager_refresh_exception";
- private static final String REFRESH_MODIFY = "bean_consumermanager_refresh_modify";
+ static final String REFRESH_MODIFY = "bean_consumermanager_refresh_modify";
public ConsumerRegistry getRegistry()
{
Modified: tags/JBoss_Portal_2_6_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties
===================================================================
--- tags/JBoss_Portal_2_6_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties 2008-07-24 19:30:06 UTC (rev 11584)
+++ tags/JBoss_Portal_2_6_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties 2008-07-24 19:39:08 UTC (rev 11585)
@@ -146,6 +146,7 @@
bean_consumer_cannot_modify_reg = Couldn't modify registration!
bean_consumer_cannot_erase_reg = Couldn't erase local registration!
bean_consumer_malformed_url = ''{0}'' is not a valid URL: {1}
+bean_consumer_update_success = Successfully updated consumer!
# ConsumerManagerBean
bean_consumermanager_invalid_new_consumer_name = Need a non-null, non-empty name for the new consumer!
Modified: tags/JBoss_Portal_2_6_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties
===================================================================
--- tags/JBoss_Portal_2_6_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties 2008-07-24 19:30:06 UTC (rev 11584)
+++ tags/JBoss_Portal_2_6_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties 2008-07-24 19:39:08 UTC (rev 11585)
@@ -133,4 +133,5 @@
bean_consumermanager_refresh_success=Le rafra\u00eechissement a r\u00e9ussi.
bean_producer_cancel_success=Toutes les modifications faites \u00e0 la configuration du producteur ont \u00e9t\u00e9 annull\u00e9es!
bean_producer_save_success=La configuration du producteur a bien \u00e9t\u00e9 sauvegard\u00e9e!
-bean_consumermanager_refresh_modify=Les informations locales ont chang\u00e9, vous devriez modifier votre enregistrement avec le producteur.
\ No newline at end of file
+bean_consumermanager_refresh_modify=Les informations locales ont chang\u00e9, vous devriez modifier votre enregistrement avec le producteur.
+bean_consumer_update_success=Consommateur mis \u00e0 jour!
\ No newline at end of file
15 years, 11 months
JBoss Portal SVN: r11584 - in branches/JBoss_Portal_Branch_2_6/core-wsrp/src: resources/portal-wsrp-admin-war/WEB-INF/classes and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-24 15:30:06 -0400 (Thu, 24 Jul 2008)
New Revision: 11584
Modified:
branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties
branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties
Log:
- JBPORTAL-2084: fixed detection of need to call modifyRegistration.
- Now perform value normalization to consider empty String as null since we can get both from JSF.
- Improved status reporting.
Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2008-07-24 19:29:46 UTC (rev 11583)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2008-07-24 19:30:06 UTC (rev 11584)
@@ -64,6 +64,7 @@
private static final String CANNOT_MODIFY_REG = "bean_consumer_cannot_modify_reg";
private static final String CANNOT_ERASE_REG = "bean_consumer_cannot_erase_reg";
private static final String MALFORMED_URL = "bean_consumer_malformed_url";
+ private static final String UPDATE_SUCCESS = "bean_consumer_update_success";
public ConsumerBean()
{
@@ -297,6 +298,11 @@
public String update()
{
+ return internalUpdate(true);
+ }
+
+ private String internalUpdate(boolean showMessage)
+ {
if (consumer != null)
{
if (isModified())
@@ -324,6 +330,10 @@
}
}
+ if (showMessage)
+ {
+ beanContext.createInfoMessage(UPDATE_SUCCESS);
+ }
return ConsumerManagerBean.CONFIGURE_CONSUMER;
}
@@ -343,14 +353,22 @@
{
if (isModified())
{
- String updateResult = update();
+ String updateResult = internalUpdate(false);
if (updateResult == null)
{
return null;
}
}
- manager.refresh(consumer);
+ // if the registration is locally modified, bypassed the refresh as it will not yield a proper result
+ if (!isRegistrationLocallyModified())
+ {
+ manager.refresh(consumer);
+ }
+ else
+ {
+ beanContext.createInfoMessage(ConsumerManagerBean.REFRESH_MODIFY);
+ }
return ConsumerManagerBean.CONFIGURE_CONSUMER;
}
@@ -464,9 +482,23 @@
private boolean isOldAndNewEqual(Object oldValue, Object newValue)
{
+ oldValue = normalizeStringIfNeeded(oldValue);
+ newValue = normalizeStringIfNeeded(newValue);
+
return (oldValue != null && !oldValue.equals(newValue)) || (oldValue == null && newValue != null);
}
+ /**
+ * Normalizes Strings by considering empty String as null as JSF would give either
+ *
+ * @param value
+ * @return
+ */
+ private Object normalizeStringIfNeeded(Object value)
+ {
+ return (value instanceof String && ((String)value).length() == 0) ? null : value;
+ }
+
// Listeners
public void useWSDLListener(ValueChangeEvent event)
@@ -481,12 +513,12 @@
{
if (!registrationLocallyModified)
{
- registrationLocallyModified = isOldAndNewEqual(event.getOldValue(), event.getNewValue());
-
- // FIX-ME: this should be handled better
- // if we modified locally, mark the registration info as modified as well
- getProducerInfo().getRegistrationInfo().setModified(registrationLocallyModified);
- getProducerInfo().setModifyRegistrationRequired(true);
+ // only mark as locally modified if we had a previous value
+ Object oldValue = normalizeStringIfNeeded(event.getOldValue());
+ if (oldValue != null)
+ {
+ registrationLocallyModified = isOldAndNewEqual(oldValue, event.getNewValue());
+ }
}
}
}
Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2008-07-24 19:29:46 UTC (rev 11583)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2008-07-24 19:30:06 UTC (rev 11584)
@@ -55,7 +55,7 @@
private static final String REFRESH_SUCCESS = "bean_consumermanager_refresh_success";
private static final String REFRESH_FAILURE = "bean_consumermanager_refresh_failure";
private static final String REFRESH_EXCEPTION = "bean_consumermanager_refresh_exception";
- private static final String REFRESH_MODIFY = "bean_consumermanager_refresh_modify";
+ static final String REFRESH_MODIFY = "bean_consumermanager_refresh_modify";
public ConsumerRegistry getRegistry()
{
Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties 2008-07-24 19:29:46 UTC (rev 11583)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties 2008-07-24 19:30:06 UTC (rev 11584)
@@ -146,6 +146,7 @@
bean_consumer_cannot_modify_reg = Couldn't modify registration!
bean_consumer_cannot_erase_reg = Couldn't erase local registration!
bean_consumer_malformed_url = ''{0}'' is not a valid URL: {1}
+bean_consumer_update_success = Successfully updated consumer!
# ConsumerManagerBean
bean_consumermanager_invalid_new_consumer_name = Need a non-null, non-empty name for the new consumer!
Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties 2008-07-24 19:29:46 UTC (rev 11583)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties 2008-07-24 19:30:06 UTC (rev 11584)
@@ -133,4 +133,5 @@
bean_consumermanager_refresh_success=Le rafra\u00eechissement a r\u00e9ussi.
bean_producer_cancel_success=Toutes les modifications faites \u00e0 la configuration du producteur ont \u00e9t\u00e9 annull\u00e9es!
bean_producer_save_success=La configuration du producteur a bien \u00e9t\u00e9 sauvegard\u00e9e!
-bean_consumermanager_refresh_modify=Les informations locales ont chang\u00e9, vous devriez modifier votre enregistrement avec le producteur.
\ No newline at end of file
+bean_consumermanager_refresh_modify=Les informations locales ont chang\u00e9, vous devriez modifier votre enregistrement avec le producteur.
+bean_consumer_update_success=Consommateur mis \u00e0 jour!
\ No newline at end of file
15 years, 11 months
JBoss Portal SVN: r11583 - in branches/JBoss_Portal_Branch_2_7/core-wsrp/src: resources/portal-wsrp-admin-war/WEB-INF/classes and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-07-24 15:29:46 -0400 (Thu, 24 Jul 2008)
New Revision: 11583
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties
Log:
- JBPORTAL-2084: fixed detection of need to call modifyRegistration.
- Now perform value normalization to consider empty String as null since we can get both from JSF.
- Improved status reporting.
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2008-07-24 16:27:14 UTC (rev 11582)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2008-07-24 19:29:46 UTC (rev 11583)
@@ -64,6 +64,7 @@
private static final String CANNOT_MODIFY_REG = "bean_consumer_cannot_modify_reg";
private static final String CANNOT_ERASE_REG = "bean_consumer_cannot_erase_reg";
private static final String MALFORMED_URL = "bean_consumer_malformed_url";
+ private static final String UPDATE_SUCCESS = "bean_consumer_update_success";
public ConsumerBean()
{
@@ -297,6 +298,11 @@
public String update()
{
+ return internalUpdate(true);
+ }
+
+ private String internalUpdate(boolean showMessage)
+ {
if (consumer != null)
{
if (isModified())
@@ -324,6 +330,10 @@
}
}
+ if (showMessage)
+ {
+ beanContext.createInfoMessage(UPDATE_SUCCESS);
+ }
return ConsumerManagerBean.CONFIGURE_CONSUMER;
}
@@ -343,14 +353,22 @@
{
if (isModified())
{
- String updateResult = update();
+ String updateResult = internalUpdate(false);
if (updateResult == null)
{
return null;
}
}
- manager.refresh(consumer);
+ // if the registration is locally modified, bypassed the refresh as it will not yield a proper result
+ if (!isRegistrationLocallyModified())
+ {
+ manager.refresh(consumer);
+ }
+ else
+ {
+ beanContext.createInfoMessage(ConsumerManagerBean.REFRESH_MODIFY);
+ }
return ConsumerManagerBean.CONFIGURE_CONSUMER;
}
@@ -464,9 +482,23 @@
private boolean isOldAndNewEqual(Object oldValue, Object newValue)
{
+ oldValue = normalizeStringIfNeeded(oldValue);
+ newValue = normalizeStringIfNeeded(newValue);
+
return (oldValue != null && !oldValue.equals(newValue)) || (oldValue == null && newValue != null);
}
+ /**
+ * Normalizes Strings by considering empty String as null as JSF would give either
+ *
+ * @param value
+ * @return
+ */
+ private Object normalizeStringIfNeeded(Object value)
+ {
+ return (value instanceof String && ((String)value).length() == 0) ? null : value;
+ }
+
// Listeners
public void useWSDLListener(ValueChangeEvent event)
@@ -481,12 +513,12 @@
{
if (!registrationLocallyModified)
{
- registrationLocallyModified = isOldAndNewEqual(event.getOldValue(), event.getNewValue());
-
- // FIX-ME: this should be handled better
- // if we modified locally, mark the registration info as modified as well
- getProducerInfo().getRegistrationInfo().setModified(registrationLocallyModified);
- getProducerInfo().setModifyRegistrationRequired(true);
+ // only mark as locally modified if we had a previous value
+ Object oldValue = normalizeStringIfNeeded(event.getOldValue());
+ if (oldValue != null)
+ {
+ registrationLocallyModified = isOldAndNewEqual(oldValue, event.getNewValue());
+ }
}
}
}
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2008-07-24 16:27:14 UTC (rev 11582)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2008-07-24 19:29:46 UTC (rev 11583)
@@ -55,7 +55,7 @@
private static final String REFRESH_SUCCESS = "bean_consumermanager_refresh_success";
private static final String REFRESH_FAILURE = "bean_consumermanager_refresh_failure";
private static final String REFRESH_EXCEPTION = "bean_consumermanager_refresh_exception";
- private static final String REFRESH_MODIFY = "bean_consumermanager_refresh_modify";
+ static final String REFRESH_MODIFY = "bean_consumermanager_refresh_modify";
public ConsumerRegistry getRegistry()
{
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties 2008-07-24 16:27:14 UTC (rev 11582)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource.properties 2008-07-24 19:29:46 UTC (rev 11583)
@@ -146,6 +146,7 @@
bean_consumer_cannot_modify_reg = Couldn't modify registration!
bean_consumer_cannot_erase_reg = Couldn't erase local registration!
bean_consumer_malformed_url = ''{0}'' is not a valid URL: {1}
+bean_consumer_update_success = Successfully updated consumer!
# ConsumerManagerBean
bean_consumermanager_invalid_new_consumer_name = Need a non-null, non-empty name for the new consumer!
Modified: branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties 2008-07-24 16:27:14 UTC (rev 11582)
+++ branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/WSRPConfigurationResource_fr.properties 2008-07-24 19:29:46 UTC (rev 11583)
@@ -133,4 +133,5 @@
bean_consumermanager_refresh_success=Le rafra\u00eechissement a r\u00e9ussi.
bean_producer_cancel_success=Toutes les modifications faites \u00e0 la configuration du producteur ont \u00e9t\u00e9 annull\u00e9es!
bean_producer_save_success=La configuration du producteur a bien \u00e9t\u00e9 sauvegard\u00e9e!
-bean_consumermanager_refresh_modify=Les informations locales ont chang\u00e9, vous devriez modifier votre enregistrement avec le producteur.
\ No newline at end of file
+bean_consumermanager_refresh_modify=Les informations locales ont chang\u00e9, vous devriez modifier votre enregistrement avec le producteur.
+bean_consumer_update_success=Consommateur mis \u00e0 jour!
\ No newline at end of file
15 years, 11 months