exo-jcr SVN: r2962 - in jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core: value and 1 other directory.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-08-20 09:02:43 -0400 (Fri, 20 Aug 2010)
New Revision: 2962
Added:
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/value/
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/value/TestPermissionValue.java
Log:
EXOJCR-908 Added tests for PermissionValue.parse(String) and PermissionValue.asString(String, String) methods.
Added: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/value/TestPermissionValue.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/value/TestPermissionValue.java (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/value/TestPermissionValue.java 2010-08-20 13:02:43 UTC (rev 2962)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+
+package org.exoplatform.services.jcr.impl.core.value;
+
+import junit.framework.TestCase;
+
+public class TestPermissionValue extends TestCase
+{
+
+ public void testParse() {
+
+ String[] parsedValues = PermissionValue.parse("root read");
+ assertEquals(2, parsedValues.length);
+ assertEquals("root", parsedValues[0]);
+ assertEquals("read", parsedValues[1]);
+
+ }
+
+ public void testAsString() {
+
+ assertEquals("root read", PermissionValue.asString("root", "read"));
+
+ }
+
+}
Property changes on: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/value/TestPermissionValue.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
13 years, 10 months
exo-jcr SVN: r2961 - in jcr/branches/1.12.x/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-08-20 08:57:11 -0400 (Fri, 20 Aug 2010)
New Revision: 2961
Added:
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
Log:
EXOJCR-898: fixes for Incorrect jcr:system node's permission initialization in ScratchWorkspaceInitializer
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-08-20 12:51:08 UTC (rev 2960)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-08-20 12:57:11 UTC (rev 2961)
@@ -347,12 +347,13 @@
if (addACL)
{
- AccessControlList acl = new AccessControlList();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
exoNamespaces =
TransientNodeData.createNodeData(nsSystem, Constants.EXO_NAMESPACES, Constants.NT_UNSTRUCTURED, mixins);
+ AccessControlList acl = exoNamespaces.getACL();
+
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(exoNamespaces, Constants.JCR_PRIMARYTYPE, PropertyType.NAME,
false, new TransientValueData(exoNamespaces.getPrimaryTypeName()));
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2010-08-20 12:51:08 UTC (rev 2960)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2010-08-20 12:57:11 UTC (rev 2961)
@@ -139,9 +139,6 @@
: Constants.NT_UNSTRUCTURED;
this.dataManager = dataManager;
- // this.nsPersister = nsPersister;
- // this.ntRegistry = ntRegistry;
-
}
public NodeData initWorkspace() throws RepositoryException
@@ -273,13 +270,14 @@
if (addACL)
{
- AccessControlList acl = new AccessControlList();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
jcrSystem =
TransientNodeData.createNodeData(root, Constants.JCR_SYSTEM, Constants.NT_UNSTRUCTURED, mixins,
Constants.SYSTEM_UUID);
+ AccessControlList acl = jcrSystem.getACL();
+
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(jcrSystem, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(jcrSystem.getPrimaryTypeName()));
@@ -340,15 +338,6 @@
dataManager.save(new TransactionChangesLog(changesLog));
- //nsPersister.initStorage(jcrSystem, addACL, NamespaceRegistryImpl.DEF_NAMESPACES);
- // nodeTypes save
- // changesLog = new PlainChangesLogImpl();
- // changesLog.addAll(ntPersister.initNodetypesRoot(jcrSystem,
- // addACL).getAllStates());
- // changesLog.addAll(ntPersister.initStorage(nodeTypeDataManager.getAllNodeTypes()).getAllStates());
- // ntPersister.saveChanges(changesLog);
-
- // nodeTypeDataManager.initDefaultNodeTypes(addACL);
return jcrSystem;
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-08-20 12:51:08 UTC (rev 2960)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-08-20 12:57:11 UTC (rev 2961)
@@ -153,13 +153,14 @@
if (addACL)
{
- AccessControlList acl = new AccessControlList();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
jcrNodetypes =
TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED, mixins,
Constants.NODETYPESROOT_UUID);
+ AccessControlList acl = jcrNodetypes.getACL();
+
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
Added: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java 2010-08-20 12:57:11 UTC (rev 2961)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 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.services.jcr.impl.access;
+
+import org.exoplatform.services.jcr.BaseStandaloneTest;
+import org.exoplatform.services.jcr.core.CredentialsImpl;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: TestRemoveSysteNode.java 111 2010-11-11 11:11:11Z tolusha $
+ *
+ */
+public class TestRemoveNodeTypeNode extends BaseStandaloneTest {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getRepositoryName() {
+ return null;
+ }
+
+ public void testRemove() throws Exception {
+ Repository repository = repositoryService.getRepository("db1tck");
+ Credentials credentials = new CredentialsImpl("demo", "exo".toCharArray());
+ Session session = repository.login(credentials, "ws");
+
+ Node node = session.getRootNode()
+ .getNode("jcr:system")
+ .getNode("jcr:nodetypes")
+ .getNode("nt:base");
+ try {
+ node.remove();
+ session.save();
+
+ fail("Exception should be thrown.");
+ } catch (AccessDeniedException e) {
+ }
+ }
+}
13 years, 10 months
exo-jcr SVN: r2960 - jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-08-20 08:51:08 -0400 (Fri, 20 Aug 2010)
New Revision: 2960
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PermissionValue.java
Log:
EXOJCR-908: fix parsing pemission value
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PermissionValue.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PermissionValue.java 2010-08-20 10:38:23 UTC (rev 2959)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PermissionValue.java 2010-08-20 12:51:08 UTC (rev 2960)
@@ -18,7 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.core.value;
-import org.exoplatform.services.jcr.access.AccessControlEntry;
import org.exoplatform.services.jcr.access.PermissionType;
import org.exoplatform.services.jcr.access.SystemIdentity;
import org.exoplatform.services.jcr.core.ExtendedPropertyType;
@@ -43,6 +42,8 @@
private static final int TYPE = ExtendedPropertyType.PERMISSION;
+ private static final String IDENTITY_DELIMITER = " ";
+
private String identity;
private String permission;
@@ -84,7 +85,7 @@
static public String[] parse(String pstring)
{
- StringTokenizer parser = new StringTokenizer(pstring, AccessControlEntry.DELIMITER);
+ StringTokenizer parser = new StringTokenizer(pstring, IDENTITY_DELIMITER);
String identityString = parser.nextToken();
String permissionString = parser.nextToken();
@@ -112,6 +113,7 @@
/**
* {@inheritDoc}
*/
+ @Override
protected String getInternalString() throws ValueFormatException
{
return asString(identity, permission);
@@ -120,7 +122,7 @@
static protected String asString(String identity, String permission)
{
if (identity != null || permission != null) // SystemIdentity.ANY, PermissionType.ALL
- return (identity != null ? identity : SystemIdentity.ANY) + AccessControlEntry.DELIMITER
+ return (identity != null ? identity : SystemIdentity.ANY) + IDENTITY_DELIMITER
+ (permission != null ? permission : PermissionType.READ);
else
return "";
13 years, 10 months
exo-jcr SVN: r2959 - in core/trunk: exo.core.component.document and 4 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-08-20 06:38:23 -0400 (Fri, 20 Aug 2010)
New Revision: 2959
Added:
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java
core/trunk/exo.core.component.document/src/test/resources/test.docx
core/trunk/exo.core.component.document/src/test/resources/test.pptx
core/trunk/exo.core.component.document/src/test/resources/test.xlsx
Modified:
core/trunk/exo.core.component.document/pom.xml
core/trunk/exo.core.component.document/src/main/resources/conf/portal/configuration.xml
core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java
core/trunk/pom.xml
Log:
EXOJCR-886: adding document readers for MS 2007 file formats
Modified: core/trunk/exo.core.component.document/pom.xml
===================================================================
--- core/trunk/exo.core.component.document/pom.xml 2010-08-20 10:31:38 UTC (rev 2958)
+++ core/trunk/exo.core.component.document/pom.xml 2010-08-20 10:38:23 UTC (rev 2959)
@@ -82,6 +82,18 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
</dependencies>
<build>
<testResources>
@@ -93,9 +105,12 @@
<include>**/*.drl</include>
<include>**/*.vm</include>
<include>**/*.doc</include>
+ <include>**/*.docx</include>
<include>**/*.dot</include>
<include>**/*.xls</include>
+ <include>**/*.xlsx</include>
<include>**/*.ppt</include>
+ <include>**/*.pptx</include>
<include>**/*.txt</include>
<include>**/*.tiff</include>
<include>**/*.pdf</include>
Added: core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java (rev 0)
+++ core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java 2010-08-20 10:38:23 UTC (rev 2959)
@@ -0,0 +1,218 @@
+/*
+ * 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.services.document.impl;
+
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.exoplatform.services.document.DocumentReadException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Created by The eXo Platform SAS A parser of Microsoft Excel 2007 files (xlsx).
+ *
+ * @author <a href="mailto:phunghainam@gmail.com">Phung Hai Nam</a>
+ * @author Gennady Azarenkov
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: MSXExcelDocumentReader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class MSXExcelDocumentReader extends BaseDocumentReader
+{
+
+ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
+
+ /**
+ * @see org.exoplatform.services.document.DocumentReader#getMimeTypes()
+ */
+ public String[] getMimeTypes()
+ {
+ return new String[]{"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};
+ }
+
+ /**
+ * Returns only a text from .xlsx file content.
+ *
+ * @param is an input stream with .xls file content.
+ * @return The string only with text from file content.
+ */
+ public String getContentAsText(InputStream is) throws IOException, DocumentReadException
+ {
+ if (is == null)
+ {
+ throw new NullPointerException("InputStream is null.");
+ }
+
+ StringBuilder builder = new StringBuilder("");
+
+ try
+ {
+ XSSFWorkbook wb;
+ try
+ {
+ wb = new XSSFWorkbook(is);
+ }
+ catch (IOException e)
+ {
+ return builder.toString();
+ }
+ catch (OpenXML4JRuntimeException e)
+ {
+ return builder.toString();
+ }
+ for (int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++)
+ {
+ XSSFSheet sheet = wb.getSheetAt(sheetNum);
+ if (sheet != null)
+ {
+ for (int rowNum = sheet.getFirstRowNum(); rowNum <= sheet.getLastRowNum(); rowNum++)
+ {
+ XSSFRow row = sheet.getRow(rowNum);
+
+ if (row != null)
+ {
+ int lastcell = row.getLastCellNum();
+ for (int k = 0; k < lastcell; k++)
+ {
+ XSSFCell cell = row.getCell(k);
+ if (cell != null)
+ {
+ switch (cell.getCellType())
+ {
+ case XSSFCell.CELL_TYPE_NUMERIC : {
+ double d = cell.getNumericCellValue();
+ if (isCellDateFormatted(cell))
+ {
+ Date date = HSSFDateUtil.getJavaDate(d);
+ String cellText = this.DATE_FORMAT.format(date);
+ builder.append(cellText).append(" ");
+ }
+ else
+ {
+ builder.append(d).append(" ");
+ }
+ break;
+ }
+ case XSSFCell.CELL_TYPE_FORMULA :
+ builder.append(cell.getCellFormula().toString()).append(" ");
+ break;
+ case XSSFCell.CELL_TYPE_BOOLEAN :
+ builder.append(cell.getBooleanCellValue()).append(" ");
+ break;
+ case XSSFCell.CELL_TYPE_ERROR :
+ builder.append(cell.getErrorCellValue()).append(" ");
+ break;
+ case XSSFCell.CELL_TYPE_STRING :
+ builder.append(cell.getStringCellValue().toString()).append(" ");
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ return builder.toString();
+ }
+
+ public String getContentAsText(InputStream is, String encoding) throws IOException, DocumentReadException
+ {
+ // Ignore encoding
+ return getContentAsText(is);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.exoplatform.services.document.DocumentReader#getProperties(java.io.
+ * InputStream)
+ */
+ public Properties getProperties(InputStream is) throws IOException, DocumentReadException
+ {
+ POIPropertiesReader reader = new POIPropertiesReader();
+ reader.readDCProperties(is);
+ return reader.getProperties();
+ }
+
+ public static boolean isCellDateFormatted(XSSFCell cell)
+ {
+ boolean bDate = false;
+ double d = cell.getNumericCellValue();
+ if (HSSFDateUtil.isValidExcelDate(d))
+ {
+ XSSFCellStyle style = cell.getCellStyle();
+ int i = style.getDataFormat();
+ switch (i)
+ {
+ case 0xe : // m/d/yy
+ case 0xf : // d-mmm-yy
+ case 0x10 : // d-mmm
+ case 0x11 : // mmm-yy
+ case 0x12 : // h:mm AM/PM
+ case 0x13 : // h:mm:ss AM/PM
+ case 0x14 : // h:mm
+ case 0x15 : // h:mm:ss
+ case 0x16 : // m/d/yy h:mm
+ case 0x2d : // mm:ss
+ case 0x2e : // [h]:mm:ss
+ case 0x2f : // mm:ss.0
+
+ case 0xa5 : // ??
+ case 0xa7 : // ??
+ case 0xa9 : // ??
+
+ case 0xac : // mm:dd:yy not specified in javadoc
+ case 0xad : // yyyy-mm-dd not specified in javadoc
+ case 0xae : // mm:dd:yyyy not specified in javadoc
+ case 0xaf : // m:d:yy not specified in javadoc
+ bDate = true;
+ break;
+ default :
+ bDate = false;
+ break;
+ }
+ }
+ return bDate;
+ }
+}
Added: core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java (rev 0)
+++ core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java 2010-08-20 10:38:23 UTC (rev 2959)
@@ -0,0 +1,122 @@
+/*
+ * 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.services.document.impl;
+
+import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
+import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
+import org.apache.xmlbeans.XmlException;
+import org.exoplatform.services.document.DocumentReadException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Created by The eXo Platform SAS A parser of Microsoft PowerPoint 2007 files (pptx).
+ *
+ * @author <a href="mailto:phunghainam@gmail.com">Phung Hai Nam</a>
+ * @author Gennady Azarenkov
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: MSXPPTDocumentReader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ */
+public class MSXPPTDocumentReader extends BaseDocumentReader
+{
+
+ /**
+ * @see org.exoplatform.services.document.DocumentReader#getMimeTypes()
+ */
+ public String[] getMimeTypes()
+ {
+ return new String[]{"application/vnd.openxmlformats-officedocument.presentationml.presentation"};
+ }
+
+ /**
+ * Returns only a text from .pptx file content.
+ *
+ * @param is an input stream with .pptx file content.
+ * @return The string only with text from file content.
+ */
+ public String getContentAsText(InputStream is) throws IOException, DocumentReadException
+ {
+ if (is == null)
+ {
+ throw new NullPointerException("InputStream is null.");
+ }
+ try
+ {
+ XSLFPowerPointExtractor ppe;
+ try
+ {
+ ppe = new XSLFPowerPointExtractor(OPCPackage.open(is));
+ }
+ catch (IOException e)
+ {
+ return "";
+ }
+ catch (OpenXML4JRuntimeException e)
+ {
+ return "";
+ }
+ catch (OpenXML4JException e)
+ {
+ return "";
+ }
+ catch (XmlException e)
+ {
+ return "";
+ }
+ return ppe.getText(true, true);
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+
+ public String getContentAsText(InputStream is, String encoding) throws IOException, DocumentReadException
+ {
+ // Ignore encoding
+ return getContentAsText(is);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.exoplatform.services.document.DocumentReader#getProperties(java.io.
+ * InputStream)
+ */
+ public Properties getProperties(InputStream is) throws IOException, DocumentReadException
+ {
+ POIPropertiesReader reader = new POIPropertiesReader();
+ reader.readDCProperties(is);
+ return reader.getProperties();
+ }
+
+}
Added: core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java (rev 0)
+++ core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java 2010-08-20 10:38:23 UTC (rev 2959)
@@ -0,0 +1,117 @@
+/*
+ * 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.services.document.impl;
+
+import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
+import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.exoplatform.services.document.DocumentReadException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Created by The eXo Platform SAS A parser of Microsoft Word 2007 files (docx).
+ *
+ * @author <a href="mailto:phunghainam@gmail.com">Phung Hai Nam</a>
+ * @author Gennady Azarenkov
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: MSXWordDocumentReader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class MSXWordDocumentReader extends BaseDocumentReader
+{
+
+ /**
+ * @see org.exoplatform.services.document.DocumentReader#getMimeTypes()
+ */
+ public String[] getMimeTypes()
+ {
+ return new String[]{"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};
+ }
+
+ /**
+ * Returns only a text from .docx file content.
+ *
+ * @param is an input stream with .docx file content.
+ * @return The string only with text from file content.
+ */
+ public String getContentAsText(InputStream is) throws IOException, DocumentReadException
+ {
+ if (is == null)
+ {
+ throw new NullPointerException("InputStream is null.");
+ }
+ String text = "";
+ try
+ {
+ XWPFDocument doc;
+ try
+ {
+ doc = new XWPFDocument(is);
+ }
+ catch (IOException e)
+ {
+ return "";
+ }
+ catch (OpenXML4JRuntimeException e)
+ {
+ return "";
+ }
+
+ XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
+ text = extractor.getText();
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ return text.trim();
+ }
+
+ /**
+ * @see org.exoplatform.services.document.DocumentReader#getContentAsText(java.io.InputStream, java.lang.String)
+ */
+ public String getContentAsText(InputStream is, String encoding) throws IOException, DocumentReadException
+ {
+ // Ignore encoding
+ return getContentAsText(is);
+ }
+
+ /**
+ * @see org.exoplatform.services.document.DocumentReader#getProperties(java.io.InputStream)
+ */
+ public Properties getProperties(InputStream is) throws IOException, DocumentReadException
+ {
+ POIPropertiesReader reader = new POIPropertiesReader();
+ reader.readDCProperties(is);
+ return reader.getProperties();
+ }
+
+}
Modified: core/trunk/exo.core.component.document/src/main/resources/conf/portal/configuration.xml
===================================================================
--- core/trunk/exo.core.component.document/src/main/resources/conf/portal/configuration.xml 2010-08-20 10:31:38 UTC (rev 2958)
+++ core/trunk/exo.core.component.document/src/main/resources/conf/portal/configuration.xml 2010-08-20 10:38:23 UTC (rev 2959)
@@ -1,25 +1,16 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
+ <!--
- 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.
-
--->
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ 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.
+ -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
<component>
@@ -55,6 +46,20 @@
</component-plugin>
<component-plugin>
+ <name>document.readerMSXWord</name>
+ <set-method>addDocumentReader</set-method>
+ <type>org.exoplatform.services.document.impl.MSXWordDocumentReader</type>
+ <description>to read the ms word inputstream</description>
+ <init-params>
+ <values-param>
+ <name>document.known.typesMSXWord</name>
+ <description>description</description>
+ <value>application/msword</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+
+ <component-plugin>
<name>document.readerMSExcel</name>
<set-method>addDocumentReader</set-method>
<type>org.exoplatform.services.document.impl.MSExcelDocumentReader</type>
@@ -69,6 +74,20 @@
</component-plugin>
<component-plugin>
+ <name>document.readerMSXExcel</name>
+ <set-method>addDocumentReader</set-method>
+ <type>org.exoplatform.services.document.impl.MSXExcelDocumentReader</type>
+ <description>to read the ms excel inputstream</description>
+ <init-params>
+ <values-param>
+ <name>document.known.typesMSXExcel</name>
+ <description>description</description>
+ <value>application/excel</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+
+ <component-plugin>
<name>document.readerMSOutlook</name>
<set-method>addDocumentReader</set-method>
<type>org.exoplatform.services.document.impl.MSOutlookDocumentReader</type>
@@ -97,6 +116,20 @@
</component-plugin>
<component-plugin>
+ <name>MSXPPTdocument.reader</name>
+ <set-method>addDocumentReader</set-method>
+ <type>org.exoplatform.services.document.impl.MSXPPTDocumentReader</type>
+ <description>to read the ms pptx inputstream</description>
+ <init-params>
+ <values-param>
+ <name>document.known.typesPPTX</name>
+ <description>description</description>
+ <value>application/ppt</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+
+ <component-plugin>
<name>document.readerHTML</name>
<set-method>addDocumentReader</set-method>
<type>org.exoplatform.services.document.impl.HTMLDocumentReader</type>
@@ -135,11 +168,10 @@
<description>description</description>
<value>text/plain</value>
</values-param>
- <!-- values-param>
- <name>defaultEncoding</name>
- <description>description</description>
- <value>UTF-8</value>
- </values-param -->
+ <!--
+ values-param> <name>defaultEncoding</name> <description>description</description> <value>UTF-8</value>
+ </values-param
+ -->
</init-params>
</component-plugin>
Modified: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java 2010-08-20 10:31:38 UTC (rev 2958)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java 2010-08-20 10:38:23 UTC (rev 2959)
@@ -24,6 +24,9 @@
import org.exoplatform.services.document.impl.MSExcelDocumentReader;
import org.exoplatform.services.document.impl.MSOutlookDocumentReader;
import org.exoplatform.services.document.impl.MSWordDocumentReader;
+import org.exoplatform.services.document.impl.MSXExcelDocumentReader;
+import org.exoplatform.services.document.impl.MSXPPTDocumentReader;
+import org.exoplatform.services.document.impl.MSXWordDocumentReader;
import org.exoplatform.services.document.impl.OpenOfficeDocumentReader;
import org.exoplatform.services.document.impl.PDFDocumentReader;
import org.exoplatform.services.document.impl.PPTDocumentReader;
@@ -52,11 +55,14 @@
serviceList = new ArrayList<DocumentReader>();
serviceList.add(new HTMLDocumentReader(null));
serviceList.add(new MSExcelDocumentReader());
+ serviceList.add(new MSXExcelDocumentReader());
serviceList.add(new MSOutlookDocumentReader());
serviceList.add(new MSWordDocumentReader());
+ serviceList.add(new MSXWordDocumentReader());
serviceList.add(new OpenOfficeDocumentReader());
serviceList.add(new PDFDocumentReader());
serviceList.add(new PPTDocumentReader());
+ serviceList.add(new MSXPPTDocumentReader());
serviceList.add(new TextPlainDocumentReader(new InitParams()));
serviceList.add(new XMLDocumentReader());
}
Added: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java (rev 0)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java 2010-08-20 10:38:23 UTC (rev 2959)
@@ -0,0 +1,77 @@
+/*
+ * 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.services.document.test;
+
+import org.exoplatform.services.document.DocumentReaderService;
+
+import java.io.InputStream;
+
+/**
+ * Created by The eXo Platform SAS Author : Sergey Karpenko
+ * <sergey.karpenko(a)exoplatform.com.ua>
+ *
+ * @version $Id: $
+ */
+
+public class TestMSXExcelDocumentReader extends BaseStandaloneTest
+{
+ DocumentReaderService service_;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ }
+
+ public void testGetContentAsString() throws Exception
+ {
+ InputStream is = TestMSXExcelDocumentReader.class.getResourceAsStream("/test.xlsx");
+ String text = service_.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet").getContentAsText(is);
+ System.out.println(" text [" + text + "]");
+ /*
+ * String etalon =
+ * "Ronaldo Eric Cantona Kaka Ronaldonho ID Group Functionality Executor Begin End Tested "
+ * +
+ * "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH 2005-02-02 00:00:00.000+0200 2005-10-02 00:00:00.000+0300 Tested "
+ * +
+ * "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 2005-10-01 00:00:00.000+0300 Tested "
+ * +
+ * "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH 2005-10-12 00:00:00.000+0300 2005-10-02 00:00:00.000+0300 Tested "
+ * +"XNNL XNNL XNNL_76 NamPH TRUE 1984-12-10 00:00:00.000+0200 No "
+ * +"XNNL XNNL XNNL_CREATE_REAP NamPH none 2005-10-03 00:00:00.000+0300 No "
+ * +
+ * "XNNL XNNL XNNL_SCALE NamPH 1984-12-10 00:00:00.000+0200 2005-10-05 00:00:00.000+0300 Tested "
+ * +
+ * "XNNL XNNL LASUCO_PROJECT NamPH 2005-10-05 00:00:00.000+0300 2005-10-06 00:00:00.000+0300 No "
+ * +"XNNL XNNL LASUCO_PROJECT NamPH Tested "+
+ * "XNNL XNNL XNNL_BRANCH NamPH 2005-12-12 00:00:00.000+0200 2005-06-10 00:00:00.000+0300 Tested "
+ * +
+ * "XNNL XNNL XNNL_SUGAR_RACE NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
+ * +
+ * "XNNL XNNL F_XNNL_DISTRI NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 Tested "
+ * +
+ * "XNNL XNNL XNNL_LASUCO_USER NamPH 2005-09-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
+ * ; System.out.println(" etalon ["+etalon+"]");
+ * assertEquals("String length is incorect",etalon.length(),text.length());
+ * assertEquals("Wrong string returned",etalon ,text );
+ */
+
+ }
+}
Added: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java (rev 0)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java 2010-08-20 10:38:23 UTC (rev 2959)
@@ -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.services.document.test;
+
+import org.exoplatform.services.document.DocumentReaderService;
+
+import java.io.InputStream;
+
+/**
+ * Created by The eXo Platform SAS Author : Sergey Karpenko
+ * <sergey.karpenko(a)exoplatform.com.ua>
+ *
+ * @version $Id: $
+ */
+
+public class TestMSXPPTDocumentReader extends BaseStandaloneTest
+{
+ DocumentReaderService service_;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ }
+
+ public void testGetContentAsString() throws Exception
+ {
+ InputStream is = TestMSXPPTDocumentReader.class.getResourceAsStream("/test.pptx");
+ String text =
+ service_.getDocumentReader("application/vnd.openxmlformats-officedocument.presentationml.presentation")
+ .getContentAsText(is);
+ String etalon =
+ "TEST POWERPOINT\n" + "Manchester United \n" + "AC Milan\n" + "SLIDE 2 \n" + "Eric Cantona\n" + "Kaka\n"
+ + "Ronaldo\n" + "The natural scients universitys\n";
+
+ assertEquals("Wrong string returned", etalon, text);
+ }
+}
Added: core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java (rev 0)
+++ core/trunk/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java 2010-08-20 10:38:23 UTC (rev 2959)
@@ -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.services.document.test;
+
+import org.exoplatform.services.document.DocumentReaderService;
+
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: TestMSXWordDocumentReader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class TestMSXWordDocumentReader extends BaseStandaloneTest
+{
+ DocumentReaderService service_;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ service_ = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ }
+
+ public void testGetContentAsStringDoc() throws Exception
+ {
+ InputStream is = TestMSXWordDocumentReader.class.getResourceAsStream("/test.docx");
+ String text = service_.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document").getContentAsText(is);
+ System.out.println("text [" + text + "]");
+
+ /*
+ * String etalon = "Hello.\n" +"This is the test document 12345\n"
+ * +"Table\n" +"Title One Two\n" +"Hello_Title Hello_One Hello_Two\n";
+ * System.out.println("etalon ["+etalon+"]");
+ * System.out.println("["+text.length()+"] ["+etalon.length()+"]");
+ * assertEquals("Wrong string returned",etalon ,text );
+ */
+ }
+}
Added: core/trunk/exo.core.component.document/src/test/resources/test.docx
===================================================================
(Binary files differ)
Property changes on: core/trunk/exo.core.component.document/src/test/resources/test.docx
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: core/trunk/exo.core.component.document/src/test/resources/test.pptx
===================================================================
(Binary files differ)
Property changes on: core/trunk/exo.core.component.document/src/test/resources/test.pptx
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: core/trunk/exo.core.component.document/src/test/resources/test.xlsx
===================================================================
(Binary files differ)
Property changes on: core/trunk/exo.core.component.document/src/test/resources/test.xlsx
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2010-08-20 10:31:38 UTC (rev 2958)
+++ core/trunk/pom.xml 2010-08-20 10:38:23 UTC (rev 2959)
@@ -301,16 +301,22 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
- <version>3.0.2-FINAL</version>
+ <version>3.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
- <version>3.0.2-FINAL</version>
+ <version>3.6</version>
</dependency>
-
+
<dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml</artifactId>
+ <version>3.6</version>
+ </dependency>
+
+ <dependency>
<groupId>com.novell.ldap</groupId>
<artifactId>jldap</artifactId>
<version>4.3</version>
13 years, 10 months
exo-jcr SVN: r2958 - in core/branches/2.3.x: exo.core.component.document and 4 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-08-20 06:31:38 -0400 (Fri, 20 Aug 2010)
New Revision: 2958
Added:
core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java
core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java
core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java
core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java
core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java
core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java
core/branches/2.3.x/exo.core.component.document/src/test/resources/test.docx
core/branches/2.3.x/exo.core.component.document/src/test/resources/test.pptx
core/branches/2.3.x/exo.core.component.document/src/test/resources/test.xlsx
Modified:
core/branches/2.3.x/exo.core.component.document/pom.xml
core/branches/2.3.x/exo.core.component.document/src/main/resources/conf/portal/configuration.xml
core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java
core/branches/2.3.x/pom.xml
Log:
EXOJCR-886: adding document readers for MS 2007 file formats
Modified: core/branches/2.3.x/exo.core.component.document/pom.xml
===================================================================
--- core/branches/2.3.x/exo.core.component.document/pom.xml 2010-08-20 09:49:54 UTC (rev 2957)
+++ core/branches/2.3.x/exo.core.component.document/pom.xml 2010-08-20 10:31:38 UTC (rev 2958)
@@ -77,6 +77,18 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
</dependencies>
<build>
<testResources>
@@ -88,9 +100,12 @@
<include>**/*.drl</include>
<include>**/*.vm</include>
<include>**/*.doc</include>
+ <include>**/*.docx</include>
<include>**/*.dot</include>
<include>**/*.xls</include>
+ <include>**/*.xlsx</include>
<include>**/*.ppt</include>
+ <include>**/*.pptx</include>
<include>**/*.txt</include>
<include>**/*.tiff</include>
<include>**/*.pdf</include>
Added: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java (rev 0)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java 2010-08-20 10:31:38 UTC (rev 2958)
@@ -0,0 +1,218 @@
+/*
+ * 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.services.document.impl;
+
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.exoplatform.services.document.DocumentReadException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * Created by The eXo Platform SAS A parser of Microsoft Excel 2007 files (xlsx).
+ *
+ * @author <a href="mailto:phunghainam@gmail.com">Phung Hai Nam</a>
+ * @author Gennady Azarenkov
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: MSXExcelDocumentReader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class MSXExcelDocumentReader extends BaseDocumentReader
+{
+
+ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
+
+ /**
+ * @see org.exoplatform.services.document.DocumentReader#getMimeTypes()
+ */
+ public String[] getMimeTypes()
+ {
+ return new String[]{"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};
+ }
+
+ /**
+ * Returns only a text from .xlsx file content.
+ *
+ * @param is an input stream with .xls file content.
+ * @return The string only with text from file content.
+ */
+ public String getContentAsText(InputStream is) throws IOException, DocumentReadException
+ {
+ if (is == null)
+ {
+ throw new NullPointerException("InputStream is null.");
+ }
+
+ StringBuilder builder = new StringBuilder("");
+
+ try
+ {
+ XSSFWorkbook wb;
+ try
+ {
+ wb = new XSSFWorkbook(is);
+ }
+ catch (IOException e)
+ {
+ return builder.toString();
+ }
+ catch (OpenXML4JRuntimeException e)
+ {
+ return builder.toString();
+ }
+ for (int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++)
+ {
+ XSSFSheet sheet = wb.getSheetAt(sheetNum);
+ if (sheet != null)
+ {
+ for (int rowNum = sheet.getFirstRowNum(); rowNum <= sheet.getLastRowNum(); rowNum++)
+ {
+ XSSFRow row = sheet.getRow(rowNum);
+
+ if (row != null)
+ {
+ int lastcell = row.getLastCellNum();
+ for (int k = 0; k < lastcell; k++)
+ {
+ XSSFCell cell = row.getCell(k);
+ if (cell != null)
+ {
+ switch (cell.getCellType())
+ {
+ case XSSFCell.CELL_TYPE_NUMERIC : {
+ double d = cell.getNumericCellValue();
+ if (isCellDateFormatted(cell))
+ {
+ Date date = HSSFDateUtil.getJavaDate(d);
+ String cellText = this.DATE_FORMAT.format(date);
+ builder.append(cellText).append(" ");
+ }
+ else
+ {
+ builder.append(d).append(" ");
+ }
+ break;
+ }
+ case XSSFCell.CELL_TYPE_FORMULA :
+ builder.append(cell.getCellFormula().toString()).append(" ");
+ break;
+ case XSSFCell.CELL_TYPE_BOOLEAN :
+ builder.append(cell.getBooleanCellValue()).append(" ");
+ break;
+ case XSSFCell.CELL_TYPE_ERROR :
+ builder.append(cell.getErrorCellValue()).append(" ");
+ break;
+ case XSSFCell.CELL_TYPE_STRING :
+ builder.append(cell.getStringCellValue().toString()).append(" ");
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ return builder.toString();
+ }
+
+ public String getContentAsText(InputStream is, String encoding) throws IOException, DocumentReadException
+ {
+ // Ignore encoding
+ return getContentAsText(is);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.exoplatform.services.document.DocumentReader#getProperties(java.io.
+ * InputStream)
+ */
+ public Properties getProperties(InputStream is) throws IOException, DocumentReadException
+ {
+ POIPropertiesReader reader = new POIPropertiesReader();
+ reader.readDCProperties(is);
+ return reader.getProperties();
+ }
+
+ public static boolean isCellDateFormatted(XSSFCell cell)
+ {
+ boolean bDate = false;
+ double d = cell.getNumericCellValue();
+ if (HSSFDateUtil.isValidExcelDate(d))
+ {
+ XSSFCellStyle style = cell.getCellStyle();
+ int i = style.getDataFormat();
+ switch (i)
+ {
+ case 0xe : // m/d/yy
+ case 0xf : // d-mmm-yy
+ case 0x10 : // d-mmm
+ case 0x11 : // mmm-yy
+ case 0x12 : // h:mm AM/PM
+ case 0x13 : // h:mm:ss AM/PM
+ case 0x14 : // h:mm
+ case 0x15 : // h:mm:ss
+ case 0x16 : // m/d/yy h:mm
+ case 0x2d : // mm:ss
+ case 0x2e : // [h]:mm:ss
+ case 0x2f : // mm:ss.0
+
+ case 0xa5 : // ??
+ case 0xa7 : // ??
+ case 0xa9 : // ??
+
+ case 0xac : // mm:dd:yy not specified in javadoc
+ case 0xad : // yyyy-mm-dd not specified in javadoc
+ case 0xae : // mm:dd:yyyy not specified in javadoc
+ case 0xaf : // m:d:yy not specified in javadoc
+ bDate = true;
+ break;
+ default :
+ bDate = false;
+ break;
+ }
+ }
+ return bDate;
+ }
+}
Added: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java (rev 0)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java 2010-08-20 10:31:38 UTC (rev 2958)
@@ -0,0 +1,122 @@
+/*
+ * 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.services.document.impl;
+
+import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
+import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
+import org.apache.xmlbeans.XmlException;
+import org.exoplatform.services.document.DocumentReadException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Created by The eXo Platform SAS A parser of Microsoft PowerPoint 2007 files (pptx).
+ *
+ * @author <a href="mailto:phunghainam@gmail.com">Phung Hai Nam</a>
+ * @author Gennady Azarenkov
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: MSXPPTDocumentReader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ */
+public class MSXPPTDocumentReader extends BaseDocumentReader
+{
+
+ /**
+ * @see org.exoplatform.services.document.DocumentReader#getMimeTypes()
+ */
+ public String[] getMimeTypes()
+ {
+ return new String[]{"application/vnd.openxmlformats-officedocument.presentationml.presentation"};
+ }
+
+ /**
+ * Returns only a text from .pptx file content.
+ *
+ * @param is an input stream with .pptx file content.
+ * @return The string only with text from file content.
+ */
+ public String getContentAsText(InputStream is) throws IOException, DocumentReadException
+ {
+ if (is == null)
+ {
+ throw new NullPointerException("InputStream is null.");
+ }
+ try
+ {
+ XSLFPowerPointExtractor ppe;
+ try
+ {
+ ppe = new XSLFPowerPointExtractor(OPCPackage.open(is));
+ }
+ catch (IOException e)
+ {
+ return "";
+ }
+ catch (OpenXML4JRuntimeException e)
+ {
+ return "";
+ }
+ catch (OpenXML4JException e)
+ {
+ return "";
+ }
+ catch (XmlException e)
+ {
+ return "";
+ }
+ return ppe.getText(true, true);
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+
+ public String getContentAsText(InputStream is, String encoding) throws IOException, DocumentReadException
+ {
+ // Ignore encoding
+ return getContentAsText(is);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.exoplatform.services.document.DocumentReader#getProperties(java.io.
+ * InputStream)
+ */
+ public Properties getProperties(InputStream is) throws IOException, DocumentReadException
+ {
+ POIPropertiesReader reader = new POIPropertiesReader();
+ reader.readDCProperties(is);
+ return reader.getProperties();
+ }
+
+}
Added: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java (rev 0)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java 2010-08-20 10:31:38 UTC (rev 2958)
@@ -0,0 +1,117 @@
+/*
+ * 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.services.document.impl;
+
+import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
+import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.exoplatform.services.document.DocumentReadException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Created by The eXo Platform SAS A parser of Microsoft Word 2007 files (docx).
+ *
+ * @author <a href="mailto:phunghainam@gmail.com">Phung Hai Nam</a>
+ * @author Gennady Azarenkov
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: MSXWordDocumentReader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class MSXWordDocumentReader extends BaseDocumentReader
+{
+
+ /**
+ * @see org.exoplatform.services.document.DocumentReader#getMimeTypes()
+ */
+ public String[] getMimeTypes()
+ {
+ return new String[]{"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};
+ }
+
+ /**
+ * Returns only a text from .docx file content.
+ *
+ * @param is an input stream with .docx file content.
+ * @return The string only with text from file content.
+ */
+ public String getContentAsText(InputStream is) throws IOException, DocumentReadException
+ {
+ if (is == null)
+ {
+ throw new NullPointerException("InputStream is null.");
+ }
+ String text = "";
+ try
+ {
+ XWPFDocument doc;
+ try
+ {
+ doc = new XWPFDocument(is);
+ }
+ catch (IOException e)
+ {
+ return "";
+ }
+ catch (OpenXML4JRuntimeException e)
+ {
+ return "";
+ }
+
+ XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
+ text = extractor.getText();
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ return text.trim();
+ }
+
+ /**
+ * @see org.exoplatform.services.document.DocumentReader#getContentAsText(java.io.InputStream, java.lang.String)
+ */
+ public String getContentAsText(InputStream is, String encoding) throws IOException, DocumentReadException
+ {
+ // Ignore encoding
+ return getContentAsText(is);
+ }
+
+ /**
+ * @see org.exoplatform.services.document.DocumentReader#getProperties(java.io.InputStream)
+ */
+ public Properties getProperties(InputStream is) throws IOException, DocumentReadException
+ {
+ POIPropertiesReader reader = new POIPropertiesReader();
+ reader.readDCProperties(is);
+ return reader.getProperties();
+ }
+
+}
Modified: core/branches/2.3.x/exo.core.component.document/src/main/resources/conf/portal/configuration.xml
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/resources/conf/portal/configuration.xml 2010-08-20 09:49:54 UTC (rev 2957)
+++ core/branches/2.3.x/exo.core.component.document/src/main/resources/conf/portal/configuration.xml 2010-08-20 10:31:38 UTC (rev 2958)
@@ -55,6 +55,20 @@
</component-plugin>
<component-plugin>
+ <name>document.readerMSXWord</name>
+ <set-method>addDocumentReader</set-method>
+ <type>org.exoplatform.services.document.impl.MSXWordDocumentReader</type>
+ <description>to read the ms word inputstream</description>
+ <init-params>
+ <values-param>
+ <name>document.known.typesMSXWord</name>
+ <description>description</description>
+ <value>application/msword</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+
+ <component-plugin>
<name>document.readerMSExcel</name>
<set-method>addDocumentReader</set-method>
<type>org.exoplatform.services.document.impl.MSExcelDocumentReader</type>
@@ -66,6 +80,20 @@
<value>application/excel</value>
</values-param>
</init-params>
+ </component-plugin>
+
+ <component-plugin>
+ <name>document.readerMSXExcel</name>
+ <set-method>addDocumentReader</set-method>
+ <type>org.exoplatform.services.document.impl.MSXExcelDocumentReader</type>
+ <description>to read the ms excel inputstream</description>
+ <init-params>
+ <values-param>
+ <name>document.known.typesMSXExcel</name>
+ <description>description</description>
+ <value>application/excel</value>
+ </values-param>
+ </init-params>
</component-plugin>
<component-plugin>
@@ -94,6 +122,20 @@
<value>application/ppt</value>
</values-param>
</init-params>
+ </component-plugin>
+
+ <component-plugin>
+ <name>MSXPPTdocument.reader</name>
+ <set-method>addDocumentReader</set-method>
+ <type>org.exoplatform.services.document.impl.MSXPPTDocumentReader</type>
+ <description>to read the ms pptx inputstream</description>
+ <init-params>
+ <values-param>
+ <name>document.known.typesPPTX</name>
+ <description>description</description>
+ <value>application/ppt</value>
+ </values-param>
+ </init-params>
</component-plugin>
<component-plugin>
Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java 2010-08-20 09:49:54 UTC (rev 2957)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java 2010-08-20 10:31:38 UTC (rev 2958)
@@ -24,6 +24,9 @@
import org.exoplatform.services.document.impl.MSExcelDocumentReader;
import org.exoplatform.services.document.impl.MSOutlookDocumentReader;
import org.exoplatform.services.document.impl.MSWordDocumentReader;
+import org.exoplatform.services.document.impl.MSXExcelDocumentReader;
+import org.exoplatform.services.document.impl.MSXPPTDocumentReader;
+import org.exoplatform.services.document.impl.MSXWordDocumentReader;
import org.exoplatform.services.document.impl.OpenOfficeDocumentReader;
import org.exoplatform.services.document.impl.PDFDocumentReader;
import org.exoplatform.services.document.impl.PPTDocumentReader;
@@ -55,11 +58,14 @@
serviceList = new ArrayList<DocumentReader>();
serviceList.add(new HTMLDocumentReader(null));
serviceList.add(new MSExcelDocumentReader());
+ serviceList.add(new MSXExcelDocumentReader());
serviceList.add(new MSOutlookDocumentReader());
serviceList.add(new MSWordDocumentReader());
+ serviceList.add(new MSXWordDocumentReader());
serviceList.add(new OpenOfficeDocumentReader());
serviceList.add(new PDFDocumentReader());
serviceList.add(new PPTDocumentReader());
+ serviceList.add(new MSXPPTDocumentReader());
serviceList.add(new TextPlainDocumentReader(new InitParams()));
serviceList.add(new XMLDocumentReader());
}
Added: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java (rev 0)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java 2010-08-20 10:31:38 UTC (rev 2958)
@@ -0,0 +1,79 @@
+/*
+ * 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.services.document.test;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.document.DocumentReaderService;
+import org.exoplatform.test.BasicTestCase;
+
+import java.io.InputStream;
+
+/**
+ * Created by The eXo Platform SAS Author : Sergey Karpenko
+ * <sergey.karpenko(a)exoplatform.com.ua>
+ *
+ * @version $Id: $
+ */
+
+public class TestMSXExcelDocumentReader extends BasicTestCase
+{
+ DocumentReaderService service_;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ PortalContainer pcontainer = PortalContainer.getInstance();
+ service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+ }
+
+ public void testGetContentAsString() throws Exception
+ {
+ InputStream is = TestMSXExcelDocumentReader.class.getResourceAsStream("/test.xlsx");
+ String text = service_.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet").getContentAsText(is);
+ System.out.println(" text [" + text + "]");
+ /*
+ * String etalon =
+ * "Ronaldo Eric Cantona Kaka Ronaldonho ID Group Functionality Executor Begin End Tested "
+ * +
+ * "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH 2005-02-02 00:00:00.000+0200 2005-10-02 00:00:00.000+0300 Tested "
+ * +
+ * "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 2005-10-01 00:00:00.000+0300 Tested "
+ * +
+ * "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH 2005-10-12 00:00:00.000+0300 2005-10-02 00:00:00.000+0300 Tested "
+ * +"XNNL XNNL XNNL_76 NamPH TRUE 1984-12-10 00:00:00.000+0200 No "
+ * +"XNNL XNNL XNNL_CREATE_REAP NamPH none 2005-10-03 00:00:00.000+0300 No "
+ * +
+ * "XNNL XNNL XNNL_SCALE NamPH 1984-12-10 00:00:00.000+0200 2005-10-05 00:00:00.000+0300 Tested "
+ * +
+ * "XNNL XNNL LASUCO_PROJECT NamPH 2005-10-05 00:00:00.000+0300 2005-10-06 00:00:00.000+0300 No "
+ * +"XNNL XNNL LASUCO_PROJECT NamPH Tested "+
+ * "XNNL XNNL XNNL_BRANCH NamPH 2005-12-12 00:00:00.000+0200 2005-06-10 00:00:00.000+0300 Tested "
+ * +
+ * "XNNL XNNL XNNL_SUGAR_RACE NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
+ * +
+ * "XNNL XNNL F_XNNL_DISTRI NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 Tested "
+ * +
+ * "XNNL XNNL XNNL_LASUCO_USER NamPH 2005-09-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
+ * ; System.out.println(" etalon ["+etalon+"]");
+ * assertEquals("String length is incorect",etalon.length(),text.length());
+ * assertEquals("Wrong string returned",etalon ,text );
+ */
+
+ }
+}
Added: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java (rev 0)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java 2010-08-20 10:31:38 UTC (rev 2958)
@@ -0,0 +1,57 @@
+/*
+ * 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.services.document.test;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.document.DocumentReaderService;
+import org.exoplatform.test.BasicTestCase;
+
+import java.io.InputStream;
+
+/**
+ * Created by The eXo Platform SAS Author : Sergey Karpenko
+ * <sergey.karpenko(a)exoplatform.com.ua>
+ *
+ * @version $Id: $
+ */
+
+public class TestMSXPPTDocumentReader extends BasicTestCase
+{
+ DocumentReaderService service_;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ PortalContainer pcontainer = PortalContainer.getInstance();
+ service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+ }
+
+ public void testGetContentAsString() throws Exception
+ {
+ InputStream is = TestMSXPPTDocumentReader.class.getResourceAsStream("/test.pptx");
+ String text =
+ service_.getDocumentReader("application/vnd.openxmlformats-officedocument.presentationml.presentation")
+ .getContentAsText(is);
+ String etalon =
+ "TEST POWERPOINT\n" + "Manchester United \n" + "AC Milan\n" + "SLIDE 2 \n" + "Eric Cantona\n" + "Kaka\n"
+ + "Ronaldo\n" + "The natural scients universitys\n";
+
+ assertEquals("Wrong string returned", etalon, text);
+ }
+}
Added: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java (rev 0)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java 2010-08-20 10:31:38 UTC (rev 2958)
@@ -0,0 +1,57 @@
+/*
+ * 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.services.document.test;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.document.DocumentReaderService;
+import org.exoplatform.test.BasicTestCase;
+
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: TestMSXWordDocumentReader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class TestMSXWordDocumentReader extends BasicTestCase
+{
+ DocumentReaderService service_;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ PortalContainer pcontainer = PortalContainer.getInstance();
+ service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+ }
+
+ public void testGetContentAsStringDoc() throws Exception
+ {
+ InputStream is = TestMSXWordDocumentReader.class.getResourceAsStream("/test.docx");
+ String text = service_.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document").getContentAsText(is);
+ System.out.println("text [" + text + "]");
+
+ /*
+ * String etalon = "Hello.\n" +"This is the test document 12345\n"
+ * +"Table\n" +"Title One Two\n" +"Hello_Title Hello_One Hello_Two\n";
+ * System.out.println("etalon ["+etalon+"]");
+ * System.out.println("["+text.length()+"] ["+etalon.length()+"]");
+ * assertEquals("Wrong string returned",etalon ,text );
+ */
+ }
+}
Added: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.docx
===================================================================
(Binary files differ)
Property changes on: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.docx
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.pptx
===================================================================
(Binary files differ)
Property changes on: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.pptx
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.xlsx
===================================================================
(Binary files differ)
Property changes on: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.xlsx
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: core/branches/2.3.x/pom.xml
===================================================================
--- core/branches/2.3.x/pom.xml 2010-08-20 09:49:54 UTC (rev 2957)
+++ core/branches/2.3.x/pom.xml 2010-08-20 10:31:38 UTC (rev 2958)
@@ -295,14 +295,20 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
- <version>3.0.2-FINAL</version>
+ <version>3.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
- <version>3.0.2-FINAL</version>
+ <version>3.6</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml</artifactId>
+ <version>3.6</version>
+ </dependency>
<dependency>
<groupId>com.novell.ldap</groupId>
13 years, 10 months
exo-jcr SVN: r2957 - in kernel: trunk/exo.kernel.commons/src/main/resources/org/exoplatform/commons/utils and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-08-20 05:49:54 -0400 (Fri, 20 Aug 2010)
New Revision: 2957
Modified:
kernel/branches/2.2.x/exo.kernel.commons/src/main/resources/org/exoplatform/commons/utils/mimetypes.properties
kernel/trunk/exo.kernel.commons/src/main/resources/org/exoplatform/commons/utils/mimetypes.properties
Log:
EXOJCR-886: updating mimetypes for resolver
Modified: kernel/branches/2.2.x/exo.kernel.commons/src/main/resources/org/exoplatform/commons/utils/mimetypes.properties
===================================================================
--- kernel/branches/2.2.x/exo.kernel.commons/src/main/resources/org/exoplatform/commons/utils/mimetypes.properties 2010-08-19 17:18:39 UTC (rev 2956)
+++ kernel/branches/2.2.x/exo.kernel.commons/src/main/resources/org/exoplatform/commons/utils/mimetypes.properties 2010-08-20 09:49:54 UTC (rev 2957)
@@ -20,6 +20,7 @@
dir=application/x-director
dms=application/octet-stream
doc=application/msword
+docx=application/vnd.openxmlformats-officedocument.wordprocessingml.document
dvi=application/x-dvi
dxr=application/x-director
ecma=text/qhtml
@@ -78,6 +79,7 @@
pnm=image/x-portable-anymap
ppm=image/x-portable-pixmap
ppt=application/ppt
+pptx=application/vnd.openxmlformats-officedocument.presentationml.presentation
properties=text/plain
ps=application/postscript
qhtml=text/qhtml
@@ -133,6 +135,7 @@
wrl=model/vrml
xbm=image/x-xbitmap
xls=application/xls
+xlsx=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xml=text/xml
xpdl=text/xml
xpm=image/x-xpixmap
Modified: kernel/trunk/exo.kernel.commons/src/main/resources/org/exoplatform/commons/utils/mimetypes.properties
===================================================================
--- kernel/trunk/exo.kernel.commons/src/main/resources/org/exoplatform/commons/utils/mimetypes.properties 2010-08-19 17:18:39 UTC (rev 2956)
+++ kernel/trunk/exo.kernel.commons/src/main/resources/org/exoplatform/commons/utils/mimetypes.properties 2010-08-20 09:49:54 UTC (rev 2957)
@@ -20,6 +20,7 @@
dir=application/x-director
dms=application/octet-stream
doc=application/msword
+docx=application/vnd.openxmlformats-officedocument.wordprocessingml.document
dvi=application/x-dvi
dxr=application/x-director
ecma=text/qhtml
@@ -78,6 +79,7 @@
pnm=image/x-portable-anymap
ppm=image/x-portable-pixmap
ppt=application/ppt
+pptx=application/vnd.openxmlformats-officedocument.presentationml.presentation
properties=text/plain
ps=application/postscript
qhtml=text/qhtml
@@ -133,6 +135,7 @@
wrl=model/vrml
xbm=image/x-xbitmap
xls=application/xls
+xlsx=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xml=text/xml
xpdl=text/xml
xpm=image/x-xpixmap
13 years, 10 months
exo-jcr SVN: r2956 - jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-08-19 13:18:39 -0400 (Thu, 19 Aug 2010)
New Revision: 2956
Modified:
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml
Log:
EXOJCR-842: commit patch (doc part)
Modified: jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml
===================================================================
--- jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml 2010-08-19 17:17:55 UTC (rev 2955)
+++ jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/kernel/configuration.xml 2010-08-19 17:18:39 UTC (rev 2956)
@@ -1148,7 +1148,7 @@
<envar>PortalContainerDefinition</envar> must be a class of type
<envar>PortalContainerDefinitionChange</envar>. The product proposes
out of the box some implementations that we describe in the next sub
- sections. </para>
+ sections.</para>
<section>
<title><envar>AddDependencies</envar></title>
@@ -1451,6 +1451,71 @@
</section>
</section>
</section>
+
+ <section>
+ <title>Disable dynamically a portal container</title>
+
+ <para>It is possible to use <envar>component-plugin</envar> elements
+ in order to dynamically disable one or several portal containers. In
+ the example below, we disable the portal container named
+ <envar>foo</envar>:</para>
+
+ <programlisting><external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>foo</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+</external-component-plugins></programlisting>
+
+ <table>
+ <title>Descriptions of the fields of a
+ <envar>PortalContainerDefinitionDisablePlugin</envar></title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>names</entry>
+
+ <entry>The list of the name of the portal containers to
+ disable.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>To prevent any accesses to a web application corresponding to
+ <envar>PortalContainer</envar> that has been disabled, you need to
+ make sure that the following Http Filter (or a sub class of it) has
+ been added to your web.xml in first position as below:</para>
+
+ <programlisting><filter>
+ <filter-name>PortalContainerFilter</filter-name>
+ <filter-class>org.exoplatform.container.web.PortalContainerFilter</filter-class>
+</filter>
+
+<filter-mapping>
+ <filter-name>PortalContainerFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+</filter-mapping></programlisting>
+
+ <note>
+ <para>It is only possible to disable a portal container when at
+ least one PortalContainerDefinition has been registered.</para>
+ </note>
+ </section>
</section>
</section>
13 years, 10 months
exo-jcr SVN: r2955 - in kernel/trunk/exo.kernel.container/src: main/java/org/exoplatform/container/definition and 4 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-08-19 13:17:55 -0400 (Thu, 19 Aug 2010)
New Revision: 2955
Added:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerDefinitionDisablePlugin.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/PortalContainerFilter.java
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpServlet.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpSessionListener.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def2.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values2.xml
Log:
EXOJCR-842: commit patch (implementation part)
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2010-08-19 17:17:55 UTC (rev 2955)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.container;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.RootContainer.PortalContainerInitTask;
import org.exoplatform.container.definition.PortalContainerConfig;
import org.exoplatform.container.jmx.MX4JComponentAdapterFactory;
@@ -378,6 +379,21 @@
}
/**
+ * @see the method isPortalContainerNameDisabled of {@link PortalContainerConfig}
+ */
+ public static boolean isPortalContainerNameDisabled(String name)
+ {
+ if (CONFIG == null)
+ {
+ return false;
+ }
+ else
+ {
+ return CONFIG.isPortalContainerNameDisabled(name);
+ }
+ }
+
+ /**
* Add an init-task to all the portal container instances related to the given ServletContext
*
* @param context the context from which we extract the context name
@@ -430,8 +446,11 @@
String portalContainerName = CONFIG.getPortalContainerName(context.getServletContextName());
if (portalContainerName == null)
{
- log.warn("The Servlet Context '" + context.getServletContextName() + "' has not been registered"
- + " has a dependency of any PortalContainerDefinitions.");
+ if (PropertyManager.isDevelopping())
+ {
+ log.warn("The Servlet Context '" + context.getServletContextName() + "' has not been registered"
+ + " has a dependency of any PortalContainerDefinitions.");
+ }
return null;
}
RootContainer root = RootContainer.getInstance();
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-08-19 17:17:55 UTC (rev 2955)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.container;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.configuration.ConfigurationManagerImpl;
import org.exoplatform.container.configuration.MockConfigurationManagerImpl;
@@ -189,12 +190,25 @@
public void registerPortalContainer(ServletContext context)
{
PortalContainerConfig config = getPortalContainerConfig();
- // Ensure that the portal container has been registered
- config.registerPortalContainerName(context.getServletContextName());
if (config.hasDefinition())
{
// The new behavior has been detected thus, the creation will be done at the end asynchronously
- portalContexts.add(new WebAppInitContext(context));
+ if (config.isPortalContainerName(context.getServletContextName()))
+ {
+ // The portal context has been registered has a portal container
+ portalContexts.add(new WebAppInitContext(context));
+ }
+ else
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("We assume that the ServletContext '" + context.getServletContextName()
+ + "' is not a portal since no portal container definition with the same name has been"
+ + " registered to the component PortalContainerConfig. The related portal container"
+ + " will be declared as disabled.");
+ }
+ config.disablePortalContainer(context.getServletContextName());
+ }
// We assume that a ServletContext of a portal container owns configuration files
final PortalContainerPreInitTask task = new PortalContainerPreInitTask()
{
@@ -208,6 +222,8 @@
}
else
{
+ // Ensure that the portal container has been registered
+ config.registerPortalContainerName(context.getServletContextName());
// The old behavior has been detected thus, the creation will be done synchronously
createPortalContainer(context);
}
@@ -244,11 +260,14 @@
PortalContainerConfig config = getPortalContainerConfig();
for (String portalContainerName : initTasks.keySet())
{
- // Unregister name of portal container that doesn't exist
- log.warn("The portal container '" + portalContainerName + "' doesn't not exist or"
- + " it has not yet been registered, please check your PortalContainerDefinitions and "
- + "the loading order.");
- config.unregisterPortalContainerName(portalContainerName);
+ if (config.isPortalContainerName(portalContainerName))
+ {
+ // Unregister name of portal container that doesn't exist
+ log.warn("The portal container '" + portalContainerName + "' doesn't not exist or"
+ + " it has not yet been registered, please check your PortalContainerDefinitions and "
+ + "the loading order.");
+ config.unregisterPortalContainerName(portalContainerName);
+ }
}
// remove all the unneeded tasks
initTasks.clear();
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-08-19 17:17:55 UTC (rev 2955)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.container.definition;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.PropertyConfigurator;
import org.exoplatform.container.RootContainer;
@@ -38,9 +39,12 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.servlet.ServletContext;
@@ -105,14 +109,19 @@
private volatile boolean initialized;
/**
- * The list of all the portal containers
+ * The set of all the portal containers
*/
- private List<String> portalContainerNames;
+ private Set<String> portalContainerNames = Collections.unmodifiableSet(new HashSet<String>());
/**
+ * The set of all the portal containers that have been disabled
+ */
+ private Set<String> portalContainerNamesDisabled = Collections.unmodifiableSet(new HashSet<String>());
+
+ /**
* The list of all the web application scopes
*/
- private Map<String, List<String>> scopes;
+ private Map<String, List<String>> scopes = Collections.unmodifiableMap(new HashMap<String, List<String>>());
/**
* The list of all the {@link PortalContainerDefinition} that have been registered
@@ -345,8 +354,70 @@
{
return !definitions.isEmpty();
}
+
+ /**
+ * Disables a portal container if it has not yet been disabled.
+ * @param name the name of the portal container to disable
+ */
+ public synchronized void disablePortalContainer(String name)
+ {
+ if (!portalContainerNamesDisabled.contains(name))
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The portal container '" + name + "' will be disabled");
+ }
+ final Set<String> lPortalContainerNames = new HashSet<String>(portalContainerNamesDisabled.size() + 1);
+ lPortalContainerNames.add(name);
+ lPortalContainerNames.addAll(portalContainerNamesDisabled);
+ this.portalContainerNamesDisabled = Collections.unmodifiableSet(lPortalContainerNames);
+ if (hasDefinition())
+ {
+ // The new behavior is expected
+ // Remove the portal container from the registered portal container list
+ unregisterPortalContainerName(name);
+ }
+ }
+ }
+
+ /**
+ * Remove the given portal container name from all the existing scopes
+ *
+ * @param name the name of the portal container to remove from all the scopes
+ */
+ private void removePortalContainerNameFromScopes(String name)
+ {
+ final Map<String, List<String>> tmpScopes = new HashMap<String, List<String>>(scopes);
+ boolean changed = false;
+ for (String ctx : tmpScopes.keySet())
+ {
+ List<String> portalContainerNames = tmpScopes.get(ctx);
+ if (portalContainerNames.contains(name))
+ {
+ List<String> tmpPortalContainerNames = new ArrayList<String>(portalContainerNames);
+ tmpPortalContainerNames.remove(name);
+ tmpScopes.put(ctx, Collections.unmodifiableList(tmpPortalContainerNames));
+ changed = true;
+ }
+ }
+ if (changed)
+ {
+ this.scopes = Collections.unmodifiableMap(tmpScopes);
+ }
+ }
/**
+ * Indicates if the given name is the name of a portal container that has been registered as disabled
+ * @param name the name to check
+ * @return <code>true</code> if the name is a name of a disabled portal container, <code>false</code>
+ * otherwise.
+ */
+ public boolean isPortalContainerNameDisabled(String name)
+ {
+ return name == null ? false : portalContainerNamesDisabled.contains(name);
+ }
+
+ /**
* Registers a name of a portal container if it has not yet been registered
* @param name the name of the portal container to register
*/
@@ -354,10 +425,10 @@
{
if (!portalContainerNames.contains(name))
{
- final List<String> lPortalContainerNames = new ArrayList<String>(portalContainerNames.size() + 1);
+ final Set<String> lPortalContainerNames = new LinkedHashSet<String>(portalContainerNames.size() + 1);
lPortalContainerNames.add(name);
lPortalContainerNames.addAll(portalContainerNames);
- this.portalContainerNames = Collections.unmodifiableList(lPortalContainerNames);
+ this.portalContainerNames = Collections.unmodifiableSet(lPortalContainerNames);
}
}
@@ -369,9 +440,15 @@
{
if (portalContainerNames.contains(name))
{
- final List<String> lPortalContainerNames = new ArrayList<String>(portalContainerNames);
+ final Set<String> lPortalContainerNames = new LinkedHashSet<String>(portalContainerNames);
lPortalContainerNames.remove(name);
- this.portalContainerNames = Collections.unmodifiableList(lPortalContainerNames);
+ this.portalContainerNames = Collections.unmodifiableSet(lPortalContainerNames);
+ if (hasDefinition())
+ {
+ // The new behavior is expected
+ // Remove the portal container from all the scopes
+ removePortalContainerNameFromScopes(name);
+ }
}
}
@@ -397,7 +474,7 @@
{
throw new IllegalArgumentException("The context name cannot be null");
}
- if (scopes.isEmpty())
+ if (definitions.isEmpty())
{
// we assume that the old behavior is expected
final String portalContainerName =
@@ -435,15 +512,20 @@
// The given context name is a context name of a portal container
return contextName;
}
- else if (scopes.isEmpty())
+ else if (definitions.isEmpty())
{
// we assume that the old behavior is expected
- return defaultDefinition.getName();
+ return defaultDefinition.getName();
}
final List<String> result = scopes.get(contextName);
if (result == null || result.isEmpty())
{
- // This context has not been added as dependency of any portal containers
+ // This context has not been added as dependency of any portal containers
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The context '" + contextName + "' has not been added as " +
+ "dependency of any portal containers");
+ }
return null;
}
return result.get(0);
@@ -457,12 +539,18 @@
public List<String> getDependencies(String portalContainerName)
{
final PortalContainerDefinition definition = definitions.get(portalContainerName);
- List<String> result = null;
if (definition != null)
{
- result = definition.getDependencies();
+ // A definition has been defined
+ List<String> result = definition.getDependencies();
+ return result == null || result.isEmpty() ? defaultDefinition.getDependencies() : result;
}
- return result == null || result.isEmpty() ? defaultDefinition.getDependencies() : result;
+ else if (definitions.isEmpty())
+ {
+ // The old behavior is expected
+ return defaultDefinition.getDependencies();
+ }
+ return null;
}
/**
@@ -542,7 +630,7 @@
if (portalContainerName == null)
{
throw new IllegalArgumentException("The portal container name cannot be null");
- }
+ }
return getPortalContainerNames(contextName).contains(portalContainerName);
}
@@ -584,6 +672,29 @@
}
/**
+ * Allow to disable a set of portal containers
+ * @param plugin the plugin that defines the name of portal containers to disable
+ */
+ public void registerDisablePlugin(PortalContainerDefinitionDisablePlugin plugin)
+ {
+ final Set<String> sPortalContainerNames = plugin.getNames();
+ if (sPortalContainerNames != null && !sPortalContainerNames.isEmpty())
+ {
+ synchronized (this)
+ {
+ if (initialized)
+ {
+ throw new IllegalStateException("The PortalContainerConfig has already been initialized");
+ }
+ for (String name : sPortalContainerNames)
+ {
+ disablePortalContainer(name);
+ }
+ }
+ }
+ }
+
+ /**
* Allow to define a set of changes to apply to the registered {@link PortalContainerDefinition}
* @param plugin the plugin that defines the changes to apply
*/
@@ -975,20 +1086,21 @@
*/
private void initialize(Map<String, PortalContainerDefinition> mDefinitions)
{
- final List<String> lPortalContainerNames = new ArrayList<String>(mDefinitions.size() + 1);
- // Add the default portal container name
- lPortalContainerNames.add(defaultDefinition.getName());
+ final Set<String> lPortalContainerNames = new LinkedHashSet<String>(mDefinitions.size() + 1);
final Map<String, List<String>> mScopes = new HashMap<String, List<String>>();
boolean first = true;
for (Map.Entry<String, PortalContainerDefinition> entry : mDefinitions.entrySet())
{
PortalContainerDefinition definition = entry.getValue();
String name = definition.getName();
- boolean hasChanged = false;
- if (!name.equals(defaultDefinition.getName()))
+ if (isPortalContainerNameDisabled(name))
{
- lPortalContainerNames.add(name);
+ // The portal container has been disabled so the related portal container definition
+ // will be ignored
+ continue;
}
+ boolean hasChanged = false;
+ lPortalContainerNames.add(name);
if (first)
{
first = false;
@@ -1020,8 +1132,10 @@
}
initializeSettings(definition, true);
}
- if (!mDefinitions.containsKey(defaultDefinition.getName()))
+ if (mDefinitions.isEmpty())
{
+ // Add the default portal container name
+ lPortalContainerNames.add(defaultDefinition.getName());
// Apply the changes corresponding to the default definition
applyChanges(defaultDefinition);
initializeSettings(defaultDefinition, false);
@@ -1031,8 +1145,18 @@
// dependencies have been defined
registerDependencies(defaultDefinition, mScopes);
}
+ if (!portalContainerNamesDisabled.isEmpty())
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.warn("No portal container definition has been registered, the old behavior is" +
+ " then expected so you cannot disable any portal container. The list of" +
+ " portal containers to disable will be ignored");
+ }
+ portalContainerNamesDisabled = Collections.unmodifiableSet(new HashSet<String>());
+ }
}
- this.portalContainerNames = Collections.unmodifiableList(lPortalContainerNames);
+ this.portalContainerNames = Collections.unmodifiableSet(lPortalContainerNames);
this.scopes = Collections.unmodifiableMap(mScopes);
// clear the changes
changes.clear();
Added: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerDefinitionDisablePlugin.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerDefinitionDisablePlugin.java (rev 0)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerDefinitionDisablePlugin.java 2010-08-19 17:17:55 UTC (rev 2955)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.container.definition;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValuesParam;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * This class allows you to dynamically disable one or several portal containers.
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 9 juil. 2010
+ */
+public class PortalContainerDefinitionDisablePlugin extends BaseComponentPlugin
+{
+
+ /**
+ * A set of specific portal container names that we want to disable.
+ */
+ private Set<String> names;
+
+ @SuppressWarnings("unchecked")
+ public PortalContainerDefinitionDisablePlugin(InitParams params)
+ {
+ ValuesParam vsp = params.getValuesParam("names");
+ if (vsp != null && !vsp.getValues().isEmpty())
+ {
+ this.names = new HashSet<String>(vsp.getValues());
+ }
+ }
+
+ public Set<String> getNames()
+ {
+ return names;
+ }
+}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpServlet.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpServlet.java 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpServlet.java 2010-08-19 17:17:55 UTC (rev 2955)
@@ -18,10 +18,13 @@
*/
package org.exoplatform.container.web;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.RootContainer;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import java.io.IOException;
@@ -40,6 +43,10 @@
*/
public abstract class AbstractHttpServlet extends HttpServlet
{
+ /**
+ * The logger
+ */
+ private static final Log log = ExoLogger.getLogger("exo.kernel.container.AbstractHttpServlet");
/**
* Serial Version ID.
@@ -102,16 +109,25 @@
ExoContainerContext.setCurrentContainer(container);
hasBeenSet = true;
}
- if (requirePortalEnvironment() && container instanceof PortalContainer)
+ if (requirePortalEnvironment())
{
- if (PortalContainer.getInstanceIfPresent() == null)
+ final String ctxName = config.getServletContext().getServletContextName();
+ if (!PortalContainer.isPortalContainerNameDisabled(ctxName) && container instanceof PortalContainer)
{
- // The portal container has not been set
- PortalContainer.setInstance((PortalContainer)container);
- hasBeenSet = true;
+ if (PortalContainer.getInstanceIfPresent() == null)
+ {
+ // The portal container has not been set
+ PortalContainer.setInstance((PortalContainer)container);
+ hasBeenSet = true;
+ }
+ // Set the full classloader of the portal container
+ Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
}
- // Set the full classloader of the portal container
- Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
+ else
+ {
+ onPortalEnvironmentError(req, res);
+ return;
+ }
}
onService(container, req, res);
}
@@ -168,6 +184,26 @@
}
/**
+ * Allow the sub classed to execute a task when the portal environment could not be set
+ * because no related portal container could be found
+ * @param req the {@link HttpServletRequest}
+ * @param res the {@link HttpServletResponse}
+ */
+ protected void onPortalEnvironmentError(HttpServletRequest req, HttpServletResponse res) throws ServletException,
+ IOException
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The portal environment could not be set for the webapp '"
+ + config.getServletContext().getServletContextName()
+ + "' because this servlet context has not been defined as a "
+ + "dependency of any portal container or it is a disabled portal"
+ + " container, the target URI was " + req.getRequestURI());
+ }
+ res.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ /**
* @return Gives the {@link ExoContainer} that fits best with the current context
*/
protected final ExoContainer getContainer()
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpSessionListener.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpSessionListener.java 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpSessionListener.java 2010-08-19 17:17:55 UTC (rev 2955)
@@ -18,10 +18,13 @@
*/
package org.exoplatform.container.web;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.RootContainer;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
@@ -34,6 +37,10 @@
*/
public abstract class AbstractHttpSessionListener implements HttpSessionListener
{
+ /**
+ * The logger
+ */
+ private static final Log log = ExoLogger.getLogger("exo.kernel.container.AbstractHttpSessionListener");
/**
* @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
@@ -57,16 +64,31 @@
ExoContainerContext.setCurrentContainer(container);
hasBeenSet = true;
}
- if (requirePortalEnvironment() && container instanceof PortalContainer)
+ if (requirePortalEnvironment())
{
- if (PortalContainer.getInstanceIfPresent() == null)
+ final String ctxName = event.getSession().getServletContext().getServletContextName();
+ if (!PortalContainer.isPortalContainerNameDisabled(ctxName) && container instanceof PortalContainer)
{
- // The portal container has not been set
- PortalContainer.setInstance((PortalContainer)container);
- hasBeenSet = true;
+ if (PortalContainer.getInstanceIfPresent() == null)
+ {
+ // The portal container has not been set
+ PortalContainer.setInstance((PortalContainer)container);
+ hasBeenSet = true;
+ }
+ // Set the full classloader of the portal container
+ Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
}
- // Set the full classloader of the portal container
- Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
+ else
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The portal environment could not be set for the webapp '" + ctxName
+ + "' because this servlet context has not been defined as a "
+ + "dependency of any portal container or it is a disabled portal"
+ + " container, the sessionCreated event will be ignored");
+ }
+ return;
+ }
}
onSessionCreated(container, event);
}
@@ -112,16 +134,31 @@
ExoContainerContext.setCurrentContainer(container);
hasBeenSet = true;
}
- if (requirePortalEnvironment() && container instanceof PortalContainer)
+ if (requirePortalEnvironment())
{
- if (PortalContainer.getInstanceIfPresent() == null)
+ final String ctxName = event.getSession().getServletContext().getServletContextName();
+ if (!PortalContainer.isPortalContainerNameDisabled(ctxName) && container instanceof PortalContainer)
{
- // The portal container has not been set
- PortalContainer.setInstance((PortalContainer)container);
- hasBeenSet = true;
+ if (PortalContainer.getInstanceIfPresent() == null)
+ {
+ // The portal container has not been set
+ PortalContainer.setInstance((PortalContainer)container);
+ hasBeenSet = true;
+ }
+ // Set the full classloader of the portal container
+ Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
}
- // Set the full classloader of the portal container
- Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
+ else
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The portal environment could not be set for the webapp '" + ctxName
+ + "' because this servlet context has not been defined as a "
+ + "dependency of any portal container or it is a disabled portal"
+ + " container, the sessionDestroyed event will be ignored");
+ }
+ return;
+ }
}
onSessionDestroyed(container, event);
}
Added: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/PortalContainerFilter.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/PortalContainerFilter.java (rev 0)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/web/PortalContainerFilter.java 2010-08-19 17:17:55 UTC (rev 2955)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.container.web;
+
+import org.exoplatform.commons.utils.PropertyManager;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * This filter will allow to prevent to any accesses to a web application corresponding to a
+ * {@link PortalContainer} that has been disabled.
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 8 juil. 2010
+ */
+public class PortalContainerFilter extends AbstractFilter
+{
+ /**
+ * The logger
+ */
+ private static final Log log = ExoLogger.getLogger("exo.kernel.container.PortalContainerFilter");
+
+ /**
+ * @see javax.servlet.Filter#destroy()
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ if (PortalContainer.isPortalContainerNameDisabled(servletContextName))
+ {
+ // The current portal container has been disabled
+ onPortalContainerDisabled(request, response, chain);
+ return;
+ }
+
+ chain.doFilter(request, response);
+ }
+
+ /**
+ * Allow the sub classed to execute a task when a user try to access to a
+ * web application corresponding to a {@link PortalContainer} that has been disabled.
+ * @param request the {@link ServletRequest}
+ * @param response the {@link ServletResponse}
+ * @param response the {@link FilterChain}
+ */
+ protected void onPortalContainerDisabled(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The portal container corresponding to the webapp '" + servletContextName
+ + "' is disabled, thus the request is cancelled: target URI was "
+ + ((HttpServletRequest)request).getRequestURI());
+ }
+ ((HttpServletResponse)response).sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+}
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java 2010-08-19 17:17:55 UTC (rev 2955)
@@ -43,7 +43,7 @@
assertEquals("myRest", portal.getRestContextName());
assertEquals("my-exo-domain", portal.getRealmName());
- assertTrue(PortalContainer.isPortalContainerName("myPortal"));
+ assertFalse(PortalContainer.isPortalContainerName("myPortal"));
assertTrue(PortalContainer.isPortalContainerName("portal"));
assertFalse(PortalContainer.isPortalContainerName("foo"));
@@ -73,7 +73,7 @@
assertEquals("myRest", PortalContainer.getRestContextName("foo"));
assertEquals("my-exo-domain", PortalContainer.getRealmName("foo"));
- assertTrue(PortalContainer.isPortalContainerName("myPortal"));
+ assertFalse(PortalContainer.isPortalContainerName("myPortal"));
assertTrue(PortalContainer.isPortalContainerName("portal"));
assertFalse(PortalContainer.isPortalContainerName("foo"));
@@ -84,7 +84,7 @@
assertEquals("myRest", PortalContainer.getCurrentRestContextName());
assertEquals("my-exo-domain", PortalContainer.getCurrentRealmName());
- assertTrue(PortalContainer.isPortalContainerName("myPortal"));
+ assertFalse(PortalContainer.isPortalContainerName("myPortal"));
assertTrue(PortalContainer.isPortalContainerName("portal"));
assertFalse(PortalContainer.isPortalContainerName("foo"));
}
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-08-19 17:17:55 UTC (rev 2955)
@@ -48,6 +48,9 @@
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getDefaultPortalContainer());
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getDefaultRestContext());
assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getDefaultRealmName());
+ assertTrue(config.isPortalContainerName("portal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.hasDefinition());
rootContainer = createRootContainer("portal-container-config-with-default-values.xml");
@@ -56,6 +59,9 @@
assertEquals("myPortal", config.getDefaultPortalContainer());
assertEquals("myRest", config.getDefaultRestContext());
assertEquals("my-exo-domain", config.getDefaultRealmName());
+ assertFalse(config.isPortalContainerName("portal"));
+ assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.hasDefinition());
rootContainer =
@@ -65,6 +71,9 @@
assertEquals("myPortal-dpcdef", config.getDefaultPortalContainer());
assertEquals("myRest-dpcdef", config.getDefaultRestContext());
assertEquals("my-exo-domain-dpcdef", config.getDefaultRealmName());
+ assertFalse(config.isPortalContainerName("portal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.hasDefinition());
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
@@ -205,6 +214,7 @@
assertFalse(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
+
// Needed for backward compatibility
assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
assertFalse(config.isScopeValid("foo", "foo"));
@@ -212,6 +222,16 @@
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
assertFalse(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-no-default-values.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
+ assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
+ assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
+
// Empty with AddDependencies, AddDependenciesBefore and AddDependenciesAfter
String[] profiles =
{"AddDependencies", "AddDependenciesBefore-No-Target", "AddDependenciesBefore-With-Fake-Target",
@@ -234,12 +254,14 @@
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && names.isEmpty());
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
- assertTrue(names != null && names.isEmpty());
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
- assertNull(config.getPortalContainerName("myPortal"));
- assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal"));
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal-pcdef"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("foo"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal-pcdef"));
@@ -256,6 +278,16 @@
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
assertFalse(config.hasDefinition());
+
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-no-default-values2.xml", profile, "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
+ assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
+ assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
}
// Without dependencies
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
@@ -264,16 +296,14 @@
assertNull(config.getDependencies("myPortal"));
assertNull(config.getDependencies("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
- assertEquals("myPortal", config.getPortalContainerName("foo"));
- assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -282,16 +312,24 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
// Needed for backward compatibility
assertFalse(config.isScopeValid("foo", "foo"));
- assertTrue(config.isScopeValid("myPortal", "foo"));
+ assertFalse(config.isScopeValid("myPortal", "foo"));
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
- assertTrue(config.isScopeValid("myPortal", "myPortal"));
+ assertFalse(config.isScopeValid("myPortal", "myPortal"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertTrue(config.hasDefinition());
-
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+
// Without dependencies and with no portal container name
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -319,6 +357,15 @@
assertFalse(config.isPortalContainerName("foo"));
assertTrue(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals("myPortal", config.getPortalContainerName("foo"));
+ assertTrue(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isScopeValid("myPortal", "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal", names.get(0));
// Without dependencies and with no rest context name an realm name
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def2.xml");
@@ -327,16 +374,14 @@
assertNull(config.getDependencies("myPortal"));
assertNull(config.getDependencies("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
- assertEquals("myPortal", config.getPortalContainerName("foo"));
- assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -345,30 +390,37 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
// Needed for backward compatibility
assertFalse(config.isScopeValid("foo", "foo"));
- assertTrue(config.isScopeValid("myPortal", "foo"));
+ assertFalse(config.isScopeValid("myPortal", "foo"));
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
- assertTrue(config.isScopeValid("myPortal", "myPortal"));
+ assertFalse(config.isScopeValid("myPortal", "myPortal"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def2.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
// Without dependencies and with default portal container definition
rootContainer =
createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
- assertEquals(2, names.size());
- assertTrue(names.contains("myPortal-dpcdef"));
+ assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && names.isEmpty());
@@ -393,6 +445,17 @@
assertFalse(config.isScopeValid("myPortal", "fooX"));
assertTrue(config.isScopeValid("myPortal-pcdef", "fooX"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+ assertFalse(config.isScopeValid("myPortal-pcdef", "fooX"));
+ names = config.getPortalContainerNames("fooX");
+ assertTrue(names != null && names.isEmpty());
profiles =
new String[]{"AddDependencies", "AddDependenciesBefore-No-Target", "AddDependenciesBefore-With-Fake-Target",
@@ -407,6 +470,10 @@
"with-profiles", profile);
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
+ assertNull(deps);
+ deps = config.getDependencies("myPortal");
+ assertNull(deps);
+ deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 2 && deps.contains("fooX") && deps.contains("foo"));
int index = deps.indexOf("foo");
if (profile.equals("AddDependenciesBefore-No-Target")
@@ -419,25 +486,20 @@
{
assertEquals(1, index);
}
- deps = config.getDependencies("myPortal");
- assertTrue(deps != null && deps.size() == 2 && deps.contains("fooX") && deps.contains("foo"));
- deps = config.getDependencies("myPortal-pcdef");
- assertTrue(deps != null && deps.size() == 2 && deps.contains("fooX") && deps.contains("foo"));
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
- assertEquals(2, names.size());
- assertTrue(names.contains("myPortal-dpcdef"));
+ assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
- assertEquals("myPortal-dpcdef", names.get(0));
+ assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
- assertEquals("myPortal-dpcdef", config.getPortalContainerName("foo"));
+ assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest-dpcdef", config.getRestContextName("foo"));
@@ -453,6 +515,22 @@
assertFalse(config.isScopeValid("myPortal", "fooX"));
assertTrue(config.isScopeValid("myPortal-pcdef", "fooX"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer(
+ "portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml",
+ "with-profiles", profile, "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+ assertFalse(config.isScopeValid("myPortal-pcdef", "fooX"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && names.isEmpty());
+ names = config.getPortalContainerNames("fooX");
+ assertTrue(names != null && names.isEmpty());
}
// With dependencies
@@ -466,13 +544,12 @@
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
- assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -481,7 +558,7 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
@@ -489,6 +566,18 @@
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal"));
assertFalse(config.isScopeValid("myPortal-pcdef", "fooY"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+ assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && names.isEmpty());
for (String profile : profiles)
{
@@ -497,9 +586,9 @@
"with-profiles", profile);
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 4);
int index = deps.indexOf("fooX");
@@ -523,13 +612,12 @@
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
- assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -538,12 +626,25 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml",
+ "with-profiles", profile, "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+ assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && names.isEmpty());
}
// With dependencies and with default portal container definition
@@ -551,27 +652,24 @@
createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 3);
names = config.getPortalContainerNames("fooX");
- assertTrue(names != null && !names.isEmpty());
- assertEquals(1, names.size());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
- assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -580,12 +678,24 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+ assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && names.isEmpty());
}
public void testSettings()
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml 2010-08-19 17:17:55 UTC (rev 2955)
@@ -57,4 +57,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml 2010-08-19 17:17:55 UTC (rev 2955)
@@ -53,4 +53,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal-pcdef</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml 2010-08-19 17:17:55 UTC (rev 2955)
@@ -107,7 +107,7 @@
<values-param>
<name>apply.specific</name>
<value>fake</value>
- <value>myPortal-dpcdef</value>
+ <value>myPortal-pcdef</value>
</values-param>
<object-param profiles="AddDependencies">
<name>change</name>
@@ -219,4 +219,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal-pcdef</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml 2010-08-19 17:17:55 UTC (rev 2955)
@@ -89,4 +89,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal-pcdef</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml 2010-08-19 17:17:55 UTC (rev 2955)
@@ -61,4 +61,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal-pcdef</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def2.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def2.xml 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def2.xml 2010-08-19 17:17:55 UTC (rev 2955)
@@ -196,4 +196,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal-pcdef</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values.xml 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values.xml 2010-08-19 17:17:55 UTC (rev 2955)
@@ -56,4 +56,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>portal</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values2.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values2.xml 2010-08-19 17:12:18 UTC (rev 2954)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values2.xml 2010-08-19 17:17:55 UTC (rev 2955)
@@ -103,4 +103,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>portal</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
13 years, 10 months
exo-jcr SVN: r2954 - jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/reference/en/src/main/docbook/en-US/modules/kernel.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-08-19 13:12:18 -0400 (Thu, 19 Aug 2010)
New Revision: 2954
Modified:
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/reference/en/src/main/docbook/en-US/modules/kernel/container-configuration.xml
Log:
EXOJCR-842: commit patch (doc part)
Modified: jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/reference/en/src/main/docbook/en-US/modules/kernel/container-configuration.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/reference/en/src/main/docbook/en-US/modules/kernel/container-configuration.xml 2010-08-19 17:11:10 UTC (rev 2953)
+++ jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/reference/en/src/main/docbook/en-US/modules/kernel/container-configuration.xml 2010-08-19 17:12:18 UTC (rev 2954)
@@ -1471,6 +1471,71 @@
</section>
</section>
</section>
+
+ <section>
+ <title>Disable dynamically a portal container</title>
+
+ <para>It is possible to use <envar>component-plugin</envar> elements
+ in order to dynamically disable one or several portal containers. In
+ the example below, we disable the portal container named
+ <envar>foo</envar>:</para>
+
+ <programlisting><external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>foo</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+</external-component-plugins></programlisting>
+
+ <table>
+ <title>Descriptions of the fields of a
+ <envar>PortalContainerDefinitionDisablePlugin</envar></title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>names</entry>
+
+ <entry>The list of the name of the portal containers to
+ disable.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>To prevent any accesses to a web application corresponding to
+ <envar>PortalContainer</envar> that has been disabled, you need to
+ make sure that the following Http Filter (or a sub class of it) has
+ been added to your web.xml in first position as below:</para>
+
+ <programlisting><filter>
+ <filter-name>PortalContainerFilter</filter-name>
+ <filter-class>org.exoplatform.container.web.PortalContainerFilter</filter-class>
+</filter>
+
+<filter-mapping>
+ <filter-name>PortalContainerFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+</filter-mapping></programlisting>
+
+ <note>
+ <para>It is only possible to disable a portal container when at
+ least one PortalContainerDefinition has been registered.</para>
+ </note>
+ </section>
</section>
</section>
13 years, 10 months
exo-jcr SVN: r2953 - in kernel/branches/2.2.x/exo.kernel.container/src: main/java/org/exoplatform/container/definition and 4 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-08-19 13:11:10 -0400 (Thu, 19 Aug 2010)
New Revision: 2953
Added:
kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerDefinitionDisablePlugin.java
kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/PortalContainerFilter.java
Modified:
kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpServlet.java
kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpSessionListener.java
kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def2.xml
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values.xml
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values2.xml
Log:
EXOJCR-842: commit patch (implementation part)
Modified: kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/PortalContainer.java 2010-08-19 17:11:10 UTC (rev 2953)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.container;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.RootContainer.PortalContainerInitTask;
import org.exoplatform.container.definition.PortalContainerConfig;
import org.exoplatform.container.jmx.MX4JComponentAdapterFactory;
@@ -378,6 +379,21 @@
}
/**
+ * @see the method isPortalContainerNameDisabled of {@link PortalContainerConfig}
+ */
+ public static boolean isPortalContainerNameDisabled(String name)
+ {
+ if (CONFIG == null)
+ {
+ return false;
+ }
+ else
+ {
+ return CONFIG.isPortalContainerNameDisabled(name);
+ }
+ }
+
+ /**
* Add an init-task to all the portal container instances related to the given ServletContext
*
* @param context the context from which we extract the context name
@@ -430,8 +446,11 @@
String portalContainerName = CONFIG.getPortalContainerName(context.getServletContextName());
if (portalContainerName == null)
{
- log.warn("The Servlet Context '" + context.getServletContextName() + "' has not been registered"
- + " has a dependency of any PortalContainerDefinitions.");
+ if (PropertyManager.isDevelopping())
+ {
+ log.warn("The Servlet Context '" + context.getServletContextName() + "' has not been registered"
+ + " has a dependency of any PortalContainerDefinitions.");
+ }
return null;
}
RootContainer root = RootContainer.getInstance();
Modified: kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/RootContainer.java 2010-08-19 17:11:10 UTC (rev 2953)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.container;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.configuration.ConfigurationManagerImpl;
import org.exoplatform.container.configuration.MockConfigurationManagerImpl;
@@ -189,12 +190,25 @@
public void registerPortalContainer(ServletContext context)
{
PortalContainerConfig config = getPortalContainerConfig();
- // Ensure that the portal container has been registered
- config.registerPortalContainerName(context.getServletContextName());
if (config.hasDefinition())
{
// The new behavior has been detected thus, the creation will be done at the end asynchronously
- portalContexts.add(new WebAppInitContext(context));
+ if (config.isPortalContainerName(context.getServletContextName()))
+ {
+ // The portal context has been registered has a portal container
+ portalContexts.add(new WebAppInitContext(context));
+ }
+ else
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("We assume that the ServletContext '" + context.getServletContextName()
+ + "' is not a portal since no portal container definition with the same name has been"
+ + " registered to the component PortalContainerConfig. The related portal container"
+ + " will be declared as disabled.");
+ }
+ config.disablePortalContainer(context.getServletContextName());
+ }
// We assume that a ServletContext of a portal container owns configuration files
final PortalContainerPreInitTask task = new PortalContainerPreInitTask()
{
@@ -208,6 +222,8 @@
}
else
{
+ // Ensure that the portal container has been registered
+ config.registerPortalContainerName(context.getServletContextName());
// The old behavior has been detected thus, the creation will be done synchronously
createPortalContainer(context);
}
@@ -244,11 +260,14 @@
PortalContainerConfig config = getPortalContainerConfig();
for (String portalContainerName : initTasks.keySet())
{
- // Unregister name of portal container that doesn't exist
- log.warn("The portal container '" + portalContainerName + "' doesn't not exist or"
- + " it has not yet been registered, please check your PortalContainerDefinitions and "
- + "the loading order.");
- config.unregisterPortalContainerName(portalContainerName);
+ if (config.isPortalContainerName(portalContainerName))
+ {
+ // Unregister name of portal container that doesn't exist
+ log.warn("The portal container '" + portalContainerName + "' doesn't not exist or"
+ + " it has not yet been registered, please check your PortalContainerDefinitions and "
+ + "the loading order.");
+ config.unregisterPortalContainerName(portalContainerName);
+ }
}
// remove all the unneeded tasks
initTasks.clear();
Modified: kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-08-19 17:11:10 UTC (rev 2953)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.container.definition;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.PropertyConfigurator;
import org.exoplatform.container.RootContainer;
@@ -38,9 +39,12 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.servlet.ServletContext;
@@ -105,14 +109,19 @@
private volatile boolean initialized;
/**
- * The list of all the portal containers
+ * The set of all the portal containers
*/
- private List<String> portalContainerNames;
+ private Set<String> portalContainerNames = Collections.unmodifiableSet(new HashSet<String>());
/**
+ * The set of all the portal containers that have been disabled
+ */
+ private Set<String> portalContainerNamesDisabled = Collections.unmodifiableSet(new HashSet<String>());
+
+ /**
* The list of all the web application scopes
*/
- private Map<String, List<String>> scopes;
+ private Map<String, List<String>> scopes = Collections.unmodifiableMap(new HashMap<String, List<String>>());
/**
* The list of all the {@link PortalContainerDefinition} that have been registered
@@ -345,8 +354,70 @@
{
return !definitions.isEmpty();
}
+
+ /**
+ * Disables a portal container if it has not yet been disabled.
+ * @param name the name of the portal container to disable
+ */
+ public synchronized void disablePortalContainer(String name)
+ {
+ if (!portalContainerNamesDisabled.contains(name))
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The portal container '" + name + "' will be disabled");
+ }
+ final Set<String> lPortalContainerNames = new HashSet<String>(portalContainerNamesDisabled.size() + 1);
+ lPortalContainerNames.add(name);
+ lPortalContainerNames.addAll(portalContainerNamesDisabled);
+ this.portalContainerNamesDisabled = Collections.unmodifiableSet(lPortalContainerNames);
+ if (hasDefinition())
+ {
+ // The new behavior is expected
+ // Remove the portal container from the registered portal container list
+ unregisterPortalContainerName(name);
+ }
+ }
+ }
+
+ /**
+ * Remove the given portal container name from all the existing scopes
+ *
+ * @param name the name of the portal container to remove from all the scopes
+ */
+ private void removePortalContainerNameFromScopes(String name)
+ {
+ final Map<String, List<String>> tmpScopes = new HashMap<String, List<String>>(scopes);
+ boolean changed = false;
+ for (String ctx : tmpScopes.keySet())
+ {
+ List<String> portalContainerNames = tmpScopes.get(ctx);
+ if (portalContainerNames.contains(name))
+ {
+ List<String> tmpPortalContainerNames = new ArrayList<String>(portalContainerNames);
+ tmpPortalContainerNames.remove(name);
+ tmpScopes.put(ctx, Collections.unmodifiableList(tmpPortalContainerNames));
+ changed = true;
+ }
+ }
+ if (changed)
+ {
+ this.scopes = Collections.unmodifiableMap(tmpScopes);
+ }
+ }
/**
+ * Indicates if the given name is the name of a portal container that has been registered as disabled
+ * @param name the name to check
+ * @return <code>true</code> if the name is a name of a disabled portal container, <code>false</code>
+ * otherwise.
+ */
+ public boolean isPortalContainerNameDisabled(String name)
+ {
+ return name == null ? false : portalContainerNamesDisabled.contains(name);
+ }
+
+ /**
* Registers a name of a portal container if it has not yet been registered
* @param name the name of the portal container to register
*/
@@ -354,10 +425,10 @@
{
if (!portalContainerNames.contains(name))
{
- final List<String> lPortalContainerNames = new ArrayList<String>(portalContainerNames.size() + 1);
+ final Set<String> lPortalContainerNames = new LinkedHashSet<String>(portalContainerNames.size() + 1);
lPortalContainerNames.add(name);
lPortalContainerNames.addAll(portalContainerNames);
- this.portalContainerNames = Collections.unmodifiableList(lPortalContainerNames);
+ this.portalContainerNames = Collections.unmodifiableSet(lPortalContainerNames);
}
}
@@ -369,9 +440,15 @@
{
if (portalContainerNames.contains(name))
{
- final List<String> lPortalContainerNames = new ArrayList<String>(portalContainerNames);
+ final Set<String> lPortalContainerNames = new LinkedHashSet<String>(portalContainerNames);
lPortalContainerNames.remove(name);
- this.portalContainerNames = Collections.unmodifiableList(lPortalContainerNames);
+ this.portalContainerNames = Collections.unmodifiableSet(lPortalContainerNames);
+ if (hasDefinition())
+ {
+ // The new behavior is expected
+ // Remove the portal container from all the scopes
+ removePortalContainerNameFromScopes(name);
+ }
}
}
@@ -397,7 +474,7 @@
{
throw new IllegalArgumentException("The context name cannot be null");
}
- if (scopes.isEmpty())
+ if (definitions.isEmpty())
{
// we assume that the old behavior is expected
final String portalContainerName =
@@ -435,15 +512,20 @@
// The given context name is a context name of a portal container
return contextName;
}
- else if (scopes.isEmpty())
+ else if (definitions.isEmpty())
{
// we assume that the old behavior is expected
- return defaultDefinition.getName();
+ return defaultDefinition.getName();
}
final List<String> result = scopes.get(contextName);
if (result == null || result.isEmpty())
{
- // This context has not been added as dependency of any portal containers
+ // This context has not been added as dependency of any portal containers
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The context '" + contextName + "' has not been added as " +
+ "dependency of any portal containers");
+ }
return null;
}
return result.get(0);
@@ -457,12 +539,18 @@
public List<String> getDependencies(String portalContainerName)
{
final PortalContainerDefinition definition = definitions.get(portalContainerName);
- List<String> result = null;
if (definition != null)
{
- result = definition.getDependencies();
+ // A definition has been defined
+ List<String> result = definition.getDependencies();
+ return result == null || result.isEmpty() ? defaultDefinition.getDependencies() : result;
}
- return result == null || result.isEmpty() ? defaultDefinition.getDependencies() : result;
+ else if (definitions.isEmpty())
+ {
+ // The old behavior is expected
+ return defaultDefinition.getDependencies();
+ }
+ return null;
}
/**
@@ -542,7 +630,7 @@
if (portalContainerName == null)
{
throw new IllegalArgumentException("The portal container name cannot be null");
- }
+ }
return getPortalContainerNames(contextName).contains(portalContainerName);
}
@@ -584,6 +672,29 @@
}
/**
+ * Allow to disable a set of portal containers
+ * @param plugin the plugin that defines the name of portal containers to disable
+ */
+ public void registerDisablePlugin(PortalContainerDefinitionDisablePlugin plugin)
+ {
+ final Set<String> sPortalContainerNames = plugin.getNames();
+ if (sPortalContainerNames != null && !sPortalContainerNames.isEmpty())
+ {
+ synchronized (this)
+ {
+ if (initialized)
+ {
+ throw new IllegalStateException("The PortalContainerConfig has already been initialized");
+ }
+ for (String name : sPortalContainerNames)
+ {
+ disablePortalContainer(name);
+ }
+ }
+ }
+ }
+
+ /**
* Allow to define a set of changes to apply to the registered {@link PortalContainerDefinition}
* @param plugin the plugin that defines the changes to apply
*/
@@ -975,20 +1086,21 @@
*/
private void initialize(Map<String, PortalContainerDefinition> mDefinitions)
{
- final List<String> lPortalContainerNames = new ArrayList<String>(mDefinitions.size() + 1);
- // Add the default portal container name
- lPortalContainerNames.add(defaultDefinition.getName());
+ final Set<String> lPortalContainerNames = new LinkedHashSet<String>(mDefinitions.size() + 1);
final Map<String, List<String>> mScopes = new HashMap<String, List<String>>();
boolean first = true;
for (Map.Entry<String, PortalContainerDefinition> entry : mDefinitions.entrySet())
{
PortalContainerDefinition definition = entry.getValue();
String name = definition.getName();
- boolean hasChanged = false;
- if (!name.equals(defaultDefinition.getName()))
+ if (isPortalContainerNameDisabled(name))
{
- lPortalContainerNames.add(name);
+ // The portal container has been disabled so the related portal container definition
+ // will be ignored
+ continue;
}
+ boolean hasChanged = false;
+ lPortalContainerNames.add(name);
if (first)
{
first = false;
@@ -1020,8 +1132,10 @@
}
initializeSettings(definition, true);
}
- if (!mDefinitions.containsKey(defaultDefinition.getName()))
+ if (mDefinitions.isEmpty())
{
+ // Add the default portal container name
+ lPortalContainerNames.add(defaultDefinition.getName());
// Apply the changes corresponding to the default definition
applyChanges(defaultDefinition);
initializeSettings(defaultDefinition, false);
@@ -1031,8 +1145,18 @@
// dependencies have been defined
registerDependencies(defaultDefinition, mScopes);
}
+ if (!portalContainerNamesDisabled.isEmpty())
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.warn("No portal container definition has been registered, the old behavior is" +
+ " then expected so you cannot disable any portal container. The list of" +
+ " portal containers to disable will be ignored");
+ }
+ portalContainerNamesDisabled = Collections.unmodifiableSet(new HashSet<String>());
+ }
}
- this.portalContainerNames = Collections.unmodifiableList(lPortalContainerNames);
+ this.portalContainerNames = Collections.unmodifiableSet(lPortalContainerNames);
this.scopes = Collections.unmodifiableMap(mScopes);
// clear the changes
changes.clear();
Added: kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerDefinitionDisablePlugin.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerDefinitionDisablePlugin.java (rev 0)
+++ kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerDefinitionDisablePlugin.java 2010-08-19 17:11:10 UTC (rev 2953)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.container.definition;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValuesParam;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * This class allows you to dynamically disable one or several portal containers.
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 9 juil. 2010
+ */
+public class PortalContainerDefinitionDisablePlugin extends BaseComponentPlugin
+{
+
+ /**
+ * A set of specific portal container names that we want to disable.
+ */
+ private Set<String> names;
+
+ @SuppressWarnings("unchecked")
+ public PortalContainerDefinitionDisablePlugin(InitParams params)
+ {
+ ValuesParam vsp = params.getValuesParam("names");
+ if (vsp != null && !vsp.getValues().isEmpty())
+ {
+ this.names = new HashSet<String>(vsp.getValues());
+ }
+ }
+
+ public Set<String> getNames()
+ {
+ return names;
+ }
+}
Modified: kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpServlet.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpServlet.java 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpServlet.java 2010-08-19 17:11:10 UTC (rev 2953)
@@ -18,10 +18,13 @@
*/
package org.exoplatform.container.web;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.RootContainer;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import java.io.IOException;
@@ -40,6 +43,10 @@
*/
public abstract class AbstractHttpServlet extends HttpServlet
{
+ /**
+ * The logger
+ */
+ private static final Log log = ExoLogger.getLogger("exo.kernel.container.AbstractHttpServlet");
/**
* Serial Version ID.
@@ -102,16 +109,25 @@
ExoContainerContext.setCurrentContainer(container);
hasBeenSet = true;
}
- if (requirePortalEnvironment() && container instanceof PortalContainer)
+ if (requirePortalEnvironment())
{
- if (PortalContainer.getInstanceIfPresent() == null)
+ final String ctxName = config.getServletContext().getServletContextName();
+ if (!PortalContainer.isPortalContainerNameDisabled(ctxName) && container instanceof PortalContainer)
{
- // The portal container has not been set
- PortalContainer.setInstance((PortalContainer)container);
- hasBeenSet = true;
+ if (PortalContainer.getInstanceIfPresent() == null)
+ {
+ // The portal container has not been set
+ PortalContainer.setInstance((PortalContainer)container);
+ hasBeenSet = true;
+ }
+ // Set the full classloader of the portal container
+ Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
}
- // Set the full classloader of the portal container
- Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
+ else
+ {
+ onPortalEnvironmentError(req, res);
+ return;
+ }
}
onService(container, req, res);
}
@@ -168,6 +184,26 @@
}
/**
+ * Allow the sub classed to execute a task when the portal environment could not be set
+ * because no related portal container could be found
+ * @param req the {@link HttpServletRequest}
+ * @param res the {@link HttpServletResponse}
+ */
+ protected void onPortalEnvironmentError(HttpServletRequest req, HttpServletResponse res) throws ServletException,
+ IOException
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The portal environment could not be set for the webapp '"
+ + config.getServletContext().getServletContextName()
+ + "' because this servlet context has not been defined as a "
+ + "dependency of any portal container or it is a disabled portal"
+ + " container, the target URI was " + req.getRequestURI());
+ }
+ res.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ /**
* @return Gives the {@link ExoContainer} that fits best with the current context
*/
protected final ExoContainer getContainer()
Modified: kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpSessionListener.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpSessionListener.java 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/AbstractHttpSessionListener.java 2010-08-19 17:11:10 UTC (rev 2953)
@@ -18,10 +18,13 @@
*/
package org.exoplatform.container.web;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.RootContainer;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
@@ -34,6 +37,10 @@
*/
public abstract class AbstractHttpSessionListener implements HttpSessionListener
{
+ /**
+ * The logger
+ */
+ private static final Log log = ExoLogger.getLogger("exo.kernel.container.AbstractHttpSessionListener");
/**
* @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
@@ -57,16 +64,31 @@
ExoContainerContext.setCurrentContainer(container);
hasBeenSet = true;
}
- if (requirePortalEnvironment() && container instanceof PortalContainer)
+ if (requirePortalEnvironment())
{
- if (PortalContainer.getInstanceIfPresent() == null)
+ final String ctxName = event.getSession().getServletContext().getServletContextName();
+ if (!PortalContainer.isPortalContainerNameDisabled(ctxName) && container instanceof PortalContainer)
{
- // The portal container has not been set
- PortalContainer.setInstance((PortalContainer)container);
- hasBeenSet = true;
+ if (PortalContainer.getInstanceIfPresent() == null)
+ {
+ // The portal container has not been set
+ PortalContainer.setInstance((PortalContainer)container);
+ hasBeenSet = true;
+ }
+ // Set the full classloader of the portal container
+ Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
}
- // Set the full classloader of the portal container
- Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
+ else
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The portal environment could not be set for the webapp '" + ctxName
+ + "' because this servlet context has not been defined as a "
+ + "dependency of any portal container or it is a disabled portal"
+ + " container, the sessionCreated event will be ignored");
+ }
+ return;
+ }
}
onSessionCreated(container, event);
}
@@ -112,16 +134,31 @@
ExoContainerContext.setCurrentContainer(container);
hasBeenSet = true;
}
- if (requirePortalEnvironment() && container instanceof PortalContainer)
+ if (requirePortalEnvironment())
{
- if (PortalContainer.getInstanceIfPresent() == null)
+ final String ctxName = event.getSession().getServletContext().getServletContextName();
+ if (!PortalContainer.isPortalContainerNameDisabled(ctxName) && container instanceof PortalContainer)
{
- // The portal container has not been set
- PortalContainer.setInstance((PortalContainer)container);
- hasBeenSet = true;
+ if (PortalContainer.getInstanceIfPresent() == null)
+ {
+ // The portal container has not been set
+ PortalContainer.setInstance((PortalContainer)container);
+ hasBeenSet = true;
+ }
+ // Set the full classloader of the portal container
+ Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
}
- // Set the full classloader of the portal container
- Thread.currentThread().setContextClassLoader(((PortalContainer)container).getPortalClassLoader());
+ else
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The portal environment could not be set for the webapp '" + ctxName
+ + "' because this servlet context has not been defined as a "
+ + "dependency of any portal container or it is a disabled portal"
+ + " container, the sessionDestroyed event will be ignored");
+ }
+ return;
+ }
}
onSessionDestroyed(container, event);
}
Added: kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/PortalContainerFilter.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/PortalContainerFilter.java (rev 0)
+++ kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/web/PortalContainerFilter.java 2010-08-19 17:11:10 UTC (rev 2953)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.container.web;
+
+import org.exoplatform.commons.utils.PropertyManager;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * This filter will allow to prevent to any accesses to a web application corresponding to a
+ * {@link PortalContainer} that has been disabled.
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 8 juil. 2010
+ */
+public class PortalContainerFilter extends AbstractFilter
+{
+ /**
+ * The logger
+ */
+ private static final Log log = ExoLogger.getLogger("exo.kernel.container.PortalContainerFilter");
+
+ /**
+ * @see javax.servlet.Filter#destroy()
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ if (PortalContainer.isPortalContainerNameDisabled(servletContextName))
+ {
+ // The current portal container has been disabled
+ onPortalContainerDisabled(request, response, chain);
+ return;
+ }
+
+ chain.doFilter(request, response);
+ }
+
+ /**
+ * Allow the sub classed to execute a task when a user try to access to a
+ * web application corresponding to a {@link PortalContainer} that has been disabled.
+ * @param request the {@link ServletRequest}
+ * @param response the {@link ServletResponse}
+ * @param response the {@link FilterChain}
+ */
+ protected void onPortalContainerDisabled(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException
+ {
+ if (PropertyManager.isDevelopping())
+ {
+ log.info("The portal container corresponding to the webapp '" + servletContextName
+ + "' is disabled, thus the request is cancelled: target URI was "
+ + ((HttpServletRequest)request).getRequestURI());
+ }
+ ((HttpServletResponse)response).sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+}
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java 2010-08-19 17:11:10 UTC (rev 2953)
@@ -43,7 +43,7 @@
assertEquals("myRest", portal.getRestContextName());
assertEquals("my-exo-domain", portal.getRealmName());
- assertTrue(PortalContainer.isPortalContainerName("myPortal"));
+ assertFalse(PortalContainer.isPortalContainerName("myPortal"));
assertTrue(PortalContainer.isPortalContainerName("portal"));
assertFalse(PortalContainer.isPortalContainerName("foo"));
@@ -73,7 +73,7 @@
assertEquals("myRest", PortalContainer.getRestContextName("foo"));
assertEquals("my-exo-domain", PortalContainer.getRealmName("foo"));
- assertTrue(PortalContainer.isPortalContainerName("myPortal"));
+ assertFalse(PortalContainer.isPortalContainerName("myPortal"));
assertTrue(PortalContainer.isPortalContainerName("portal"));
assertFalse(PortalContainer.isPortalContainerName("foo"));
@@ -84,7 +84,7 @@
assertEquals("myRest", PortalContainer.getCurrentRestContextName());
assertEquals("my-exo-domain", PortalContainer.getCurrentRealmName());
- assertTrue(PortalContainer.isPortalContainerName("myPortal"));
+ assertFalse(PortalContainer.isPortalContainerName("myPortal"));
assertTrue(PortalContainer.isPortalContainerName("portal"));
assertFalse(PortalContainer.isPortalContainerName("foo"));
}
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-08-19 17:11:10 UTC (rev 2953)
@@ -48,6 +48,9 @@
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getDefaultPortalContainer());
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getDefaultRestContext());
assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getDefaultRealmName());
+ assertTrue(config.isPortalContainerName("portal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.hasDefinition());
rootContainer = createRootContainer("portal-container-config-with-default-values.xml");
@@ -56,6 +59,9 @@
assertEquals("myPortal", config.getDefaultPortalContainer());
assertEquals("myRest", config.getDefaultRestContext());
assertEquals("my-exo-domain", config.getDefaultRealmName());
+ assertFalse(config.isPortalContainerName("portal"));
+ assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.hasDefinition());
rootContainer =
@@ -65,6 +71,9 @@
assertEquals("myPortal-dpcdef", config.getDefaultPortalContainer());
assertEquals("myRest-dpcdef", config.getDefaultRestContext());
assertEquals("my-exo-domain-dpcdef", config.getDefaultRealmName());
+ assertFalse(config.isPortalContainerName("portal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.hasDefinition());
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
@@ -205,6 +214,7 @@
assertFalse(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
+
// Needed for backward compatibility
assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
assertFalse(config.isScopeValid("foo", "foo"));
@@ -212,6 +222,16 @@
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
assertFalse(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-no-default-values.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
+ assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
+ assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
+
// Empty with AddDependencies, AddDependenciesBefore and AddDependenciesAfter
String[] profiles =
{"AddDependencies", "AddDependenciesBefore-No-Target", "AddDependenciesBefore-With-Fake-Target",
@@ -234,12 +254,14 @@
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && names.isEmpty());
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
- assertTrue(names != null && names.isEmpty());
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
- assertNull(config.getPortalContainerName("myPortal"));
- assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal"));
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal-pcdef"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("foo"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal-pcdef"));
@@ -256,6 +278,16 @@
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
assertFalse(config.hasDefinition());
+
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-no-default-values2.xml", profile, "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
+ assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
+ assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
}
// Without dependencies
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
@@ -264,16 +296,14 @@
assertNull(config.getDependencies("myPortal"));
assertNull(config.getDependencies("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
- assertEquals("myPortal", config.getPortalContainerName("foo"));
- assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -282,16 +312,24 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
// Needed for backward compatibility
assertFalse(config.isScopeValid("foo", "foo"));
- assertTrue(config.isScopeValid("myPortal", "foo"));
+ assertFalse(config.isScopeValid("myPortal", "foo"));
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
- assertTrue(config.isScopeValid("myPortal", "myPortal"));
+ assertFalse(config.isScopeValid("myPortal", "myPortal"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertTrue(config.hasDefinition());
-
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+
// Without dependencies and with no portal container name
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -319,6 +357,15 @@
assertFalse(config.isPortalContainerName("foo"));
assertTrue(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertEquals("myPortal", config.getPortalContainerName("foo"));
+ assertTrue(config.isPortalContainerName("myPortal"));
+ assertTrue(config.isScopeValid("myPortal", "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals("myPortal", names.get(0));
// Without dependencies and with no rest context name an realm name
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def2.xml");
@@ -327,16 +374,14 @@
assertNull(config.getDependencies("myPortal"));
assertNull(config.getDependencies("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
- assertEquals("myPortal", config.getPortalContainerName("foo"));
- assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -345,30 +390,37 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
// Needed for backward compatibility
assertFalse(config.isScopeValid("foo", "foo"));
- assertTrue(config.isScopeValid("myPortal", "foo"));
+ assertFalse(config.isScopeValid("myPortal", "foo"));
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
- assertTrue(config.isScopeValid("myPortal", "myPortal"));
+ assertFalse(config.isScopeValid("myPortal", "myPortal"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def2.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
// Without dependencies and with default portal container definition
rootContainer =
createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
- assertEquals(2, names.size());
- assertTrue(names.contains("myPortal-dpcdef"));
+ assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && names.isEmpty());
@@ -393,6 +445,17 @@
assertFalse(config.isScopeValid("myPortal", "fooX"));
assertTrue(config.isScopeValid("myPortal-pcdef", "fooX"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+ assertFalse(config.isScopeValid("myPortal-pcdef", "fooX"));
+ names = config.getPortalContainerNames("fooX");
+ assertTrue(names != null && names.isEmpty());
profiles =
new String[]{"AddDependencies", "AddDependenciesBefore-No-Target", "AddDependenciesBefore-With-Fake-Target",
@@ -407,6 +470,10 @@
"with-profiles", profile);
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
+ assertNull(deps);
+ deps = config.getDependencies("myPortal");
+ assertNull(deps);
+ deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 2 && deps.contains("fooX") && deps.contains("foo"));
int index = deps.indexOf("foo");
if (profile.equals("AddDependenciesBefore-No-Target")
@@ -419,25 +486,20 @@
{
assertEquals(1, index);
}
- deps = config.getDependencies("myPortal");
- assertTrue(deps != null && deps.size() == 2 && deps.contains("fooX") && deps.contains("foo"));
- deps = config.getDependencies("myPortal-pcdef");
- assertTrue(deps != null && deps.size() == 2 && deps.contains("fooX") && deps.contains("foo"));
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
- assertEquals(2, names.size());
- assertTrue(names.contains("myPortal-dpcdef"));
+ assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
- assertEquals("myPortal-dpcdef", names.get(0));
+ assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
- assertEquals("myPortal-dpcdef", config.getPortalContainerName("foo"));
+ assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest-dpcdef", config.getRestContextName("foo"));
@@ -453,6 +515,22 @@
assertFalse(config.isScopeValid("myPortal", "fooX"));
assertTrue(config.isScopeValid("myPortal-pcdef", "fooX"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer(
+ "portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml",
+ "with-profiles", profile, "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+ assertFalse(config.isScopeValid("myPortal-pcdef", "fooX"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && names.isEmpty());
+ names = config.getPortalContainerNames("fooX");
+ assertTrue(names != null && names.isEmpty());
}
// With dependencies
@@ -466,13 +544,12 @@
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
- assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -481,7 +558,7 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
@@ -489,6 +566,18 @@
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal"));
assertFalse(config.isScopeValid("myPortal-pcdef", "fooY"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+ assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && names.isEmpty());
for (String profile : profiles)
{
@@ -497,9 +586,9 @@
"with-profiles", profile);
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 4);
int index = deps.indexOf("fooX");
@@ -523,13 +612,12 @@
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
- assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -538,12 +626,25 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml",
+ "with-profiles", profile, "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+ assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && names.isEmpty());
}
// With dependencies and with default portal container definition
@@ -551,27 +652,24 @@
createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal");
- assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
+ assertNull(deps);
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 3);
names = config.getPortalContainerNames("fooX");
- assertTrue(names != null && !names.isEmpty());
- assertEquals(1, names.size());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
- assertTrue(names != null && !names.isEmpty());
- assertEquals("myPortal", names.get(0));
+ assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
- assertEquals("myPortal", config.getPortalContainerName("myPortal"));
+ assertNull(config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
@@ -580,12 +678,24 @@
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
- assertTrue(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.hasDefinition());
+ // Unregister the portal container
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml", "disable-pc");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getPortalContainerName("foo"));
+ assertNull(config.getPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && names.isEmpty());
+ assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && names.isEmpty());
}
public void testSettings()
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def.xml 2010-08-19 17:11:10 UTC (rev 2953)
@@ -57,4 +57,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-empty-portal-def2.xml 2010-08-19 17:11:10 UTC (rev 2953)
@@ -53,4 +53,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal-pcdef</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml 2010-08-19 17:11:10 UTC (rev 2953)
@@ -107,7 +107,7 @@
<values-param>
<name>apply.specific</name>
<value>fake</value>
- <value>myPortal-dpcdef</value>
+ <value>myPortal-pcdef</value>
</values-param>
<object-param profiles="AddDependencies">
<name>change</name>
@@ -219,4 +219,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal-pcdef</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml 2010-08-19 17:11:10 UTC (rev 2953)
@@ -89,4 +89,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal-pcdef</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def.xml 2010-08-19 17:11:10 UTC (rev 2953)
@@ -61,4 +61,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal-pcdef</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def2.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def2.xml 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-def2.xml 2010-08-19 17:11:10 UTC (rev 2953)
@@ -196,4 +196,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>myPortal-pcdef</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values.xml 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values.xml 2010-08-19 17:11:10 UTC (rev 2953)
@@ -56,4 +56,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>portal</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values2.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values2.xml 2010-08-19 14:26:58 UTC (rev 2952)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values2.xml 2010-08-19 17:11:10 UTC (rev 2953)
@@ -103,4 +103,23 @@
</init-params>
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin profiles="disable-pc">
+ <!-- The name of the plugin -->
+ <name>Disable a PortalContainer</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions -->
+ <set-method>registerDisablePlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionDisablePlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionDisablePlugin</type>
+ <init-params>
+ <!-- The list of the name of the portal containers to disable -->
+ <values-param>
+ <name>names</name>
+ <value>portal</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
13 years, 10 months