gatein SVN: r2498 - in portal/branches/EPP_5_0_Branch: portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin and 1 other directories.
by do-not-reply@jboss.org
Author: mpodolin
Date: 2010-04-06 10:37:28 -0400 (Tue, 06 Apr 2010)
New Revision: 2498
Modified:
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java
Log:
JBEPP-285: GTNPORTAL-1018 ported to the branch
Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetEditor.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -42,7 +42,10 @@
import org.exoplatform.webui.exception.MessageException;
import org.exoplatform.webui.form.UIForm;
import org.exoplatform.webui.form.UIFormInput;
+import org.exoplatform.webui.form.UIFormStringInput;
import org.exoplatform.webui.form.UIFormTextAreaInput;
+import org.exoplatform.webui.form.validator.ExpressionValidator;
+import org.exoplatform.webui.form.validator.IdentifierValidator;
import org.exoplatform.webui.form.validator.MandatoryValidator;
import org.exoplatform.webui.form.validator.Validator;
@@ -61,19 +64,24 @@
{
final static public String FIELD_SOURCE = "source";
+ final static public String FIELD_NAME = "name";
private Source source_;
private String fullName_;
private String dirPath;
+
+ private String gadgetName_;
public UIGadgetEditor(InitParams initParams) throws Exception
{
Param param = initParams.getParam("SampleGadget");
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
String sample = (String)param.getMapGroovyObject(context);
- addUIFormInput(new UIFormTextAreaInput(FIELD_SOURCE, null, sample).addValidator(MandatoryValidator.class)
+ addUIFormInput(new UIFormStringInput(FIELD_NAME, null, null).addValidator(MandatoryValidator.class).addValidator(ExpressionValidator.class, "^[\\p{L}][\\p{ASCII}]+$",
+ "UIGadgetEditor.msg.Invalid"));
+ addUIFormInput(new UIFormTextAreaInput(FIELD_SOURCE, FIELD_SOURCE, sample).addValidator(MandatoryValidator.class)
.addValidator(GadgetSpecValidator.class));
}
@@ -89,6 +97,11 @@
UIFormTextAreaInput uiInputSource = getUIFormTextAreaInput(FIELD_SOURCE);
uiInputSource.setValue(source_.getTextContent());
}
+
+ public void setGadgetName(String name) {
+ UIFormStringInput uiInputName = getUIStringInput(FIELD_NAME);
+ uiInputName.setValue(name);
+ }
public String getSourceFullName()
{
@@ -103,8 +116,13 @@
public void processRender(WebuiRequestContext context) throws Exception
{
UIFormTextAreaInput uiInputSource = getUIFormTextAreaInput(FIELD_SOURCE);
+ UIFormStringInput uiInputName = getUIStringInput(FIELD_NAME);
String encoded = StringEscapeUtils.escapeHtml(StringEscapeUtils.unescapeHtml(uiInputSource.getValue()));
uiInputSource.setValue(encoded);
+ if(this.isEdit()) {
+ uiInputName.setEditable(false);
+ }
+
super.processRender(context);
}
@@ -137,56 +155,57 @@
{
UIGadgetEditor uiForm = event.getSource();
UIGadgetManagement uiManagement = uiForm.getParent();
- String name, fileName, dirPath;
+ String gadgetName;
String text = uiForm.getUIFormTextAreaInput(UIGadgetEditor.FIELD_SOURCE).getValue();
GadgetRegistryService service = uiForm.getApplicationComponent(GadgetRegistryService.class);
SourceStorage sourceStorage = uiForm.getApplicationComponent(SourceStorage.class);
- boolean isEdit = uiForm.getSource() != null;
+ boolean isEdit = uiForm.isEdit();
if (isEdit)
{
- fileName = uiForm.getSourceFullName();
- name = uiForm.getSourceName();
- dirPath = uiForm.getDirPath();
+ gadgetName = uiForm.getSourceFullName();
}
else
{
- name = "gadget" + Calendar.getInstance().hashCode();
- fileName = name + ".xml";
- dirPath = name;
+ gadgetName = uiForm.getUIStringInput(UIGadgetEditor.FIELD_NAME).getValue();
}
//
- Gadget gadget = service.getGadget(name);
- if (isEdit)
- {
- if (gadget == null)
- {
- UIApplication uiApp = event.getRequestContext().getUIApplication();
- uiApp.addMessage(new ApplicationMessage("gadget.msg.changeNotExist", null));
- uiManagement.reload();
- return;
- }
+ Gadget gadget = service.getGadget(gadgetName);
+
+ if(isEdit) {
+ if (gadget == null)
+ {
+ UIApplication uiApp = event.getRequestContext().getUIApplication();
+ uiApp.addMessage(new ApplicationMessage("gadget.msg.changeNotExist", null, ApplicationMessage.WARNING));
+ uiManagement.reload();
+ return;
+ }
}
+ else {
+ // If gadget is null we need to create it first
+ if (gadget == null)
+ {
+ gadget = new Gadget();
+ gadget.setName(gadgetName);
- // If gadget is null we need to create it first
- if (gadget == null)
- {
- gadget = new Gadget();
- gadget.setName("CHANGME");
+ // Those data will be taken from the gadget XML anyway
+ gadget.setDescription("");
+ gadget.setThumbnail("");
+ gadget.setLocal(true);
+ gadget.setTitle("");
+ gadget.setReferenceUrl("");
- // Those data will be taken from the gadget XML anyway
- gadget.setDescription("");
- gadget.setThumbnail("");
- gadget.setLocal(true);
- gadget.setTitle("");
- gadget.setReferenceUrl("");
-
- // Save gadget with empty data first
- service.saveGadget(gadget);
+ // Save gadget with empty data first
+ service.saveGadget(gadget);
+ }
+ else {
+ UIApplication uiApp = event.getRequestContext().getUIApplication();
+ uiApp.addMessage(new ApplicationMessage("UIGadgetEditor.gadget.msg.gadgetIsExist", null, ApplicationMessage.WARNING));
+ return;
+ }
}
-
//
- Source source = new Source(fileName, "application/xml");
+ Source source = new Source(gadgetName, "application/xml");
source.setTextContent(text);
source.setLastModified(Calendar.getInstance());
@@ -202,6 +221,10 @@
}
}
+
+ private boolean isEdit() {
+ return (this.getSource() != null);
+ }
public static class CancelActionListener extends EventListener<UIGadgetEditor>
{
Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -160,6 +160,7 @@
// get gadget's source: path = dir path + file name
Source source = sourceStorage.getSource(gadget);
uiEditor.setSource(source);
+ uiEditor.setGadgetName(gadget.getName());
uiEditor.setDirPath(dirPath);
uiManagement.getChildren().clear();
uiManagement.addChild(uiEditor);
Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties 2010-04-06 14:37:28 UTC (rev 2498)
@@ -139,10 +139,13 @@
UIAddGadget.label.urlError=Data in url: '{0}' is not valid
## org.exoplatform.applicationregistry.webui.component.UIGadgetEditor
-UIGadgetEditor.label.source=Source:
+UIGadgetEditor.label.source=Source:
+UIGadgetEditor.label.name=Name:
UIGadgetEditor.action.Save=#{word.save}
UIGadgetEditor.action.Cancel=#{word.cancel}
UIGadgetEditor.msg.invalidSpec=This source is invalid gadget specification.
+UIGadgetEditor.gadget.msg.gadgetIsExist=This name already exists, please enter a different name.
+UIGadgetEditor.msg.Invalid=The "{0}" field must not contains special characters.
##package org.exoplatform.organization.webui.component.UIListPermissionSelector
UIListPermissionSelector.header.groupId=Group
UIListPermissionSelector.header.membership=Membership
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -59,7 +59,7 @@
String s = (String)uiInput.getValue();
if (s.matches(EMAIL_REGEX))
return;
- Object[] args = {label, uiInput.getBindingField()};
+ Object[] args = {label};
throw new MessageException(new ApplicationMessage("EmailAddressValidator.msg.Invalid-input", args,
ApplicationMessage.WARNING));
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -85,7 +85,7 @@
{
label = uiInput.getName();
}
- Object[] args = {label,};
+ Object[] args = {label};
throw new MessageException(new ApplicationMessage(key_, args, ApplicationMessage.WARNING));
}
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -68,7 +68,7 @@
{
continue;
}
- Object[] args = {label, uiInput.getBindingField()};
+ Object[] args = {label};
throw new MessageException(new ApplicationMessage("IdentifierValidator.msg.Invalid-char", args,
ApplicationMessage.WARNING));
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -61,7 +61,7 @@
label = uiInput.getName();
}
label = label.trim();
- Object[] args = {label, uiInput.getBindingField()};
+ Object[] args = {label};
throw new MessageException(new ApplicationMessage("EmptyFieldValidator.msg.empty-input", args,
ApplicationMessage.WARNING));
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -62,7 +62,7 @@
{
continue;
}
- Object[] args = {label, uiInput.getBindingField()};
+ Object[] args = {label};
throw new MessageException(new ApplicationMessage("NameValidator.msg.Invalid-char", args));
}
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -52,7 +52,7 @@
{
label = uiInput.getName();
}
- Object[] args = {label, uiInput.getBindingField()};
+ Object[] args = {label};
throw new MessageException(new ApplicationMessage("EmptyFieldValidator.msg.empty-input", args));
}
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -61,7 +61,7 @@
{
continue;
}
- Object[] args = {label, uiInput.getBindingField()};
+ Object[] args = {label};
throw new MessageException(new ApplicationMessage("NumberFormatValidator.msg.Invalid-number", args));
}
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -69,7 +69,7 @@
}
if (error == true && s.charAt(0) == '-')
{
- Object[] args = {label, uiInput.getBindingField()};
+ Object[] args = {label};
throw new MessageException(new ApplicationMessage("PositiveNumberFormatValidator.msg.Invalid-number", args));
}
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -68,7 +68,7 @@
{
continue;
}
- Object[] args = {label, uiInput.getBindingField()};
+ Object[] args = {label};
throw new MessageException(new ApplicationMessage("ResourceValidator.msg.Invalid-char", args,
ApplicationMessage.WARNING));
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java 2010-04-06 14:35:01 UTC (rev 2497)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java 2010-04-06 14:37:28 UTC (rev 2498)
@@ -60,7 +60,7 @@
{
continue;
}
- Object[] args = {label, uiInput.getBindingField()};
+ Object[] args = {label};
throw new MessageException(new ApplicationMessage("SpecialCharacterValidator.msg.Invalid-char", args,
ApplicationMessage.WARNING));
}
14 years, 9 months
gatein SVN: r2497 - portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal.
by do-not-reply@jboss.org
Author: wesleyhales
Date: 2010-04-06 10:35:01 -0400 (Tue, 06 Apr 2010)
New Revision: 2497
Modified:
portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_fr.properties
Log:
JBEPP-264 remove non-epp text from copyright
Modified: portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
===================================================================
--- portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-04-06 14:32:42 UTC (rev 2496)
+++ portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-04-06 14:35:01 UTC (rev 2497)
@@ -254,7 +254,7 @@
UILoginForm.label.Signin=Sign in
UILoginForm.label.ForAccount=Register now for an account
UILoginForm.label.SigninFail=Sign in failed. Wrong username or password.
-UILoginForm.label.Copyright=Copyright © 2009-2010. All rights reserved, Red Hat, Inc and eXo Platform SAS
+UILoginForm.label.Copyright=Copyright © 2009-2010. All rights reserved, Red Hat, Inc
#############################################################################
# Message Error #
@@ -977,7 +977,7 @@
############################################################################
UIPortalToolPanel.label.copyrightText=Copyright © 2010. All rights reserved,
-UIPortalToolPanel.label.companyTitleText= Red Hat, Inc and eXo Platform SAS
+UIPortalToolPanel.label.companyTitleText= Red Hat, Inc
############################################################################
# org.exoplatform.portal.component.view.UIContainer #
Modified: portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_fr.properties
===================================================================
--- portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_fr.properties 2010-04-06 14:32:42 UTC (rev 2496)
+++ portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_fr.properties 2010-04-06 14:35:01 UTC (rev 2497)
@@ -239,7 +239,7 @@
UILoginForm.label.Signup=Enregistrement
UILoginForm.label.ForAccount=Créer un compte
UILoginForm.label.SigninFail=Sign in failed. Wrong username or password.
-UILoginForm.label.Copyright=Copyright © 2009-2010. All rights reserved, Red Hat, Inc. and eXo Platform SAS
+UILoginForm.label.Copyright=Copyright © 2009-2010. All rights reserved, Red Hat, Inc.
#############################################################################
# Message Error #
14 years, 9 months
gatein SVN: r2496 - in portal/branches/EPP_5_0_Branch: webui/core/src/main/java/org/exoplatform/webui/form/validator and 1 other directory.
by do-not-reply@jboss.org
Author: mpodolin
Date: 2010-04-06 10:32:42 -0400 (Tue, 06 Apr 2010)
New Revision: 2496
Modified:
portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PasswordStringLengthValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/StringLengthValidator.java
portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/URLValidator.java
Log:
JBEPP-200: GTNPORTAL-173 ported to the branch
Modified: portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl
===================================================================
--- portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl 2010-04-06 14:32:42 UTC (rev 2496)
@@ -60,7 +60,7 @@
Object[] msgArguments = mess.getMessageAruments();
if(msgArguments != null && msgArguments.length > 0) {
for(i in 0..msgArguments.length-1){
- msgValue = msgValue.replaceAll("\\{" + i + "\\}", msgArguments [i]);
+ msgValue = msgValue.replaceAll("\\{" + i + "\\}", _ctx.appRes(msgArguments [i]));
}
}
println msgValue;
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -61,7 +61,7 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/EmailAddressValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -48,15 +48,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
if (uiInput.getValue() == null || ((String)uiInput.getValue()).trim().length() == 0)
return;
String s = (String)uiInput.getValue();
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ExpressionValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -79,17 +79,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- {
- label = label.substring(0, label.length() - 1);
- }
Object[] args = {label,};
throw new MessageException(new ApplicationMessage(key_, args, ApplicationMessage.WARNING));
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/IdentifierValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -48,15 +48,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
String s = (String)uiInput.getValue();
if (Character.isDigit(s.charAt(0)) || s.charAt(0) == '-')
{
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/MandatoryValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -54,15 +54,13 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
Object[] args = {label, uiInput.getBindingField()};
throw new MessageException(new ApplicationMessage("EmptyFieldValidator.msg.empty-input", args,
ApplicationMessage.WARNING));
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NameValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -48,15 +48,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
String s = (String)uiInput.getValue();
for (int i = 0; i < s.length(); i++)
{
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NullFieldValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -46,15 +46,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
Object[] args = {label, uiInput.getBindingField()};
throw new MessageException(new ApplicationMessage("EmptyFieldValidator.msg.empty-input", args));
}
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/NumberFormatValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -46,15 +46,13 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
String s = (String)uiInput.getValue();
for (int i = 0; i < s.length(); i++)
{
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PasswordStringLengthValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PasswordStringLengthValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PasswordStringLengthValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -80,15 +80,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- label = label;
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
Object[] args = {label, min_.toString(), max_.toString()};
throw new MessageException(new ApplicationMessage("StringLengthValidator.msg.length-invalid", args,
ApplicationMessage.WARNING));
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/PositiveNumberFormatValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -47,15 +47,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
String s = (String)uiInput.getValue();
boolean error = false;
for (int i = 0; i < s.length(); i++)
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/ResourceValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -48,15 +48,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
String s = (String)uiInput.getValue();
if (Character.isDigit(s.charAt(0)) || s.charAt(0) == '-' || s.charAt(0) == '.' || s.charAt(0) == '_')
{
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/SpecialCharacterValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -46,15 +46,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
String s = (String)uiInput.getValue();
for (int i = 0; i < s.length(); i++)
{
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/StringLengthValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/StringLengthValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/StringLengthValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -75,15 +75,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- label = label.trim();
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
Object[] args = {label, min_.toString(), max_.toString()};
throw new MessageException(new ApplicationMessage("StringLengthValidator.msg.length-invalid", args,
ApplicationMessage.WARNING));
Modified: portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/URLValidator.java
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/URLValidator.java 2010-04-06 14:21:35 UTC (rev 2495)
+++ portal/branches/EPP_5_0_Branch/webui/core/src/main/java/org/exoplatform/webui/form/validator/URLValidator.java 2010-04-06 14:32:42 UTC (rev 2496)
@@ -75,14 +75,12 @@
String label;
try
{
- label = uiForm.getLabel(uiInput.getName());
+ label = uiForm.getId() + ".label." + uiInput.getName();
}
catch (Exception e)
{
label = uiInput.getName();
}
- if (label.charAt(label.length() - 1) == ':')
- label = label.substring(0, label.length() - 1);
Object[] args = {label};
throw new MessageException(new ApplicationMessage(key_, args, ApplicationMessage.WARNING));
}
14 years, 9 months
gatein SVN: r2495 - in portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal: template/classic and 1 other directory.
by do-not-reply@jboss.org
Author: wesleyhales
Date: 2010-04-06 10:21:35 -0400 (Tue, 06 Apr 2010)
New Revision: 2495
Modified:
portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/portal.xml
portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/portal.xml
Log:
add bread crumb portlet back to default layout
Modified: portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/portal.xml
===================================================================
--- portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/portal.xml 2010-04-06 14:12:38 UTC (rev 2494)
+++ portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/portal.xml 2010-04-06 14:21:35 UTC (rev 2495)
@@ -58,14 +58,14 @@
<show-info-bar>false</show-info-bar>
</portlet-application>
- <!--<portlet-application>-->
- <!--<portlet>-->
- <!--<application-ref>web</application-ref>-->
- <!--<portlet-ref>BreadcumbsPortlet</portlet-ref>-->
- <!--</portlet>-->
- <!--<access-permissions>Everyone</access-permissions>-->
- <!--<show-info-bar>false</show-info-bar>-->
- <!--</portlet-application>-->
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>BreadcumbsPortlet</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ </portlet-application>
<page-body> </page-body>
Modified: portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/portal.xml
===================================================================
--- portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/portal.xml 2010-04-06 14:12:38 UTC (rev 2494)
+++ portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/portal.xml 2010-04-06 14:21:35 UTC (rev 2495)
@@ -58,14 +58,14 @@
<show-info-bar>false</show-info-bar>
</portlet-application>
- <!--<portlet-application>-->
- <!--<portlet>-->
- <!--<application-ref>web</application-ref>-->
- <!--<portlet-ref>BreadcumbsPortlet</portlet-ref>-->
- <!--</portlet>-->
- <!--<access-permissions>Everyone</access-permissions>-->
- <!--<show-info-bar>false</show-info-bar>-->
- <!--</portlet-application>-->
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>BreadcumbsPortlet</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ </portlet-application>
<page-body> </page-body>
14 years, 9 months
gatein SVN: r2494 - in portal/branches/EPP_5_0_Branch/component/portal/src: test/java/org/exoplatform/portal/config and 1 other directory.
by do-not-reply@jboss.org
Author: mpodolin
Date: 2010-04-06 10:12:38 -0400 (Tue, 06 Apr 2010)
New Revision: 2494
Modified:
portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
portal/branches/EPP_5_0_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
Log:
JBEPP-232: GTNPORTAL-858 ported to the branch
Modified: portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java 2010-04-06 13:55:32 UTC (rev 2493)
+++ portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java 2010-04-06 14:12:38 UTC (rev 2494)
@@ -194,6 +194,11 @@
PageLink link = dst.linkTo(ObjectType.PAGE_LINK);
link.setPage(target);
}
+ else
+ {
+ PageLink link = dst.linkTo(ObjectType.PAGE_LINK);
+ link.setPage(null);
+ }
//
Described described = dst.adapt(Described.class);
Modified: portal/branches/EPP_5_0_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2010-04-06 13:55:32 UTC (rev 2493)
+++ portal/branches/EPP_5_0_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2010-04-06 14:12:38 UTC (rev 2494)
@@ -358,6 +358,54 @@
PageNavigation newPageNavi = storage_.getPageNavigation(pageNavi.getOwnerType(), pageNavi.getOwnerId());
}
+ /**
+ * Test that setting a page reference to null will actually remove the page reference from the PageNode
+ * @throws Exception
+ */
+ public void testNullPageReferenceDeletes() throws Exception
+ {
+ // create portal
+ PortalConfig portal = new PortalConfig();
+ portal.setName("foo");
+ portal.setLocale("en");
+ portal.setAccessPermissions(new String[]{UserACL.EVERYONE});
+ storage_.create(portal);
+
+ // create page
+ Page page = new Page();
+ page.setOwnerType(PortalConfig.PORTAL_TYPE);
+ page.setOwnerId("test");
+ page.setName("foo");
+ storage_.create(page);
+
+ //create a page node and add page
+ PageNode pageNode = new PageNode();
+ pageNode.setName("testPage");
+ pageNode.setPageReference(page.getPageId());
+ pageNode.build();
+
+ // create a new page navigation and add node
+ PageNavigation navigation = new PageNavigation();
+ navigation.setOwnerId("foo");
+ navigation.setOwnerType("portal");
+ navigation.addNode(pageNode);
+ storage_.create(navigation);
+
+ // get the page reference from the created page and check that it exists
+ PageNavigation pageNavigationWithPageReference = storage_.getPageNavigation("portal", navigation.getOwnerId());
+ assertNotNull("Expected page reference should not be null.", pageNavigationWithPageReference.getNodes().get(0).getPageReference());
+
+ // set the page reference to null and save.
+ ArrayList<PageNode> nodes = navigation.getNodes();
+ nodes.get(0).setPageReference(null);
+ navigation.setNodes(nodes);
+ storage_.save(navigation);
+
+ // check that setting the page reference to null actually removes the page reference
+ PageNavigation pageNavigationWithoutPageReference = storage_.getPageNavigation("portal", navigation.getOwnerId());
+ assertNull("Expected page reference should be null.", pageNavigationWithoutPageReference.getNodes().get(0).getPageReference());
+ }
+
public void testRemoveNavigation() throws Exception
{
PageNavigation navigation = storage_.getPageNavigation("portal", "test");
14 years, 9 months
gatein SVN: r2493 - components/sso/trunk.
by do-not-reply@jboss.org
Author: sohil.shah(a)jboss.com
Date: 2010-04-06 09:55:32 -0400 (Tue, 06 Apr 2010)
New Revision: 2493
Removed:
components/sso/trunk/spengo/
Log:
cleanup
14 years, 9 months
gatein SVN: r2492 - in portal/branches/EPP_5_0_Branch/component: common/src/main/java/org/exoplatform/commons/cache/future and 5 other directories.
by do-not-reply@jboss.org
Author: mpodolin
Date: 2010-04-06 09:32:13 -0400 (Tue, 06 Apr 2010)
New Revision: 2492
Added:
portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/
portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java
portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java
portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java
portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java
portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/
portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/
portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java
portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java
portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java
portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/StringLoader.java
portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/resolver/ResourceKey.java
Modified:
portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java
portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/resolver/ResourceResolver.java
Log:
JBEPP-265: GTNPORTAL-945 ported to the branch
Added: portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.commons.cache.future;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Entry<V> implements Serializable
+{
+
+ public static <V> Entry<V> create(V v)
+ {
+ return new Entry<V>(v);
+ }
+
+ /** . */
+ private final V value;
+
+ private Entry(V value)
+ {
+ if (value == null)
+ {
+ throw new NullPointerException();
+ }
+ this.value = value;
+ }
+
+ public V getValue()
+ {
+ return value;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Entry[" + value + "]";
+ }
+}
Added: portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.commons.cache.future;
+
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import java.util.concurrent.*;
+
+/**
+ * A future cache that prevents the loading of the same resource twice. This should be used when the resource
+ * to load is very expensive or cannot be concurrently retrieved (like a classloading).
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class FutureCache<K, V, C>
+{
+
+ /** . */
+ private final Loader<K, V, C> loader;
+
+ /** . */
+ private final ConcurrentMap<K, FutureTask<Entry<V>>> local;
+
+ /** . */
+ private final Logger log = LoggerFactory.getLogger(FutureCache.class);
+
+ public FutureCache(Loader<K, V, C> loader)
+ {
+ this.loader = loader;
+ this.local = new ConcurrentHashMap<K, FutureTask<Entry<V>>>();
+ }
+
+ protected abstract Entry<V> get(K key);
+
+ protected abstract void put(K key, Entry<V> entry);
+
+ public V get(final C context, final K key)
+ {
+ // First we try a simple cache get
+ Entry<V> entry = get(key);
+
+ // If it does not succeed then we go through a process that will avoid to load
+ // the same resource concurrently
+ if (entry == null)
+ {
+ // Create our future
+ FutureTask<Entry<V>> future = new FutureTask<Entry<V>>(new Callable<Entry<V>>()
+ {
+ public Entry<V> call() throws Exception
+ {
+ // Retrieve the value from the loader
+ V value = loader.retrieve(context, key);
+
+ //
+ if (value != null)
+ {
+ // Create the entry
+ Entry<V> entry = Entry.create(value);
+
+ // Cache it, it is made available to other threads (unless someone removes it)
+ put(key, entry);
+
+ // Return entry
+ return entry;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ });
+
+ // Was our means that we inserted in the local
+ boolean inserted = true;
+
+ //
+ try
+ {
+ FutureTask<Entry<V>> phantom = local.putIfAbsent(key, future);
+
+ // Use the entry that could have been inserted by another thread
+ if (phantom != null)
+ {
+ future = phantom;
+ inserted = false;
+ }
+ else
+ {
+ future.run();
+ }
+
+ // Returns the entry
+ entry = future.get();
+ }
+ catch (ExecutionException e)
+ {
+ log.error("Computing of resource " + key + " threw an exception", e.getCause());
+ }
+ catch (Exception e)
+ {
+ log.error("Retrieval of resource " + key + " threw an exception", e);
+ }
+ finally
+ {
+ // Clean up the per key map but only if our insertion succeeded and with our future
+ if (inserted)
+ {
+ local.remove(key, future);
+ }
+ }
+ }
+
+ //
+ return entry != null ? entry.getValue() : null;
+ }
+}
Added: portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.commons.cache.future;
+
+import org.exoplatform.services.cache.ExoCache;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class FutureExoCache<K extends Serializable, V, C> extends FutureCache<K, V, C>
+{
+
+ /** . */
+ private final ExoCache<K, Entry<V>> cache;
+
+ public FutureExoCache(Loader<K, V, C> loader, ExoCache<K, Entry<V>> cache)
+ {
+ super(loader);
+
+ //
+ this.cache = cache;
+ }
+
+ @Override
+ protected Entry<V> get(K key)
+ {
+ return cache.get(key);
+ }
+
+ @Override
+ protected void put(K key, Entry<V> entry)
+ {
+ cache.put(key, entry);
+ }
+}
Added: portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.commons.cache.future;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public interface Loader<K, V, C>
+{
+
+ V retrieve(C context, K key) throws Exception;
+
+}
Added: portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.commons.cache.future;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import org.exoplatform.commons.cache.future.Entry;
+import org.exoplatform.commons.cache.future.FutureCache;
+import org.gatein.common.util.Tools;
+
+import java.util.*;
+import java.util.concurrent.Callable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ConcurrentGetWhenPutTestCase extends TestCase
+{
+
+ /** . */
+ private AssertionFailedError failure;
+
+ /** . */
+ private LinkedList<String> events = new LinkedList<String>();
+
+ FutureCache<String, String, Callable<String>> futureCache = new FutureCache<String, String, Callable<String>>(new StringLoader()) {
+
+
+ @Override
+ protected Entry<String> get(String key)
+ {
+ if (key == key1)
+ {
+ if (Thread.currentThread() != thread1)
+ {
+ failure = new AssertionFailedError();
+ }
+ events.addLast("get/key1");
+ }
+ else if (key == key2)
+ {
+ if (Thread.currentThread() != thread2)
+ {
+ failure = new AssertionFailedError();
+ }
+ events.addLast("get/key2");
+ }
+ else
+ {
+ failure = new AssertionFailedError();
+ }
+ return null;
+ }
+
+ @Override
+ protected void put(String key, Entry<String> entry)
+ {
+ if (key == key1)
+ {
+ if (Thread.currentThread() == thread1)
+ {
+ events.addLast("begin_put/key1/" + entry);
+
+ //
+ thread2.start();
+
+ //
+ while (thread2.getState() != Thread.State.WAITING)
+ {
+ // Wait until thread 2 is blocked
+ }
+
+ //
+ events.addLast("end_put/key1");
+ }
+ else
+ {
+ failure = new AssertionFailedError();
+ }
+ }
+ else
+ {
+ failure = new AssertionFailedError();
+ }
+ }
+ };
+
+ /** . */
+ private final String key1 = new String("foo");
+
+ /** . */
+ private final String key2 = new String("foo");
+
+ Thread thread1 = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ String v = futureCache.get(new Callable<String>()
+ {
+ public String call() throws Exception
+ {
+ events.addLast("call/key1");
+ return "foo_value_1";
+ }
+ }, key1);
+ events.addLast("retrieved/key1/" + v);
+ }
+ };
+
+ Thread thread2 = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ String v = futureCache.get(new Callable<String>()
+ {
+ public String call() throws Exception
+ {
+ failure = new AssertionFailedError();
+ return "foo_value_2";
+ }
+ }, key2);
+ events.addLast("retrieved/key2/" + v);
+ }
+ };
+
+ public void testMain() throws Exception
+ {
+ thread1.start();
+
+ //
+ thread1.join();
+ thread2.join();
+
+ //
+ if (failure != null)
+ {
+ throw failure;
+ }
+
+ //
+ List<String> expectedEvents = Arrays.asList(
+ "get/key1",
+ "call/key1",
+ "begin_put/key1/Entry[foo_value_1]",
+ "get/key2",
+ "end_put/key1"
+ );
+
+ //
+ assertEquals(expectedEvents, events.subList(0, expectedEvents.size()));
+
+ //
+ Set<String> expectedEndEvents = Tools.toSet("retrieved/key1/foo_value_1", "retrieved/key2/foo_value_1");
+ assertEquals(expectedEndEvents, new HashSet<String>(events.subList(expectedEvents.size(), events.size())));
+ }
+
+}
\ No newline at end of file
Added: portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.commons.cache.future;
+
+import org.exoplatform.commons.cache.future.Entry;
+import org.exoplatform.commons.cache.future.FutureCache;
+import org.exoplatform.commons.cache.future.Loader;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class FutureMap<C> extends FutureCache<String, String, C>
+{
+
+ /** . */
+ final Map<String, Entry<String>> data;
+
+ public FutureMap(Loader<String, String, C> loader)
+ {
+ super(loader);
+
+ //
+ this.data = Collections.synchronizedMap(new HashMap<String, Entry<String>>());
+ }
+
+ @Override
+ protected Entry<String> get(String key)
+ {
+ return data.get(key);
+ }
+
+ @Override
+ protected void put(String key, Entry<String> entry)
+ {
+ data.put(key, entry);
+ }
+}
Added: portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.commons.cache.future;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import java.util.concurrent.Callable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class GetTestCase extends TestCase
+{
+ public void testGet()
+ {
+ FutureMap<Callable<String>> futureCache = new FutureMap<Callable<String>>(new StringLoader());
+ Assert.assertEquals("foo_value", futureCache.get(new Callable<String>()
+ {
+ public String call() throws Exception
+ {
+ return "foo_value";
+ }
+ }, "foo"));
+ Assert.assertEquals("foo_value", futureCache.data.get("foo").getValue());
+ }
+
+ public void testNullValue()
+ {
+ FutureMap<Callable<String>> futureCache = new FutureMap<Callable<String>>(new StringLoader());
+ Assert.assertEquals(null, futureCache.get(new Callable<String>()
+ {
+ public String call() throws Exception
+ {
+ return null;
+ }
+ }, "foo"));
+ Assert.assertFalse(futureCache.data.containsKey("foo"));
+ }
+
+ public void testThrowException()
+ {
+ FutureMap<Callable<String>> futureCache = new FutureMap<Callable<String>>(new StringLoader());
+ Assert.assertEquals(null, futureCache.get(new Callable<String>()
+ {
+ public String call() throws Exception
+ {
+ throw new Exception("DON'T FREAK OUT");
+ }
+ }, "foo"));
+ Assert.assertFalse(futureCache.data.containsKey("foo"));
+ }
+}
Added: portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/StringLoader.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/StringLoader.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/StringLoader.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.commons.cache.future;
+
+import org.exoplatform.commons.cache.future.Loader;
+
+import java.util.concurrent.Callable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class StringLoader implements Loader<String, String, Callable<String>>
+{
+ public String retrieve(Callable<String> context, String key) throws Exception
+ {
+ return context.call();
+ }
+}
Modified: portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java 2010-04-06 13:11:04 UTC (rev 2491)
+++ portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -22,8 +22,11 @@
import groovy.lang.Writable;
import groovy.text.Template;
+import org.exoplatform.commons.cache.future.Entry;
+import org.exoplatform.commons.cache.future.FutureCache;
+import org.exoplatform.commons.cache.future.FutureExoCache;
+import org.exoplatform.commons.cache.future.Loader;
import org.exoplatform.commons.utils.IOUtil;
-import org.exoplatform.container.xml.InitParams;
import org.exoplatform.groovyscript.GroovyTemplate;
import org.exoplatform.groovyscript.GroovyTemplateEngine;
import org.exoplatform.management.annotations.Impact;
@@ -34,9 +37,11 @@
import org.exoplatform.management.jmx.annotations.NameTemplate;
import org.exoplatform.management.jmx.annotations.Property;
import org.exoplatform.management.rest.annotations.RESTEndpoint;
+import org.exoplatform.resolver.ResourceKey;
import org.exoplatform.resolver.ResourceResolver;
import org.exoplatform.services.cache.CacheService;
import org.exoplatform.services.cache.ExoCache;
+import org.gatein.common.io.IOTools;
import java.io.InputStream;
import java.util.ArrayList;
@@ -54,17 +59,52 @@
private GroovyTemplateEngine engine_;
- private ExoCache<String, GroovyTemplate> templatesCache_;
+ private ExoCache<ResourceKey, Entry<GroovyTemplate>> templatesCache_;
private TemplateStatisticService statisticService;
private boolean cacheTemplate_ = true;
+ private final Loader<ResourceKey, GroovyTemplate, ResourceResolver> loader = new Loader<ResourceKey, GroovyTemplate, ResourceResolver>()
+ {
+ public GroovyTemplate retrieve(ResourceResolver context, ResourceKey key) throws Exception
+ {
+ byte[] bytes;
+ InputStream is = context.getInputStream(key.getURL());
+ try
+ {
+ bytes = IOUtil.getStreamContentAsBytes(is);
+ is.close();
+ }
+ finally
+ {
+ IOTools.safeClose(is);
+ }
+
+ // The template class name
+ int pos = key.getURL().lastIndexOf('/');
+ if (pos == -1)
+ {
+ pos = 0;
+ }
+ String name = key.getURL().substring(pos);
+
+ // Julien: it's a bit dangerious here, with respect to the file encoding...
+ String text = new String(bytes);
+
+ // Finally do the expensive template creation
+ return engine_.createTemplate(key.getURL(), name, text);
+ }
+ };
+
+ private FutureCache<ResourceKey, GroovyTemplate, ResourceResolver> futureCache;
+
public TemplateService(TemplateStatisticService statisticService, CacheService cservice) throws Exception
{
this.engine_ = new GroovyTemplateEngine();
this.statisticService = statisticService;
this.templatesCache_ = cservice.getCacheInstance(TemplateService.class.getSimpleName());
+ this.futureCache = new FutureExoCache<ResourceKey, GroovyTemplate, ResourceResolver>(loader, templatesCache_);
}
public void merge(String name, BindingContext context) throws Exception
@@ -108,37 +148,18 @@
final public GroovyTemplate getTemplate(String url, ResourceResolver resolver, boolean cacheable) throws Exception
{
- GroovyTemplate template = null;
+ GroovyTemplate template;
+ ResourceKey resourceId = resolver.createResourceKey(url);
if (cacheable)
{
- String resourceId = resolver.createResourceId(url);
- template = getTemplatesCache().get(resourceId);
+ template = futureCache.get(resolver, resourceId);
}
- if (template != null)
- return template;
- InputStream is;
- byte[] bytes = null;
- is = resolver.getInputStream(url);
- bytes = IOUtil.getStreamContentAsBytes(is);
- is.close();
-
- // The template class name
- int pos = url.lastIndexOf('/');
- if (pos == -1)
+ else
{
- pos = 0;
+ template = loader.retrieve(resolver, resourceId);
}
- String name = url.substring(pos);
- String text = new String(bytes);
- template = engine_.createTemplate(url, name, text);
-
- if (cacheable)
- {
- String resourceId = resolver.createResourceId(url);
- getTemplatesCache().put(resourceId, template);
- }
-
+ //
return template;
}
@@ -148,7 +169,7 @@
getTemplatesCache().remove(resourceId);
}
- public ExoCache<String, GroovyTemplate> getTemplatesCache()
+ public ExoCache<ResourceKey, Entry<GroovyTemplate>> getTemplatesCache()
{
return templatesCache_;
}
@@ -198,9 +219,13 @@
try
{
ArrayList<String> list = new ArrayList<String>();
- for (GroovyTemplate template : templatesCache_.getCachedObjects())
+ for (Entry<GroovyTemplate> entry : templatesCache_.getCachedObjects())
{
- list.add(template.getId());
+ GroovyTemplate template = entry.getValue();
+ if (template != null)
+ {
+ list.add(template.getId());
+ }
}
return list.toArray(new String[list.size()]);
}
Added: portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/resolver/ResourceKey.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/resolver/ResourceKey.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/resolver/ResourceKey.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.resolver;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ResourceKey implements Serializable
+{
+
+ /** . */
+ private final int resolverId;
+
+ /** . */
+ private final String url;
+
+ public ResourceKey(int resolverId, String url)
+ {
+ if (url == null)
+ {
+ throw new NullPointerException("no null URL accepted");
+ }
+ this.resolverId = resolverId;
+ this.url = url;
+ }
+
+ public String getURL()
+ {
+ return url;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return resolverId ^ url.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof ResourceKey)
+ {
+ ResourceKey that = (ResourceKey)o;
+ return resolverId == that.resolverId && url.equals(that.url);
+ }
+ return false;
+ }
+}
Modified: portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/resolver/ResourceResolver.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/resolver/ResourceResolver.java 2010-04-06 13:11:04 UTC (rev 2491)
+++ portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/resolver/ResourceResolver.java 2010-04-06 13:32:13 UTC (rev 2492)
@@ -54,6 +54,11 @@
throw new RuntimeException("unsupported method");
}
+ public ResourceKey createResourceKey(String url)
+ {
+ return new ResourceKey(hashCode(), url);
+ }
+
public String createResourceId(String url)
{
return hashCode() + ":" + url;
14 years, 9 months
gatein SVN: r2491 - portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-04-06 09:11:04 -0400 (Tue, 06 Apr 2010)
New Revision: 2491
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java
Log:
- GTNPORTAL-1026: only save state if it's not transient.
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java 2010-04-06 13:09:18 UTC (rev 2490)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java 2010-04-06 13:11:04 UTC (rev 2491)
@@ -228,10 +228,14 @@
WSRP wsrp = dataStorage.load(state, ApplicationType.WSRP_PORTLET);
if (wsrp == null)
{
- // create and save state
+ // create
wsrp = new WSRP();
wsrp.setPortletId(applicationId);
- dataStorage.save(state, wsrp);
+ if (!(state instanceof TransientApplicationState))
+ {
+ // only save state if it's not transient
+ dataStorage.save(state, wsrp);
+ }
}
return StatefulPortletContext.create(wsrp.getPortletId(), WSRPPortletStateType.instance, wsrp);
}
14 years, 9 months
gatein SVN: r2490 - portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-04-06 09:09:18 -0400 (Tue, 06 Apr 2010)
New Revision: 2490
Modified:
portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java
Log:
improve unit test relibility
Modified: portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java
===================================================================
--- portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java 2010-04-06 11:44:01 UTC (rev 2489)
+++ portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java 2010-04-06 13:09:18 UTC (rev 2490)
@@ -39,7 +39,7 @@
private AssertionFailedError failure;
/** . */
- private LinkedList<String> events = new LinkedList<String>();
+ private List<String> events = Collections.synchronizedList(new LinkedList<String>());
FutureCache<String, String, Callable<String>> futureCache = new FutureCache<String, String, Callable<String>>(new StringLoader()) {
@@ -53,7 +53,7 @@
{
failure = new AssertionFailedError();
}
- events.addLast("get/key1");
+ events.add("get/key1");
}
else if (key == key2)
{
@@ -61,7 +61,7 @@
{
failure = new AssertionFailedError();
}
- events.addLast("get/key2");
+ events.add("get/key2");
}
else
{
@@ -77,7 +77,7 @@
{
if (Thread.currentThread() == thread1)
{
- events.addLast("begin_put/key1/" + entry);
+ events.add("begin_put/key1/" + entry);
//
thread2.start();
@@ -89,7 +89,7 @@
}
//
- events.addLast("end_put/key1");
+ events.add("end_put/key1");
}
else
{
@@ -118,11 +118,11 @@
{
public String call() throws Exception
{
- events.addLast("call/key1");
+ events.add("call/key1");
return "foo_value_1";
}
}, key1);
- events.addLast("retrieved/key1/" + v);
+ events.add("retrieved/key1/" + v);
}
};
@@ -139,7 +139,7 @@
return "foo_value_2";
}
}, key2);
- events.addLast("retrieved/key2/" + v);
+ events.add("retrieved/key2/" + v);
}
};
14 years, 9 months
gatein SVN: r2489 - components/wsrp/trunk/admin-gui/src/main/webapp/skin/wsrp/DefaultSkin.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-04-06 07:44:01 -0400 (Tue, 06 Apr 2010)
New Revision: 2489
Modified:
components/wsrp/trunk/admin-gui/src/main/webapp/skin/wsrp/DefaultSkin/DefaultStylesheet.css
Log:
- GTNWSRP-19: Remove input styling so that commandButton don't look weird.
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/skin/wsrp/DefaultSkin/DefaultStylesheet.css
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/skin/wsrp/DefaultSkin/DefaultStylesheet.css 2010-04-06 10:30:22 UTC (rev 2488)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/skin/wsrp/DefaultSkin/DefaultStylesheet.css 2010-04-06 11:44:01 UTC (rev 2489)
@@ -1,3 +1,26 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
.UIWsrpPortlet .UIControlBar {
/*background: url('background/ControlIcon.gif') repeat-x center -222px;*/
/*border: 1px solid #b7b7b7;*/
@@ -106,6 +129,11 @@
padding: 0px 12px;
}
+.UIWsrpPortlet .ButtonMiddle input {
+ background: transparent;
+ border: none;
+}
+
/***************************** GrayTabStyle ************************/
.UIWsrpPortlet .TabsActionContainer {
14 years, 9 months