";
-
-
- // dependencies
- private FacebookServletRequest fbReq;
- private WebScriptServletResponse fbRes;
-
- /**
- * Construct
- *
- * @param authenticationService
- * @param req
- * @param res
- */
- public FacebookAuthenticator(FacebookServletRequest req, WebScriptServletResponse res)
- {
- this.fbReq = req;
- this.fbRes = res;
- }
-
- /* (non-Javadoc)
- * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
- */
- public boolean authenticate(RequiredAuthentication required, boolean isGuest)
- {
- String sessionKey = fbReq.getSessionKey();
- String user = fbReq.getUserId();
-
- if (logger.isDebugEnabled())
- {
- logger.debug("fb_sig_session_key = '" + sessionKey + "'");
- logger.debug("fb_sig_user = '" + user + "'");
- }
-
- if ((sessionKey == null || sessionKey.length() == 0) || (user == null || user.length() == 0))
- {
- // session has not been established, redirect to login
-
- String apiKey = fbReq.getApiKey();
- String canvas = (fbReq.isInCanvas()) ? "&canvas" : "";
-
- if (logger.isDebugEnabled())
- {
- logger.debug("fb_sig_api_key = '" + apiKey + "'");
- logger.debug("fb_sig_in_canvas = '" + canvas + "'");
- }
-
- try
- {
- String redirect = String.format(LOGIN_REDIRECT, apiKey, canvas);
-
- if (logger.isDebugEnabled())
- logger.debug("Facebook session not established; redirecting via " + redirect);
-
- fbRes.getWriter().write(redirect);
- }
- catch (IOException e)
- {
- throw new WebScriptException("Redirect to login failed", e);
- }
- return false;
- }
-
- if (logger.isDebugEnabled())
- logger.debug("Facebook session established; authenticating as user " + user);
-
- // session has been established, authenticate as Facebook user id
- AuthenticationUtil.setCurrentUser(user);
- return true;
- }
- }
-
-}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/web/scripts/portlet/JSR168PortletAuthenticatorFactory.java b/source/java/org/alfresco/repo/web/scripts/portlet/JSR168PortletAuthenticatorFactory.java
deleted file mode 100644
index d8ab2b7dc8..0000000000
--- a/source/java/org/alfresco/repo/web/scripts/portlet/JSR168PortletAuthenticatorFactory.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.web.scripts.portlet;
-
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.servlet.http.HttpServletResponse;
-import javax.transaction.UserTransaction;
-
-import org.alfresco.error.AlfrescoRuntimeException;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.service.cmr.security.AuthenticationService;
-import org.alfresco.service.transaction.TransactionService;
-import org.alfresco.web.scripts.Authenticator;
-import org.alfresco.web.scripts.WebScriptException;
-import org.alfresco.web.scripts.Description.RequiredAuthentication;
-import org.alfresco.web.scripts.portlet.PortletAuthenticatorFactory;
-import org.alfresco.web.scripts.portlet.WebScriptPortletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Portlet authenticator
- *
- * @author davidc
- */
-public class JSR168PortletAuthenticatorFactory implements PortletAuthenticatorFactory
-{
- // Logger
- private static final Log logger = LogFactory.getLog(JSR168PortletAuthenticatorFactory.class);
-
- // dependencies
- private AuthenticationService unprotAuthenticationService;
- private TransactionService txnService;
-
- /**
- * @param authenticationService
- */
- public void setUnprotAuthenticationService(AuthenticationService authenticationService)
- {
- this.unprotAuthenticationService = authenticationService;
- }
-
- /**
- * @param transactionService
- */
- public void setTransactionService(TransactionService transactionService)
- {
- this.txnService = transactionService;
- }
-
- /* (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 JSR168PortletAuthenticator(req, res);
- }
-
-
- /**
- * Portlet authenticator
- *
- * @author davidc
- */
- public class JSR168PortletAuthenticator implements Authenticator
- {
- // dependencies
- private RenderRequest req;
-
- /**
- * Construct
- *
- * @param authenticationService
- * @param req
- * @param res
- */
- public JSR168PortletAuthenticator(RenderRequest req, RenderResponse res)
- {
- this.req = req;
- }
-
- /*(non-Javadoc)
- * @see org.alfresco.web.scripts.Authenticator#authenticate(org.alfresco.web.scripts.Description.RequiredAuthentication, boolean)
- */
- public boolean authenticate(RequiredAuthentication required, boolean isGuest)
- {
- // first look for the username key in the session - we add this by hand for some portals
- // when the WebScriptPortletRequest is created
- String portalUser = (String)req.getPortletSession().getAttribute(WebScriptPortletRequest.ALFPORTLETUSERNAME);
- if (portalUser == null)
- {
- portalUser = req.getRemoteUser();
- }
-
- if (logger.isDebugEnabled())
- {
- logger.debug("JSR-168 Remote user: " + portalUser);
- }
-
- if (isGuest || portalUser == null)
- {
- if (logger.isDebugEnabled())
- logger.debug("Authenticating as Guest");
-
- // authenticate as guest
- AuthenticationUtil.setCurrentUser(AuthenticationUtil.getGuestUserName());
- }
- else
- {
- if (logger.isDebugEnabled())
- logger.debug("Authenticating as user " + portalUser);
-
- UserTransaction txn = null;
- try
- {
- txn = txnService.getUserTransaction();
- txn.begin();
-
- if (!unprotAuthenticationService.authenticationExists(portalUser))
- {
- throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "User " + portalUser + " is not a known Alfresco user");
- }
- AuthenticationUtil.setCurrentUser(portalUser);
- }
- catch (Throwable err)
- {
- throw new AlfrescoRuntimeException("Error authenticating user: " + portalUser, err);
- }
- finally
- {
- try
- {
- if (txn != null)
- {
- txn.rollback();
- }
- }
- catch (Exception tex)
- {
- // nothing useful we can do with this
- }
- }
- }
-
- return true;
- }
- }
-
-}
diff --git a/source/java/org/alfresco/repo/web/scripts/portlet/WebClientPortletAuthenticatorFactory.java b/source/java/org/alfresco/repo/web/scripts/portlet/WebClientPortletAuthenticatorFactory.java
deleted file mode 100644
index 528fb6e1af..0000000000
--- a/source/java/org/alfresco/repo/web/scripts/portlet/WebClientPortletAuthenticatorFactory.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.web.scripts.portlet;
-
-import javax.portlet.PortletSession;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.transaction.UserTransaction;
-
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.repo.web.scripts.Repository;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.security.AuthenticationService;
-import org.alfresco.service.transaction.TransactionService;
-import org.alfresco.web.app.servlet.AuthenticationHelper;
-import org.alfresco.web.bean.repository.User;
-import org.alfresco.web.scripts.Authenticator;
-import org.alfresco.web.scripts.Description.RequiredAuthentication;
-import org.alfresco.web.scripts.portlet.PortletAuthenticatorFactory;
-import org.alfresco.web.scripts.portlet.WebScriptPortletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Portlet authenticator which synchronizes with the Alfresco Web Client authentication
- *
- * @author davidc
- */
-public class WebClientPortletAuthenticatorFactory implements PortletAuthenticatorFactory
-{
- // Logger
- private static final Log logger = LogFactory.getLog(WebClientPortletAuthenticatorFactory.class);
-
- // dependencies
- private AuthenticationService authenticationService;
- private TransactionService transactionService;
- private Repository repository;
-
- /**
- * @param authenticationService
- */
- public void setAuthenticationService(AuthenticationService authenticationService)
- {
- this.authenticationService = authenticationService;
- }
-
- /**
- * @param scriptContext
- */
- public void setRepository(Repository repository)
- {
- this.repository = repository;
- }
-
- /**
- * @param transactionService
- */
- public void setTransactionService(TransactionService transactionService)
- {
- this.transactionService = transactionService;
- }
-
- /* (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 authenticationService
- * @param req
- * @param res
- */
- 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();
-
- // first look for the username key in the session - we add this by hand for some portals
- // when the WebScriptPortletRequest is created
- String portalUser = (String)req.getPortletSession().getAttribute(WebScriptPortletRequest.ALFPORTLETUSERNAME);
- if (portalUser == null)
- {
- portalUser = req.getRemoteUser();
- }
-
- if (logger.isDebugEnabled())
- {
- logger.debug("JSR-168 Remote user: " + portalUser);
- }
-
- if (isGuest || portalUser == null)
- {
- if (logger.isDebugEnabled())
- logger.debug("Authenticating as Guest");
-
- // authenticate as guest
- AuthenticationUtil.setCurrentUser(AuthenticationUtil.getGuestUserName());
-
- if (logger.isDebugEnabled())
- logger.debug("Setting Web Client authentication context for guest");
-
- createWebClientUser(session);
- removeSessionInvalidated(session);
- }
- else
- {
- if (logger.isDebugEnabled())
- logger.debug("Authenticating as user " + portalUser);
-
- AuthenticationUtil.setCurrentUser(portalUser);
-
- // determine if Web Client context needs to be updated
- User user = getWebClientUser(session);
- if (user == null || !portalUser.equals(user.getUserName()))
- {
- if (logger.isDebugEnabled())
- logger.debug("Setting Web Client authentication context for user " + portalUser);
-
- createWebClientUser(session);
- removeSessionInvalidated(session);
- }
- }
-
- return true;
- }
-
- /**
- * Helper. Remove Web Client session invalidated flag
- *
- * @param session
- */
- private void removeSessionInvalidated(PortletSession session)
- {
- session.removeAttribute(AuthenticationHelper.SESSION_INVALIDATED, PortletSession.APPLICATION_SCOPE);
- }
-
- /**
- * Helper. Create Web Client session user
- *
- * @param session
- */
- private void createWebClientUser(PortletSession session)
- {
- UserTransaction tx = null;
- try
- {
- // start a txn as this method interacts with public services
- tx = transactionService.getUserTransaction();
- tx.begin();
-
- NodeRef personRef = repository.getPerson();
- User user = new User(authenticationService.getCurrentUserName(), authenticationService.getCurrentTicket(), personRef);
- NodeRef homeRef = repository.getUserHome(personRef);
- if (homeRef != null)
- {
- user.setHomeSpaceId(homeRef.getId());
- }
- session.setAttribute(AuthenticationHelper.AUTHENTICATION_USER, user, PortletSession.APPLICATION_SCOPE);
-
- tx.commit();
- }
- catch (Throwable e)
- {
- try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
- }
- }
-
- /**
- * Helper. Get Web Client session user
- *
- * @param session
- * @return
- */
- private User getWebClientUser(PortletSession session)
- {
- return (User)session.getAttribute(AuthenticationHelper.AUTHENTICATION_USER, PortletSession.APPLICATION_SCOPE);
- }
- }
-
-}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/web/scripts/portlet/WebScriptRepoPortlet.java b/source/java/org/alfresco/repo/web/scripts/portlet/WebScriptRepoPortlet.java
deleted file mode 100644
index d6d9dcca22..0000000000
--- a/source/java/org/alfresco/repo/web/scripts/portlet/WebScriptRepoPortlet.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-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.alfresco.web.scripts.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);
- super.processAction(req, res);
- }
-
- /* (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);
- super.render(req, res);
- }
-
-}
diff --git a/source/java/org/alfresco/repo/web/scripts/servlet/BasicHttpAuthenticatorFactory.java b/source/java/org/alfresco/repo/web/scripts/servlet/BasicHttpAuthenticatorFactory.java
deleted file mode 100644
index 333a69facc..0000000000
--- a/source/java/org/alfresco/repo/web/scripts/servlet/BasicHttpAuthenticatorFactory.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.web.scripts.servlet;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.alfresco.repo.security.authentication.AuthenticationException;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.service.cmr.security.AuthenticationService;
-import org.alfresco.util.Base64;
-import org.alfresco.web.scripts.Authenticator;
-import org.alfresco.web.scripts.WebScriptException;
-import org.alfresco.web.scripts.Description.RequiredAuthentication;
-import org.alfresco.web.scripts.servlet.ServletAuthenticatorFactory;
-import org.alfresco.web.scripts.servlet.WebScriptServletRequest;
-import org.alfresco.web.scripts.servlet.WebScriptServletResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * HTTP Basic Authentication
- *
- * @author davidc
- */
-public class BasicHttpAuthenticatorFactory implements ServletAuthenticatorFactory
-{
- // Logger
- private static Log logger = LogFactory.getLog(BasicHttpAuthenticator.class);
-
- // Component dependencies
- private AuthenticationService authenticationService;
-
-
- /**
- * @param authenticationService
- */
- public void setAuthenticationService(AuthenticationService authenticationService)
- {
- this.authenticationService = authenticationService;
- }
-
- /* (non-Javadoc)
- * @see org.alfresco.web.scripts.servlet.ServletAuthenticatorFactory#create(org.alfresco.web.scripts.servlet.WebScriptServletRequest, org.alfresco.web.scripts.servlet.WebScriptServletResponse)
- */
- public Authenticator create(WebScriptServletRequest req, WebScriptServletResponse res)
- {
- return new BasicHttpAuthenticator(req, res);
- }
-
-
- /**
- * HTTP Basic Authentication
- *
- * @author davidc
- */
- public class BasicHttpAuthenticator implements Authenticator
- {
- // dependencies
- private WebScriptServletRequest servletReq;
- private WebScriptServletResponse servletRes;
-
- /**
- * Construct
- *
- * @param authenticationService
- * @param req
- * @param res
- */
- public BasicHttpAuthenticator(WebScriptServletRequest req, WebScriptServletResponse res)
- {
- this.servletReq = req;
- this.servletRes = res;
- }
-
- /* (non-Javadoc)
- * @see org.alfresco.web.scripts.Authenticator#authenticate(org.alfresco.web.scripts.Description.RequiredAuthentication, boolean)
- */
- public boolean authenticate(RequiredAuthentication required, boolean isGuest)
- {
- boolean authorized = false;
-
- //
- // validate credentials
- //
-
- HttpServletRequest req = servletReq.getHttpServletRequest();
- HttpServletResponse res = servletRes.getHttpServletResponse();
- String authorization = req.getHeader("Authorization");
- String ticket = req.getParameter("alf_ticket");
-
- if (logger.isDebugEnabled())
- {
- logger.debug("HTTP Authorization provided: " + (authorization != null && authorization.length() > 0));
- logger.debug("URL ticket provided: " + (ticket != null && ticket.length() > 0));
- }
-
- // authenticate as guest, if service allows
- if (isGuest && RequiredAuthentication.guest == required)
- {
- if (logger.isDebugEnabled())
- logger.debug("Authenticating as Guest");
-
- authenticationService.authenticateAsGuest();
- authorized = true;
- }
-
- // authenticate as specified by explicit ticket on url
- else if (ticket != null && ticket.length() > 0)
- {
- try
- {
- if (logger.isDebugEnabled())
- logger.debug("Authenticating (URL argument) ticket " + ticket);
-
- // assume a ticket has been passed
- authenticationService.validate(ticket);
- authorized = true;
- }
- catch(AuthenticationException e)
- {
- // failed authentication
- }
- }
-
- // authenticate as specified by HTTP Basic Authentication
- else if (authorization != null && authorization.length() > 0)
- {
- try
- {
- String[] authorizationParts = authorization.split(" ");
- if (!authorizationParts[0].equalsIgnoreCase("basic"))
- {
- throw new WebScriptException("Authorization '" + authorizationParts[0] + "' not supported.");
- }
- String decodedAuthorisation = new String(Base64.decode(authorizationParts[1]));
- String[] parts = decodedAuthorisation.split(":");
-
- if (parts.length == 1)
- {
- if (logger.isDebugEnabled())
- logger.debug("Authenticating (BASIC HTTP) ticket " + parts[0]);
-
- // assume a ticket has been passed
- authenticationService.validate(parts[0]);
- authorized = true;
- }
- else
- {
- if (logger.isDebugEnabled())
- logger.debug("Authenticating (BASIC HTTP) user " + parts[0]);
-
- // assume username and password passed
- if (parts[0].equals(AuthenticationUtil.getGuestUserName()))
- {
- if (required == RequiredAuthentication.guest)
- {
- authenticationService.authenticateAsGuest();
- authorized = true;
- }
- }
- else
- {
- authenticationService.authenticate(parts[0], parts[1].toCharArray());
- authorized = true;
- }
- }
- }
- catch(AuthenticationException e)
- {
- // failed authentication
- }
- }
-
- //
- // request credentials if not authorized
- //
-
- if (!authorized)
- {
- if (logger.isDebugEnabled())
- logger.debug("Requesting authorization credentials");
-
- res.setStatus(401);
- res.setHeader("WWW-Authenticate", "Basic realm=\"Alfresco\"");
- }
- return authorized;
- }
- }
-
-}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/web/scripts/servlet/WebClientAuthenticatorFactory.java b/source/java/org/alfresco/repo/web/scripts/servlet/WebClientAuthenticatorFactory.java
deleted file mode 100644
index a36c46b8c9..0000000000
--- a/source/java/org/alfresco/repo/web/scripts/servlet/WebClientAuthenticatorFactory.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-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.alfresco.web.scripts.Authenticator;
-import org.alfresco.web.scripts.WebScriptException;
-import org.alfresco.web.scripts.Description.RequiredAuthentication;
-import org.alfresco.web.scripts.servlet.ServletAuthenticatorFactory;
-import org.alfresco.web.scripts.servlet.WebScriptServletRequest;
-import org.alfresco.web.scripts.servlet.WebScriptServletResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.web.context.ServletContextAware;
-
-
-/**
- * Alfresco Web Client Authentication
- *
- * @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;
-
- /**
- * Construct
- *
- * @param authenticationService
- * @param req
- * @param res
- */
- public WebClientAuthenticator(WebScriptServletRequest req, WebScriptServletResponse res)
- {
- this.servletReq = req;
- this.servletRes = res;
- }
-
- /* (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();
- String ticket = req.getParameter("ticket");
-
- if (logger.isDebugEnabled())
- {
- logger.debug("Alfresco ticket provided: " + (ticket != null && ticket.length() > 0));
- }
-
- if (ticket != null && ticket.length() > 0)
- {
- 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)
- {
- // 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);
- }
- }
-
-}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/web/scripts/site/TestSiteService.java b/source/java/org/alfresco/repo/web/scripts/site/TestSiteService.java
deleted file mode 100644
index 1957f4b9df..0000000000
--- a/source/java/org/alfresco/repo/web/scripts/site/TestSiteService.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.repo.web.scripts.site;
-
-import org.alfresco.repo.web.scripts.BaseWebScriptTest;
-import org.alfresco.util.GUID;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.springframework.mock.web.MockHttpServletResponse;
-
-/**
- * Unit test to test site Web Script API
- *
- * @author Roy Wetherall
- */
-public class TestSiteService extends BaseWebScriptTest
-{
- private static final String URL_SITES = "/api/sites";
-
- public void testCreateSite() throws Exception
- {
- String shortName = GUID.generate();
-
- // == Create a new site ==
-
- JSONObject site = new JSONObject();
- site.put("sitePreset", "myPreset");
- site.put("shortName", shortName);
- site.put("title", "myTitle");
- site.put("description", "myDescription");
- site.put("isPublic", true);
-
- MockHttpServletResponse response = postRequest(URL_SITES, 200, site.toString(), "application/json");
-
- JSONObject result = new JSONObject(response.getContentAsString());
-
- assertEquals("myPreset", result.get("sitePreset"));
- assertEquals(shortName, result.get("shortName"));
- assertEquals("myTitle", result.get("title"));
- assertEquals("myDescription", result.get("description"));
- assertTrue(result.getBoolean("isPublic"));
-
- // == Create a site with a duplicate shortName ==
-
- response = postRequest(URL_SITES, 500, site.toString(), "application/json");
- result = new JSONObject(response.getContentAsString());
- }
-
- public void testGetSites() throws Exception
- {
- // == Test basic GET with no filters ==
-
- MockHttpServletResponse response = getRequest(URL_SITES, 200);
- JSONArray result = new JSONArray(response.getContentAsString());
-
- // TODO formalise this test once i can be sure that i know what's already in the site store
- // ie: .. i need to clean up after myself in this test
-
- System.out.println(response.getContentAsString());
- }
-
-}
diff --git a/source/java/org/alfresco/web/app/servlet/BaseTemplateContentServlet.java b/source/java/org/alfresco/web/app/servlet/BaseTemplateContentServlet.java
index c0f3965741..a1c245f534 100644
--- a/source/java/org/alfresco/web/app/servlet/BaseTemplateContentServlet.java
+++ b/source/java/org/alfresco/web/app/servlet/BaseTemplateContentServlet.java
@@ -40,6 +40,7 @@ import javax.transaction.UserTransaction;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.permissions.AccessDeniedException;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -50,7 +51,6 @@ import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
-import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
/**
@@ -63,6 +63,7 @@ import org.apache.commons.logging.Log;
* @author Kevin Roast
* @author gavinc
*/
+@SuppressWarnings("serial")
public abstract class BaseTemplateContentServlet extends BaseServlet
{
private static final String MIMETYPE_HTML = "text/html;charset=utf-8";
@@ -339,7 +340,7 @@ public abstract class BaseTemplateContentServlet extends BaseServlet
{
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
- return Utils.getFileTypeImage(getServletContext(), filename, size);
+ return FileTypeImageUtils.getFileTypeImage(getServletContext(), filename, size);
}
};
diff --git a/source/java/org/alfresco/web/bean/BaseDetailsBean.java b/source/java/org/alfresco/web/bean/BaseDetailsBean.java
index ac55396ef8..c8eef663b3 100644
--- a/source/java/org/alfresco/web/bean/BaseDetailsBean.java
+++ b/source/java/org/alfresco/web/bean/BaseDetailsBean.java
@@ -38,6 +38,7 @@ import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.repository.CopyService;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -329,7 +330,7 @@ public abstract class BaseDetailsBean extends BaseDialogBean
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
- return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
+ return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
}
};
diff --git a/source/java/org/alfresco/web/bean/BrowseBean.java b/source/java/org/alfresco/web/bean/BrowseBean.java
index 924e82488e..a74e495c16 100644
--- a/source/java/org/alfresco/web/bean/BrowseBean.java
+++ b/source/java/org/alfresco/web/bean/BrowseBean.java
@@ -45,6 +45,7 @@ import org.alfresco.config.ConfigService;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.SearcherException;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.cmr.lock.LockService;
@@ -1258,7 +1259,7 @@ public class BrowseBean implements IContextListener, Serializable
private static final long serialVersionUID = -2690520488415178029L;
public Object get(Node node) {
- return Utils.getFileTypeImage(node.getName(), true);
+ return FileTypeImageUtils.getFileTypeImage(node.getName(), true);
}
};
@@ -1266,7 +1267,7 @@ public class BrowseBean implements IContextListener, Serializable
private static final long serialVersionUID = 1991254398502584389L;
public Object get(Node node) {
- return Utils.getFileTypeImage(node.getName(), false);
+ return FileTypeImageUtils.getFileTypeImage(node.getName(), false);
}
};
diff --git a/source/java/org/alfresco/web/bean/NavigationBean.java b/source/java/org/alfresco/web/bean/NavigationBean.java
index 626918c6b8..d521ff8ebd 100644
--- a/source/java/org/alfresco/web/bean/NavigationBean.java
+++ b/source/java/org/alfresco/web/bean/NavigationBean.java
@@ -45,6 +45,7 @@ import org.alfresco.jlan.server.filesys.DiskSharedDevice;
import org.alfresco.jlan.server.filesys.FilesystemsConfigSection;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.permissions.AccessDeniedException;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -632,7 +633,7 @@ public class NavigationBean implements Serializable
{
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
- return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
+ return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
}
});
diff --git a/source/java/org/alfresco/web/bean/ajax/NodeInfoBean.java b/source/java/org/alfresco/web/bean/ajax/NodeInfoBean.java
index 9f270aa564..a90b9aeed5 100644
--- a/source/java/org/alfresco/web/bean/ajax/NodeInfoBean.java
+++ b/source/java/org/alfresco/web/bean/ajax/NodeInfoBean.java
@@ -35,13 +35,13 @@ import javax.faces.context.ResponseWriter;
import org.alfresco.repo.template.CropContentMethod;
import org.alfresco.repo.template.TemplateNode;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.web.app.servlet.BaseTemplateContentServlet;
import org.alfresco.web.bean.repository.Repository;
-import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -152,7 +152,7 @@ public class NodeInfoBean implements Serializable
{
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
- return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
+ return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
}
};
diff --git a/source/java/org/alfresco/web/bean/ajax/PickerBean.java b/source/java/org/alfresco/web/bean/ajax/PickerBean.java
index e93e045c4b..7465298839 100644
--- a/source/java/org/alfresco/web/bean/ajax/PickerBean.java
+++ b/source/java/org/alfresco/web/bean/ajax/PickerBean.java
@@ -38,6 +38,7 @@ import javax.transaction.UserTransaction;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
@@ -535,7 +536,7 @@ public class PickerBean implements Serializable
out.writeValue(ID_ID, item.getNodeRef().toString());
String name = (String)item.getProperties().get(ContentModel.PROP_NAME);
out.writeValue(ID_NAME, name);
- String icon = Utils.getFileTypeImage(fc, name, FileTypeImageSize.Small);
+ String icon = FileTypeImageUtils.getFileTypeImage(fc, name, FileTypeImageSize.Small);
out.writeValue(ID_ICON, icon);
out.writeValue(ID_URL, DownloadContentServlet.generateBrowserURL(item.getNodeRef(), name));
out.endObject();
diff --git a/source/java/org/alfresco/web/bean/ajax/TaskInfoBean.java b/source/java/org/alfresco/web/bean/ajax/TaskInfoBean.java
index 6166f66170..e68b24b946 100644
--- a/source/java/org/alfresco/web/bean/ajax/TaskInfoBean.java
+++ b/source/java/org/alfresco/web/bean/ajax/TaskInfoBean.java
@@ -34,13 +34,13 @@ import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.alfresco.repo.template.Workflow;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.web.app.servlet.BaseTemplateContentServlet;
import org.alfresco.web.bean.repository.Repository;
-import org.alfresco.web.ui.common.Utils;
/**
* Bean used by an AJAX control to send information back on the requested workflow task.
@@ -158,7 +158,7 @@ public class TaskInfoBean implements Serializable
{
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
- return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
+ return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
}
};
}
diff --git a/source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java b/source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java
index ee1ff0d0f7..baeca098d2 100644
--- a/source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java
@@ -27,6 +27,7 @@ package org.alfresco.web.bean.coci;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -143,7 +144,7 @@ public class CCCheckoutFileDialog extends CheckinCheckoutDialog
String url = DownloadContentServlet.generateDownloadURL(workingCopyRef, workingCopy.getName());
workingCopy.getProperties().put("url", url);
- workingCopy.getProperties().put("fileType32", Utils.getFileTypeImage(workingCopy.getName(), false));
+ workingCopy.getProperties().put("fileType32", FileTypeImageUtils.getFileTypeImage(workingCopy.getName(), false));
// mark as successful
checkoutSuccessful = true;
diff --git a/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java b/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java
index a12a437f23..b9b43fa177 100644
--- a/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java
@@ -39,6 +39,7 @@ import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.version.VersionModel;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
@@ -283,7 +284,7 @@ public class CheckinCheckoutDialog extends BaseDialogBean
String url = DownloadContentServlet.generateDownloadURL(ref, node.getName());
node.getProperties().put("url", url);
node.getProperties().put("workingCopy", node.hasAspect(ContentModel.ASPECT_WORKING_COPY));
- node.getProperties().put("fileType32", Utils.getFileTypeImage(node.getName(), false));
+ node.getProperties().put("fileType32", FileTypeImageUtils.getFileTypeImage(node.getName(), false));
// remember the document
property.setDocument(node);
diff --git a/source/java/org/alfresco/web/bean/coci/EditOfflineDialog.java b/source/java/org/alfresco/web/bean/coci/EditOfflineDialog.java
index ef72d511c5..e197495cbb 100644
--- a/source/java/org/alfresco/web/bean/coci/EditOfflineDialog.java
+++ b/source/java/org/alfresco/web/bean/coci/EditOfflineDialog.java
@@ -33,6 +33,7 @@ import javax.faces.event.ActionEvent;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet;
@@ -164,7 +165,7 @@ public class EditOfflineDialog extends CheckinCheckoutDialog
workingCopy.getProperties().put("url", url);
workingCopy.getProperties().put("fileType32",
- Utils.getFileTypeImage(workingCopy.getName(), false));
+ FileTypeImageUtils.getFileTypeImage(workingCopy.getName(), false));
// commit the transaction
tx.commit();
diff --git a/source/java/org/alfresco/web/bean/content/VersionedDocumentDetailsDialog.java b/source/java/org/alfresco/web/bean/content/VersionedDocumentDetailsDialog.java
index 70b2b01070..9678bd2667 100644
--- a/source/java/org/alfresco/web/bean/content/VersionedDocumentDetailsDialog.java
+++ b/source/java/org/alfresco/web/bean/content/VersionedDocumentDetailsDialog.java
@@ -40,6 +40,7 @@ import javax.faces.event.ActionEvent;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.version.common.VersionLabelComparator;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
import org.alfresco.service.cmr.ml.EditionService;
import org.alfresco.service.cmr.ml.MultilingualContentService;
@@ -401,7 +402,7 @@ public class VersionedDocumentDetailsDialog implements Serializable
*/
public String getFileType32()
{
- String fileType = Utils.getFileTypeImage(getName(), false);
+ String fileType = FileTypeImageUtils.getFileTypeImage(getName(), false);
return fileType;
}
diff --git a/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java b/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java
index 3369355fa4..2b915bd754 100644
--- a/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java
+++ b/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java
@@ -24,15 +24,13 @@
*/
package org.alfresco.web.bean.preview;
-import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
-import org.alfresco.repo.security.permissions.AccessDeniedException;
-import org.alfresco.service.cmr.dictionary.DictionaryService;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
@@ -42,7 +40,6 @@ import org.alfresco.web.bean.TemplateSupportBean;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
-import org.alfresco.web.ui.common.Utils;
/**
* Backing bean for the Preview Document in Template action page
@@ -116,7 +113,7 @@ public abstract class BasePreviewBean extends BaseDialogBean
{
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
- return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
+ return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
}
};
diff --git a/source/java/org/alfresco/web/bean/trashcan/TrashcanDialog.java b/source/java/org/alfresco/web/bean/trashcan/TrashcanDialog.java
index 478bfd79d5..7931f05448 100644
--- a/source/java/org/alfresco/web/bean/trashcan/TrashcanDialog.java
+++ b/source/java/org/alfresco/web/bean/trashcan/TrashcanDialog.java
@@ -40,6 +40,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.archive.RestoreNodeReport;
import org.alfresco.repo.node.archive.RestoreNodeReport.RestoreStatus;
import org.alfresco.repo.search.impl.lucene.QueryParser;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
@@ -312,7 +313,7 @@ public class TrashcanDialog extends BaseDialogBean implements IContextListener
public Object get(Node node)
{
- return Utils.getFileTypeImage(node.getName(), true);
+ return FileTypeImageUtils.getFileTypeImage(node.getName(), true);
}
};
@@ -335,7 +336,7 @@ public class TrashcanDialog extends BaseDialogBean implements IContextListener
public Object get(Node node)
{
- return Utils.getFileTypeImage(node.getName(), false);
+ return FileTypeImageUtils.getFileTypeImage(node.getName(), false);
}
};
@@ -749,7 +750,7 @@ public class TrashcanDialog extends BaseDialogBean implements IContextListener
}
else
{
- img = Utils.getFileTypeImage(node.getName(), true);
+ img = FileTypeImageUtils.getFileTypeImage(node.getName(), true);
}
buf.append("
");
buf.append("");
diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java
index 7dc22ccc80..6e21797927 100644
--- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java
+++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java
@@ -53,6 +53,7 @@ import org.alfresco.repo.avm.AVMNodeType;
import org.alfresco.repo.avm.actions.AVMRevertStoreAction;
import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
import org.alfresco.repo.domain.PropertyValue;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.sandbox.SandboxConstants;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
@@ -1014,7 +1015,7 @@ public class AVMBrowseBean implements IContextListener
{
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
- return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
+ return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
}
});
@@ -1280,7 +1281,7 @@ public class AVMBrowseBean implements IContextListener
}
else
{
- node.getProperties().put("fileType16", Utils.getFileTypeImage(avmRef.getName(), true));
+ node.getProperties().put("fileType16", FileTypeImageUtils.getFileTypeImage(avmRef.getName(), true));
node.getProperties().put("url", DownloadContentServlet.generateBrowserURL(
AVMNodeConverter.ToNodeRef(-1, avmRef.getPath()), avmRef.getName()));
this.files.add(node);
diff --git a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java
index aec22a30cd..48e04c2449 100644
--- a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java
+++ b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java
@@ -18,7 +18,6 @@
package org.alfresco.web.bean.wcm;
import java.io.File;
-import java.io.Serializable;
import java.text.MessageFormat;
import java.util.List;
@@ -26,6 +25,7 @@ import javax.faces.context.FacesContext;
import javax.transaction.UserTransaction;
import org.alfresco.model.WCMAppModel;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.web.app.AlfrescoNavigationHandler;
@@ -123,7 +123,7 @@ public class AVMEditBean extends BaseDialogBean
*/
public String getFileType32()
{
- return Utils.getFileTypeImage(getAvmNode().getName(), false);
+ return FileTypeImageUtils.getFileTypeImage(getAvmNode().getName(), false);
}
/**
@@ -131,7 +131,7 @@ public class AVMEditBean extends BaseDialogBean
*/
public String getFileType16()
{
- return Utils.getFileTypeImage(getAvmNode().getName(), true);
+ return FileTypeImageUtils.getFileTypeImage(getAvmNode().getName(), true);
}
/**
diff --git a/source/java/org/alfresco/web/bean/wcm/AVMNode.java b/source/java/org/alfresco/web/bean/wcm/AVMNode.java
index ff47272c51..88441f440b 100644
--- a/source/java/org/alfresco/web/bean/wcm/AVMNode.java
+++ b/source/java/org/alfresco/web/bean/wcm/AVMNode.java
@@ -34,6 +34,7 @@ import javax.faces.context.FacesContext;
import org.alfresco.model.WCMModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -45,7 +46,6 @@ import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.NodePropertyResolver;
import org.alfresco.web.config.ClientConfigElement;
-import org.alfresco.web.ui.common.Utils;
/**
* Node class representing an AVM specific Node.
@@ -128,7 +128,7 @@ public class AVMNode extends Node implements Map
}
else
{
- return Utils.getFileTypeImage(node.getName(), true);
+ return FileTypeImageUtils.getFileTypeImage(node.getName(), true);
}
}
};
diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java
index 83863b8afc..df66703e39 100644
--- a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java
+++ b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java
@@ -51,6 +51,7 @@ import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.avm.AVMExistsException;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
@@ -815,7 +816,7 @@ public class CreateWebContentWizard extends CreateContentWizard
item.setValue(name);
item.setLabel((String) this.getNodeService().getProperty(nodeRef, ContentModel.PROP_TITLE));
item.setDescription((String) this.getNodeService().getProperty(nodeRef, ContentModel.PROP_DESCRIPTION));
- item.setImage(Utils.getFileTypeImage(name, false));
+ item.setImage(FileTypeImageUtils.getFileTypeImage(name, false));
result.add(item);
}
return result;
diff --git a/source/java/org/alfresco/web/bean/wcm/EditAvmFileDialog.java b/source/java/org/alfresco/web/bean/wcm/EditAvmFileDialog.java
index b57e13809e..32f64271c4 100644
--- a/source/java/org/alfresco/web/bean/wcm/EditAvmFileDialog.java
+++ b/source/java/org/alfresco/web/bean/wcm/EditAvmFileDialog.java
@@ -29,13 +29,13 @@ import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.avm.AVMNodeConverter;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
-import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -96,7 +96,7 @@ public class EditAvmFileDialog
*/
public String getFileType32()
{
- return Utils.getFileTypeImage(getAvmNode().getName(), false);
+ return FileTypeImageUtils.getFileTypeImage(getAvmNode().getName(), false);
}
/**
diff --git a/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java b/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java
index e8a7bfa6bd..0dd69be433 100644
--- a/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java
+++ b/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java
@@ -38,6 +38,7 @@ import javax.transaction.UserTransaction;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.actions.AVMRevertToVersionAction;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
@@ -150,7 +151,7 @@ public class FileDetailsBean extends AVMDetailsBean
*/
public String getFileType32()
{
- return Utils.getFileTypeImage(getAvmNode().getName(), false);
+ return FileTypeImageUtils.getFileTypeImage(getAvmNode().getName(), false);
}
/**
@@ -183,7 +184,7 @@ public class FileDetailsBean extends AVMDetailsBean
wrapper.put("url", DownloadContentServlet.generateBrowserURL(
AVMNodeConverter.ToNodeRef(path.getFirst(), path.getSecond()), avmNode.getName()));
}
- wrapper.put("fileType16", Utils.getFileTypeImage(avmNode.getName(), true));
+ wrapper.put("fileType16", FileTypeImageUtils.getFileTypeImage(avmNode.getName(), true));
wrappers.add(wrapper);
}
diff --git a/source/java/org/alfresco/web/bean/wcm/FilePickerBean.java b/source/java/org/alfresco/web/bean/wcm/FilePickerBean.java
index 85d43d8527..f8ca8b30cd 100644
--- a/source/java/org/alfresco/web/bean/wcm/FilePickerBean.java
+++ b/source/java/org/alfresco/web/bean/wcm/FilePickerBean.java
@@ -70,7 +70,6 @@ import org.alfresco.web.bean.FileUploadBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.forms.XMLUtil;
-import org.alfresco.web.ui.common.Utils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
@@ -634,7 +633,7 @@ public class FilePickerBean implements Serializable
this.uploads.add(AVMNodeConverter.ToNodeRef(-1, currentPath + "/"
+ filename));
- returnPage = returnPage.replace("${_FILE_TYPE_IMAGE}", Utils
+ returnPage = returnPage.replace("${_FILE_TYPE_IMAGE}", org.alfresco.repo.web.scripts.FileTypeImageUtils
.getFileTypeImage(facesContext, filename, true));
} catch (Exception e)
{
@@ -1042,7 +1041,7 @@ public class FilePickerBean implements Serializable
// TODO (Glen): IS this the right image to set?
// originally from Ariel's code
childNodeElement.setAttribute("image",
- (node.isDirectory() ? "/images/icons/space_small.gif" : Utils
+ (node.isDirectory() ? "/images/icons/space_small.gif" : org.alfresco.repo.web.scripts.FileTypeImageUtils
.getFileTypeImage(facesContext, node.getName(), true)));
boolean selectable = false;
diff --git a/source/java/org/alfresco/web/bean/wcm/RegenerateRenditionsWizard.java b/source/java/org/alfresco/web/bean/wcm/RegenerateRenditionsWizard.java
index bb866a4f94..504ef6e865 100644
--- a/source/java/org/alfresco/web/bean/wcm/RegenerateRenditionsWizard.java
+++ b/source/java/org/alfresco/web/bean/wcm/RegenerateRenditionsWizard.java
@@ -36,6 +36,7 @@ import javax.faces.model.SelectItem;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
@@ -324,7 +325,7 @@ public class RegenerateRenditionsWizard
item.setDescription(MessageFormat.format(bundle.getString("regenerate_renditions_select_renditions_select_item_desc"),
rs.size(),
this.selectedWebProject.getName()));
- item.setImage(Utils.getFileTypeImage(ret.getName(), false));
+ item.setImage(FileTypeImageUtils.getFileTypeImage(ret.getName(), false));
result.add(item);
}
}
diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java
index 59bf47a665..608922ced1 100644
--- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java
+++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java
@@ -49,6 +49,7 @@ import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
@@ -1451,7 +1452,7 @@ public class SubmitDialog extends BaseDialogBean
public String getIcon()
{
return (descriptor.isFile() || descriptor.isDeletedFile()
- ? Utils.getFileTypeImage(descriptor.getName(), true)
+ ? FileTypeImageUtils.getFileTypeImage(descriptor.getName(), true)
: SPACE_ICON);
}
diff --git a/source/java/org/alfresco/web/config/OpenSearchConfigElement.java b/source/java/org/alfresco/web/config/OpenSearchConfigElement.java
deleted file mode 100644
index f1c3b20ddc..0000000000
--- a/source/java/org/alfresco/web/config/OpenSearchConfigElement.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.web.config;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.alfresco.config.ConfigElement;
-import org.alfresco.config.ConfigException;
-import org.alfresco.config.element.ConfigElementAdapter;
-
-
-/**
- * Custom config element that represents the config data for open search
- *
- * @author davidc
- */
-public class OpenSearchConfigElement extends ConfigElementAdapter
-{
- public static final String CONFIG_ELEMENT_ID = "opensearch";
-
- private ProxyConfig proxy;
- private Set engines = new HashSet(8, 10f);
- private Map enginesByProxy = new HashMap();
-
-
- /**
- * Default constructor
- */
- public OpenSearchConfigElement()
- {
- super(CONFIG_ELEMENT_ID);
- }
-
- /**
- * Constructor
- *
- * @param name Name of the element this config element represents
- */
- public OpenSearchConfigElement(String name)
- {
- super(name);
- }
-
- /**
- * @see org.alfresco.config.ConfigElement#getChildren()
- */
- public List getChildren()
- {
- throw new ConfigException("Reading the open search config via the generic interfaces is not supported");
- }
-
- /**
- * @see org.alfresco.config.ConfigElement#combine(org.alfresco.config.ConfigElement)
- */
- public ConfigElement combine(ConfigElement configElement)
- {
- OpenSearchConfigElement newElement = (OpenSearchConfigElement) configElement;
- OpenSearchConfigElement combinedElement = new OpenSearchConfigElement();
-
- // add all the plugins from this element
- for (EngineConfig plugin : this.getEngines())
- {
- combinedElement.addEngine(plugin);
- }
-
- // add all the plugins from the given element
- for (EngineConfig plugin : newElement.getEngines())
- {
- combinedElement.addEngine(plugin);
- }
-
- // set the proxy configuration
- ProxyConfig proxyConfig = this.getProxy();
- if (proxyConfig != null)
- {
- combinedElement.setProxy(proxyConfig);
- }
-
- return combinedElement;
- }
-
- /**
- * Sets the proxy configuration
- *
- * @param proxyConfig
- */
- /*package*/ void setProxy(ProxyConfig proxyConfig)
- {
- this.proxy = proxyConfig;
- }
-
- /**
- * Gets the proxy configuration
- *
- * @return The proxy configuration
- */
- public ProxyConfig getProxy()
- {
- return this.proxy;
- }
-
- /**
- * @return Returns a set of the engines
- */
- public Set getEngines()
- {
- return this.engines;
- }
-
- /**
- * @param proxy name of engine proxy
- * @return associated engine config (or null, if none registered against proxy)
- */
- public EngineConfig getEngine(String proxy)
- {
- return this.enginesByProxy.get(proxy);
- }
-
- /**
- * Adds an engine
- *
- * @param pluginConfig A pre-configured engine config object
- */
- /*package*/ void addEngine(EngineConfig engineConfig)
- {
- this.engines.add(engineConfig);
- String proxy = engineConfig.getProxy();
- if (proxy != null && proxy.length() > 0)
- {
- this.enginesByProxy.put(proxy, engineConfig);
- }
- }
-
-
- /**
- * Inner class representing the configuration of an OpenSearch engine
- *
- * @author davidc
- */
- public static class EngineConfig
- {
- protected String label;
- protected String labelId;
- protected String proxy;
- protected Map urls = new HashMap(8, 10f);
-
-
- /**
- * Construct
- *
- * @param label
- * @param labelId
- */
- public EngineConfig(String label, String labelId)
- {
- if ((label == null || label.length() == 0) && (labelId == null || labelId.length() == 0))
- {
- throw new IllegalArgumentException("'label' or 'label-id' must be specified");
- }
- this.label = label;
- this.labelId = labelId;
- }
-
- /**
- * Construct
- *
- * @param label
- * @param labelId
- * @param proxy
- */
- public EngineConfig(String label, String labelId, String proxy)
- {
- this(label, labelId);
- this.proxy = proxy;
- }
-
- /**
- * @return I18N label id
- */
- public String getLabelId()
- {
- return labelId;
- }
-
- /**
- * @return label
- */
- public String getLabel()
- {
- return label;
- }
-
- /**
- * @return proxy
- */
- public String getProxy()
- {
- return proxy;
- }
-
- /**
- * Gets the urls supported by this engine
- *
- * @return urls
- */
- public Map getUrls()
- {
- return urls;
- }
-
- /**
- * Adds a url
- *
- * @param pluginConfig A pre-configured plugin config object
- */
- /*package*/ void addUrl(String mimetype, String uri)
- {
- this.urls.put(mimetype, uri);
- }
-
- }
-
-
- /**
- * Inner class representing the configuration of the OpenSearch proxy
- *
- * @author davidc
- */
- public static class ProxyConfig
- {
- protected String url;
-
- /**
- * Construct
- *
- * @param url
- */
- public ProxyConfig(String url)
- {
- if (url == null || url.length() == 0)
- {
- throw new IllegalArgumentException("'url' must be specified");
- }
- this.url = url;
- }
-
- /**
- * @return url
- */
- public String getUrl()
- {
- return url;
- }
- }
-
-}
diff --git a/source/java/org/alfresco/web/config/OpenSearchElementReader.java b/source/java/org/alfresco/web/config/OpenSearchElementReader.java
deleted file mode 100644
index 2fd1000a0a..0000000000
--- a/source/java/org/alfresco/web/config/OpenSearchElementReader.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- * As a special exception to the terms and conditions of version 2.0 of
- * the GPL, you may redistribute this Program in connection with Free/Libre
- * and Open Source Software ("FLOSS") applications as described in Alfresco's
- * FLOSS exception. You should have recieved a copy of the text describing
- * the FLOSS exception, and it is also available here:
- * http://www.alfresco.com/legal/licensing"
- */
-package org.alfresco.web.config;
-
-import java.util.Iterator;
-
-import org.alfresco.config.ConfigElement;
-import org.alfresco.config.ConfigException;
-import org.alfresco.config.xml.elementreader.ConfigElementReader;
-import org.alfresco.web.config.OpenSearchConfigElement.EngineConfig;
-import org.alfresco.web.config.OpenSearchConfigElement.ProxyConfig;
-import org.dom4j.Element;
-
-
-/**
- * Custom element reader to parse config for the open search
- *
- * @author davidc
- */
-public class OpenSearchElementReader implements ConfigElementReader
-{
- public static final String ELEMENT_OPENSEARCH = "opensearch";
- public static final String ELEMENT_ENGINES = "engines";
- public static final String ELEMENT_ENGINE = "engine";
- public static final String ELEMENT_URL = "url";
- public static final String ELEMENT_PROXY = "proxy";
- public static final String ATTR_TYPE = "type";
- public static final String ATTR_LABEL = "label";
- public static final String ATTR_LABEL_ID = "label-id";
- public static final String ATTR_PROXY = "proxy";
-
-
- /**
- * @see org.alfresco.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
- */
- @SuppressWarnings("unchecked")
- public ConfigElement parse(Element element)
- {
- OpenSearchConfigElement configElement = null;
-
- if (element != null)
- {
- String elementName = element.getName();
- if (elementName.equals(ELEMENT_OPENSEARCH) == false)
- {
- throw new ConfigException("OpenSearchElementReader can only parse " + ELEMENT_OPENSEARCH
- + "elements, the element passed was '" + elementName + "'");
- }
-
- // go through the registered engines
- configElement = new OpenSearchConfigElement();
- Element pluginsElem = element.element(ELEMENT_ENGINES);
- if (pluginsElem != null)
- {
- Iterator engines = pluginsElem.elementIterator(ELEMENT_ENGINE);
- while(engines.hasNext())
- {
- // construct engine
- Element engineElem = engines.next();
- String label = engineElem.attributeValue(ATTR_LABEL);
- String labelId = engineElem.attributeValue(ATTR_LABEL_ID);
- String proxy = engineElem.attributeValue(ATTR_PROXY);
- EngineConfig engineCfg = new EngineConfig(label, labelId, proxy);
-
- // construct urls for engine
- Iterator urlsConfig = engineElem.elementIterator(ELEMENT_URL);
- while (urlsConfig.hasNext())
- {
- Element urlConfig = urlsConfig.next();
- String type = urlConfig.attributeValue(ATTR_TYPE);
- String url = urlConfig.getTextTrim();
- engineCfg.addUrl(type, url);
- }
-
- // register engine config
- configElement.addEngine(engineCfg);
- }
- }
-
- // extract proxy configuration
- String url = null;
- Element proxyElem = element.element(ELEMENT_PROXY);
- if (proxyElem != null)
- {
- Element urlElem = proxyElem.element(ELEMENT_URL);
- if (urlElem != null)
- {
- url = urlElem.getTextTrim();
- ProxyConfig proxyCfg = new ProxyConfig(url);
- configElement.setProxy(proxyCfg);
- }
- }
- }
-
- return configElement;
- }
-}
diff --git a/source/java/org/alfresco/web/forms/RenditionImpl.java b/source/java/org/alfresco/web/forms/RenditionImpl.java
index e7d60e8e9f..b02d7f0800 100644
--- a/source/java/org/alfresco/web/forms/RenditionImpl.java
+++ b/source/java/org/alfresco/web/forms/RenditionImpl.java
@@ -33,16 +33,15 @@ import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.util.Pair;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.AVMUtil;
-import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xml.sax.SAXException;
@@ -214,7 +213,7 @@ import org.xml.sax.SAXException;
public String getFileTypeImage()
{
- return Utils.getFileTypeImage(this.getName(), false);
+ return FileTypeImageUtils.getFileTypeImage(this.getName(), false);
}
public OutputStream getOutputStream()
diff --git a/source/java/org/alfresco/web/ui/common/Utils.java b/source/java/org/alfresco/web/ui/common/Utils.java
index 3121247755..a3a7266505 100644
--- a/source/java/org/alfresco/web/ui/common/Utils.java
+++ b/source/java/org/alfresco/web/ui/common/Utils.java
@@ -32,7 +32,6 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -49,7 +48,6 @@ import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
-import javax.servlet.ServletContext;
import org.alfresco.config.ConfigElement;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -67,7 +65,6 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
-import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NoTransformerException;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -98,17 +95,6 @@ public final class Utils
private static final String MSG_DATE_PATTERN = "date_pattern";
private static final String MSG_DATE_TIME_PATTERN = "date_time_pattern";
- private static final String IMAGE_PREFIX16 = "/images/filetypes/";
- private static final String IMAGE_PREFIX32 = "/images/filetypes32/";
- private static final String IMAGE_PREFIX64 = "/images/filetypes64/";
- private static final String IMAGE_POSTFIX_GIF = ".gif";
- private static final String IMAGE_POSTFIX_PNG = ".png";
- private static final String DEFAULT_FILE_IMAGE16 = IMAGE_PREFIX16 + "_default" + IMAGE_POSTFIX_GIF;
- private static final String DEFAULT_FILE_IMAGE32 = IMAGE_PREFIX32 + "_default" + IMAGE_POSTFIX_GIF;
- private static final String DEFAULT_FILE_IMAGE64 = IMAGE_PREFIX64 + "_default" + IMAGE_POSTFIX_PNG;
-
- private static final Map s_fileExtensionMap = new HashMap(89, 1.0f);
-
private static final Log logger = LogFactory.getLog(Utils.class);
private static final Set safeTags = new HashSet();
@@ -1326,137 +1312,7 @@ public final class Utils
return parsed;
}
- /**
- * Return the image path to the filetype icon for the specified file name string
- *
- * @param name File name to build filetype icon path for
- * @param small True for the small 16x16 icon or false for the large 32x32
- *
- * @return the image path for the specified node type or the default icon if not found
- */
- public static String getFileTypeImage(String name, boolean small)
- {
- return getFileTypeImage(FacesContext.getCurrentInstance(), null, name,
- (small ? FileTypeImageSize.Small : FileTypeImageSize.Medium));
- }
- /**
- * Return the image path to the filetype icon for the specified file name string
- *
- * @param fc FacesContext
- * @param name File name to build filetype icon path for
- * @param small True for the small 16x16 icon or false for the large 32x32
- *
- * @return the image path for the specified node type or the default icon if not found
- */
- public static String getFileTypeImage(FacesContext fc, String name, boolean small)
- {
- return getFileTypeImage(fc, null, name, (small ? FileTypeImageSize.Small : FileTypeImageSize.Medium));
- }
-
- /**
- * Return the image path to the filetype icon for the specified file name string
- *
- * @param fc FacesContext
- * @param name File name to build filetype icon path for
- * @param size Size of the icon to return
- *
- * @return the image path for the specified node type or the default icon if not found
- */
- public static String getFileTypeImage(FacesContext fc, String name, FileTypeImageSize size)
- {
- return getFileTypeImage(fc, null, name, size);
- }
-
- /**
- * Return the image path to the filetype icon for the specified file name string
- *
- * @param sc ServletContext
- * @param name File name to build filetype icon path for
- * @param small True for the small 16x16 icon or false for the large 32x32
- *
- * @return the image path for the specified node type or the default icon if not found
- */
- public static String getFileTypeImage(ServletContext sc, String name, boolean small)
- {
- return getFileTypeImage(null, sc, name, (small ? FileTypeImageSize.Small : FileTypeImageSize.Medium));
- }
-
- /**
- * Return the image path to the filetype icon for the specified file name string
- *
- * @param sc ServletContext
- * @param name File name to build filetype icon path for
- * @param size Size of the icon to return
- *
- * @return the image path for the specified node type or the default icon if not found
- */
- public static String getFileTypeImage(ServletContext sc, String name, FileTypeImageSize size)
- {
- return getFileTypeImage(null, sc, name, size);
- }
-
- private static String getFileTypeImage(FacesContext fc, ServletContext sc, String name, FileTypeImageSize size)
- {
- String image = null;
- String defaultImage = null;
- switch (size)
- {
- case Small:
- defaultImage = DEFAULT_FILE_IMAGE16; break;
- case Medium:
- defaultImage = DEFAULT_FILE_IMAGE32; break;
- case Large:
- defaultImage = DEFAULT_FILE_IMAGE64; break;
- }
-
- int extIndex = name.lastIndexOf('.');
- if (extIndex != -1 && name.length() > extIndex + 1)
- {
- String ext = name.substring(extIndex + 1).toLowerCase();
- String key = ext + ' ' + size.toString();
-
- // found file extension for appropriate size image
- synchronized (s_fileExtensionMap)
- {
- image = s_fileExtensionMap.get(key);
- if (image == null)
- {
- // not found create for first time
- if (size != FileTypeImageSize.Large)
- {
- image = (size == FileTypeImageSize.Small ? IMAGE_PREFIX16 : IMAGE_PREFIX32) +
- ext + IMAGE_POSTFIX_GIF;
- }
- else
- {
- image = IMAGE_PREFIX64 + ext + IMAGE_POSTFIX_PNG;
- }
-
- // does this image exist on the web-server?
- if ((fc != null && fc.getExternalContext().getResourceAsStream(image) != null) ||
- (sc != null && sc.getResourceAsStream(image) != null))
- {
- // found the image for this extension - save it for later
- s_fileExtensionMap.put(key, image);
- }
- else if ((fc == null) && (sc == null))
- {
- // we have neither FacesContext nor ServerContext so return the default image but don't cache it
- image = defaultImage;
- }
- else
- {
- // not found, save the default image for this extension instead
- s_fileExtensionMap.put(key, defaultImage);
- image = defaultImage;
- }
- }
- }
- }
-
- return (image != null ? image : defaultImage);
- }
/**
* Given a ConfigElement instance retrieve the display label, this could be
diff --git a/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java b/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java
index f7ea217d75..f358e1a216 100644
--- a/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java
+++ b/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java
@@ -27,7 +27,6 @@ package org.alfresco.web.ui.repo.component;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.faces.context.FacesContext;
@@ -37,10 +36,9 @@ import org.alfresco.config.Config;
import org.alfresco.config.ConfigService;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.web.scripts.bean.SearchProxy;
+import org.alfresco.repo.web.scripts.config.OpenSearchConfigElement;
+import org.alfresco.repo.web.scripts.config.OpenSearchConfigElement.EngineConfig;
import org.alfresco.web.app.Application;
-import org.alfresco.web.config.OpenSearchConfigElement;
-import org.alfresco.web.config.OpenSearchConfigElement.EngineConfig;
-import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
import org.springframework.web.jsf.FacesContextUtils;
diff --git a/source/java/org/alfresco/web/ui/repo/component/shelf/UIClipboardShelfItem.java b/source/java/org/alfresco/web/ui/repo/component/shelf/UIClipboardShelfItem.java
index e01203e32b..d45dcbe0df 100644
--- a/source/java/org/alfresco/web/ui/repo/component/shelf/UIClipboardShelfItem.java
+++ b/source/java/org/alfresco/web/ui/repo/component/shelf/UIClipboardShelfItem.java
@@ -40,7 +40,7 @@ import javax.faces.event.ActionEvent;
import javax.faces.event.FacesEvent;
import org.alfresco.model.ContentModel;
-import org.alfresco.repo.avm.AVMNodeConverter;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.Application;
@@ -207,7 +207,7 @@ public class UIClipboardShelfItem extends UIShelfItem
}
else
{
- String image = Utils.getFileTypeImage(item.getName(), true);
+ String image = FileTypeImageUtils.getFileTypeImage(item.getName(), true);
out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
}
diff --git a/source/java/org/alfresco/web/ui/repo/component/shelf/UIShortcutsShelfItem.java b/source/java/org/alfresco/web/ui/repo/component/shelf/UIShortcutsShelfItem.java
index 20aa7204dd..8448e60494 100644
--- a/source/java/org/alfresco/web/ui/repo/component/shelf/UIShortcutsShelfItem.java
+++ b/source/java/org/alfresco/web/ui/repo/component/shelf/UIShortcutsShelfItem.java
@@ -39,6 +39,7 @@ import javax.faces.event.ActionEvent;
import javax.faces.event.FacesEvent;
import org.alfresco.model.ContentModel;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
@@ -204,7 +205,7 @@ public class UIShortcutsShelfItem extends UIShelfItem
}
else if (dd.isSubClass(item.getType(), ContentModel.TYPE_CONTENT))
{
- String image = Utils.getFileTypeImage(item.getName(), true);
+ String image = FileTypeImageUtils.getFileTypeImage(item.getName(), true);
out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
}
diff --git a/source/java/org/alfresco/web/ui/repo/component/template/DefaultModelHelper.java b/source/java/org/alfresco/web/ui/repo/component/template/DefaultModelHelper.java
index 1ab2ec5307..69ff0a436d 100644
--- a/source/java/org/alfresco/web/ui/repo/component/template/DefaultModelHelper.java
+++ b/source/java/org/alfresco/web/ui/repo/component/template/DefaultModelHelper.java
@@ -28,6 +28,7 @@ import java.util.Map;
import javax.faces.context.FacesContext;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -35,7 +36,6 @@ import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User;
-import org.alfresco.web.ui.common.Utils;
/**
* Helper class to generate the default template model.
@@ -106,7 +106,7 @@ public class DefaultModelHelper
{
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
- return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
+ return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
}
};
}
diff --git a/source/java/org/alfresco/web/ui/repo/component/template/UITemplate.java b/source/java/org/alfresco/web/ui/repo/component/template/UITemplate.java
index 4b2715059f..349408b1dc 100644
--- a/source/java/org/alfresco/web/ui/repo/component/template/UITemplate.java
+++ b/source/java/org/alfresco/web/ui/repo/component/template/UITemplate.java
@@ -31,6 +31,7 @@ import java.util.StringTokenizer;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -298,7 +299,7 @@ public class UITemplate extends SelfRenderingComponent
{
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
- return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
+ return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
}
};
}
diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java
index 6d733400be..e2768f8afb 100644
--- a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java
+++ b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java
@@ -46,6 +46,7 @@ import javax.transaction.UserTransaction;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
+import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
@@ -812,7 +813,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
if (node.isFile())
{
out.write(linkPrefix);
- out.write(Utils.buildImageTag(fc, Utils.getFileTypeImage(fc, name, true), ""));
+ out.write(Utils.buildImageTag(fc, FileTypeImageUtils.getFileTypeImage(fc, name, true), ""));
out.write(" | ");
out.write(linkPrefix);
out.write(name);
@@ -872,7 +873,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
out.write(" | ");
if (node.isDeletedFile())
{
- out.write(Utils.buildImageTag(fc, Utils.getFileTypeImage(fc, name, true), ""));
+ out.write(Utils.buildImageTag(fc, FileTypeImageUtils.getFileTypeImage(fc, name, true), ""));
out.write(" | ");
out.write(name + " [" + bundle.getString(MSG_DELETED_ITEM) + "]");
out.write("");
|