mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-07 18:25:23 +00:00
12003: ETHREEOH-535: User with Editor role can't edit content 12016: ETHREEOH-864 12018: Fixed NullPointerException during NFS mount. JLAN-51. 12019: Fixed problems in mounting the Alfresco filesystems with NFS. ETHREEOH-913. 12020: Use a default RPC authenticator if not specified in the xml configuration. JLAN-51. 12021: Fixed typo in Portmapper server class name that is loader dynamically. JLAN-52. 12025: MT - fix export/import tenant (ensure tenant admin ops run in tx) 12026: Site service now returns information about the site managers. First part of fix for ETHREEOH-547 12027: Fix for ETHREEOH-664 and ETHREEOH-789. RSS feed issues and authentication errors when trying to retrieve user details via feed service endpoint. 12029: Fix for some wiki page links being highlighted as "missing page" when they're not 12030: ETHREEOH-916 - Unable to "Publish Internally" a newly created blog post 12031: Added logging to thumbnail service to help diagnose ETHREEOH-910 should it occur again 12032: Removed out of date comment on mysql driver 12034: Suppress freemarker.runtime ERROR log messages. These may correspond to exceptions that get handled by Alfresco's retrying transaction handler (e.g. optimistic locking failures) and are only passed on and logged if the retry threshold is exceeded. 12037: Fix for ETHREEOH-901: Radio buttons using a enumeration can not be selected in internet explorer and selecting an option in a drop down menu causes a script error in Internet Explorer 12038: Merged 2.2 to 3.0 12017: Integrated ETWOTWO-926: Inline callouts should be able to reference a web script maintained in the Data Dictionary 12042: Build fix 12043: Fix for ETHREEOH-472 & ETHREEOH-473: File picker restrictions (folder and search) do not work. 12065: New class Alfresco.service.Preferences that makes it easy to add and remove user preferences. 12069: Fix for ETHREEOH-926. Fixed bug webscript matching code when url element containing a dot is followed by further url elements. 12071: Added support to Alfresco.service.Preferences so it can handle hirerchial properties, ie "org.alfresco.share.sites.favourites" 12074: Fix for ETHREEOH-896: XML Form layout is incorrect on Firefox 3 12075: Fix for ETHREEOH-917 - help text for Create Site changed as requested. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12497 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
350 lines
12 KiB
Java
Executable File
350 lines
12 KiB
Java
Executable File
/*
|
|
* 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.tenant;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.PrintStream;
|
|
import java.util.List;
|
|
|
|
import org.alfresco.i18n.I18NUtil;
|
|
import org.alfresco.repo.admin.BaseInterpreter;
|
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
|
/**
|
|
* An interactive console for Tenants.
|
|
*
|
|
*/
|
|
public class TenantInterpreter extends BaseInterpreter
|
|
{
|
|
// Service dependencies
|
|
|
|
private TenantAdminService tenantAdminService;
|
|
|
|
private AuthenticationService authenticationService;
|
|
|
|
public void setTenantAdminService(TenantAdminService tenantAdminService)
|
|
{
|
|
this.tenantAdminService = tenantAdminService;
|
|
}
|
|
|
|
public void setAuthenticationService(AuthenticationService authenticationService)
|
|
{
|
|
this.authenticationService = authenticationService;
|
|
}
|
|
|
|
/**
|
|
* Main entry point.
|
|
*/
|
|
public static void main(String[] args)
|
|
{
|
|
runMain("tenantInterpreter");
|
|
}
|
|
|
|
|
|
protected boolean hasAuthority(String username)
|
|
{
|
|
// must be super "admin" for tenant administrator
|
|
return ((username != null) && (username.equals(BaseInterpreter.DEFAULT_ADMIN)));
|
|
}
|
|
|
|
public String interpretCommand(final String line) throws IOException
|
|
{
|
|
String currentUserName = getCurrentUserName();
|
|
if (hasAuthority(currentUserName))
|
|
{
|
|
try
|
|
{
|
|
AuthenticationUtil.setSystemUserAsCurrentUser();
|
|
RetryingTransactionCallback<String> txnWork = new RetryingTransactionCallback<String>()
|
|
{
|
|
public String execute() throws Exception
|
|
{
|
|
return executeCommand(line);
|
|
}
|
|
};
|
|
return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork);
|
|
}
|
|
finally
|
|
{
|
|
AuthenticationUtil.setCurrentUser(currentUserName);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return("Error: User '"+ currentUserName + "' not authorised");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Execute a single command using the BufferedReader passed in for any data needed.
|
|
*
|
|
* TODO: Use decent parser!
|
|
*
|
|
* @param line The unparsed command
|
|
* @return The textual output of the command.
|
|
*/
|
|
public String executeCommand(String line)
|
|
throws IOException
|
|
{
|
|
String[] command = line.split(" ");
|
|
if (command.length == 0)
|
|
{
|
|
command = new String[1];
|
|
command[0] = line;
|
|
}
|
|
|
|
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
|
PrintStream out = new PrintStream(bout);
|
|
|
|
// repeat last command?
|
|
if (command[0].equals("r"))
|
|
{
|
|
if (lastCommand == null)
|
|
{
|
|
return "No command entered yet.";
|
|
}
|
|
return "repeating command " + lastCommand + "\n\n" + executeCommand(lastCommand);
|
|
}
|
|
|
|
// remember last command
|
|
lastCommand = line;
|
|
|
|
// execute command
|
|
if (command[0].equals("help"))
|
|
{
|
|
String helpFile = I18NUtil.getMessage("tenant_console.help");
|
|
ClassPathResource helpResource = new ClassPathResource(helpFile);
|
|
byte[] helpBytes = new byte[500];
|
|
InputStream helpStream = helpResource.getInputStream();
|
|
try
|
|
{
|
|
int read = helpStream.read(helpBytes);
|
|
while (read != -1)
|
|
{
|
|
bout.write(helpBytes, 0, read);
|
|
read = helpStream.read(helpBytes);
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
helpStream.close();
|
|
}
|
|
}
|
|
|
|
else if (command[0].equals("show"))
|
|
{
|
|
if (command.length < 2)
|
|
{
|
|
return "Syntax Error, try 'help'.\n";
|
|
}
|
|
|
|
else if (command[1].equals("tenants"))
|
|
{
|
|
List<Tenant> tenants = tenantAdminService.getAllTenants();
|
|
|
|
for (Tenant tenant : tenants)
|
|
{
|
|
if (tenant.isEnabled())
|
|
{
|
|
String rootContentStoreDir = tenant.getRootContentStoreDir();
|
|
out.println("Enabled - Tenant: " + tenant.getTenantDomain() + " (" + rootContentStoreDir + ")");
|
|
}
|
|
}
|
|
|
|
out.println("");
|
|
|
|
for (Tenant tenant : tenants)
|
|
{
|
|
if (! tenant.isEnabled())
|
|
{
|
|
String rootContentStoreDir = tenant.getRootContentStoreDir();
|
|
out.println("Disabled - Tenant: " + tenant.getTenantDomain() + " (" + rootContentStoreDir + ")");
|
|
}
|
|
}
|
|
}
|
|
|
|
else if (command[1].equals("tenant"))
|
|
{
|
|
if (command.length != 3)
|
|
{
|
|
return "Syntax Error, try 'help'.\n";
|
|
}
|
|
|
|
String tenantDomain = new String(command[2]).toLowerCase();
|
|
Tenant tenant = tenantAdminService.getTenant(tenantDomain);
|
|
|
|
String rootContentStoreDir = tenant.getRootContentStoreDir();
|
|
if (tenant.isEnabled())
|
|
{
|
|
out.println("Enabled - Tenant: " + tenant.getTenantDomain() + " (" + rootContentStoreDir + ")");
|
|
}
|
|
else
|
|
{
|
|
out.println("Disabled - Tenant: " + tenant.getTenantDomain() + " (" + rootContentStoreDir + ")");
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
return "No such sub-command, try 'help'.\n";
|
|
}
|
|
}
|
|
|
|
else if (command[0].equals("create"))
|
|
{
|
|
if ((command.length != 3) && (command.length != 4))
|
|
{
|
|
return "Syntax Error, try 'help'.\n";
|
|
}
|
|
|
|
String newTenant = new String(command[1]).toLowerCase();
|
|
char[] tenantAdminRawPassword = new String(command[2]).toCharArray();
|
|
String rootContentStoreDir = null;
|
|
if (command.length == 4)
|
|
{
|
|
rootContentStoreDir = new String(command[3]);
|
|
}
|
|
|
|
tenantAdminService.createTenant(newTenant, tenantAdminRawPassword, rootContentStoreDir);
|
|
|
|
out.println("created tenant: " + newTenant);
|
|
}
|
|
|
|
else if (command[0].equals("import"))
|
|
{
|
|
if ((command.length != 3) && (command.length != 4))
|
|
{
|
|
return "Syntax Error, try 'help'.\n";
|
|
}
|
|
|
|
String newTenant = new String(command[1]).toLowerCase();
|
|
File directorySource = new File(command[2]);
|
|
|
|
String rootContentStoreDir = null;
|
|
if (command.length == 4)
|
|
{
|
|
rootContentStoreDir = new String(command[3]);
|
|
}
|
|
|
|
tenantAdminService.importTenant(newTenant, directorySource, rootContentStoreDir);
|
|
|
|
out.println("imported tenant: " + newTenant);
|
|
}
|
|
|
|
else if (command[0].equals("export"))
|
|
{
|
|
if (command.length != 3)
|
|
{
|
|
return "Syntax Error, try 'help'.\n";
|
|
}
|
|
|
|
String tenant = new String(command[1]).toLowerCase();
|
|
File directoryDestination = new File(command[2]);
|
|
|
|
tenantAdminService.exportTenant(tenant, directoryDestination);
|
|
|
|
out.println("exported tenant: " + tenant);
|
|
}
|
|
|
|
// TODO - not fully working yet
|
|
else if (command[0].equals("delete"))
|
|
{
|
|
if (command.length != 2)
|
|
{
|
|
return "Syntax Error, try 'help'.\n";
|
|
}
|
|
|
|
String tenantDomain = new String(command[1]).toLowerCase();
|
|
|
|
tenantAdminService.deleteTenant(tenantDomain);
|
|
out.println("Deleted tenant: " + tenantDomain);
|
|
}
|
|
|
|
else if (command[0].equals("enable"))
|
|
{
|
|
if (command.length != 2)
|
|
{
|
|
return "Syntax Error, try 'help'.\n";
|
|
}
|
|
|
|
String tenantDomain = new String(command[1]).toLowerCase();
|
|
|
|
tenantAdminService.enableTenant(tenantDomain);
|
|
out.println("Enabled tenant: " + tenantDomain);
|
|
}
|
|
|
|
else if (command[0].equals("disable"))
|
|
{
|
|
if (command.length != 2)
|
|
{
|
|
return "Syntax Error, try 'help'.\n";
|
|
}
|
|
|
|
String tenantDomain = new String(command[1]).toLowerCase();
|
|
|
|
tenantAdminService.disableTenant(tenantDomain);
|
|
out.println("Disabled tenant: " + tenantDomain);
|
|
}
|
|
|
|
else if (command[0].equals("changeAdminPassword"))
|
|
{
|
|
if (command.length != 3)
|
|
{
|
|
return "Syntax Error, try 'help'.\n";
|
|
}
|
|
|
|
String tenantDomain = new String(command[1]).toLowerCase();
|
|
|
|
final String newPassword = new String(command[2]);
|
|
final String tenantAdminUsername = tenantService.getDomainUser(TenantService.ADMIN_BASENAME, tenantDomain);
|
|
|
|
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
|
{
|
|
public Object doWork() throws Exception
|
|
{
|
|
authenticationService.setAuthentication(tenantAdminUsername, newPassword.toCharArray());
|
|
return null;
|
|
}
|
|
}, tenantAdminUsername);
|
|
}
|
|
|
|
else
|
|
{
|
|
return "No such command, try 'help'.\n";
|
|
}
|
|
|
|
out.flush();
|
|
String retVal = new String(bout.toByteArray());
|
|
out.close();
|
|
return retVal;
|
|
}
|
|
} |