Merge branch 'master' into GOOGLEDOCS-430

This commit is contained in:
Cezar.Leahu
2018-04-04 11:50:09 +03:00
714 changed files with 138 additions and 134077 deletions

5
.gitignore vendored
View File

@@ -30,5 +30,6 @@ hs_err_pid*
# Alfresco
alf_data/
helm/alfresco-content-services/charts/*
helm/alfresco-content-services/requirements.lock
helm/alfresco-content-services-community/charts/*
helm/alfresco-content-services-community/requirements.lock
helm/alfresco-content-services-community*.tgz

View File

@@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-content-services-community-full-distribution</artifactId>
<name>Alfresco Content Services Community Full Distribution zip</name>
<artifactId>alfresco-content-services-community-distribution</artifactId>
<name>Alfresco Content Services Community Distribution zip</name>
<packaging>jar</packaging>
<parent>
@@ -12,18 +12,50 @@
</parent>
<dependencies>
<!-- WAR files -->
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-content-services-community-distribution</artifactId>
<artifactId>content-services-community</artifactId>
<version>${project.version}</version>
<type>zip</type>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
<type>war</type>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-repository</artifactId>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-data-model</artifactId>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-server-root</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-mmt</artifactId>
</dependency>
<!-- 3rd party libs -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${dependency.postgresql.version}</version>
</dependency>
<!-- Alfresco Pdf Renderer -->
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-pdf-renderer</artifactId>
<classifier>linux</classifier>
<type>tgz</type>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-pdf-renderer</artifactId>
<classifier>win64</classifier>
<type>tgz</type>
</dependency>
<!-- SOLR Distribution -->
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-solr4-distribution</artifactId>
@@ -35,6 +67,7 @@
</exclusion>
</exclusions>
</dependency>
<!-- SHARE Distribution -->
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-content-services-share-distribution</artifactId>
@@ -49,7 +82,7 @@
</dependencies>
<build>
<finalName>${project.artifactId}-${installer.version.name}</finalName>
<finalName>${project.artifactId}-${project.version}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
@@ -68,11 +101,13 @@
</goals>
<configuration>
<artifactItems>
<!-- Extract keystore from alfresco-repository -->
<artifactItem>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-content-services-community-distribution</artifactId>
<type>zip</type>
<artifactId>alfresco-repository</artifactId>
<includes>alfresco/keystore/**</includes>
</artifactItem>
<artifactItem>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-solr4-distribution</artifactId>
@@ -87,6 +122,43 @@
</artifactItems>
</configuration>
</execution>
<execution>
<id>extract-jlan-dll</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-jlan-embed</artifactId>
<classifier>windll</classifier>
<includes>*.dll</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<!-- Copy ROOT.war -->
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-server-root</artifactId>
<type>war</type>
<outputDirectory>${project.build.outputDirectory}/web-server/webapps</outputDirectory>
<destFileName>ROOT.war</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
@@ -102,7 +174,7 @@
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/full-distribution.xml</descriptor>
<descriptor>src/assembly/distribution.xml</descriptor>
</descriptors>
</configuration>
</execution>

View File

@@ -1,6 +1,8 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>warinstallation</id>
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>distribution</id>
<formats>
<format>zip</format>
</formats>
@@ -29,14 +31,37 @@
<include>*.dll</include>
</includes>
</fileSet>
<!-- Empty endorsed folder -->
<!-- Solr4 Distribution -->
<fileSet>
<directory>src/assembly</directory>
<outputDirectory>web-server/endorsed</outputDirectory>
<directory>${project.build.directory}/dependency/solr4</directory>
<outputDirectory>solr4</outputDirectory>
<excludes>
<exclude>*</exclude>
<exclude>solr4.war</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/dependency/solr4</directory>
<outputDirectory>web-server/webapps</outputDirectory>
<includes>
<include>solr4.war</include>
</includes>
</fileSet>
<!-- Share -->
<fileSet>
<directory>${project.build.directory}/dependency/alfresco-content-services-share-distribution-${alfresco.share.version}</directory>
<outputDirectory/>
<includes>
<include>web-server/**</include>
<include>modules/**</include>
<include>amps/**</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/dependency/alfresco-content-services-share-distribution-${alfresco.share.version}/web-extension-samples</directory>
<outputDirectory>web-server/shared/classes/alfresco/web-extension</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>

View File

@@ -1,56 +0,0 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>distribution</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<!-- Local resources: README, etc. -->
<fileSet>
<directory>target/classes</directory>
<outputDirectory></outputDirectory>
</fileSet>
<!-- Platform Community Distribution -->
<fileSet>
<directory>${project.build.directory}/dependency/alfresco-content-services-community-distribution-${project.version}</directory>
<outputDirectory/>
</fileSet>
<!-- Solr4 Distribution -->
<fileSet>
<directory>${project.build.directory}/dependency/solr4</directory>
<outputDirectory>solr4</outputDirectory>
<excludes>
<exclude>solr4.war</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/dependency/solr4</directory>
<outputDirectory>web-server/webapps</outputDirectory>
<includes>
<include>solr4.war</include>
</includes>
</fileSet>
<!-- Share -->
<fileSet>
<directory>${project.build.directory}/dependency/alfresco-content-services-share-distribution-${alfresco.share.version}</directory>
<outputDirectory/>
<includes>
<include>web-server/**</include>
<include>modules/**</include>
<include>amps/**</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/dependency/alfresco-content-services-share-distribution-${alfresco.share.version}/web-extension-samples</directory>
<outputDirectory>web-server/shared/classes/alfresco/web-extension</outputDirectory>
</fileSet>
</fileSets>
</assembly>

View File

@@ -107,4 +107,4 @@ To apply the ImageMagick License to your work, attach the following boilerplate
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
under the License.

View File

@@ -10,14 +10,14 @@ FROM quay.io/alfresco/alfresco-base-tomcat:8.5.28-java-8-oracle-centos-7-f7b1278
# LibreOffice is from The Document Foundation. See the license at https://www.libreoffice.org/download/license/ or in /libreoffice.txt
ENV ALFRESCO_PDF_RENDERER_LIB_RPM_URL=https://nexus.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/alfresco-pdf-renderer/1.1/alfresco-pdf-renderer-1.1-linux.tgz
ENV PDFIUM_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/zip/src/main/resources/licenses/3rd-party/pdfium.txt
ENV PDFIUM_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/distribution/src/main/resources/licenses/3rd-party/pdfium.txt
ENV LIBREOFFICE_RPM_URL=https://nexus.alfresco.com/nexus/service/local/repositories/thirdparty/content/org/libreoffice/libreoffice-dist/5.4.6/libreoffice-dist-5.4.6-linux.gz
ENV LIBREOFFICE_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/zip/src/main/resources/licenses/3rd-party/libreoffice.txt
ENV LIBREOFFICE_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/distribution/src/main/resources/licenses/3rd-party/libreoffice.txt
ENV IMAGEMAGICK_RPM_URL=https://nexus.alfresco.com/nexus/service/local/repositories/thirdparty/content/org/imagemagick/imagemagick-distribution/7.0.7-27/imagemagick-distribution-7.0.7-27-linux.rpm
ENV IMAGEMAGICK_LIB_RPM_URL=https://nexus.alfresco.com/nexus/service/local/repositories/thirdparty/content/org/imagemagick/imagemagick-distribution/7.0.7-27/imagemagick-distribution-7.0.7-27-libs-linux.rpm
ENV IMAGEMAGICK_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/zip/src/main/resources/licenses/3rd-party/ImageMagick-license.txt
ENV IMAGEMAGICK_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/distribution/src/main/resources/licenses/3rd-party/ImageMagick-license.txt
RUN yum install wget -y && \
\

View File

@@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: alfresco-volume-claim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi

17
pom.xml
View File

@@ -32,7 +32,6 @@
</activation>
<modules>
<module>war</module>
<module>zip</module>
<module>distribution</module>
<module>public-javadoc</module>
<module>docker-alfresco</module>
@@ -64,9 +63,9 @@
<image.tag>latest</image.tag>
<dependency.alfresco-core.version>7.1</dependency.alfresco-core.version>
<dependency.alfresco-data-model.version>8.2</dependency.alfresco-data-model.version>
<dependency.alfresco-repository.version>6.38</dependency.alfresco-repository.version>
<dependency.alfresco-remote-api.version>6.25</dependency.alfresco-remote-api.version>
<dependency.alfresco-data-model.version>8.3</dependency.alfresco-data-model.version>
<dependency.alfresco-repository.version>6.41</dependency.alfresco-repository.version>
<dependency.alfresco-remote-api.version>6.27</dependency.alfresco-remote-api.version>
<dependency.alfresco-hb-data-sender.version>1.0.7</dependency.alfresco-hb-data-sender.version>
<dependency.alfresco-mmt.version>6.0</dependency.alfresco-mmt.version>
@@ -261,16 +260,6 @@
<artifactId>httpclient-cache</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>

View File

@@ -76,12 +76,6 @@
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>

View File

@@ -1,113 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.web.scripts.portlet;
import java.io.IOException;
import javax.portlet.PortletContext;
import javax.portlet.PortletException;
import javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.alfresco.repo.web.scripts.servlet.AuthenticatorServlet;
import org.alfresco.web.app.servlet.AuthenticationStatus;
import org.springframework.extensions.webscripts.Authenticator;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.Description.RequiredAuthentication;
import org.springframework.extensions.webscripts.portlet.PortletAuthenticatorFactory;
/**
* Portlet authenticator which synchronizes with the Alfresco Web Client authentication
*
* @author davidc
* @author dward
*/
public class WebClientPortletAuthenticatorFactory implements PortletAuthenticatorFactory
{
/* (non-Javadoc)
* @see org.alfresco.web.scripts.portlet.PortletAuthenticatorFactory#create(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
public Authenticator create(RenderRequest req, RenderResponse res)
{
return new WebClientPortletAuthenticator(req, res);
}
public class WebClientPortletAuthenticator implements Authenticator
{
// dependencies
private RenderRequest req;
private RenderResponse res;
/**
* Construct
*
* @param req RenderRequest
* @param res RenderResponse
*/
public WebClientPortletAuthenticator(RenderRequest req, RenderResponse res)
{
this.req = req;
this.res = res;
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.Authenticator#authenticate(org.alfresco.web.scripts.Description.RequiredAuthentication, boolean)
*/
public boolean authenticate(RequiredAuthentication required, boolean isGuest)
{
PortletSession session = req.getPortletSession();
req.setAttribute(AuthenticatorServlet.ATTR_REQUIRED_AUTH, required);
req.setAttribute(AuthenticatorServlet.ATTR_IS_GUEST, isGuest);
PortletContext context = session.getPortletContext();
try
{
context.getNamedDispatcher(AuthenticatorServlet.SERVLET_NAME).include(req, res);
}
catch (PortletException e)
{
throw new WebScriptException("Failed to authenticate", e);
}
catch (IOException e)
{
throw new WebScriptException("Failed to authenticate", e);
}
AuthenticationStatus status = (AuthenticationStatus) req.getAttribute(AuthenticatorServlet.ATTR_AUTH_STATUS);
return !(status == null || status == AuthenticationStatus.Failure);
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.Authenticator#emptyCredentials()
*/
public boolean emptyCredentials()
{
// Ticket - based authentication not supported
return true;
}
}
}

View File

@@ -1,85 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.web.scripts.portlet;
import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletSecurityException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.alfresco.web.app.Application;
import org.springframework.extensions.webscripts.portlet.WebScriptPortlet;
/**
* Repository (server-tier) implementation of Web Script Portlet
*
* Informs Web Client Application of Portlet request.
*
* @author davidc
*/
public class WebScriptRepoPortlet extends WebScriptPortlet
{
/* (non-Javadoc)
* @see org.alfresco.web.scripts.portlet.WebScriptPortlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
*/
@Override
public void processAction(ActionRequest req, ActionResponse res) throws PortletException, PortletSecurityException, IOException
{
Application.setInPortalServer(true);
try
{
super.processAction(req, res);
}
finally
{
Application.setInPortalServer(false);
}
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.portlet.WebScriptPortlet#render(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
@Override
public void render(RenderRequest req, RenderResponse res) throws PortletException, PortletSecurityException, IOException
{
Application.setInPortalServer(true);
try
{
super.render(req, res);
}
finally
{
Application.setInPortalServer(false);
}
}
}

View File

@@ -1,88 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.web.scripts.servlet;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.web.app.servlet.AuthenticationHelper;
import org.alfresco.web.app.servlet.AuthenticationStatus;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.webscripts.Description.RequiredAuthentication;
/**
* This servlet serves as a useful 'subroutine' for portlets, which using their request dispatcher, can go 'through the
* looking glass' to this servlet and use the standard Alfresco servlet api-based authentication mechanisms.
*
* @author dward
* @deprecated 5.0 not exposed in web-client web.xml
*/
public class AuthenticatorServlet extends HttpServlet
{
public static final String SERVLET_NAME = "authenticatorServlet";
public static final String ATTR_IS_GUEST = "_alf_isGuest";
public static final String ATTR_REQUIRED_AUTH = "_alf_requiredAuth";
public static final String ATTR_AUTH_STATUS = "_alf_authStatus";
private static final long serialVersionUID = 5657140557243797744L;
private static final Log logger = LogFactory.getLog(AuthenticatorServlet.class);
/*
* (non-Javadoc)
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
@Override
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
ServletContext context = getServletContext();
boolean isGuest = (Boolean) req.getAttribute(ATTR_IS_GUEST);
RequiredAuthentication required = (RequiredAuthentication) req.getAttribute(ATTR_REQUIRED_AUTH);
AuthenticationStatus status;
if (isGuest && RequiredAuthentication.guest == required)
{
if (logger.isDebugEnabled())
logger.debug("Authenticating as Guest");
status = AuthenticationHelper.authenticate(context, req, res, true);
}
else
{
if (logger.isDebugEnabled())
logger.debug("Authenticating session");
status = AuthenticationHelper.authenticate(context, req, res, false, false);
}
req.setAttribute(ATTR_AUTH_STATUS, status);
}
}

View File

@@ -1,200 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.web.scripts.servlet;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.web.app.servlet.AuthenticationHelper;
import org.alfresco.web.app.servlet.AuthenticationStatus;
import org.alfresco.web.app.servlet.BaseServlet;
import org.springframework.extensions.webscripts.Authenticator;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.Description.RequiredAuthentication;
import org.springframework.extensions.webscripts.servlet.ServletAuthenticatorFactory;
import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest;
import org.springframework.extensions.webscripts.servlet.WebScriptServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.ServletContextAware;
/**
* Alfresco Web Client Authentication
*
* NOTE: 5.0 - Explorer client has been removed - as have the JSF bean definitions. This effectively mean this is now just
* a web Session based authenticator - ticket and user wrapper is stored in a Session and the JSESSIONID cookie is returned.
* No user prefs for language etc. are set due to the removal of Explorer beans.
*
* @author davidc
*/
public class WebClientAuthenticatorFactory implements ServletAuthenticatorFactory, ServletContextAware
{
// Logger
private static final Log logger = LogFactory.getLog(WebClientAuthenticator.class);
// dependencies
private ServletContext context;
/* (non-Javadoc)
* @see org.springframework.web.context.ServletContextAware#setServletContext(javax.servlet.ServletContext)
*/
public void setServletContext(ServletContext context)
{
this.context = context;
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.servlet.ServletAuthenticatorFactory#create(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public Authenticator create(WebScriptServletRequest req, WebScriptServletResponse res)
{
return new WebClientAuthenticator(req, res);
}
/**
* Alfresco Web Client Authentication
*
* @author davidc
*/
public class WebClientAuthenticator implements Authenticator
{
// dependencies
private WebScriptServletRequest servletReq;
private WebScriptServletResponse servletRes;
private String ticket;
/**
* Construct
*
* @param req WebScriptServletRequest
* @param res WebScriptServletResponse
*/
public WebClientAuthenticator(WebScriptServletRequest req, WebScriptServletResponse res)
{
this.servletReq = req;
this.servletRes = res;
this.ticket = req.getParameter("ticket");
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.WebScriptServletAuthenticator#authenticate(org.alfresco.web.scripts.WebScriptDescription.RequiredAuthentication, boolean, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public boolean authenticate(RequiredAuthentication required, boolean isGuest)
{
AuthenticationStatus status = null;
try
{
//
// validate credentials
//
HttpServletRequest req = servletReq.getHttpServletRequest();
HttpServletResponse res = servletRes.getHttpServletResponse();
if (logger.isDebugEnabled())
{
logger.debug("Alfresco ticket provided: " + (ticket != null && ticket.length() > 0));
}
if (! emptyCredentials())
{
if (logger.isDebugEnabled())
logger.debug("Authenticating ticket " + ticket);
status = AuthenticationHelper.authenticate(context, req, res, ticket);
}
else
{
if (isGuest && RequiredAuthentication.guest == required)
{
if (logger.isDebugEnabled())
logger.debug("Authenticating as Guest");
status = AuthenticationHelper.authenticate(context, req, res, true);
}
else
{
if (logger.isDebugEnabled())
logger.debug("Authenticating session");
status = AuthenticationHelper.authenticate(context, req, res, false, false);
}
}
//
// if not authorized, redirect to login page
//
if (status == null || status == AuthenticationStatus.Failure)
{
// ALF-13194: The client has asserted itself as guest, but guest authentication is forbidden. Signal
// with a 401 response rather than the login page!
if (isGuest && RequiredAuthentication.guest == required)
{
res.setStatus(401);
}
else
{
// authentication failed - now need to display the login page to the user, if asked to
if (logger.isDebugEnabled())
logger.debug("Redirecting to Alfresco Login");
BaseServlet.redirectToLoginPage(req, res, context);
}
}
}
catch(IOException e)
{
throw new WebScriptException("Failed to authenticate", e);
}
return !(status == null || status == AuthenticationStatus.Failure);
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.Authenticator#emptyCredentials()
*/
public boolean emptyCredentials()
{
return (ticket == null || ticket.length() == 0);
}
@Override
public String toString()
{
return servletReq.toString() + " [ticket=" + ticket + "]";
}
}
}

View File

@@ -1,63 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action;
import java.io.Serializable;
import org.alfresco.web.bean.repository.Node;
/**
* Contract supported by all classes that provide dynamic evaluation for a UI action.
* <p>
* Evaluators are supplied with a Node instance context object.
* <p>
* The evaluator should decide if the action precondition is valid based on the appropriate
* logic and the properties etc. of the Node context and return the result.
*
* @author Kevin Roast
*/
public interface ActionEvaluator extends Serializable
{
/**
* The evaluator should decide if the action precondition is valid based on the appropriate
* logic and the properties etc. of the Node context and return the result.
*
* @param node Node context for the action
*
* @return result of whether the action can proceed.
*/
public boolean evaluate(Node node);
/**
* The evaluator should decide if the action precondition is valid based on the appropriate
* logic and the state etc. of the given object and return the result.
*
* @param obj The object the action is for
*
* @return result of whether the action can proceed.
*/
public boolean evaluate(Object obj);
}

View File

@@ -1,93 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.users.UserPreferencesBean;
import org.alfresco.web.bean.ml.MultilingualUtils;
import org.alfresco.web.bean.repository.Node;
/**
* Evaluates whether the Add Translation (with or without content) action should be visible.
*
* If the node is not already Multilingual, locked, or if a translation exists for each available
* filter language, don't allow the action.
*
* The current user can add a translation to a translation set only if he has enough right to add
* a content to the space where the pivot translation is located in.
*
* @author Yannick Pignot
*/
public class AddTranslationEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -1513219397606505237L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean isNodeMultililingal = node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
boolean isMLContainer = node.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
// the node must be multiligual (translation or ml container)
if(isNodeMultililingal || isMLContainer)
{
FacesContext fc = FacesContext.getCurrentInstance();
// the current user must have enough right to add a content to the space
// where the pivot translation is located in
if(MultilingualUtils.canAddChildrenToPivotSpace(node, fc))
{
MultilingualContentService mlservice =
(MultilingualContentService) FacesHelper.getManagedBean(fc, "MultilingualContentService");
UserPreferencesBean userprefs =
(UserPreferencesBean) FacesHelper.getManagedBean(fc, "UserPreferencesBean");
// the number of translation of this document
int availableTranslationCount = mlservice.getTranslations(node.getNodeRef()).size();
// the total number of available languages for the translation
int contentFilterLanguagesCount = userprefs.getContentFilterLanguages(false).length;
// the number of translation must be < to the total number of available language for the content filter
return (availableTranslationCount < contentFilterLanguagesCount);
}
else
{
return false;
}
}
else
{
return false;
}
}
}

View File

@@ -1,59 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import java.util.Map;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - 'Approve' workflow step for document or space.
*
* @author Kevin Roast
*/
public class ApproveDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 2958297435415449179L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
Map<String,Object> properties = node.getProperties();
Boolean approveMove = (Boolean) properties.get("app:approveMove");
boolean isMove = approveMove == null ? false : approveMove;
boolean canProceed = (properties.get("app:approveStep") != null) && !node.isLocked();
//If this approval is going to result in a move of the node then we check whether the user
//has permission. The delete permission is required in order to move a node (odd, perhaps, but true).
canProceed &= (!isMove || node.hasPermission(PermissionService.DELETE));
return canProceed;
}
}

View File

@@ -1,49 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ContentModel;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - 'Approve' workflow step for document.
*
* @author Kevin Roast
*/
public class ApproveNonDraftDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -277600395385704689L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.getProperties().get("app:approveStep") != null &&
node.isLocked() == false &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false);
}
}

View File

@@ -1,75 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.web.action.ActionEvaluator;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* Base class for all action evaluators.
*
* @author gavinc
*/
public class BaseActionEvaluator implements ActionEvaluator
{
public boolean evaluate(Node node)
{
// Allow the action by default
return true;
}
public boolean evaluate(final Object obj)
{
// if a Node object is passed to this method call
// the explicit evaluate(Node) method otherwise
// allow the action by default.
if (obj instanceof Node)
{
RetryingTransactionCallback<Boolean> txnCallback = new RetryingTransactionCallback<Boolean>()
{
@Override
public Boolean execute() throws Throwable
{
return evaluate((Node)obj);
}
};
TransactionService txnService =
Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getTransactionService();
return txnService.getRetryingTransactionHelper().doInTransaction(txnCallback, true, true);
}
else
{
return true;
}
}
}

View File

@@ -1,50 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Cancel checkout document.
*
* @author Kevin Roast
*/
public class CancelCheckoutDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -9015403093449070254L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null &&
node.hasPermission(PermissionService.CANCEL_CHECK_OUT));
}
}

View File

@@ -1,46 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Cancel editing document.
*/
public class CancelEditingDocEvaluator extends BaseActionEvaluator
{
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) != null &&
node.hasPermission(PermissionService.CANCEL_CHECK_OUT));
}
}

View File

@@ -1,84 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User;
/**
* UI Action Evaluator for cancel workflow action. The action
* is only allowed if the workflow the task belongs to was
* started by the current user.
*
* @author gavinc
*/
public class CancelWorkflowEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 7663087149225546333L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean result = false;
FacesContext context = FacesContext.getCurrentInstance();
// get the task from the node
WorkflowTask task = (WorkflowTask)node.getProperties().get("workflowTask");
if (task != null)
{
NodeRef initiator = task.path.instance.initiator;
if (initiator != null)
{
// find the current username
User user = Application.getCurrentUser(context);
String currentUserName = user.getUserName();
// get the username of the initiator
NodeService nodeSvc = Repository.getServiceRegistry(
context).getNodeService();
String userName = (String)nodeSvc.getProperty(initiator, ContentModel.PROP_USERNAME);
// if the current user started the workflow allow the cancel action
if (currentUserName.equals(userName))
{
result = true;
}
}
}
return result;
}
}

View File

@@ -1,50 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Checkin document.
*
* @author Kevin Roast
*/
public class CheckinDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5398249535631219663L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null &&
node.hasPermission(PermissionService.CHECK_IN));
}
}

View File

@@ -1,59 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Checkout document.
*
* @author Kevin Roast
*/
public class CheckoutDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5510366635124591353L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
DictionaryService dd = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getDictionaryService();
return dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT) &&
((node.hasPermission(PermissionService.CHECK_OUT) &&
(node.isLocked() == false &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false) &&
node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION) == false));
}
}

View File

@@ -1,55 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.web.bean.ml.MultilingualUtils;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Create a forum around a multilingual content node.
*
* @author Yanick Pignot
*/
public class CreateForumMLNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -8621940623410511065L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
// the current user must have enough right to add a content to the space
// where the pivot translation is located in
return MultilingualUtils.canAddChildrenToPivotSpace(node, FacesContext.getCurrentInstance())
&& node.hasAspect(ForumModel.ASPECT_DISCUSSABLE) == false
&& node.isLocked() == false;
}
}

View File

@@ -1,48 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ForumModel;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Create a forum around a node.
*
* @author Kevin Roast
*/
public class CreateForumNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -5132048668011887505L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE) == false &&
node.isLocked() == false);
}
}

View File

@@ -1,78 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.web.bean.ml.MultilingualUtils;
import org.alfresco.web.bean.repository.Node;
/**
* Evaluates whether the Cut Node action should be visible.
*
* Among all available operations over non-multilingual documents (i.e. copy,
* delete, start discussion, etc), there is a missing one: <b>Move</b>.
* Translations cannot be moved due to the exiting link it has with the logical
* document. Despite it is technically achievable, it could be functionally
* troublesome. Spreading translations of the same semantic message among several
* spaces could lead to confusion and problems.
*
* If the node to move is a mlContainer, the user must have enough right to delete each translation
*
* @author Yannick Pignot
*/
public class CutNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5162681242056158214L;
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();
// the node to delete is a ml container, test if the user has enought right on each translation
if(node.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
{
return MultilingualUtils.canMoveEachTranslation(node, fc);
}
boolean eval = true;
// impossible to cut/copy a translation without content.
if (node.getAspects().contains(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
{
eval = false;
}
else
{
eval = !node.getAspects().contains(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
}
return eval;
}
}

View File

@@ -1,84 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.ml.MultilingualUtils;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Delete document.
*
* @author Kevin Roast
*/
public class DeleteDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5742287199692844685L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();
// the node to delete is a ml container, test if the user has enought right on each translation
if(node.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
{
return MultilingualUtils.canDeleteEachTranslation(node, fc);
}
boolean isPivot = false;
// special case for multilingual documents
if (node.getAspects().contains(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
{
MultilingualContentService mlservice =
(MultilingualContentService) FacesHelper.getManagedBean(fc, "MultilingualContentService");
// if the translation is the last translation, user can delete it
if (mlservice.getTranslations(node.getNodeRef()).size() == 1)
{
isPivot = false;
}
// Else if the node is the pivot language, user can't delete it
else if (mlservice.getPivotTranslation(node.getNodeRef()).getId()
.equalsIgnoreCase(node.getNodeRef().getId()))
{
isPivot = true;
}
// finally, the node is not the pivot translation, user can delete it
}
return (node.isLocked() == false &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false &&
isPivot == false);
}
}

View File

@@ -1,72 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import java.util.List;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Discuss a node.
*
* @author Kevin Roast
*/
public class DiscussNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 8754174908349998903L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean result = false;
if (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE))
{
NodeService nodeService = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getNodeService();
List<ChildAssociationRef> children = nodeService.getChildAssocs(
node.getNodeRef(), ForumModel.ASSOC_DISCUSSION,
RegexQNamePattern.MATCH_ALL);
// make sure there is one visible child association for the node
if (children.size() == 1)
{
result = true;
}
}
return result;
}
}

View File

@@ -1,84 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* Evaluates whether the copy action should be visible.
*
* If the node is a discussion don't allow the action.
*
* @author gavinc
*/
public class DiscussionCopyEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -4080878553011296677L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean result = true;
// if the node in question is a forum...
if (node.getType().equals(ForumModel.TYPE_FORUM))
{
// get the association type
FacesContext context = FacesContext.getCurrentInstance();
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(node.getNodeRef());
QName assocType = parentAssoc.getTypeQName();
// only allow the action if the association type is not the discussion assoc
result = (assocType.equals(ForumModel.ASSOC_DISCUSSION) == false);
}
// impossible to copy a translation without content.
if (result && node.getAspects().contains(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
{
result = false;
}
if (!node.hasPermission(PermissionService.READ))
{
result = false;
}
return result;
}
}

View File

@@ -1,71 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* Evaluates whether the cut action should be visible.
*
* If the node is a discussion don't allow the action.
*
* @author gavinc
*/
public class DiscussionCutEvaluator extends CutNodeEvaluator
{
private static final long serialVersionUID = 7260556874788184200L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean result = super.evaluate(node);
// if the node in question is a forum...
if (result && node.getType().equals(ForumModel.TYPE_FORUM))
{
// get the association type
FacesContext context = FacesContext.getCurrentInstance();
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(node.getNodeRef());
QName assocType = parentAssoc.getTypeQName();
// only allow the action if the association type is not the discussion assoc
result = (assocType.equals(ForumModel.ASSOC_DISCUSSION) == false);
}
return result;
}
}

View File

@@ -1,46 +0,0 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Done editing document.
*/
public class DoneEditingDocEvaluator extends BaseActionEvaluator
{
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) != null &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.hasPermission(PermissionService.CHECK_IN));
}
}

Some files were not shown because too many files have changed in this diff Show More