All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aoindustries.aoserv.client.SimpleAOClient Maven / Gradle / Ivy

There is a newer version: 1.92.0
Show newest version
/*
 * aoserv-client - Java client for the AOServ platform.
 * Copyright (C) 2001-2013, 2014, 2015, 2016  AO Industries, Inc.
 *     [email protected]
 *     7262 Bull Pen Cir
 *     Mobile, AL 36695
 *
 * This file is part of aoserv-client.
 *
 * aoserv-client is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * aoserv-client is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with aoserv-client.  If not, see .
 */
package com.aoindustries.aoserv.client;

import com.aoindustries.aoserv.client.validator.AccountingCode;
import com.aoindustries.aoserv.client.validator.DomainName;
import com.aoindustries.aoserv.client.validator.Gecos;
import com.aoindustries.aoserv.client.validator.HashedPassword;
import com.aoindustries.aoserv.client.validator.InetAddress;
import com.aoindustries.aoserv.client.validator.MySQLUserId;
import com.aoindustries.aoserv.client.validator.PostgresUserId;
import com.aoindustries.aoserv.client.validator.UserId;
import com.aoindustries.aoserv.client.validator.ValidationException;
import com.aoindustries.io.TerminalWriter;
import com.aoindustries.util.SortedArrayList;
import com.aoindustries.util.StringUtility;
import com.aoindustries.util.WrappedException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.SQLException;
import java.util.List;
import java.util.Locale;

/**
 * SimpleAOClient is a simplified interface into the client
 * code.  Not all information is available, but less knowledge is required
 * to accomplish some common tasks.  All methods are invoked using standard
 * data types.  The underlying implementation changes over time, but
 * this access point does not change as frequently.
 * 

* Most of the AOSH commands resolve to these method calls. * * @see AOSH * @see AOServConnector * * @author AO Industries, Inc. */ final public class SimpleAOClient { final AOServConnector connector; /** * Creates a new AOServClient using the provided * AOServConnector. * * @param connector the AOServConnector that will be * used for communication with the server. * * @see AOServConnector#getConnector() * @see TCPConnector#getTCPConnector * @see SSLConnector#getSSLConnector */ SimpleAOClient(AOServConnector connector) { this.connector=connector; } private Architecture getArchitecture(String architecture) throws IllegalArgumentException, IOException, SQLException { Architecture ar=connector.getArchitectures().get(architecture); if(ar==null) throw new IllegalArgumentException("Unable to find Architecture: "+architecture); return ar; } private AOServer getAOServer(String hostname) throws IllegalArgumentException, IOException, SQLException { try { AOServer ao=DomainName.validate(hostname).isValid() ? connector.getAoServers().get(DomainName.valueOf(hostname)) : null; if(ao==null) throw new IllegalArgumentException("Server is not an AOServer: "+hostname); return ao; } catch(ValidationException e) { // Should not happen since isValid checked first throw new WrappedException(e); } } private Business getBusiness(AccountingCode accounting) throws IllegalArgumentException, IOException, SQLException { Business bu=connector.getBusinesses().get(accounting); if(bu==null) throw new IllegalArgumentException("Unable to find Business: "+accounting); return bu; } private DNSZone getDNSZone(String zone) throws IllegalArgumentException, IOException, SQLException { DNSZone dz=connector.getDnsZones().get(zone); if(dz==null) throw new IllegalArgumentException("Unable to find DNSZone: "+zone); return dz; } private EmailAddress getEmailAddress(String aoServer, DomainName domain, String address) throws IllegalArgumentException, IOException, SQLException { EmailAddress ea=getEmailDomain(aoServer, domain).getEmailAddress(address); if(ea==null) throw new IllegalArgumentException("Unable to find EmailAddress: "+address+'@'+domain+" on "+aoServer); return ea; } private EmailDomain getEmailDomain(String aoServer, DomainName domain) throws IllegalArgumentException, IOException, SQLException { EmailDomain ed=getAOServer(aoServer).getEmailDomain(domain); if(ed==null) throw new IllegalArgumentException("Unable to find EmailDomain: "+domain+" on "+aoServer); return ed; } private EmailList getEmailList(String aoServer, String path) throws IllegalArgumentException, IOException, SQLException { EmailList el=getAOServer(aoServer).getEmailList(path); if(el==null) throw new IllegalArgumentException("Unable to find EmailList: "+path+" on "+aoServer); return el; } private EmailSpamAssassinIntegrationMode getEmailSpamAssassinIntegrationMode(String mode) throws IllegalArgumentException, IOException, SQLException { EmailSpamAssassinIntegrationMode esaim=connector.getEmailSpamAssassinIntegrationModes().get(mode); if(esaim==null) throw new IllegalArgumentException("Unable to find EmailSpamAssassinIntegrationMode: "+mode); return esaim; } private FailoverFileReplication getFailoverFileReplication(String fromServer, String toServer, String path) throws IllegalArgumentException, IOException, SQLException { Server fromSe = getServer(fromServer); BackupPartition bp=getAOServer(toServer).getBackupPartitionForPath(path); if(bp==null) throw new IllegalArgumentException("Unable to find BackupPartition: "+path+" on "+toServer); FailoverFileReplication replication = null; for(FailoverFileReplication ffr : fromSe.getFailoverFileReplications()) { if(ffr.getBackupPartition().equals(bp)) { replication = ffr; break; } } if(replication==null) throw new IllegalArgumentException("Unable to find FailoverFileReplication: From "+fromServer+" to "+toServer+" at "+path); return replication; } private HttpdSharedTomcat getHttpdSharedTomcat(String aoServer, String name) throws IllegalArgumentException, IOException, SQLException { HttpdSharedTomcat hst=getAOServer(aoServer).getHttpdSharedTomcat(name); if(hst==null) throw new IllegalArgumentException("Unable to find HttpdSharedTomcat: "+name+" on "+aoServer); return hst; } private HttpdSite getHttpdSite(String aoServer, String siteName) throws IllegalArgumentException, IOException, SQLException { HttpdSite hs=getAOServer(aoServer).getHttpdSite(siteName); if(hs==null) throw new IllegalArgumentException("Unable to find HttpdSite: "+siteName+" on "+aoServer); return hs; } private IPAddress getIPAddress(String server, String netDevice, InetAddress ipAddress) throws IllegalArgumentException, SQLException, IOException { IPAddress ia=getNetDevice(server, netDevice).getIPAddress(ipAddress); if(ia==null) throw new IllegalArgumentException("Unable to find IPAddress: "+ipAddress+" on "+netDevice+" on "+server); return ia; } private Language getLanguage(String code) throws IllegalArgumentException, IOException, SQLException { Language la = connector.getLanguages().get(code); if(la==null) throw new IllegalArgumentException("Unable to find Language: "+code); return la; } private LinuxAccount getLinuxAccount(String username) throws IllegalArgumentException, IOException, SQLException { LinuxAccount la=getUsername(username).getLinuxAccount(); if(la==null) throw new IllegalArgumentException("Unable to find LinuxAccount: "+username); return la; } private LinuxGroup getLinuxGroup(String name) throws IllegalArgumentException, IOException, SQLException { LinuxGroup lg=connector.getLinuxGroups().get(name); if(lg==null) throw new IllegalArgumentException("Unable to find LinuxGroup: "+name); return lg; } private LinuxServerAccount getLinuxServerAccount(String aoServer, String username) throws IllegalArgumentException, IOException, SQLException { LinuxServerAccount lsa=getAOServer(aoServer).getLinuxServerAccount(username); if(lsa==null) throw new IllegalArgumentException("Unable to find LinuxServerAccount: "+username+" on "+aoServer); return lsa; } private LinuxServerGroup getLinuxServerGroup(String server, String name) throws IllegalArgumentException, IOException, SQLException { LinuxServerGroup lsg=getAOServer(server).getLinuxServerGroup(name); if(lsg==null) throw new IllegalArgumentException("Unable to find LinuxServerGroup: "+name+" on "+server); return lsg; } private MySQLServer getMySQLServer(String aoServer, String name) throws IllegalArgumentException, IOException, SQLException { MySQLServer ms=getAOServer(aoServer).getMySQLServer(name); if(ms==null) throw new IllegalArgumentException("Unable to find MySQLServer: "+name+" on "+aoServer); return ms; } private MySQLDatabase getMySQLDatabase(String aoServer, String mysqlServer, String name) throws IllegalArgumentException, IOException, SQLException { MySQLServer ms=getMySQLServer(aoServer, mysqlServer); MySQLDatabase md=ms.getMySQLDatabase(name); if(md==null) throw new IllegalArgumentException("Unable to find MySQLDatabase: "+name+" on "+mysqlServer+" on "+aoServer); return md; } private MySQLServerUser getMySQLServerUser(String aoServer, String mysqlServer, String username) throws IllegalArgumentException, IOException, SQLException { MySQLServerUser msu=getMySQLServer(aoServer, mysqlServer).getMySQLServerUser(username); if(msu==null) throw new IllegalArgumentException("Unable to find MySQLServerUser: "+username+" on "+aoServer); return msu; } private MySQLUser getMySQLUser(String username) throws IllegalArgumentException, IOException, SQLException { MySQLUser mu=getUsername(username).getMySQLUser(); if(mu==null) throw new IllegalArgumentException("Unable to find MySQLUser: "+username); return mu; } private NetBind getNetBind(int pkey) throws IllegalArgumentException, IOException, SQLException { NetBind nb=connector.getNetBinds().get(pkey); if(nb==null) throw new IllegalArgumentException("Unable to find NetBind: "+pkey); return nb; } private NetDevice getNetDevice(String server, String netDevice) throws IllegalArgumentException, SQLException, IOException { NetDevice nd=getServer(server).getNetDevice(netDevice); if(nd==null) throw new IllegalArgumentException("Unable to find NetDevice: "+netDevice+" on "+server); return nd; } private OperatingSystem getOperatingSystem(String name) throws IllegalArgumentException, IOException, SQLException { OperatingSystem os=connector.getOperatingSystems().get(name); if(os==null) throw new IllegalArgumentException("Unable to find OperatingSystem: "+name); return os; } private OperatingSystemVersion getOperatingSystemVersion(String name, String version, Architecture architecture) throws IllegalArgumentException, IOException, SQLException { OperatingSystemVersion ov=getOperatingSystem(name).getOperatingSystemVersion(connector, version, architecture); if(ov==null) throw new IllegalArgumentException("Unable to find OperatingSystemVersion: "+name+" version "+version+" for architecture of "+architecture); return ov; } private PackageDefinition getPackageDefinition(int packageDefinition) throws IllegalArgumentException, IOException, SQLException { PackageDefinition pd=connector.getPackageDefinitions().get(packageDefinition); if(pd==null) throw new IllegalArgumentException("Unable to find PackageDefinition: "+packageDefinition); return pd; } private Package getPackage(String name) throws IllegalArgumentException, IOException, SQLException { Package pk=connector.getPackages().get(name); if(pk==null) throw new IllegalArgumentException("Unable to find Package: "+name); return pk; } private PostgresDatabase getPostgresDatabase(String aoServer, String postgres_server, String name) throws IllegalArgumentException, IOException, SQLException { PostgresServer ps=getPostgresServer(aoServer, postgres_server); PostgresDatabase pd=ps.getPostgresDatabase(name); if(pd==null) throw new IllegalArgumentException("Unable to find PostgresDatabase: "+name+" on "+postgres_server+" on "+aoServer); return pd; } private PostgresServer getPostgresServer(String aoServer, String name) throws IllegalArgumentException, IOException, SQLException { PostgresServer ps=getAOServer(aoServer).getPostgresServer(name); if(ps==null) throw new IllegalArgumentException("Unable to find PostgresServer: "+name+" on "+aoServer); return ps; } private PostgresServerUser getPostgresServerUser(String aoServer, String postgres_server, String username) throws IllegalArgumentException, IOException, SQLException { PostgresServerUser psu=getPostgresServer(aoServer, postgres_server).getPostgresServerUser(username); if(psu==null) throw new IllegalArgumentException("Unable to find PostgresServerUser: "+username+" on "+postgres_server+" on "+aoServer); return psu; } private PostgresUser getPostgresUser(String username) throws IllegalArgumentException, IOException, SQLException { PostgresUser pu=getUsername(username).getPostgresUser(); if(pu==null) throw new IllegalArgumentException("Unable to find PostgresUser: "+username); return pu; } private Server getServer(String server) throws IllegalArgumentException, SQLException, IOException { Server se=connector.getServers().get(server); if(se==null) throw new IllegalArgumentException("Unable to find Server: "+server); return se; } private ServerFarm getServerFarm(String name) throws IllegalArgumentException, SQLException, IOException { ServerFarm sf=connector.getServerFarms().get(name); if(sf==null) throw new IllegalArgumentException("Unable to find ServerFarm: "+name); return sf; } /** * Gets the ticket category in "/ path" form. */ private TicketCategory getTicketCategory(String path) throws IllegalArgumentException, IOException, SQLException { TicketCategory tc = null; for(String name : StringUtility.splitString(path, '/')) { TicketCategory newTc = connector.getTicketCategories().getTicketCategory(tc, name); if(newTc==null) { if(tc==null) throw new IllegalArgumentException("Unable to find top-level TicketCategory: "+name); else throw new IllegalArgumentException("Unable to TicketCategory: "+name+" in "+tc); } tc = newTc; } if(tc==null) throw new IllegalArgumentException("Unable to find TicketCategory: "+path); return tc; } private TicketPriority getTicketPriority(String priority) throws IllegalArgumentException, IOException, SQLException { TicketPriority tp = connector.getTicketPriorities().get(priority); if(tp==null) throw new IllegalArgumentException("Unable to find TicketPriority: "+priority); return tp; } private TicketType getTicketType(String type) throws IllegalArgumentException, IOException, SQLException { TicketType tt = connector.getTicketTypes().get(type); if(tt==null) throw new IllegalArgumentException("Unable to find TicketType: "+type); return tt; } private Username getUsername(String username) throws IllegalArgumentException, IOException, SQLException { Username un=connector.getUsernames().get(username); if(un==null) throw new IllegalArgumentException("Unable to find Username: "+username); return un; } private VirtualServer getVirtualServer(String virtualServer) throws IllegalArgumentException, SQLException, IOException { Server se = getServer(virtualServer); VirtualServer vs = se.getVirtualServer(); if(vs==null) throw new IllegalArgumentException("Unable to find VirtualServer: "+virtualServer); return vs; } private VirtualDisk getVirtualDisk(String virtualServer, String device) throws IllegalArgumentException, SQLException, IOException { VirtualServer vs = getVirtualServer(virtualServer); VirtualDisk vd = vs.getVirtualDisk(device); if(vd==null) throw new IllegalArgumentException("Unable to find VirtualDisk: "+virtualServer+":/dev/"+device); return vd; } private IpReputationSet getIpReputationSet(String identifier) throws IllegalArgumentException, SQLException, IOException { IpReputationSet set = connector.getIpReputationSets().get(identifier); if(set==null) throw new IllegalArgumentException("Unable to find IpReputationSet: "+identifier); return set; } /** * Adds a new backup Server. * * @param hostname the desired hostname for the server * @param farm the farm the server is part of * @param owner the package the server belongs to * @param description a description of the server * @param backup_hour the hour the backup will be run if used in daemon mode, * expressed in server-local time * @param os_type the type of operating system on the server * @param os_version the version of operating system on the server * @param architecture the type of CPU(s) on the server * @param username the desired backup account username * @param password the desired backup account password * @param contact_phone the phone number to call for anything related to this server * @param contact_email the email address to contact for anything related to this server * * @exception IOException if unable to communicate with the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the ServerFarm, Business, Architecture, * OperatingSystem, or OperatingSystemVersion * * @see Server * @see ServerTable#addBackupServer */ public int addBackupServer( String hostname, String farm, String owner, String description, int backup_hour, String os_type, String os_version, String architecture, String username, String password, String contact_phone, String contact_email ) throws IllegalArgumentException, IOException, SQLException { return connector.getServers().addBackupServer( hostname, getServerFarm(farm), getPackage(owner), description, backup_hour, getOperatingSystemVersion(os_type, os_version, getArchitecture(architecture)), username, password, contact_phone, contact_email ); } /** * Adds a new Business to the system. * * @param accounting the accounting code of the new business * @param contractVersion the version number of the digitally signed contract * @param defaultServer the hostname of the default server * @param parent the parent business of the new business * @param can_add_backup_servers allows backup servers to be added to the system * @param can_add_businesses if true, the new business * is allowed to add additional businesses * @param billParent if true the parent account will be billed instead * of this account * * @exception IOException if unable to communicate with the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the server or parent business * * @see Business * @see #checkAccounting * @see Server#addBusiness */ public void addBusiness( AccountingCode accounting, String contractVersion, String defaultServer, AccountingCode parent, boolean can_add_backup_servers, boolean can_add_businesses, boolean can_see_prices, boolean billParent ) throws IllegalArgumentException, SQLException, IOException { if(contractVersion!=null && contractVersion.length()==0) contractVersion=null; getServer(defaultServer).addBusiness( accounting, contractVersion, getBusiness(parent), can_add_backup_servers, can_add_businesses, can_see_prices, billParent ); } /** * Adds a new BusinessAdministrator to a * Business. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Username * * @see BusinessAdministrator * @see Business * @see Username#addBusinessAdministrator */ public void addBusinessAdministrator( String username, String name, String title, Date birthday, boolean isPrivate, String workPhone, String homePhone, String cellPhone, String fax, String email, String address1, String address2, String city, String state, String country, String zip, boolean enableEmailSupport ) throws IllegalArgumentException, IOException, SQLException { Username usernameObj=getUsername(username); checkBusinessAdministratorUsername(username); usernameObj.addBusinessAdministrator( name, title, birthday, isPrivate, workPhone, homePhone, cellPhone, fax, email, address1, address2, city, state, country, zip, enableEmailSupport ); } /** * Adds a new BusinessProfile to a Business. The * profile is a complete set of contact information about a business. New * profiles can be added, and they are used as the contact information, but * old profiles are still available. * * @exception IllegalArgumentException if unable to find the Business * * @see BusinessProfile * @see Business * @see Business#addBusinessProfile */ public int addBusinessProfile( AccountingCode business, String name, boolean isPrivate, String phone, String fax, String address1, String address2, String city, String state, String country, String zip, boolean sendInvoice, String billingContact, String billingEmail, String technicalContact, String technicalEmail ) throws IllegalArgumentException, IOException, SQLException { return getBusiness(business).addBusinessProfile( name, isPrivate, phone, fax, address1, address2, city, state, country, zip, sendInvoice, billingContact, billingEmail, technicalContact, technicalEmail ); } /** * Grants a Business access to a Server. * * @param accounting the accounting code of the business * @param server the hostname of the server * * @return the pkey of the new BusinessServer * * @exception IOException if unable to communicate with the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the business or server * * @see BusinessServer * @see #checkAccounting * @see Business#addBusinessServer */ public int addBusinessServer( AccountingCode accounting, String server ) throws IllegalArgumentException, SQLException, IOException { return getBusiness(accounting).addBusinessServer(getServer(server)); } /** * Adds a new CvsRepository to a Server. * * @param aoServer the hostname of the server * @param path the full path of the repository * @param username the name of the shell account that owns the directory * @param group the group that owns the directory * @param mode the permissions of the directory * * @return the pkey of the new CvsRepository * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server, LinuxServerAccount, * or LinuxServerGroup * * @see AOServer#addCvsRepository */ public int addCvsRepository( String aoServer, String path, String username, String group, long mode ) throws IllegalArgumentException, IOException, SQLException { AOServer ao=getAOServer(aoServer); return ao.addCvsRepository( path, getLinuxServerAccount(aoServer, username), getLinuxServerGroup(aoServer, group), mode ); } /** * Adds a new DNSRecord to a DNSZone. Each DNSZone * can have multiple DNS records in it, each being a DNSRecord. * * @param zone the zone, in the name.topleveldomain. format. Please note the * trailing period (.) * @param domain the part of the name before the zone or @ for the zone itself. For example, * the domain for the hostname of www.aoindustries.com. in the * aoindustries.com. zone is www. * @param type the DNSType * @param priority if a MX or SRV type, then the value is the priority of the record, otherwise * it is DNSRecord.NO_PRIORITY. * @param weight if a SRV type, then the value is the weight of the record, otherwise * it is DNSRecord.NO_WEIGHT. * @param port if a SRV type, then the value is the port of the record, otherwise * it is DNSRecord.NO_PORT. * * @return the pkey of the new DNSRecord * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the priority is provided for a non-MX and non-SRV record, * the priority is not provided for a MX or SRV record, * if the weight is provided for a non-SRV record, * the weight is not provided for a SRV record, * if the port is provided for a non-SRV record, * the port is not provided for a SRV record, * the destination is not the correct format for the DNSType, * or unable to find the DNSZone or DNSType * * @see DNSZone#addDNSRecord * @see DNSRecord * @see #addDNSZone * @see DNSType#checkDestination */ public int addDNSRecord( String zone, String domain, String type, int priority, int weight, int port, String destination, int ttl ) throws IllegalArgumentException, IOException, SQLException { DNSZone nz=getDNSZone(zone); // Must be a valid type DNSType nt=connector.getDnsTypes().get(type); if(nt==null) throw new IllegalArgumentException("Unable to find DNSType: "+type); // Must have appropriate priority if(nt.hasPriority()) { if(priority==DNSRecord.NO_PRIORITY) throw new IllegalArgumentException("priority required for type="+type); else if(priority<=0) throw new IllegalArgumentException("Invalid priority: "+priority); } else { if(priority!=DNSRecord.NO_PRIORITY) throw new IllegalArgumentException("No priority allowed for type="+type); } // Must have appropriate weight if(nt.hasWeight()) { if(weight==DNSRecord.NO_WEIGHT) throw new IllegalArgumentException("weight required for type="+type); else if(weight<=0) throw new IllegalArgumentException("Invalid weight: "+weight); } else { if(weight!=DNSRecord.NO_WEIGHT) throw new IllegalArgumentException("No weight allowed for type="+type); } // Must have appropriate port if(nt.hasPort()) { if(port==DNSRecord.NO_PORT) throw new IllegalArgumentException("port required for type="+type); else if(port<1 || port>65535) throw new IllegalArgumentException("Invalid port: "+port); } else { if(port!=DNSRecord.NO_PORT) throw new IllegalArgumentException("No port allowed for type="+type); } // Must have a valid destination type nt.checkDestination(destination); return nz.addDNSRecord( domain, nt, priority, weight, port, destination, ttl ); } /** * Adds a new DNSZone to a system. A DNSZone is one unique domain in * the name servers. It is always one host up from a top level domain. In mydomain.com. * com is the top level domain, which are defined by DNSTLDs. * * @param packageName the name of the Package that owns this domain * @param zone the complete domain of the new DNSZone * @param ip the IP address that will be used for the default DNSRecords * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Package or either parameter is not in * the proper format. * * @see Package#addDNSZone * @see DNSZone * @see #addDNSRecord * @see IPAddress * @see DNSTLD */ public void addDNSZone( String packageName, String zone, InetAddress ip, int ttl ) throws IllegalArgumentException, IOException, SQLException { if(!connector.getDnsZones().checkDNSZone(zone)) throw new IllegalArgumentException("Invalid zone: "+zone); getPackage(packageName).addDNSZone(zone, ip, ttl); } /** * Forwards email addressed to an address at a EmailDomain to * a different email address. The destination email address may be any email * address, not just those in a EmailDomain. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * @param aoServer the hostname of the server hosting the domain * @param destination the completed email address of the final delivery address * * @exception IOException if unable to communicate with the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable find the EmailDomain * * @see #checkEmailForwarding * @see EmailAddress#addEmailForwarding * @see EmailDomain */ public int addEmailForwarding( String address, DomainName domain, String aoServer, String destination ) throws IllegalArgumentException, IOException, SQLException { EmailDomain sd=getEmailDomain(aoServer, domain); EmailAddress eaddress=sd.getEmailAddress(address); boolean added=false; if(eaddress==null) { eaddress=connector.getEmailAddresses().get(sd.addEmailAddress(address)); added=true; } try { return eaddress.addEmailForwarding(destination); } catch(RuntimeException err) { if(added && !eaddress.isUsed()) eaddress.remove(); throw err; } } /** * Adds a new EmailList to the system. When an email is sent * to an EmailList, it is immediately forwarded to all addresses * contained in the list. The list may accept mail on any number of addresses * and forward to any number of recipients. *

* Even though the EmailList may receive email on any number of * addresses, each address must be part of a EmailDomain that * is hosted on the same Server as the EmailList. * If email in a domain on another Server is required to be sent * to this list, it must be forwarded from the other Server via * a EmailForwarding. *

* The list of destinations for the EmailList is stored on the * Server in a flat file of one address per line. This file * may be either manipulated through the API or used directly on the * filesystem. * * @param aoServer the hostname of the server the list is hosted on * @param path the name of the file that stores the list * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find find the AOServer, * LinuxServerAccount, or LinuxServerGroup * * @see #checkEmailListPath * @see #addEmailListAddress * @see EmailListAddress * @see EmailDomain * @see EmailForwarding * @see Server * @see LinuxServerAccount * @see LinuxServerGroup */ public int addEmailList( String aoServer, String path, String username, String group ) throws IllegalArgumentException, IOException, SQLException { return connector.getEmailLists().addEmailList( path, getLinuxServerAccount(aoServer, username), getLinuxServerGroup(aoServer, group) ); } /** * Adds to the list of EmailAddresses to which the EmailList * will accept mail. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * @param path the path of the list * @param aoServer the hostname of the server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the EmailDomain * or EmailList * * @see #addEmailList * @see EmailList * @see EmailAddress * @see EmailDomain */ public int addEmailListAddress( String address, DomainName domain, String path, String aoServer ) throws IllegalArgumentException, IOException, SQLException { EmailDomain sd=getEmailDomain(aoServer, domain); EmailList el=getEmailList(aoServer, path); EmailAddress ea=sd.getEmailAddress(address); boolean added=false; if(ea==null) { ea=connector.getEmailAddresses().get(connector.getEmailAddresses().addEmailAddress(address, sd)); added=true; } try { return el.addEmailAddress(ea); } catch(RuntimeException err) { if(added && !ea.isUsed()) ea.remove(); throw err; } } /** * Adds a new EmailPipe to the system. When an email is sent * to an EmailPipe, a process is invoked with the email pipes into * the process' standard input. * * @param aoServer the hostname of the server that the process exists on * @param path the name of the executable to launch * @param packageName the package that this EmailPipe belongs to * * @return the pkey of the new pipe * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find find the Server or * Package * * @see #addEmailPipeAddress * @see AOServer#addEmailPipe */ public int addEmailPipe( String aoServer, String path, String packageName ) throws IllegalArgumentException, IOException, SQLException { return connector.getEmailPipes().addEmailPipe( getAOServer(aoServer), path, getPackage(packageName) ); } /** * Adds an address to the list of email addresses that will be piped to * an EmailPipe. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * @param pkey the pkey of the EmailList * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the EmailDomain * or EmailPipe * * @see #addEmailPipe * @see EmailPipe * @see EmailAddress * @see EmailDomain */ public int addEmailPipeAddress( String address, DomainName domain, int pkey ) throws IllegalArgumentException, IOException, SQLException { EmailPipe ep=connector.getEmailPipes().get(pkey); if(ep==null) throw new IllegalArgumentException("Unable to find EmailPipe: "+ep); AOServer ao=ep.getAOServer(); EmailDomain sd=ao.getEmailDomain(domain); if(sd==null) throw new IllegalArgumentException("Unable to find EmailDomain: "+domain+" on "+ao.getHostname()); EmailAddress ea=sd.getEmailAddress(address); boolean added=false; if(ea==null) { ea=connector.getEmailAddresses().get(connector.getEmailAddresses().addEmailAddress(address, sd)); added=true; } try { return ep.addEmailAddress(ea); } catch(RuntimeException err) { if(added && !ea.isUsed()) ea.remove(); throw err; } } /** * Adds a FileBackupSetting to a FailoverFileReplication. * * @param replication the pkey of the FailoverFileReplication * @param path the path that is being configured * @param backupEnabled the enabled flag for the prefix * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the FailoverFileReplication, or Package * * @return the pkey of the newly created FileBackupSetting * * @see FailoverFileReplication#addFileBackupSetting * @see FileBackupSetting */ public int addFileBackupSetting( int replication, String path, boolean backupEnabled, boolean required ) throws IllegalArgumentException, IOException, SQLException { FailoverFileReplication ffr = getConnector().getFailoverFileReplications().get(replication); if(ffr==null) throw new IllegalArgumentException("Unable to find FailoverFileReplication: "+replication); return ffr.addFileBackupSetting( path, backupEnabled, required ); } /** * Flags a LinuxAccount as being a FTPGuestUser. Once * flagged, FTP connections as that user will be limited to transfers in their * home directory. * * @param username the username of the LinuxAccount * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the LinuxAccount * * @see #addLinuxAccount * @see LinuxAccount#addFTPGuestUser */ public void addFTPGuestUser( String username ) throws IllegalArgumentException, IOException, SQLException { getLinuxAccount(username).addFTPGuestUser(); } /** * Adds a new HttpdJBossSite to the system. An HttpdJBossSite is * an HttpdSite that uses the Tomcat servlet engine and JBoss as an EJB container. * * @param aoServer the hostname of the AOServer * @param siteName the name of the HttpdTomcatStdSite * @param packageName the name of the Package * @param jvmUsername the username of the LinuxAccount that the Java VM * will run as * @param groupName the name of the LinuxGroup that the web site will * be owned by * @param serverAdmin the email address of the person who is responsible for the site * content and reliability * @param useApache instructs the system to host static content, shtml, CGI, and PHP using Apache, * comes at the price of less request control through Tomcat * @param ipAddress the IPAddress that the web site will bind to. In * order for HTTP requests to succeed, DNSRecord entries * must point the hostnames of this HttpdTomcatStdSite to this * IPAddress. If null, the system will assign a * shared IP address. * @param primaryHttpHostname the primary hostname of the HttpdTomcatStdSite for the * HTTP protocol * @param altHttpHostnames any number of alternate hostnames for the HTTP protocol or * null for none * @param jBossVersion the version number of JBoss to install in the site * * @param contentSrc initial content installed to the site directory upon creation * * @return the pkey of the new HttpdTomcatStdSite * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find a referenced object or a * parameter is not in the right format * * @see HttpdSite */ public int addHttpdJBossSite( String aoServer, String siteName, String packageName, String jvmUsername, String groupName, String serverAdmin, boolean useApache, InetAddress ipAddress, String netDevice, String primaryHttpHostname, String[] altHttpHostnames, String jBossVersion, String contentSrc ) throws IllegalArgumentException, SQLException, IOException { AOServer ao=getAOServer(aoServer); checkSiteName(siteName); if(!EmailAddress.isValidEmailAddress(serverAdmin)) throw new IllegalArgumentException("Invalid serverAdmin email address: "+serverAdmin); IPAddress ip; if (netDevice!=null && (netDevice=netDevice.trim()).length()==0) netDevice=null; if (ipAddress!=null && netDevice!=null) { ip=getIPAddress(aoServer, netDevice, ipAddress); } else if(ipAddress==null && netDevice==null) { ip=null; } else { throw new IllegalArgumentException("ip_address and net_device must both be null or both be not null"); } if(!EmailDomain.isValidFormat(primaryHttpHostname)) throw new IllegalArgumentException("Invalid hostname: "+primaryHttpHostname); for(int c=0;cHttpdSharedTomcat to a server. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the LinuxServerAccount, * the LinuxServerGroup, or the Server * * @see HttpdSharedTomcat * @see LinuxServerAccount * @see LinuxServerGroup * @see Server */ public int addHttpdSharedTomcat( String name, String aoServer, String version, String linuxServerAccount, String linuxServerGroup, boolean isSecure, boolean isOverflow ) throws IllegalArgumentException, SQLException, IOException { AOServer ao=getAOServer(aoServer); HttpdTomcatVersion ve = connector.getHttpdTomcatVersions().getHttpdTomcatVersion(version, ao.getServer().getOperatingSystemVersion()); if (ve==null) throw new IllegalArgumentException("Unable to find HttpdTomcatVersion: "+version); return ao.addHttpdSharedTomcat( name, ve, getLinuxServerAccount(aoServer, linuxServerAccount), getLinuxServerGroup(aoServer, linuxServerGroup), isSecure, isOverflow ); } /** * Adds a new HttpdSiteURL to a HttpdSiteBind. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the HttpdSiteBind */ public int addHttpdSiteURL( int hsbPKey, String hostname ) throws IllegalArgumentException, IOException, SQLException { HttpdSiteBind hsb=connector.getHttpdSiteBinds().get(hsbPKey); if(hsb==null) throw new IllegalArgumentException("Unable to find HttpdSiteBind: "+hsbPKey); return hsb.addHttpdSiteURL(hostname); } /** * Adds a new HttpdTomcatContext to a HttpdTomcatSite. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server, HttpdSite, * or HttpdTomcatSite */ public int addHttpdTomcatContext( String siteName, String aoServer, String className, boolean cookies, boolean crossContext, String docBase, boolean override, String path, boolean privileged, boolean reloadable, boolean useNaming, String wrapperClass, int debug, String workDir ) throws IllegalArgumentException, IOException, SQLException { HttpdSite hs=getHttpdSite(aoServer, siteName); HttpdTomcatSite hts=hs.getHttpdTomcatSite(); if(hts==null) throw new IllegalArgumentException("Unable to find HttpdTomcatSite: "+siteName+" on "+aoServer); return hts.addHttpdTomcatContext( className==null||(className=className.trim()).length()==0?null:className, cookies, crossContext, docBase, override, path, privileged, reloadable, useNaming, wrapperClass==null || (wrapperClass=wrapperClass.trim()).length()==0?null:wrapperClass, debug, workDir==null || (workDir=workDir.trim()).length()==0?null:workDir ); } /** * Adds a new data source to a HttpdTomcatContext. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server, HttpdSite, * HttpdTomcatSite or HttpdTomcatContext. */ public int addHttpdTomcatDataSource( String siteName, String aoServer, String path, String name, String driverClassName, String url, String username, String password, int maxActive, int maxIdle, int maxWait, String validationQuery ) throws IllegalArgumentException, IOException, SQLException { HttpdSite hs=getHttpdSite(aoServer, siteName); HttpdTomcatSite hts=hs.getHttpdTomcatSite(); if(hts==null) throw new IllegalArgumentException("Unable to find HttpdTomcatSite: "+siteName+" on "+aoServer); HttpdTomcatContext htc=hts.getHttpdTomcatContext(path); if(htc==null) throw new IllegalArgumentException("Unable to find HttpdTomcatContext: "+siteName+" on "+aoServer+" path='"+path+'\''); return htc.addHttpdTomcatDataSource( name, driverClassName, url, username, password, maxActive, maxIdle, maxWait, validationQuery ); } /** * Adds a new parameter to a HttpdTomcatContext. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server, HttpdSite, * HttpdTomcatSite or HttpdTomcatContext. */ public int addHttpdTomcatParameter( String siteName, String aoServer, String path, String name, String value, boolean override, String description ) throws IllegalArgumentException, IOException, SQLException { HttpdSite hs=getHttpdSite(aoServer, siteName); HttpdTomcatSite hts=hs.getHttpdTomcatSite(); if(hts==null) throw new IllegalArgumentException("Unable to find HttpdTomcatSite: "+siteName+" on "+aoServer); HttpdTomcatContext htc=hts.getHttpdTomcatContext(path); if(htc==null) throw new IllegalArgumentException("Unable to find HttpdTomcatContext: "+siteName+" on "+aoServer+" path='"+path+'\''); return htc.addHttpdTomcatParameter( name, value, override, description ); } /** * Adds a new HttpdTomcatSharedSite to the system. An HttpdTomcatSharedSite is * an HttpdSite that contains a Tomcat servlet engine in the standard configuration. It * only hosts one site per Java VM, but is arranged in the stock Tomcat structure and uses no * special code. * * @param aoServer the hostname of the AOServer * @param siteName the name of the HttpdTomcatSharedSite * @param packageName the name of the Package * @param jvmUsername the username of the LinuxAccount that the Java VM * will run as * @param groupName the name of the LinuxGroup that the web site will * be owned by * @param serverAdmin the email address of the person who is responsible for the site * content and reliability * @param useApache instructs the system to host static content, shtml, CGI, and PHP using Apache, * comes at the price of less request control through Tomcat * @param ipAddress the IPAddress that the web site will bind to. In * order for HTTP requests to succeed, DNSRecord entries * must point the hostnames of this HttpdTomcatSharedSite to this * IPAddress. If null, the system will assign a * shared IP address. * @param primaryHttpHostname the primary hostname of the HttpdTomcatSharedSite for the * HTTP protocol * @param altHttpHostnames any number of alternate hostnames for the HTTP protocol or * null for none * @param sharedTomcatName the shared Tomcat JVM under which this site runs or null * to use an overflow JVM * @param version the version of Tomcat to support * * @param contentSrc initial content installed to the site directories upon creation * * @return the pkey of the new HttpdTomcatSharedSite * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find a referenced object or a * parameter is not in the right format * * @see AOServer#addHttpdTomcatSharedSite * @see HttpdTomcatSharedSite * @see HttpdTomcatSite * @see HttpdSite */ public int addHttpdTomcatSharedSite( String aoServer, String siteName, String packageName, String jvmUsername, String groupName, String serverAdmin, boolean useApache, InetAddress ipAddress, String netDevice, String primaryHttpHostname, String[] altHttpHostnames, String sharedTomcatName, String version, String contentSrc ) throws IllegalArgumentException, SQLException, IOException { AOServer ao=getAOServer(aoServer); checkSiteName(siteName); if(!EmailAddress.isValidEmailAddress(serverAdmin)) throw new IllegalArgumentException("Invalid serverAdmin email address: "+serverAdmin); IPAddress ip; if (netDevice!=null && (netDevice=netDevice.trim()).length()==0) netDevice=null; if (ipAddress!=null && netDevice!=null) { ip=getIPAddress(aoServer, netDevice, ipAddress); } else if(ipAddress==null && netDevice==null) { ip=null; } else { throw new IllegalArgumentException("ip_address and net_device must both be null or both be not null"); } if(!EmailDomain.isValidFormat(primaryHttpHostname)) throw new IllegalArgumentException("Invalid hostname: "+primaryHttpHostname); for(int c=0;c0) { TechnologyName tn=connector.getTechnologyNames().get(HttpdTomcatVersion.TECHNOLOGY_NAME); if(tn==null) throw new SQLException("Unable to find TechnologyName: "+HttpdTomcatVersion.TECHNOLOGY_NAME); TechnologyVersion tv=tn.getTechnologyVersion(connector, version, ao.getServer().getOperatingSystemVersion()); if(tv==null) throw new IllegalArgumentException("Unable to find TechnologyVersion: "+HttpdTomcatVersion.TECHNOLOGY_NAME+" version "+version); htv=tv.getHttpdTomcatVersion(connector); if(htv==null) throw new IllegalArgumentException("Unable to find HttpdTomcatVersion: "+HttpdTomcatVersion.TECHNOLOGY_NAME+" version "+version); } else htv=null; return ao.addHttpdTomcatSharedSite( siteName, getPackage(packageName), getLinuxServerAccount(aoServer, jvmUsername).getLinuxAccount(), getLinuxServerGroup(aoServer, groupName).getLinuxGroup(), serverAdmin, useApache, ip, primaryHttpHostname, altHttpHostnames, sharedTomcatName, htv, (contentSrc==null || contentSrc.length()==0)?null:contentSrc ); } /** * Adds a new HttpdTomcatStdSite to the system. An HttpdTomcatStdSite is * an HttpdSite that contains a Tomcat servlet engine in the standard configuration. It * only hosts one site per Java VM, but is arranged in the stock Tomcat structure and uses no * special code. * * @param aoServer the hostname of the AOServer * @param siteName the name of the HttpdTomcatStdSite * @param packageName the name of the Package * @param jvmUsername the username of the LinuxAccount that the Java VM * will run as * @param groupName the name of the LinuxGroup that the web site will * be owned by * @param serverAdmin the email address of the person who is responsible for the site * content and reliability * @param useApache instructs the system to host static content, shtml, CGI, and PHP using Apache, * comes at the price of less request control through Tomcat * @param ipAddress the IPAddress that the web site will bind to. In * order for HTTP requests to succeed, DNSRecord entries * must point the hostnames of this HttpdTomcatStdSite to this * IPAddress. If null, the system will assign a * shared IP address. * @param primaryHttpHostname the primary hostname of the HttpdTomcatStdSite for the * HTTP protocol * @param altHttpHostnames any number of alternate hostnames for the HTTP protocol or * null for none * @param tomcatVersion the version number of Tomcat to install in the site * * @param contentSrc initial content installed to the site directory upon creation * * @return the pkey of the new HttpdTomcatStdSite * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find a referenced object or a * parameter is not in the right format * * @see AOServer#addHttpdTomcatStdSite * @see HttpdTomcatStdSite * @see HttpdTomcatSite * @see HttpdSite */ public int addHttpdTomcatStdSite( String aoServer, String siteName, String packageName, String jvmUsername, String groupName, String serverAdmin, boolean useApache, InetAddress ipAddress, String netDevice, String primaryHttpHostname, String[] altHttpHostnames, String tomcatVersion, String contentSrc ) throws IllegalArgumentException, SQLException, IOException { AOServer ao=getAOServer(aoServer); checkSiteName(siteName); if(!EmailAddress.isValidEmailAddress(serverAdmin)) throw new IllegalArgumentException("Invalid serverAdmin email address: "+serverAdmin); IPAddress ip; if (netDevice!=null && (netDevice=netDevice.trim()).length()==0) netDevice=null; if (ipAddress!=null && netDevice!=null) { ip=getIPAddress(aoServer, netDevice, ipAddress); } else if(ipAddress==null && netDevice==null) { ip=null; } else { throw new IllegalArgumentException("ip_address and net_device must both be null or both be not null"); } if(!EmailDomain.isValidFormat(primaryHttpHostname)) throw new IllegalArgumentException("Invalid hostname: "+primaryHttpHostname); for(int c=0;cEmailAddress to a LinuxAccount. Not all * LinuxAccounts may be used as an email inbox. The LinuxAccountType * of the account determines which accounts may store email. When email is allowed for the account, * an EmailAddress is associated with the account as a LinuxAccAddress. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * @param aoServer the hostname of the server storing the email account * @param username the uesrname of the LinuxAccount to route the emails to * * @return the pkey of the new LinuxAccAddress * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the EmailDomain or * LinuxAccount * * @see LinuxServerAccount#addEmailAddress * @see LinuxAccAddress * @see #addLinuxAccount * @see #addEmailDomain * @see EmailAddress */ public int addLinuxAccAddress( String address, DomainName domain, String aoServer, String username ) throws IllegalArgumentException, IOException, SQLException { EmailDomain sd=getEmailDomain(aoServer, domain); LinuxServerAccount lsa=getLinuxServerAccount(aoServer, username); EmailAddress ea=sd.getEmailAddress(address); boolean added; if(ea==null) { ea=connector.getEmailAddresses().get(sd.addEmailAddress(address)); added=true; } else added=false; try { return lsa.addEmailAddress(ea); } catch(RuntimeException err) { if(added && !ea.isUsed()) ea.remove(); throw err; } } /** * Adds a new LinuxAccount the system. A LinuxAccount does not * grant access to any Servers, addLinuxServerAccount must be used * after the LinuxAccount has been created. * * @param username the username of the new LinuxAccount * @param primary_group the primary group of the new account * @param name the account's full name * @param office_location optional office location available via the Unix finger command * @param office_phone optional phone number available via the Unix finger command * @param home_phone optional home phone number available vie the Unix finger command * @param type the LinuxAccountType * @param shell the login Shell * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the name is not a valid format or unable to find * the Username, LinuxAccountType, * or Shell * * @see Username#addLinuxAccount * @see #checkLinuxAccountName * @see #addUsername * @see #addLinuxServerAccount * @see LinuxAccount * @see LinuxAccountType * @see LinuxServerAccount */ public void addLinuxAccount( String username, String primary_group, Gecos name, Gecos office_location, Gecos office_phone, Gecos home_phone, String type, String shell ) throws IllegalArgumentException, IOException, SQLException { Username un=getUsername(username); checkLinuxAccountUsername(username); LinuxGroup lg=getLinuxGroup(primary_group); LinuxAccountType lat=connector.getLinuxAccountTypes().get(type); if(lat==null) throw new IllegalArgumentException("Unable to find LinuxAccountType: "+type); Shell sh=connector.getShells().get(shell); if(sh==null) throw new IllegalArgumentException("Unable to find Shell: "+shell); un.addLinuxAccount( primary_group, name, office_location, office_phone, home_phone, type, shell ); } /** * Adds a LinuxGroup to the system. After adding the LinuxGroup, the group * may be added to a Server via a LinuxServerGroup. Also, LinuxAccounts * may be granted access to the group using LinuxGroupAccount. * * @param name the name of the new LinuxGroup * @param packageName the name of the Package that the group belongs to * @param type the LinuxGroupType * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the Package or * LinuxGroupType * * @see Package#addLinuxGroup * @see LinuxGroup * @see LinuxGroupType * @see Package * @see #addLinuxServerGroup * @see #addLinuxGroupAccount */ public void addLinuxGroup( String name, String packageName, String type ) throws IllegalArgumentException, IOException, SQLException { LinuxGroupType lgt=connector.getLinuxGroupTypes().get(type); if(lgt==null) throw new IllegalArgumentException("Unable to find LinuxGroupType: "+type); connector.getLinuxGroups().addLinuxGroup( name, getPackage(packageName), type ); } /** * Once a LinuxAccount and a LinuxGroup have been established, * permission for the LinuxAccount to access the LinuxGroup may * be granted using a LinuxGroupAccount. * * @param group the name of the LinuxGroup * @param username the username of the LinuxAccount * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the LinuxGroup or * LinuxAccount * * @see LinuxGroup#addLinuxAccount * @see LinuxGroupAccount * @see LinuxGroup * @see LinuxAccount * @see LinuxServerAccount * @see LinuxServerGroup */ public int addLinuxGroupAccount( String group, String username ) throws IllegalArgumentException, IOException, SQLException { return getLinuxGroup(group).addLinuxAccount(getLinuxAccount(username)); } /** * Grants a LinuxAccount access to a Server. The primary * LinuxGroup for this account must already have a LinuxServerGroup * for the Server. * * @param username the username of the LinuxAccount * @param aoServer the hostname of the AOServer * @param home the home directory of the user, typically /home/first_letter_of_username/username. * If null, "", or "~", the default home directory for username * is used. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the LinuxAccount, Server * or AOServer * * @see LinuxAccount#addLinuxServerAccount * @see #addLinuxAccount * @see #addLinuxGroupAccount * @see #addLinuxServerGroup * @see AOServer */ public int addLinuxServerAccount( String username, String aoServer, String home ) throws IllegalArgumentException, IOException, SQLException { LinuxAccount la=getLinuxAccount(username); AOServer ao=getAOServer(aoServer); if( home==null || home.length()==0 || home.equals("~") ) home=LinuxServerAccount.getDefaultHomeDirectory(username); return la.addLinuxServerAccount(ao, home); } /** * Grants a LinuxGroup access to a Server. If the group is * the primary LinuxGroup for any LinuxAccount that will be * added to the Server, the LinuxGroup must be added to the * Server first via a LinuxServerGroup. * * @param group the name of the LinuxGroup * @param aoServer the hostname of the AOServer * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the LinuxGroup or * Server * * @see LinuxGroup#addLinuxServerGroup * @see #addLinuxGroup * @see #addLinuxGroupAccount * @see Server */ public int addLinuxServerGroup( String group, String aoServer ) throws IllegalArgumentException, IOException, SQLException { return getLinuxGroup(group).addLinuxServerGroup(getAOServer(aoServer)); } /** * Adds a new MajordomoList to a MajordomoServer. * * @param domain the domain of the MajordomoServer * @param aoServer the hostname of the AOServer * @param listName the name of the new list * * @return the pkey of the new EmailList * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if the name is not valid or unable to find the * Server, code>EmailDomain, or * MajordomoServer * * @see MajordomoServer#addMajordomoList * @see #removeEmailList */ public int addMajordomoList( DomainName domain, String aoServer, String listName ) throws IllegalArgumentException, IOException, SQLException { EmailDomain ed=getEmailDomain(aoServer, domain); MajordomoServer ms=ed.getMajordomoServer(); if(ms==null) throw new IllegalArgumentException("Unable to find MajordomoServer: "+domain+" on "+aoServer); checkMajordomoListName(listName); return ms.addMajordomoList(listName); } /** * Adds a new MajordomoServer to an EmailDomain. * * @param domain the domain of the EmailDomain * @param aoServer the hostname of the AOServer * @param linux_account the username of the LinuxAccount * @param linux_group the naem of the LinuxGroup * @param version the version of the MajordomoVersion * * @exception IllegalArgumentException if unable to find the Server, * EmailDomain, LinuxServerAccount, * LinuxServerGroup, or MajordomoVersion * * @see EmailDomain#addMajordomoServer * @see #removeMajordomoServer */ public void addMajordomoServer( DomainName domain, String aoServer, String linux_account, String linux_group, String version ) throws IllegalArgumentException, IOException, SQLException { EmailDomain ed=getEmailDomain(aoServer, domain); MajordomoVersion mv=connector.getMajordomoVersions().get(version); if(mv==null) throw new IllegalArgumentException("Unable to find MajordomoVersion: "+version); ed.addMajordomoServer( getLinuxServerAccount(aoServer, linux_account), getLinuxServerGroup(aoServer, linux_group), mv ); } /** * Adds a new MySQLDatabase to the system. Once added, MySQLUsers may * be granted access to the MySQLDatabase using a MySQLDBUser. *

* Because updates the the MySQL configurations are batched, the database may not be immediately * created in the MySQL system. To ensure the database is ready for use, call waitForMySQLDatabaseRebuild. * * @param name the name of the new database * @param aoServer the hostname of the AOServer * @param packageName the name of the Package that owns the database * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if the database name is not valid or unable to * find the Server or Package * * @see MySQLServer#addMySQLDatabase * @see #checkMySQLDatabaseName * @see #addMySQLUser * @see #addMySQLServerUser * @see #addMySQLDBUser * @see #removeMySQLDatabase * @see #waitForMySQLDatabaseRebuild */ public int addMySQLDatabase( String name, String mysqlServer, String aoServer, String packageName ) throws IllegalArgumentException, IOException, SQLException { checkMySQLDatabaseName(name); return connector.getMysqlDatabases().addMySQLDatabase( name, getMySQLServer(aoServer, mysqlServer), getPackage(packageName) ); } /** * Grants a MySQLServerUser permission to access a MySQLDatabase. * * @param name the name of the MySQLDatabase * @param aoServer the hostname of the AOServer * @param username the username of the MySQLUser * @param canSelect grants the user SELECT privileges * @param canInsert grants the user INSERT privileges * @param canUpdate grants the user UPDATE privileges * @param canDelete grants the user DELETE privileges * @param canCreate grants the user CREATE privileges * @param canDrop grants the user DROP privileges * @param canIndex grants the user INDEX privileges * @param canAlter grants the user ALTER privileges * @param canCreateTempTable grants the user CREATE TEMPORARY TABLE privileges * @param canLockTables grants the user LOCK TABLE privileges * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the Server, * MySQLDatabase, or MySQLServerUser * * @see MySQLDatabase#addMySQLServerUser * @see #addMySQLUser * @see #addMySQLServerUser * @see #addMySQLDatabase */ public int addMySQLDBUser( String name, String mysqlServer, String aoServer, String username, boolean canSelect, boolean canInsert, boolean canUpdate, boolean canDelete, boolean canCreate, boolean canDrop, boolean canIndex, boolean canAlter, boolean canCreateTempTable, boolean canLockTables, boolean canCreateView, boolean canShowView, boolean canCreateRoutine, boolean canAlterRoutine, boolean canExecute, boolean canEvent, boolean canTrigger ) throws IllegalArgumentException, IOException, SQLException { MySQLDatabase md=getMySQLDatabase(aoServer, mysqlServer, name); return md.addMySQLServerUser( getMySQLServerUser(aoServer, mysqlServer, username), canSelect, canInsert, canUpdate, canDelete, canCreate, canDrop, canIndex, canAlter, canCreateTempTable, canLockTables, canCreateView, canShowView, canCreateRoutine, canAlterRoutine, canExecute, canEvent, canTrigger ); } /** * Grants a MySQLUser access to a Server by adding a * MySQLServerUser. * * @param username the username of the MySQLUser * @param aoServer the hostname of the AOServer * @param host the host the user is allowed to connect from, almost always * MySQLHost.ANY_LOCAL_HOST because the host limitation * is provided on a per-database level by MySQLDBUser * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the MySQLUser or * Server * * @see MySQLUser#addMySQLServerUser * @see MySQLServerUser#ANY_LOCAL_HOST * @see #addMySQLUser * @see #addMySQLDBUser */ public int addMySQLServerUser( String username, String mysqlServer, String aoServer, String host ) throws IllegalArgumentException, IOException, SQLException { return getMySQLUser(username).addMySQLServerUser(getMySQLServer(aoServer, mysqlServer), host==null || host.length()==0?null:host); } /** * Adds a MySQLUser to the system. A MySQLUser does not * exist on any Server, it merely indicates that a Username * will be used for accessing a MySQLDatabase. In order to grant * the new MySQLUser access to a MySQLDatabase, first * add a MySQLServerUser on the same Server as the * MySQLDatabase, then add a MySQLDBUser granting * permission to the MySQLDatabase. * * @param username the Username that will be used for accessing MySQL * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the Username * * @see Username#addMySQLUser * @see #addUsername * @see #addMySQLServerUser * @see #addMySQLDatabase * @see #addMySQLDBUser * @see MySQLUser */ public void addMySQLUser( String username ) throws IllegalArgumentException, IOException, SQLException { Username un=getUsername(username); checkMySQLUsername(username); un.addMySQLUser(); } /** * Adds a network bind to the system. * * @exception IOException if unable to access the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find a referenced object. * * @see Server#addNetBind */ public int addNetBind( String server, String packageName, InetAddress ipAddress, String net_device, int netPort, String netProtocol, String appProtocol, boolean openFirewall, boolean monitoringEnabled ) throws IllegalArgumentException, SQLException, IOException { IPAddress ia=getIPAddress(server, net_device, ipAddress); NetPort netPortObj=connector.getNetPorts().get(netPort); if(netPortObj==null) throw new IllegalArgumentException("Unable to find NetPort: "+netPort); NetProtocol netProt=connector.getNetProtocols().get(netProtocol); if(netProt==null) throw new IllegalArgumentException("Unable to find NetProtocol: "+netProtocol); Protocol appProt=connector.getProtocols().get(appProtocol); if(appProt==null) throw new IllegalArgumentException("Unable to find Protocol: "+appProtocol); return getServer(server).addNetBind( getPackage(packageName), ia, netPortObj, netProt, appProt, openFirewall, monitoringEnabled ); } /** * Whenever a credit card transaction fails, or when an account has not been paid for * over month, the billing contact for the Business is notified. The details * of this notification are logged as a NoticeLog. * * @param accounting the accounting code of the Business * @param billingContact the name of the person who was contacted * @param emailAddress the email address that the email was sent to * @param balance their account balance at the time the notification was sent * @param type the NoticeType * @param transid the transaction ID associated with this notification or * NoticeLog.NO_TRANSACTION for none * * @exception IOException if unable to access the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Business, * NoticeType, or Transaction. * * @see Business#addNoticeLog * @see NoticeType * @see Business * @see Transaction */ public void addNoticeLog( AccountingCode accounting, String billingContact, String emailAddress, BigDecimal balance, String type, int transid ) throws IllegalArgumentException, IOException, SQLException { Business bu=getBusiness(accounting); NoticeType nt=connector.getNoticeTypes().get(type); if(nt==null) throw new IllegalArgumentException("Unable to find NoticeType: "+type); if(transid!=NoticeLog.NO_TRANSACTION) { Transaction trans=connector.getTransactions().get(transid); if(trans==null) throw new IllegalArgumentException("Unable to find Transaction: "+transid); } connector.getNoticeLogs().addNoticeLog( accounting, billingContact, emailAddress, balance, type, transid ); } /** * Each Business can have multiple Packages associated with it. * Each Package is an allotment of resources with a monthly charge. *

* To determine if this connection can set prices: *

	 * SimpleAOClient client=new SimpleAOClient();
	 *
	 * boolean canSetPrices=client
	 *     .getConnector()
	 *     .getThisBusinessAdministrator()
	 *     .getUsername()
	 *     .getPackage()
	 *     .getBusiness()
	 *     .canSetPrices();
	 * 
* * @param packageName the name for the new package * @param accounting the accounting code of the Business * @param packageDefinition the unique identifier of the PackageDefinition * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find * * @see #checkPackageName * @see #addBusiness * @see PackageDefinition */ public int addPackage( String packageName, AccountingCode accounting, int packageDefinition ) throws IllegalArgumentException, IOException, SQLException { checkPackageName(packageName); Business business=getBusiness(accounting); PackageDefinition pd=getPackageDefinition(packageDefinition); return business.addPackage( packageName, pd ); } /** * Adds a new PostgresDatabase to the system. * * Because updates the the PostgreSQL configurations are batched, the database may not be immediately * created in the PostgreSQL system. To ensure the database is ready for use, call * waitForPostgresDatabaseRebuild. * * @param name the name of the new database * @param aoServer the hostname of the Server * @param datdba the username of the PostgresServerUser who owns the database * @param encoding the encoding of the database * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if the database name is not valid or unable to * find the Server, PostgresUser, * PostgresServerUser, or PostgresEncoding * * @see PostgresServer#addPostgresDatabase * @see #checkPostgresDatabaseName * @see #addPostgresUser * @see #addPostgresServerUser * @see #removePostgresDatabase * @see #waitForPostgresDatabaseRebuild * @see PostgresEncoding */ public int addPostgresDatabase( String name, String postgres_server, String aoServer, String datdba, String encoding, boolean enablePostgis ) throws IllegalArgumentException, SQLException, IOException { checkPostgresDatabaseName(name); PostgresServerUser psu=getPostgresServerUser(aoServer, postgres_server, datdba); PostgresServer ps=psu.getPostgresServer(); PostgresVersion pv=ps.getPostgresVersion(); PostgresEncoding pe=pv.getPostgresEncoding(connector, encoding); if(pe==null) throw new IllegalArgumentException("Unable to find PostgresEncoding for PostgresVersion "+pv.getTechnologyVersion(connector).getVersion()+": "+encoding); if(enablePostgis && pv.getPostgisVersion(connector)==null) throw new IllegalArgumentException("Unable to enable PostGIS, PostgresVersion "+pv.getTechnologyVersion(connector).getVersion()+" doesn't support PostGIS"); return connector.getPostgresDatabases().addPostgresDatabase( name, ps, psu, pe, enablePostgis ); } /** * Grants a PostgresUser access to a Server by adding a * PostgresServerUser. * * @param username the username of the PostgresUser * @param postgresServer the name of the PostgreSQL server * @param aoServer the hostname of the Server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the PostgresUser or * Server * * @see PostgresUser#addPostgresServerUser * @see #addPostgresUser */ public int addPostgresServerUser( String username, String postgresServer, String aoServer ) throws IllegalArgumentException, IOException, SQLException { return getPostgresUser(username).addPostgresServerUser(getPostgresServer(aoServer, postgresServer)); } /** * Adds a PostgresUser to the system. A PostgresUser does not * exist on any Server, it merely indicates that a Username * will be used for accessing a PostgresDatabase. In order to grant * the new PostgresUser access to a PostgresDatabase, first * add a PostgresServerUser on the same Server as the * PostgresDatabase, then use the PostgreSQL grant and * revoke commands. * * @param username the Username that will be used for accessing PostgreSQL * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if unable to find the Username * * @see Username#addPostgresUser * @see #addUsername * @see #addPostgresServerUser * @see #addPostgresDatabase * @see PostgresUser */ public void addPostgresUser( String username ) throws IllegalArgumentException, IOException, SQLException { Username un=getUsername(username); checkPostgresUsername(username); un.addPostgresUser(); } /** * Adds a new EmailDomain to a Server. Once added, the Server * will accept email for the provided domain. In order for the email to function, however, a DNS * MX entry for the domain must point to a hostname that resolves to an * IPAddress on the Server. * * @param domain the email domain that will be hosted * @param aoServer the hostname of the Server that is being added * @param packageName the name of the Package that owns the email domain * * @exception IOException if unable to access the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the domain is not in the correct format or * unable to find the Package * * @see EmailDomain#isValidFormat * @see AOServer#addEmailDomain * @see #addDNSRecord * @see #addEmailForwarding * @see #addEmailListAddress * @see #addEmailPipeAddress * @see #addLinuxAccAddress */ public int addEmailDomain( String domain, String aoServer, String packageName ) throws IllegalArgumentException, IOException, SQLException { if(!EmailDomain.isValidFormat(domain)) throw new IllegalArgumentException("Invalid domain name: "+domain); return getAOServer(aoServer).addEmailDomain(domain, getPackage(packageName)); } /** * Grants access to the SMTP server. Access to the SMTP server is granted when an * email client successfully logs into either the IMAP or POP3 servers. If desired, * access to the SMTP server may also be granted from the API. In either case, * the SMTP access will be revoked after 24 hours unless refresh. * * @param packageName the name of the Package that is granted access * @param aoServer the hostname of the AOServer * @param host the hostname or IP address that is being configured * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the IP address is for valid or unable to * find the Package or Server * * @see Package#addEmailSmtpRelay */ public int addEmailSmtpRelay( String packageName, String aoServer, String host, String type, long duration ) throws IllegalArgumentException, SQLException, IOException { AOServer ao; if(aoServer!=null && (aoServer=aoServer.trim()).length()==0) aoServer=null; if(aoServer==null) ao=null; else ao=getAOServer(aoServer); EmailSmtpRelayType esrt=connector.getEmailSmtpRelayTypes().get(type); if(esrt==null) throw new SQLException("Unable to find EmailSmtpRelayType: "+type); return getPackage(packageName).addEmailSmtpRelay(ao, host, esrt, duration); } /** * Adds a SpamEmailMessage. * * @return the pkey of the SpamEmailMessage that was created * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to the EmailSmtpRelay * * @see EmailSmtpRelay#addSpamEmailMessage */ public int addSpamEmailMessage( int email_relay, String message ) throws IllegalArgumentException, IOException, SQLException { EmailSmtpRelay esr=connector.getEmailSmtpRelays().get(email_relay); if(esr==null) throw new IllegalArgumentException("Unable to find EmailSmtpRelay: "+email_relay); return esr.addSpamEmailMessage(message); } /** * Adds a new support request Ticket to the system. * * @param accounting the name of the Business that the support * request relates to * @param business_administrator the person to contact regarding the ticket * @param ticket_type the TicketType * @param details the content of the Ticket * @param deadline the requested deadline for ticket completion or * Ticket.NO_DEADLINE for none * @param client_priority the priority assigned by the client * @param admin_priority the priority assigned by the ticket administrator * @param technology the TechnologyName that this Ticket * relates to or null for none * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Package, * BusinessAdministrator, TicketType, * client TicketPriority, admin TicketPriority, * or TechnologyName * * @see BusinessAdministrator#addTicket(Business,TicketType,String,long,TicketPriority,TicketPriority,TechnologyName,BusinessAdministrator,String,String) * @see BusinessAdministrator#isActiveTicketAdmin * @see Action * @see Package * @see TechnologyName * @see Ticket * @see TicketPriority * @see TicketType */ /* public int addTicket( String accounting, String language, String category, String ticketType, String summary, String details, String clientPriority, String contactEmails, String contactPhoneNumbers ) throws IllegalArgumentException, IOException, SQLException { return connector.getTickets().addTicket( (accounting==null || accounting.length()==0) ? null : getBusiness(accounting), getLanguage(language), (category==null || category.length()==0) ? null : getTicketCategory(category), getTicketType(ticketType), summary, (details==null || details.length()==0) ? null : details, getTicketPriority(clientPriority), contactEmails, contactPhoneNumbers ); }*/ /** * Adds a work entry to a Ticket when a Ticket is worked on, * but not completed. * * @param ticket_id the pkey of the Ticket * @param business_administrator the username of the BusinessAdministrator * making the change * @param comments the details of their work * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Ticket or * BusinessAdministrator * * @see Ticket#actWorkEntry * @see #addTicket * @see Action */ /* public void addTicketWork( int ticket_id, String business_administrator, String comments ) throws IllegalArgumentException, IOException, SQLException { Ticket ti=connector.getTickets().get(ticket_id); if(ti==null) throw new IllegalArgumentException("Unable to find Ticket: "+ticket_id); BusinessAdministrator pe=connector.getBusinessAdministrators().get(business_administrator); if(pe==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+business_administrator); ti.actWorkEntry(pe, comments); }*/ /** * Adds a new Transaction to a Business. * * @param business the accounting code of the Business * @param source_business the accounting code of the originating Business * @param business_administrator the username of the BusinessAdministrator making * this Transaction * @param type the type as found in Rate * @param description the description * @param quantity the quantity in thousandths * @param rate the rate in hundredths * @param paymentType * @param paymentInfo * @param processor * @param payment_confirmed the confirmation status of the transaction * * @return the transid of the new Transaction * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server, * Business, BusinessAdministrator, Rate, * PaymentType, or payment_confirmed * * @see Business#addTransaction * @see Transaction * @see #addBusiness * @see Business * @see #addBusinessAdministrator * @see BusinessAdministrator * @see TransactionType */ public int addTransaction( AccountingCode business, AccountingCode source_business, String business_administrator, String type, String description, int quantity, int rate, String paymentType, String paymentInfo, String processor, byte payment_confirmed ) throws IllegalArgumentException, IOException, SQLException { Business bu=getBusiness(business); Business sourceBU=getBusiness(source_business); BusinessAdministrator pe=connector.getBusinessAdministrators().get(business_administrator); if(pe==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+business_administrator); TransactionType tt=connector.getTransactionTypes().get(type); if(tt==null) throw new IllegalArgumentException("Unable to find TransactionType: "+type); PaymentType pt; if(paymentType==null || paymentType.length()==0) pt=null; else { pt=connector.getPaymentTypes().get(paymentType); if(pt==null) throw new IllegalArgumentException("Unable to find PaymentType: "+paymentType); } if(paymentInfo!=null && paymentInfo.length()==0) paymentInfo=null; CreditCardProcessor ccProcessor; if(processor==null || processor.length()==0) ccProcessor=null; else { ccProcessor = connector.getCreditCardProcessors().get(processor); if(ccProcessor==null) throw new IllegalArgumentException("Unable to find CreditCardProcessor: "+processor); } return bu.addTransaction( sourceBU, pe, tt, description, quantity, rate, pt, paymentInfo, ccProcessor, payment_confirmed ); } /** * Adds a new Username to a Package. A username is unique to the * system, regardless of which service(s) it is used for. For example, if a username is * allocated for use as a MySQL user for business A, business B may not use the username as * a PostgreSQL user. * * @param packageName the name of the Package that owns the Username * @param username the username to add * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the username is not a valid username or * unable to find the Package * * @see Package#addUsername * @see Username * @see #addPackage * @see Package */ public void addUsername( String packageName, String username ) throws IllegalArgumentException, IOException, SQLException { checkUsername(username); getPackage(packageName).addUsername(username); } /** * Determines if a LinuxAccount currently has passwords set. * * @param username the username of the account * * @return an int containing PasswordProtected.NONE, * PasswordProtected.SOME, or PasswordProtected.ALL * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the LinuxAccount is not found * * @see LinuxAccount#arePasswordsSet * @see #setLinuxAccountPassword * @see LinuxAccount * @see PasswordProtected */ public int areLinuxAccountPasswordsSet( String username ) throws IllegalArgumentException, IOException, SQLException { return getLinuxAccount(username).arePasswordsSet(); } /** * Determines if a MySQLUser currently has passwords set. * * @param username the username of the user * * @return an int containing PasswordProtected.NONE, * PasswordProtected.SOME, or PasswordProtected.ALL * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the MySQLUser is not found * * @see MySQLUser#arePasswordsSet * @see #setMySQLUserPassword * @see MySQLUser * @see PasswordProtected */ public int areMySQLUserPasswordsSet( String username ) throws IllegalArgumentException, IOException, SQLException { return getMySQLUser(username).arePasswordsSet(); } /** * Determines if a PostgresUser currently has passwords set. * * @param username the username of the user * * @return an int containing PasswordProtected.NONE, * PasswordProtected.SOME, or PasswordProtected.ALL * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the PostgresUser is not found * * @see PostgresUser#arePasswordsSet * @see #setPostgresUserPassword * @see PostgresUser * @see PasswordProtected */ public int arePostgresUserPasswordsSet( String username ) throws IllegalArgumentException, IOException, SQLException { return getPostgresUser(username).arePasswordsSet(); } /** * Determines if a Username currently has passwords set. * * @param username the username * * @return an int containing PasswordProtected.NONE, * PasswordProtected.SOME, or PasswordProtected.ALL * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the Username is not found * * @see Username#arePasswordsSet * @see #setUsernamePassword * @see Username * @see PasswordProtected */ public int areUsernamePasswordsSet( String username ) throws IllegalArgumentException, IOException, SQLException { return getUsername(username).arePasswordsSet(); } /** * Bounces a Ticket. * * @param ticket_id the pkey of the Ticket * @param business_administrator the username of the BusinessAdministrator * making the change * @param comments the details of the bounce * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Ticket or * BusinessAdministrator * * @see Ticket#actBounceTicket * @see #addTicket * @see Action */ /* public void bounceTicket( int ticket_id, String business_administrator, String comments ) throws IllegalArgumentException, IOException, SQLException { Ticket ti=connector.getTickets().get(ticket_id); if(ti==null) throw new IllegalArgumentException("Unable to find Ticket: "+ticket_id); BusinessAdministrator pe=connector.getBusinessAdministrators().get(business_administrator); if(pe==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+business_administrator); ti.actBounceTicket(pe, comments); }*/ /** * Cancels a Business. The Business must already be disabled. * * @param accounting the accounting code of the business * @param reason the reason the account is being canceled * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the Business * * @see Business#cancel */ public void cancelBusiness( AccountingCode accounting, String reason ) throws IllegalArgumentException, IOException, SQLException { getBusiness(accounting).cancel(reason); } /** * Changes the administrative priority of a Ticket. * * @param ticket_id the pkey of the Ticket * @param priority the new TicketPriority * @param business_administrator the username of the BusinessAdministrator * making the change * @param comments the details of the change * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Ticket, * BusinessAdministrator, or TicketPriority * * @see Ticket#actChangeAdminPriority * @see #addTicket * @see TicketPriority * @see Action */ /* public void changeTicketAdminPriority( int ticket_id, String priority, String business_administrator, String comments ) throws IllegalArgumentException, IOException, SQLException { Ticket ti=connector.getTickets().get(ticket_id); if(ti==null) throw new IllegalArgumentException("Unable to find Ticket: "+ticket_id); TicketPriority pr; if(priority==null || priority.length()==0) { pr=null; } else { pr=connector.getTicketPriorities().get(priority); if(pr==null) throw new IllegalArgumentException("Unable to find TicketPriority: "+priority); } BusinessAdministrator pe=connector.getBusinessAdministrators().get(business_administrator); if(pe==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+business_administrator); ti.actChangeAdminPriority(pr, pe, comments); }*/ /** * Changes the client's priority of a Ticket. * * @param ticket_id the pkey of the Ticket * @param priority the new TicketPriority * @param business_administrator the username of the BusinessAdministrator * making the change * @param comments the details of the change * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Ticket, * BusinessAdministrator, or TicketPriority * * @see Ticket#actChangeClientPriority * @see #addTicket * @see TicketPriority * @see Action */ /* public void changeTicketClientPriority( int ticket_id, String priority, String business_administrator, String comments ) throws IllegalArgumentException, IOException, SQLException { Ticket ti=connector.getTickets().get(ticket_id); if(ti==null) throw new IllegalArgumentException("Unable to find Ticket: "+ticket_id); TicketPriority pr=connector.getTicketPriorities().get(priority); if(pr==null) throw new IllegalArgumentException("Unable to find TicketPriority: "+priority); BusinessAdministrator pe=connector.getBusinessAdministrators().get(business_administrator); if(pe==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+business_administrator); ti.actChangeClientPriority(pr, pe, comments); }*/ /** * Changes the TicketType of a Ticket. * * @param ticket_id the pkey of the Ticket * @param type the name of the new TicketType * @param business_administrator the username of the BusinessAdministrator * making the change * @param comments the details of the change * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Ticket, * TicketType, or BusinessAdministrator * * @see Ticket#actChangeTicketType * @see TicketType * @see #addTicket * @see TicketPriority * @see Action */ /* public void changeTicketType( int ticket_id, String type, String business_administrator, String comments ) throws IllegalArgumentException, IOException, SQLException { Ticket ti=connector.getTickets().get(ticket_id); if(ti==null) throw new IllegalArgumentException("Unable to find Ticket: "+ticket_id); TicketType tt=connector.getTicketTypes().get(type); if(tt==null) throw new IllegalArgumentException("Unable to find TicketType: "+type); BusinessAdministrator pe=connector.getBusinessAdministrators().get(business_administrator); if(pe==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+business_administrator); ti.actChangeTicketType(tt, pe, comments); }*/ /** * Checks the strength of a password that will be used for * a BusinessAdministrator. * * @param username the username of the BusinessAdministrator whos * password will be set * @param password the new password * * @return a description of why the password is weak or null * if all checks succeed * * @exception IllegalArgumentException if username is not a valid Username * * @see #setBusinessAdministratorPassword * @see Username#isValidUsername * @see BusinessAdministrator#checkPassword */ public static List checkBusinessAdministratorPassword( String username, String password ) throws IllegalArgumentException, IOException, SQLException { String check = Username.checkUsername(username); if(check!=null) throw new IllegalArgumentException(check); try { return BusinessAdministrator.checkPassword(UserId.valueOf(username), password); } catch(ValidationException e) { throw new IllegalArgumentException(e.getMessage(), e); } } /** * Checks the format of a username that will be used for a BusinessAdministrator. * * @param username the username * * @exception IllegalArgumentException if the username is not in a valid format * * @see BusinessAdministrator#isValidUsername * @see #addBusinessAdministrator */ public static void checkBusinessAdministratorUsername( String username ) throws IllegalArgumentException { String check = BusinessAdministrator.checkUsername(username); if(check!=null) throw new IllegalArgumentException(check); } /** * Checks the format of a DNSZone. * * @param zone the new DNS zone name, some examples include aoindustries.com. * and netspade.co.uk. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the format is not valid * * @see DNSZoneTable#checkDNSZone * @see DNSZone */ public void checkDNSZone( String zone ) throws IllegalArgumentException, IOException, SQLException { if(!connector.getDnsZones().checkDNSZone(zone)) throw new IllegalArgumentException("Invalid DNS zone: "+zone); } /** * Checks the format of an email address. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * * @exception IllegalArgumentException if the address is not in a valid format * * @see EmailAddress#isValidFormat * @see EmailDomain#isValidFormat */ public static void checkEmailAddress( String address, String domain ) throws IllegalArgumentException { if(!EmailAddress.isValidFormat(address)) throw new IllegalArgumentException("Invalid EmailAddress: "+address); if(!EmailDomain.isValidFormat(domain)) throw new IllegalArgumentException("Invalid EmailDomain: "+domain); } /** * Checks the format of an email address that will be forwarded to another destination. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * @param destination the final destination of emails sent to address@domain * * @exception IllegalArgumentException if the address or destination is not in a valid format * * @see EmailAddress#isValidFormat * @see EmailDomain#isValidFormat * @see EmailAddress#isValidEmailAddress */ public static void checkEmailForwarding( String address, String domain, String destination ) throws IllegalArgumentException { if(!EmailAddress.isValidFormat(address)) throw new IllegalArgumentException("Invalid EmailAddress: "+address); if(!EmailDomain.isValidFormat(domain)) throw new IllegalArgumentException("Invalid EmailDomain: "+domain); if(!EmailAddress.isValidEmailAddress(destination)) throw new IllegalArgumentException("Invalid destination: "+destination); } /** * Checks the format of an email list path. * * @param path the path of the list * * @exception IllegalArgumentException if the name is not in a valid format * * @see EmailList#isValidRegularPath */ public static void checkEmailListPath( String path ) throws IllegalArgumentException { if(!EmailList.isValidRegularPath(path)) throw new IllegalArgumentException("Invalid EmailList path: "+path); } /** * Checks the format of an IP address. * * @param ip the IP address to check * * @exception IllegalArgumentException if the IP address is not in a valid format * * @see IPAddress#isValidIPAddress */ public static void checkIPAddress( String ip ) throws IllegalArgumentException { if(!IPAddress.isValidIPAddress(ip)) throw new IllegalArgumentException("Invalid IP address: "+ip); } /** * Checks the strength of a password that will be used for a LinuxAccount or * LinuxServerAccount. * * @param username the username of the account that will have its password set * @param password the new password for the account * * @return a String describing why the password is not secure or null * if the password is strong * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxAccount * * @see LinuxAccount#checkPassword * @see #setLinuxAccountPassword * @see #setLinuxServerAccountPassword * @see PasswordChecker */ public List checkLinuxAccountPassword( String username, String password ) throws IllegalArgumentException, IOException, SQLException { return getLinuxAccount(username).checkPassword(password); } /** * Checks the format of a username that will be used for a LinuxAccount. * * @param username the username * * @exception IllegalArgumentException if the username is not in a valid format * * @see LinuxAccount#isValidUsername * @see #addLinuxAccount */ public static void checkLinuxAccountUsername( String username ) throws IllegalArgumentException { if(!LinuxAccount.isValidUsername(username)) throw new IllegalArgumentException("Invalid LinuxAccount username: "+username); } /** * Checks the format of a groupname. * * @param groupname the groupname that will be used to name a LinuxGroup * * @exception IllegalArgumentException if the groupname is not in a valid format * * @see LinuxGroup#isValidGroupname * @see #addLinuxGroup */ public static void checkLinuxGroupname( String groupname ) throws IllegalArgumentException { if(!LinuxGroup.isValidGroupname(groupname)) throw new IllegalArgumentException("Invalid groupname: "+groupname); } /** * Checks the format of a MySQL database name. * * @param name the name that will be used to create a new database * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the database name is not allowed * * @see MySQLDatabaseTable#isValidDatabaseName * @see #addMySQLDatabase */ public void checkMySQLDatabaseName( String name ) throws IllegalArgumentException, IOException, SQLException { String invalidReason = connector.getMysqlDatabases().isValidDatabaseName(name); if(invalidReason!=null) throw new IllegalArgumentException(invalidReason); } /** * Checks the strength of a password that will be used for * a MySQLServerUser. * * @param username the username of the MySQLServerUser whos * password will be set * @param password the new password * * @return a description of why the password is weak or null * if all checks succeed * * @exception IOException if unable to load the dictionary resource * * @see #setMySQLUserPassword * @see #setMySQLServerUserPassword * @see MySQLUser#checkPassword */ public static List checkMySQLPassword( String username, String password ) throws IllegalArgumentException, IOException { try { return MySQLUser.checkPassword(MySQLUserId.valueOf(username), password); } catch(ValidationException e) { throw new IllegalArgumentException(e.getMessage(), e); } } /** * Checks the format of a MySQL server name. * * @param name the name that will be used to create a new server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the database name is not allowed * * @see MySQLServer#checkServerName */ public static void checkMySQLServerName( String name ) throws IllegalArgumentException { MySQLServer.checkServerName(name); } /** * Checks the format of a username that will be used for a MySQLUser. * * @param username the username * * @exception IllegalArgumentException if the username is not in a valid format * * @see MySQLUser#isValidUsername * @see #addMySQLUser */ public static void checkMySQLUsername( String username ) throws IllegalArgumentException { if(!MySQLUser.isValidUsername(username)) throw new IllegalArgumentException("Invalid MySQLUser username: "+username); } /** * Checks the format of a Package name. * * @param packageName the name that will be used for a Package * * @exception IllegalArgumentException if the name is not valid * * @see Package#isValidPackageName * @see #addPackage */ public static void checkPackageName( String packageName ) throws IllegalArgumentException { if(!Package.isValidPackageName(packageName)) throw new IllegalArgumentException("Invalid package name: "+packageName); } /** * Checks the format of a PostgreSQL database name. * * @param name the name that will be used to create a new database * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the database name is not allowed * * @see PostgresDatabaseTable#isValidDatabaseName * @see #addPostgresDatabase */ public void checkPostgresDatabaseName( String name ) throws IllegalArgumentException, IOException, SQLException { if(!connector.getPostgresDatabases().isValidDatabaseName(name)) throw new IllegalArgumentException("Invalid PostgreSQL database name: "+name); } /** * Checks the strength of a password that will be used for * a PostgresServerUser. * * @param username the username of the PostgresServerUser whos * password will be set * @param password the new password * * @return a description of why the password is weak or null * if all checks succeed * * @exception IOException if unable to load the dictionary resource * * @see #setPostgresUserPassword * @see #setPostgresServerUserPassword * @see PostgresUser#checkPassword */ public static List checkPostgresPassword( String username, String password ) throws IllegalArgumentException, IOException { try { return PostgresUser.checkPassword(PostgresUserId.valueOf(username), password); } catch(ValidationException e) { throw new IllegalArgumentException(e.getMessage(), e); } } /** * Checks the format of a PostgreSQL server name. * * @param name the name that will be used to create a new server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the database name is not allowed * * @see PostgresServer#checkServerName */ public static void checkPostgresServerName( String name ) throws IllegalArgumentException { PostgresServer.checkServerName(name); } /** * Checks the format of a username that will be used for a PostgresUser. * * @param username the username * * @exception IllegalArgumentException if the username is not in a valid format * * @see PostgresUser#isValidUsername * @see #addPostgresUser */ public static void checkPostgresUsername( String username ) throws IllegalArgumentException { if(!PostgresUser.isValidUsername(username)) throw new IllegalArgumentException("Invalid PostgresUser username: "+username); } /** * Checks the format of an email domain. * * @param domain the domain that will be used as a EmailDomain * * @exception IllegalArgumentException if the domain is not in a valid format * * @see EmailDomain#isValidFormat * @see #addEmailDomain */ public static void checkEmailDomain( String domain ) throws IllegalArgumentException { if(!EmailDomain.isValidFormat(domain)) throw new IllegalArgumentException("Invalid EmailDomain: "+domain); } /** * Checks the format of a Majordomo list name. * * @exception IllegalArgumentException if the domain is not in a valid format * * @see MajordomoList#isValidListName * @see #addMajordomoList */ public static void checkMajordomoListName( String listName ) throws IllegalArgumentException { if(!MajordomoList.isValidListName(listName)) throw new IllegalArgumentException("Invalid Majordomo list name: "+listName); } /** * Checks the format of an HttpdSharedTomcat name. * * @param tomcatName the name of the HttpdSharedTomcat * * @exception IllegalArgumentException if the name is not in a valid format * * @see HttpdSharedTomcat#isValidSharedTomcatName * @see #addHttpdSharedTomcat * @see #addHttpdTomcatSharedSite */ public static void checkSharedTomcatName( String tomcatName ) throws IllegalArgumentException { if(!HttpdSharedTomcat.isValidSharedTomcatName(tomcatName)) throw new IllegalArgumentException("Invalid shared Tomcat name: "+tomcatName); } /** * Checks the format of an HttpdSite name. * * @param siteName the name of the HttpdSite * * @exception IllegalArgumentException if the name is not in a valid format * * @see HttpdSite#isValidSiteName * @see #addHttpdTomcatStdSite */ public static void checkSiteName( String siteName ) throws IllegalArgumentException { if(!HttpdSite.isValidSiteName(siteName)) throw new IllegalArgumentException("Invalid site name: "+siteName); } /** * Checks the format of a username. * * @param username the username that will be used as a Username * * @exception IllegalArgumentException if the username is not in a valid format * * @see Username#isValidUsername * @see #addUsername */ public static void checkUsername( String username ) throws IllegalArgumentException { String check = Username.checkUsername(username); if(check!=null) throw new IllegalArgumentException(check); } /** * Checks the strength of a password that will be used for * a Username. The strength requirement is based on * which services use the Username. * * @param username the username whos password will be set * @param password the new password * * @return a description of why the password is weak or null * if all checks succeed * * @exception IOException if unable to load the dictionary resource or unable to access the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Username * * @see #setUsernamePassword * @see Username#checkPassword */ public List checkUsernamePassword( String username, String password ) throws IllegalArgumentException, IOException, SQLException { return getUsername(username).checkPassword(password); } /** * Checks if a password matches a LinuxServerAccount. * * @param username the username of the account * @param aoServer the hostname of the server to check * @param password the password to compare against * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the LinuxAccount, Server, * AOServer, or LinuxServerAccount is not found * * @see LinuxServerAccount#passwordMatches * @see #addLinuxServerAccount */ public boolean compareLinuxServerAccountPassword( String username, String aoServer, String password ) throws IllegalArgumentException, IOException, SQLException { return getLinuxServerAccount(aoServer, username).passwordMatches(password); } /** * Completes a Ticket. Once a Ticket is completed, no more * modifications or actions may be applied to the Ticket. * * @param ticket_id the pkey of the Ticket * @param business_administrator the username of the BusinessAdministrator * making the change * @param comments the details of the change * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Ticket, * TicketType, or BusinessAdministrator * * @see Ticket#actCompleteTicket * @see #addTicket * @see Action */ /* public void completeTicket( int ticket_id, String business_administrator, String comments ) throws IllegalArgumentException, IOException, SQLException { Ticket ti=connector.getTickets().get(ticket_id); if(ti==null) throw new IllegalArgumentException("Unable to find Ticket: "+ticket_id); BusinessAdministrator pe=connector.getBusinessAdministrators().get(business_administrator); if(pe==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+business_administrator); ti.actCompleteTicket(pe, comments); }*/ /** * Copies the contents of user's home directory from one server to another. * * @param username the username of the LinuxAccount * @param from_ao_server the server to get the data from * @param to_ao_server the server to put the data on * * @return the number of bytes transferred * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the source LinuxServerAccount * or destination AOServer * * @see LinuxServerAccount#copyHomeDirectory * @see #addLinuxServerAccount * @see #removeLinuxServerAccount */ public long copyHomeDirectory( String username, String from_ao_server, String to_ao_server ) throws IOException, SQLException { return getLinuxServerAccount(from_ao_server, username).copyHomeDirectory(getAOServer(to_ao_server)); } /** * Copies the password from one LinuxServerAccount to another. * * @param from_username the username to copy from * @param from_ao_server the server to get the data from * @param to_username the username to copy to * @param to_ao_server the server to put the data on * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find a LinuxServerAccount * * @see LinuxServerAccount#copyPassword * @see #addLinuxServerAccount * @see #removeLinuxServerAccount */ public void copyLinuxServerAccountPassword( String from_username, String from_ao_server, String to_username, String to_ao_server ) throws IOException, SQLException { getLinuxServerAccount(from_ao_server, from_username).copyPassword(getLinuxServerAccount(to_ao_server, to_username)); } /** * Encrypts a password using a pure Java implementation of the standard Unix crypt * function. * * @param password the password that is to be encrypted * @param salt the two character salt for the encryption process, if null, * a random salt will be used * * @deprecated Please use hash instead. * @see #hash(String) */ @Deprecated public static String crypt(String password, String salt) { if(password==null || password.length()==0) return "*"; return salt==null || salt.length()==0?com.aoindustries.util.UnixCrypt.crypt(password):com.aoindustries.util.UnixCrypt.crypt(password, salt); } /** * Hashes a password using SHA-1. */ public static String hash(String password) { return HashedPassword.hash(password); } /** * Disables a CreditCard. When a Transaction using a * CreditCard fails, the CreditCard is disabled. * * @param pkey the unique identifier of the CreditCard * @param reason the reason the card is being disabled * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the CreditCard * * @see CreditCard#declined * @see Transaction * @see CreditCard */ public void declineCreditCard( int pkey, String reason ) throws IllegalArgumentException, IOException, SQLException { CreditCard card=connector.getCreditCards().get(pkey); if(card==null) throw new IllegalArgumentException("Unable to find CreditCard: "+pkey); card.declined(reason); } /** * Disables a business, recursively disabling all of its enabled child components. * * @param accounting the accounting code to disable * @param disableReason the reason the account is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the necessary AOServObjects */ public int disableBusiness(AccountingCode accounting, String disableReason) throws IllegalArgumentException, IOException, SQLException { Business bu=getBusiness(accounting); DisableLog dl=connector.getDisableLogs().get(bu.addDisableLog(disableReason)); for(Package pk : bu.getPackages()) if(pk.disable_log==-1) disablePackage(dl, pk); bu.disable(dl); return dl.getPkey(); } /** * Disables a package, recursively disabling all of its enabled child components. * * @param name the name of the package * @param disableReason the reason the account is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the necessary AOServObjects */ public int disablePackage(String name, String disableReason) throws IllegalArgumentException, SQLException, IOException { Package pk=getPackage(name); DisableLog dl=connector.getDisableLogs().get(pk.getBusiness().addDisableLog(disableReason)); disablePackage(dl, pk); return dl.getPkey(); } private void disablePackage(DisableLog dl, Package pk) throws IOException, SQLException { /* * Email stuff */ for(EmailList el : pk.getEmailLists()) if(el.disable_log==-1) el.disable(dl); for(EmailPipe ep : pk.getEmailPipes()) if(ep.disable_log==-1) ep.disable(dl); for(EmailSmtpRelay ssr : pk.getEmailSmtpRelays()) if(ssr.disable_log==-1) ssr.disable(dl); /* * HTTP stuff */ List httpdServers=new SortedArrayList<>(); for(HttpdSharedTomcat hst : pk.getHttpdSharedTomcats()) { if(hst.disable_log==-1) { hst.disable(dl); AOServer ao=hst.getAOServer(); if(!httpdServers.contains(ao)) httpdServers.add(ao); } } for(HttpdSite hs : pk.getHttpdSites()) { if(hs.disable_log==-1) { disableHttpdSite(dl, hs); AOServer ao=hs.getAOServer(); if(!httpdServers.contains(ao)) httpdServers.add(ao); } } // Wait for httpd site rebuilds to complete, which shuts down all the appropriate processes for(AOServer httpdServer : httpdServers) httpdServer.waitForHttpdSiteRebuild(); // Disable the user accounts once the JVMs have been shut down for(Username un : pk.getUsernames()) if(un.disable_log==-1) disableUsername(dl, un); pk.disable(dl); } /** * Disables a HttpdSharedTomcat. * * @param name the name of the tomcat JVM * @param aoServer the server that hosts the JVM * @param disableReason the reason the JVM is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the AOServer, or HttpdSharedTomcat */ public int disableHttpdSharedTomcat( String name, String aoServer, String disableReason ) throws IllegalArgumentException, IOException, SQLException { HttpdSharedTomcat hst=getHttpdSharedTomcat(aoServer, name); DisableLog dl=connector.getDisableLogs().get(hst.getLinuxServerGroup().getLinuxGroup().getPackage().getBusiness().addDisableLog(disableReason)); hst.disable(dl); return dl.getPkey(); } /** * Disables an EmailPipe. * * @param pkey the pkey of the pipe * @param disableReason the reason the pipe is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailPipe */ public int disableEmailPipe( int pkey, String disableReason ) throws IllegalArgumentException, SQLException, IOException { EmailPipe ep=connector.getEmailPipes().get(pkey); if(ep==null) throw new IllegalArgumentException("Unable to find EmailPipe: "+pkey); DisableLog dl=connector.getDisableLogs().get(ep.getPackage().getBusiness().addDisableLog(disableReason)); ep.disable(dl); return dl.getPkey(); } /** * Disables a HttpdSite. * * @param name the name of the site * @param aoServer the server that hosts the site * @param disableReason the reason the site is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server, or HttpdSite */ public int disableHttpdSite( String name, String aoServer, String disableReason ) throws IllegalArgumentException, SQLException, IOException { HttpdSite hs=getHttpdSite(aoServer, name); DisableLog dl=connector.getDisableLogs().get(hs.getPackage().getBusiness().addDisableLog(disableReason)); disableHttpdSite(dl, hs); return dl.getPkey(); } private void disableHttpdSite(DisableLog dl, HttpdSite hs) throws IOException, SQLException { for(HttpdSiteBind hsb : hs.getHttpdSiteBinds()) if(hsb.disable_log==-1) hsb.disable(dl); hs.disable(dl); } /** * Disables a HttpdSiteBind. * * @param pkey the pkey of the bind * @param disableReason the reason the bind is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the HttpdSiteBind */ public int disableHttpdSiteBind( int pkey, String disableReason ) throws IllegalArgumentException, SQLException, IOException { HttpdSiteBind hsb=connector.getHttpdSiteBinds().get(pkey); if(hsb==null) throw new IllegalArgumentException("Unable to find HttpdSiteBind: "+pkey); DisableLog dl=connector.getDisableLogs().get(hsb.getHttpdSite().getPackage().getBusiness().addDisableLog(disableReason)); hsb.disable(dl); return dl.getPkey(); } /** * Disables an EmailList. * * @param path the path of the list * @param aoServer the server the list is part of * @param disableReason the reason the bind is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailList */ public int disableEmailList( String path, String aoServer, String disableReason ) throws IllegalArgumentException, SQLException, IOException { EmailList el=getEmailList(aoServer, path); DisableLog dl=connector.getDisableLogs().get(el.getLinuxServerGroup().getLinuxGroup().getPackage().getBusiness().addDisableLog(disableReason)); el.disable(dl); return dl.getPkey(); } /** * Disables a EmailSmtpRelay. * * @param pkey the pkey of the relay * @param disableReason the reason the bind is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailSmtpRelay */ public int disableEmailSmtpRelay( int pkey, String disableReason ) throws IllegalArgumentException, SQLException, IOException { EmailSmtpRelay ssr=connector.getEmailSmtpRelays().get(pkey); if(ssr==null) throw new IllegalArgumentException("Unable to find EmailSmtpRelay: "+pkey); DisableLog dl=connector.getDisableLogs().get(ssr.getPackage().getBusiness().addDisableLog(disableReason)); ssr.disable(dl); return dl.getPkey(); } /** * Disables a Username and all uses of the username. * * @param username the username to disable * @param disableReason the reason the bind is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username */ public int disableUsername( String username, String disableReason ) throws IllegalArgumentException, SQLException, IOException { Username un=getUsername(username); DisableLog dl=connector.getDisableLogs().get(un.getPackage().getBusiness().addDisableLog(disableReason)); disableUsername(dl, un); return dl.getPkey(); } private void disableUsername(DisableLog dl, Username un) throws IOException, SQLException { LinuxAccount la=un.getLinuxAccount(); if(la!=null && la.disable_log==-1) disableLinuxAccount(dl, la); MySQLUser mu=un.getMySQLUser(); if(mu!=null && mu.disable_log==-1) disableMySQLUser(dl, mu); PostgresUser pu=un.getPostgresUser(); if(pu!=null && pu.disable_log==-1) disablePostgresUser(dl, pu); un.disable(dl); } /** * Disables a LinuxAccount. * * @param username the username to disable * @param disableReason the reason the account is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username or LinuxAccount */ public int disableLinuxAccount( String username, String disableReason ) throws IllegalArgumentException, SQLException, IOException { LinuxAccount la=getLinuxAccount(username); DisableLog dl=connector.getDisableLogs().get(la.getUsername().getPackage().getBusiness().addDisableLog(disableReason)); disableLinuxAccount(dl, la); return dl.getPkey(); } private void disableLinuxAccount(DisableLog dl, LinuxAccount la) throws IOException, SQLException { for(LinuxServerAccount lsa : la.getLinuxServerAccounts()) { if(lsa.disable_log==-1) disableLinuxServerAccount(dl, lsa); } la.disable(dl); } /** * Disables a LinuxServerAccount. * * @param username the username to disable * @param aoServer the server the account is on * @param disableReason the reason the account is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username, * LinuxAccount, or LinuxServerAccount */ public int disableLinuxServerAccount( String username, String aoServer, String disableReason ) throws IllegalArgumentException, SQLException, IOException { LinuxServerAccount lsa=getLinuxServerAccount(aoServer, username); DisableLog dl=connector.getDisableLogs().get(lsa.getLinuxAccount().getUsername().getPackage().getBusiness().addDisableLog(disableReason)); disableLinuxServerAccount(dl, lsa); return dl.getPkey(); } private void disableLinuxServerAccount(DisableLog dl, LinuxServerAccount lsa) throws IOException, SQLException { for(CvsRepository cr : lsa.getCvsRepositories()) if(cr.disable_log==-1) cr.disable(dl); lsa.disable(dl); } /** * Disables a CvsRepository. * * @param pkey the pkey of the repository to disable * @param disableReason the reason the account is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the CvsRepository */ public int disableCvsRepository( int pkey, String disableReason ) throws IllegalArgumentException, SQLException, IOException { CvsRepository cr=connector.getCvsRepositories().get(pkey); if(cr==null) throw new IllegalArgumentException("Unable to find CvsRepository: "+pkey); DisableLog dl=connector.getDisableLogs() .get( cr .getLinuxServerAccount() .getLinuxAccount() .getUsername() .getPackage() .getBusiness() .addDisableLog(disableReason) ) ; cr.disable(dl); return dl.getPkey(); } /** * Disables a MySQLUser. * * @param username the username to disable * @param disableReason the reason the account is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username or MySQLUser */ public int disableMySQLUser( String username, String disableReason ) throws IllegalArgumentException, SQLException, IOException { MySQLUser mu=getMySQLUser(username); DisableLog dl=connector.getDisableLogs().get(mu.getUsername().getPackage().getBusiness().addDisableLog(disableReason)); disableMySQLUser(dl, mu); return dl.getPkey(); } private void disableMySQLUser(DisableLog dl, MySQLUser mu) throws IOException, SQLException { for(MySQLServerUser msu : mu.getMySQLServerUsers()) if(msu.disable_log==-1) msu.disable(dl); mu.disable(dl); } /** * Disables a MySQLServerUser. * * @param username the username to disable * @param aoServer the server the account is on * @param disableReason the reason the account is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or MySQLUser */ public int disableMySQLServerUser( String username, String mysqlServer, String aoServer, String disableReason ) throws IllegalArgumentException, SQLException, IOException { MySQLServerUser msu=getMySQLServerUser(aoServer, mysqlServer, username); DisableLog dl=connector.getDisableLogs().get(msu.getMySQLUser().getUsername().getPackage().getBusiness().addDisableLog(disableReason)); msu.disable(dl); return dl.getPkey(); } /** * Disables a PostgresUser. * * @param username the username to disable * @param disableReason the reason the account is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username or PostgresUser */ public int disablePostgresUser( String username, String disableReason ) throws IllegalArgumentException, SQLException, IOException { Username un=getUsername(username); PostgresUser pu=un.getPostgresUser(); if(pu==null) throw new IllegalArgumentException("Unable to find PostgresUser: "+username); DisableLog dl=connector.getDisableLogs().get(un.getPackage().getBusiness().addDisableLog(disableReason)); disablePostgresUser(dl, pu); return dl.getPkey(); } private void disablePostgresUser(DisableLog dl, PostgresUser pu) throws IOException, SQLException{ for(PostgresServerUser psu : pu.getPostgresServerUsers()) if(psu.disable_log==-1) psu.disable(dl); pu.disable(dl); } /** * Disables a PostgresServerUser. * * @param username the username to disable * @param postgresServer the name of the PostgresServer * @param aoServer the server the account is on * @param disableReason the reason the account is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or PostgresUser */ public int disablePostgresServerUser( String username, String postgresServer, String aoServer, String disableReason ) throws IllegalArgumentException, SQLException, IOException { PostgresServerUser psu=getPostgresServerUser(aoServer, postgresServer, username); DisableLog dl=connector.getDisableLogs() .get( psu .getPostgresUser() .getUsername() .getPackage() .getBusiness() .addDisableLog(disableReason) ) ; psu.disable(dl); return dl.getPkey(); } /** * Disables a BusinessAdministrator. * * @param username the username to disable * @param disableReason the reason the account is being disabled * * @return the pkey of the new DisableLog * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username or BusinessAdministrator */ public int disableBusinessAdministrator( String username, String disableReason ) throws IllegalArgumentException, SQLException, IOException { Username un=getUsername(username); BusinessAdministrator ba=un.getBusinessAdministrator(); if(ba==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+username); DisableLog dl=connector.getDisableLogs().get(un.getPackage().getBusiness().addDisableLog(disableReason)); ba.disable(dl); return dl.getPkey(); } /** * Enables a business, recursively enabling all of its disabled child components. * * @param accounting the accounting code to enable * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the necessary Businesss */ public void enableBusiness(AccountingCode accounting) throws IllegalArgumentException, IOException, SQLException { Business bu=getBusiness(accounting); DisableLog dl=bu.getDisableLog(); if(dl==null) throw new IllegalArgumentException("Business not disabled: "+accounting); bu.enable(); for(Package pk : bu.getPackages()) if(pk.disable_log==dl.pkey) enablePackage(dl, pk); } /** * Enables a package, recursively enabling all of its disabled child components. * * @param name the name of the package * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the necessary AOServObjects */ public void enablePackage(String name) throws IllegalArgumentException, SQLException, IOException { Package pk=getPackage(name); DisableLog dl=pk.getDisableLog(); if(dl==null) throw new IllegalArgumentException("Package not disabled: "+name); enablePackage(dl, pk); } private void enablePackage(DisableLog dl, Package pk) throws IOException, SQLException { pk.enable(); /* * Email stuff */ for(EmailList el : pk.getEmailLists()) if(el.disable_log==dl.pkey) el.enable(); for(EmailPipe ep : pk.getEmailPipes()) if(ep.disable_log==dl.pkey) ep.enable(); for(EmailSmtpRelay ssr : pk.getEmailSmtpRelays()) if(ssr.disable_log==dl.pkey) ssr.enable(); // Various accounts List linuxAccountServers=new SortedArrayList<>(); List mysqlServers=new SortedArrayList<>(); List postgresServers=new SortedArrayList<>(); for(Username un : pk.getUsernames()) { if(un.disable_log==dl.pkey) enableUsername( dl, un, linuxAccountServers, mysqlServers, postgresServers ); } // Wait for rebuilds for (AOServer linuxAccountServer : linuxAccountServers) { linuxAccountServer.waitForLinuxAccountRebuild(); } for (AOServer mysqlServer : mysqlServers) { mysqlServer.waitForMySQLUserRebuild(); } for (AOServer postgresServer : postgresServers) { postgresServer.waitForPostgresUserRebuild(); } // Start up the web sites for(HttpdSharedTomcat hst : pk.getHttpdSharedTomcats()) if(hst.disable_log==dl.pkey) hst.enable(); for(HttpdSite hs : pk.getHttpdSites()) if(hs.disable_log==dl.pkey) enableHttpdSite(dl, hs); } /** * Enables a HttpdSharedTomcat. * * @param name the name of the tomcat JVM * @param aoServer the server that hosts the JVM * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the AOServer, or HttpdSharedTomcat */ public void enableHttpdSharedTomcat( String name, String aoServer ) throws IllegalArgumentException, SQLException, IOException { HttpdSharedTomcat hst=getHttpdSharedTomcat(aoServer, name); DisableLog dl=hst.getDisableLog(); if(dl==null) throw new IllegalArgumentException("HttpdSharedTomcat not disabled: "+name+" on "+aoServer); hst.enable(); } /** * Enables an EmailPipe. * * @param pkey the pkey of the pipe * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailPipe */ public void enableEmailPipe( int pkey ) throws IllegalArgumentException, SQLException, IOException { EmailPipe ep=connector.getEmailPipes().get(pkey); if(ep==null) throw new IllegalArgumentException("Unable to find EmailPipe: "+pkey); DisableLog dl=ep.getDisableLog(); if(dl==null) throw new IllegalArgumentException("EmailPipe not disabled: "+pkey); ep.enable(); } /** * Enables a HttpdSite. * * @param name the name of the site * @param aoServer the server that hosts the site * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the AOServer, or HttpdSite */ public void enableHttpdSite( String name, String aoServer ) throws IllegalArgumentException, SQLException, IOException { HttpdSite hs=getHttpdSite(aoServer, name); DisableLog dl=hs.getDisableLog(); if(dl==null) throw new IllegalArgumentException("HttpdSite not disabled: "+name+" on "+aoServer); enableHttpdSite(dl, hs); } private void enableHttpdSite(DisableLog dl, HttpdSite hs) throws IOException, SQLException { hs.enable(); for(HttpdSiteBind hsb : hs.getHttpdSiteBinds()) if(hsb.disable_log==dl.pkey) hsb.enable(); } /** * Enables a HttpdSiteBind. * * @param pkey the pkey of the bind * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the HttpdSiteBind */ public void enableHttpdSiteBind( int pkey ) throws IllegalArgumentException, SQLException, IOException { HttpdSiteBind hsb=connector.getHttpdSiteBinds().get(pkey); if(hsb==null) throw new IllegalArgumentException("Unable to find HttpdSiteBind: "+pkey); DisableLog dl=hsb.getDisableLog(); if(dl==null) throw new IllegalArgumentException("HttpdSiteBind not disabled: "+pkey); hsb.enable(); } /** * Enables an EmailList. * * @param path the path of the list * @param aoServer the server the list is part of * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailList */ public void enableEmailList( String path, String aoServer ) throws IllegalArgumentException, SQLException, IOException { EmailList el=getEmailList(aoServer, path); DisableLog dl=el.getDisableLog(); if(dl==null) throw new IllegalArgumentException("EmailList not disabled: "+path+" on "+aoServer); el.enable(); } /** * Enables a EmailSmtpRelay. * * @param pkey the pkey of the relay * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailSmtpRelay */ public void enableEmailSmtpRelay( int pkey ) throws IllegalArgumentException, IOException, SQLException { EmailSmtpRelay ssr=connector.getEmailSmtpRelays().get(pkey); if(ssr==null) throw new IllegalArgumentException("Unable to find EmailSmtpRelay: "+pkey); DisableLog dl=ssr.getDisableLog(); if(dl==null) throw new IllegalArgumentException("EmailSmtpRelay not disabled: "+pkey); ssr.enable(); } /** * Enables a Username and all uses of the username. * * @param username the username to enable * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username */ public void enableUsername( String username ) throws IllegalArgumentException, SQLException, IOException { Username un=getUsername(username); DisableLog dl=un.getDisableLog(); if(dl==null) throw new IllegalArgumentException("Username not disabled: "+username); enableUsername(dl, un, null, null, null); } private void enableUsername( DisableLog dl, Username un, List linuxAccountServers, List mysqlServers, List postgresServers ) throws IOException, SQLException { un.enable(); BusinessAdministrator ba=un.getBusinessAdministrator(); if(ba!=null && ba.disable_log==dl.pkey) ba.enable(); LinuxAccount la=un.getLinuxAccount(); if(la!=null && la.disable_log==dl.pkey) enableLinuxAccount(dl, la, linuxAccountServers); MySQLUser mu=un.getMySQLUser(); if(mu!=null && mu.disable_log==dl.pkey) enableMySQLUser(dl, mu, mysqlServers); PostgresUser pu=un.getPostgresUser(); if(pu!=null && pu.disable_log==dl.pkey) enablePostgresUser(dl, pu, postgresServers); } /** * Enables a LinuxAccount. * * @param username the username to enable * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username or LinuxAccount */ public void enableLinuxAccount( String username ) throws IllegalArgumentException, SQLException, IOException { LinuxAccount la=getLinuxAccount(username); DisableLog dl=la.getDisableLog(); if(dl==null) throw new IllegalArgumentException("LinuxAccount not disabled: "+username); enableLinuxAccount(dl, la, null); } private void enableLinuxAccount(DisableLog dl, LinuxAccount la, List linuxAccountServers) throws SQLException, IOException { la.enable(); for(LinuxServerAccount lsa : la.getLinuxServerAccounts()) { if(lsa.disable_log==dl.pkey) { enableLinuxServerAccount(dl, lsa); if(linuxAccountServers!=null) { AOServer ao=lsa.getAOServer(); if(!linuxAccountServers.contains(ao)) linuxAccountServers.add(ao); } } } } /** * Enables a LinuxServerAccount. * * @param username the username to enable * @param aoServer the server the account is on * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username, * LinuxAccount, or LinuxServerAccount */ public void enableLinuxServerAccount( String username, String aoServer ) throws IllegalArgumentException, SQLException, IOException { LinuxServerAccount lsa=getLinuxServerAccount(aoServer, username); DisableLog dl=lsa.getDisableLog(); if(dl==null) throw new IllegalArgumentException("LinuxServerAccount not disabled: "+username+" on "+aoServer); enableLinuxServerAccount(dl, lsa); } private void enableLinuxServerAccount(DisableLog dl, LinuxServerAccount lsa) throws IOException, SQLException { lsa.enable(); for(CvsRepository cr : lsa.getCvsRepositories()) if(cr.disable_log==dl.pkey) cr.enable(); } /** * Enables a CvsRepository. * * @param pkey the pkey of the repository to enable * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the CvsRepository */ public void enableCvsRepository( int pkey ) throws IllegalArgumentException, SQLException, IOException { CvsRepository cr=connector.getCvsRepositories().get(pkey); if(cr==null) throw new IllegalArgumentException("Unable to find CvsRepository: "+pkey); DisableLog dl=cr.getDisableLog(); if(dl==null) throw new IllegalArgumentException("CvsRepository not disabled: "+pkey); cr.enable(); } /** * Enables a MySQLUser. * * @param username the username to enable * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username or MySQLUser */ public void enableMySQLUser( String username ) throws IllegalArgumentException, SQLException, IOException { MySQLUser mu=getMySQLUser(username); DisableLog dl=mu.getDisableLog(); if(dl==null) throw new IllegalArgumentException("MySQLUser not disabled: "+username); enableMySQLUser(dl, mu, null); } private void enableMySQLUser(DisableLog dl, MySQLUser mu, List mysqlServers) throws IOException, SQLException { mu.enable(); for(MySQLServerUser msu : mu.getMySQLServerUsers()) { if(msu.disable_log==dl.pkey) { msu.enable(); if(mysqlServers!=null) { AOServer ao=msu.getMySQLServer().getAOServer(); if(!mysqlServers.contains(ao)) mysqlServers.add(ao); } } } } /** * Enables a MySQLServerUser. * * @param username the username to enable * @param aoServer the server the account is on * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or MySQLUser */ public void enableMySQLServerUser( String username, String mysqlServer, String aoServer ) throws IllegalArgumentException, SQLException, IOException { MySQLServerUser msu=getMySQLServerUser(aoServer, mysqlServer, username); DisableLog dl=msu.getDisableLog(); if(dl==null) throw new IllegalArgumentException("MySQLServerUser not disabled: "+username+" on "+mysqlServer+" on "+aoServer); msu.enable(); } /** * Enables a PostgresUser. * * @param username the username to enable * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username or PostgresUser */ public void enablePostgresUser( String username ) throws IllegalArgumentException, SQLException, IOException { Username un=getUsername(username); PostgresUser pu=un.getPostgresUser(); if(pu==null) throw new IllegalArgumentException("Unable to find PostgresUser: "+username); DisableLog dl=pu.getDisableLog(); if(dl==null) throw new IllegalArgumentException("PostgresUser not disabled: "+username); enablePostgresUser(dl, pu, null); } private void enablePostgresUser(DisableLog dl, PostgresUser pu, List postgresServers) throws IOException, SQLException { pu.enable(); for(PostgresServerUser psu : pu.getPostgresServerUsers()) { if(psu.disable_log==dl.pkey) { psu.enable(); if(postgresServers!=null) { AOServer ao=psu.getPostgresServer().getAOServer(); if(!postgresServers.contains(ao)) postgresServers.add(ao); } } } } /** * Enables a PostgresServerUser. * * @param username the username to enable * @param postgresServer the name of the PostgreSQL server * @param aoServer the server the account is on * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or PostgresUser */ public void enablePostgresServerUser( String username, String postgresServer, String aoServer ) throws IllegalArgumentException, IOException, SQLException { PostgresServerUser psu=getPostgresServerUser(aoServer, postgresServer, username); DisableLog dl=psu.getDisableLog(); if(dl==null) throw new IllegalArgumentException("PostgresServerUser not disabled: "+username+" on "+aoServer); psu.enable(); } /** * Enables a BusinessAdministrator. * * @param username the username to enable * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username or BusinessAdministrator */ public void enableBusinessAdministrator( String username ) throws IllegalArgumentException, SQLException, IOException { Username un=getUsername(username); BusinessAdministrator ba=un.getBusinessAdministrator(); if(ba==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+username); DisableLog dl=ba.getDisableLog(); if(dl==null) throw new IllegalArgumentException("BusinessAdministrator not disabled: "+username); ba.enable(); } /** * Dumps the contents of a MySQLDatabase to a Writer. * * @param name the name of the MySQLDatabase * @param aoServer the hostname of the AOServer * @param out the Writer to dump to * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or * MySQLDatabase * * @see MySQLDatabase#dump * @see MySQLDatabase */ public void dumpMySQLDatabase( String name, String mysqlServer, String aoServer, Writer out ) throws IllegalArgumentException, IOException, SQLException { getMySQLDatabase(aoServer, mysqlServer, name).dump(out); } /** * Dumps the contents of a PostgresDatabase to a Writer. * * @param name the name of the PostgresDatabase * @param postgresServer the name of the PostgreSQL server * @param aoServer the hostname of the Server * @param out the Writer to dump to * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or * PostgresDatabase * * @see PostgresDatabase#dump * @see PostgresDatabase */ public void dumpPostgresDatabase( String name, String postgresServer, String aoServer, Writer out ) throws IllegalArgumentException, IOException, SQLException { getPostgresDatabase(aoServer, postgresServer, name).dump(out); } /** * Generates a unique accounting code that may be used to create a new Business. * * @param accountingTemplate the beginning part of the accounting code, such as "AO_" * * @return the available accounting code * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * * @see BusinessTable#generateAccountingCode * @see #addBusiness * @see Business */ public AccountingCode generateAccountingCode( AccountingCode accountingTemplate ) throws IOException, SQLException { return connector.getBusinesses().generateAccountingCode(accountingTemplate); } /** * Generates a unique MySQL database name. * * @param template_base the beginning part of the template, such as "AO" * @param template_added the part of the template added between the template_base and * the generated number, such as "_" * * @return the available database name * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * * @see MySQLDatabaseTable#generateMySQLDatabaseName * @see #addMySQLDatabase * @see MySQLDatabase */ public String generateMySQLDatabaseName( String template_base, String template_added ) throws IOException, SQLException { return connector.getMysqlDatabases().generateMySQLDatabaseName(template_base, template_added); } /** * Generates a unique Package name. * * @param template the beginning part of the template, such as "AO_" * * @return the available Package name * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * * @see PackageTable#generatePackageName * @see #addPackage * @see Package */ public String generatePackageName( String template ) throws IOException, SQLException { return connector.getPackages().generatePackageName(template); } /** * Generates a random, valid password. * * @return the password * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * */ public String generatePassword() throws IOException { return PasswordGenerator.generatePassword(); } /** * Generates a unique PostgreSQL database name. * * @param template_base the beginning part of the template, such as "AO" * @param template_added the part of the template added between the template_base and * the generated number, such as "_" * * @return the available database name * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * * @see PostgresDatabaseTable#generatePostgresDatabaseName * @see #addPostgresDatabase * @see PostgresDatabase */ public String generatePostgresDatabaseName( String template_base, String template_added ) throws IOException, SQLException { return connector.getPostgresDatabases().generatePostgresDatabaseName(template_base, template_added); } /** * Generates a unique HttpdSharedTomcat name. * * @param template the beginning part of the template, such as "ao" * * @return the available HttpdSharedTomcat name * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * * @see HttpdSharedTomcatTable#generateSharedTomcatName * @see #addHttpdSharedTomcat * @see #addHttpdTomcatSharedSite * @see HttpdSite */ public String generateSharedTomcatName( String template ) throws IOException, SQLException { return connector.getHttpdSharedTomcats().generateSharedTomcatName(template); } /** * Generates a unique HttpdSite name. * * @param template the beginning part of the template, such as "ao" * * @return the available HttpdSite name * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * * @see HttpdSiteTable#generateSiteName * @see #addHttpdTomcatStdSite * @see HttpdSite */ public String generateSiteName( String template ) throws IOException, SQLException { return connector.getHttpdSites().generateSiteName(template); } /** * Gets the autoresponder content. * * @param username the username of the LinuxServerAccount * @param aoServer the server to get the data from * * @return the autoresponder content * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the source LinuxServerAccount * * @see LinuxServerAccount#getAutoresponderContent * @see #setAutoresponder */ public String getAutoresponderContent( String username, String aoServer ) throws IOException, SQLException { return getLinuxServerAccount(aoServer, username).getAutoresponderContent(); } /** * Gets the AOServConnector used for communication with the server. */ public AOServConnector getConnector() { return connector; } /** * Gets a user's cron table on one server. * * @param username the username of the LinuxAccount * @param aoServer the server to get the data from * * @return the cron table * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the source LinuxServerAccount * * @see LinuxServerAccount#getCronTable * @see #setCronTable * @see #addLinuxServerAccount * @see #removeLinuxServerAccount */ public String getCronTable( String username, String aoServer ) throws IOException, SQLException { return getLinuxServerAccount(aoServer, username).getCronTable(); } /** * Gets the list of email addresses that an EmailList will be forwarded to. * * @param path the path of the list * @param aoServer the server this list is part of * * @return the list of addresses, one address per line separated by '\n' * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the EmailList * * @see EmailList#getAddressList * @see #addEmailList * @see #setEmailListAddressList * @see EmailList */ public String getEmailListAddressList( String path, String aoServer ) throws IllegalArgumentException, IOException, SQLException { return getEmailList(aoServer, path).getAddressList(); } /** * Gets the total size of a BackupPartition. * * @param aoServer the hostname of the server * @param path the path of the BackupPartition * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the AOServer or BackupPartition * * @see BackupPartition#getDiskTotalSize */ public long getBackupPartitionTotalSize( String aoServer, String path ) throws IllegalArgumentException, IOException, SQLException { BackupPartition bp=getAOServer(aoServer).getBackupPartitionForPath(path); if(bp==null) throw new IllegalArgumentException("Unable to find BackupPartition: "+path+" on "+aoServer); return bp.getDiskTotalSize(); } /** * Gets the used size of a BackupPartition. * * @param aoServer the hostname of the server * @param path the path of the BackupPartition * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the AOServer or BackupPartition * * @see BackupPartition#getDiskUsedSize */ public long getBackupPartitionUsedSize( String aoServer, String path ) throws IllegalArgumentException, IOException, SQLException { BackupPartition bp=getAOServer(aoServer).getBackupPartitionForPath(path); if(bp==null) throw new IllegalArgumentException("Unable to find BackupPartition: "+path+" on "+aoServer); return bp.getDiskUsedSize(); } /** * Gets the last reported activity for a FailoverFileReplication. * * @param fromServer the server that is being backed-up * @param toServer the hostname of the server the stores the backups * @param path the path of the BackupPartition * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server, AOServer, BackupPartition, or FailoverFileReplication * * @see FailoverFileReplication#getActivity() */ public FailoverFileReplication.Activity getFailoverFileReplicationActivity( String fromServer, String toServer, String path ) throws IllegalArgumentException, IOException, SQLException { return getFailoverFileReplication(fromServer, toServer, path).getActivity(); } /** * Gets the attributes of an inbox. * * @param username the username of the LinuxServerAccount * @param aoServer the server hosting the account * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the LinuxServerAccount * * @see LinuxServerAccount#getInboxAttributes */ public InboxAttributes getInboxAttributes( String username, String aoServer ) throws IllegalArgumentException, IOException, SQLException { return getLinuxServerAccount(aoServer, username).getInboxAttributes(); } /** * Gets the IMAP folder sizes for an inbox. * * @param username the username of the LinuxServerAccount * @param aoServer the server hosting the account * @param folderNames the folder names * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the LinuxServerAccount * * @see LinuxServerAccount#getImapFolderSizes */ public long[] getImapFolderSizes( String username, String aoServer, String[] folderNames ) throws IllegalArgumentException, IOException, SQLException { return getLinuxServerAccount(aoServer, username).getImapFolderSizes(folderNames); } /** * Gets the info file for a MajordomoList. * * @param domain the domain of the MajordomoServer * @param aoServer the hostname of the AOServer * @param listName the name of the new list * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if the name is not valid or unable to find the * Server, code>EmailDomain, * MajordomoServer, or MajordomoList * * @see MajordomoList#getInfoFile * @see #addMajordomoList * @see #removeEmailList */ public String getMajordomoInfoFile( DomainName domain, String aoServer, String listName ) throws IllegalArgumentException, IOException, SQLException { EmailDomain ed=getEmailDomain(aoServer, domain); MajordomoServer ms=ed.getMajordomoServer(); if(ms==null) throw new IllegalArgumentException("Unable to find MajordomoServer: "+domain+" on "+aoServer); MajordomoList ml=ms.getMajordomoList(listName); if(ml==null) throw new IllegalArgumentException("Unable to find MajordomoList: "+listName+'@'+domain+" on "+aoServer); return ml.getInfoFile(); } /** * Gets the intro file for a MajordomoList. * * @param domain the domain of the MajordomoServer * @param aoServer the hostname of the AOServer * @param listName the name of the new list * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if the name is not valid or unable to find the * Server, code>EmailDomain, * MajordomoServer, or MajordomoList * * @see MajordomoList#getIntroFile * @see #addMajordomoList * @see #removeEmailList */ public String getMajordomoIntroFile( DomainName domain, String aoServer, String listName ) throws IllegalArgumentException, IOException, SQLException { EmailDomain ed=getEmailDomain(aoServer, domain); MajordomoServer ms=ed.getMajordomoServer(); if(ms==null) throw new IllegalArgumentException("Unable to find MajordomoServer: "+domain+" on "+aoServer); MajordomoList ml=ms.getMajordomoList(listName); if(ml==null) throw new IllegalArgumentException("Unable to find MajordomoList: "+listName+'@'+domain+" on "+aoServer); return ml.getIntroFile(); } /** * Gets the contents of a MRTG file. * * @param aoServer the hostname of the server to get the file from * @param filename the filename on the server * @param out the OutputStream to write the file to * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#getMrtgFile */ public void getMrtgFile( String aoServer, String filename, OutputStream out ) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).getMrtgFile(filename, out); } /** * Gets the current status of the UPS. * * @param aoServer the hostname of the server to get the file from * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#getMrtgFile */ public String getUpsStatus( String aoServer ) throws IllegalArgumentException, IOException, SQLException { return getAOServer(aoServer).getUpsStatus(); } /** * Gets the contents of an AWStats file. * * @param siteName the site name * @param aoServer the hostname of the server to get the file from * @param path the filename on the server * @param queryString the query string for the request * @param out the OutputStream to write the file to * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server, AOServer, or HttpdSite * * @see HttpdSite#getAWStatsFile */ public void getAWStatsFile( String siteName, String aoServer, String path, String queryString, OutputStream out ) throws IllegalArgumentException, IOException, SQLException { getHttpdSite(aoServer, siteName).getAWStatsFile(path, queryString, out); } /** * Gets the name of the root Business in the tree of Businesses. * * @return the accounting code of the root Business * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * * @see BusinessTable#getRootAccounting */ public AccountingCode getRootBusiness() throws IOException, SQLException { return connector.getBusinesses().getRootAccounting(); } /** * Places a Ticket in the hold state. When in a hold state, a Ticket * is not being worked on because the support personnel are waiting for something out of their * immediate control. * * @param ticket_id the pkey of the Ticket * @param comments the details of the change * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Ticket, * TicketType, or BusinessAdministrator * * @see Ticket#actHoldTicket * @see #addTicket * @see Action */ /* public void holdTicket( int ticket_id, String comments ) throws IllegalArgumentException, IOException, SQLException { Ticket ti=connector.getTickets().get(ticket_id); if(ti==null) throw new IllegalArgumentException("Unable to find Ticket: "+ticket_id); ti.actHoldTicket(comments); }*/ /** * Initializes the password files for an HttpdSite. These files are * typically contained in /www/sitename/conf/passwd and * /www/sitename/conf/group. * * @param siteName the name of the site to initialize * @param aoServer the hostname of the AOServer * @param username the username granted access to the site * @param password the password for that username * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the AOServer or * HttpdSite * * @see HttpdSite#initializePasswdFile * @see #addHttpdTomcatStdSite */ /* public void initializeHttpdSitePasswdFile( String siteName, String aoServer, String username, String password ) { getHttpdSite(aoServer, siteName).initializePasswdFile(username, password); } */ private static final int numTables = SchemaTable.TableID.values().length; /** * Invalidates a table, causing all caches of the table to be removed and all configurations * based on the table to be reevaluated. * * @param tableID the ID of the AOServTable to invalidate * @param server the server that should be invalidated or null or "" for none, accepts ao_servers.hostname, servers.package||'/'||servers.name, or servers.pkey * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the table ID is invalid * * @see AOServConnector#invalidateTable * @see BusinessAdministrator#isActiveTableInvalidator */ public void invalidate( int tableID, String server ) throws IllegalArgumentException, SQLException, IOException { if(tableID<0 || tableID>=numTables) throw new IllegalArgumentException("Invalid table ID: "+tableID); Server se; if(server!=null && server.length()==0) server=null; if(server==null) se=null; else { se = connector.getServers().get(server); if(se==null) throw new IllegalArgumentException("Unable to find Server: "+server); } connector.invalidateTable(tableID, se==null ? -1 : se.pkey); } /** * Determines if an accounting code is available. * * @param accounting the accounting code * * @return true if the accounting code is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the accounting code is invalid * * @see BusinessTable#isAccountingAvailable * @see #checkAccounting * @see #addBusiness * @see #generateAccountingCode * @see Business */ public boolean isAccountingAvailable( AccountingCode accounting ) throws IllegalArgumentException, SQLException, IOException { return connector.getBusinesses().isAccountingAvailable(accounting); } /** * Determines if a BusinessAdministrator currently has a password set. * * @param username the username of the administrator * * @return if the BusinessAdministrator has a password set * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the BusinessAdministrator is not found * * @see BusinessAdministrator#arePasswordsSet * @see #setBusinessAdministratorPassword * @see BusinessAdministrator */ public boolean isBusinessAdministratorPasswordSet( String username ) throws IllegalArgumentException, IOException, SQLException { BusinessAdministrator ba=connector.getBusinessAdministrators().get(username); if(ba==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+username); return ba.arePasswordsSet()==PasswordProtected.ALL; } /** * Determines if a DNSZone is available. * * @param zone the zone in domain.tld. format * * @return true if the DNSZone is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the DNSZone is invalid * * @see DNSZoneTable#isDNSZoneAvailable * @see #addDNSZone * @see DNSZone */ public boolean isDNSZoneAvailable( String zone ) throws IllegalArgumentException, IOException, SQLException { return connector.getDnsZones().isDNSZoneAvailable(zone); } /** * Determines if an IPAddress is currently being used. * * @param ipAddress the IP address * * @return true if the IPAddress is in use * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the IPAddress * * @see IPAddress#isUsed * @see #setIPAddressPackage */ public boolean isIPAddressUsed( InetAddress ipAddress, String server, String net_device ) throws IllegalArgumentException, IOException, SQLException { return getIPAddress(server, net_device, ipAddress).isUsed(); } /** * Determines if a groupname is available. * * @param groupname the groupname * * @return true if the groupname is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the groupname is invalid * * @see LinuxGroupTable#isLinuxGroupNameAvailable * @see #addLinuxGroup * @see LinuxGroup */ public boolean isLinuxGroupNameAvailable( String groupname ) throws IllegalArgumentException, IOException, SQLException { checkLinuxGroupname(groupname); return connector.getLinuxGroups().isLinuxGroupNameAvailable(groupname); } /** * Determines if a LinuxServerAccount currently has a password set. * * @param username the username of the account * @param aoServer the server the account is hosted on * * @return if the LinuxServerAccount/code> has a password set * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the LinuxServerAccount is not found * * @see LinuxServerAccount#arePasswordsSet * @see #setLinuxServerAccountPassword * @see LinuxServerAccount */ public boolean isLinuxServerAccountPasswordSet( String username, String aoServer ) throws IllegalArgumentException, IOException, SQLException { return getLinuxServerAccount(aoServer, username).arePasswordsSet()==PasswordProtected.ALL; } /** * Determines if a LinuxServerAccount is currently in manual procmail mode. Manual * procmail mode is initiated when the header comment in the .procmailrc file is altered or removed. * * @param username the username of the account * @param aoServer the server the account is hosted on * * @return if the LinuxServerAccount/code> is in manual mode * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the LinuxServerAccount is not found * * @see LinuxServerAccount#isProcmailManual * @see LinuxServerAccount */ public int isLinuxServerAccountProcmailManual( String username, String aoServer ) throws IllegalArgumentException, IOException, SQLException { return getLinuxServerAccount(aoServer, username).isProcmailManual(); } /** * Determines if a MySQLDatabase name is available on the specified * Server. * * @param name the name of the database * @param aoServer the hostname of the Server * * @return true if the MySQLDatabase is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the database name is invalid or unable * to find the Server * * @see MySQLServer#isMySQLDatabaseNameAvailable * @see #checkMySQLDatabaseName */ public boolean isMySQLDatabaseNameAvailable( String name, String mysqlServer, String aoServer ) throws IllegalArgumentException, IOException, SQLException { checkMySQLDatabaseName(name); return getMySQLServer(aoServer, mysqlServer).isMySQLDatabaseNameAvailable(name); } /** * Determines if a MySQLServer name is available on the specified * Server. * * @param name the name of the MySQL server * @param aoServer the hostname of the Server * * @return true if the MySQLServer is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the server name is invalid or unable * to find the Server * * @see AOServer#isMySQLServerNameAvailable * @see #checkMySQLServerName */ public boolean isMySQLServerNameAvailable( String name, String aoServer ) throws IllegalArgumentException, IOException, SQLException { checkMySQLServerName(name); return getAOServer(aoServer).isMySQLServerNameAvailable(name); } /** * Determines if a MySQLServerUser currently has a password set. * * @param username the username of the account * @param aoServer the server the account is hosted on * * @return if the MySQLServerUser has a password set * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the MySQLServerUser is not found * * @see MySQLServerUser#arePasswordsSet * @see #setMySQLServerUserPassword * @see MySQLServerUser */ public boolean isMySQLServerUserPasswordSet( String username, String mysqlServer, String aoServer ) throws IllegalArgumentException, IOException, SQLException { return getMySQLServerUser(aoServer, mysqlServer, username).arePasswordsSet()==PasswordProtected.ALL; } /** * Determines if a Package name is available. * * @param packageName the name of the Package * * @return true if the Package name is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the Package name is invalid * * @see PackageTable#isPackageNameAvailable * @see #generatePackageName * @see #addPackage * @see Package */ public boolean isPackageNameAvailable( String packageName ) throws IllegalArgumentException, IOException, SQLException { checkPackageName(packageName); return connector.getPackages().isPackageNameAvailable(packageName); } /** * Determines if a PostgresDatabase name is available on the specified * Server. * * @param name the name of the database * @param postgresServer the name of the PostgreSQL server * @param aoServer the hostname of the Server * * @return true if the PostgresDatabase is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the database name is invalid or unable * to find the Server * * @see PostgresServer#isPostgresDatabaseNameAvailable * @see #checkPostgresDatabaseName */ public boolean isPostgresDatabaseNameAvailable( String name, String postgresServer, String aoServer ) throws IllegalArgumentException, IOException, SQLException { checkPostgresDatabaseName(name); return getPostgresServer(aoServer, postgresServer).isPostgresDatabaseNameAvailable(name); } /** * Determines if a PostgresServer name is available on the specified * Server. * * @param name the name of the PostgreSQL server * @param aoServer the hostname of the Server * * @return true if the PostgresServer is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the server name is invalid or unable * to find the Server * * @see AOServer#isPostgresServerNameAvailable * @see #checkPostgresServerName */ public boolean isPostgresServerNameAvailable( String name, String aoServer ) throws IllegalArgumentException, IOException, SQLException { checkPostgresServerName(name); return getAOServer(aoServer).isPostgresServerNameAvailable(name); } /** * Determines if a PostgresServerUser currently has a password set. * * @param username the username of the account * @param postgresServer the name of the PostgreSQL server * @param aoServer the server the account is hosted on * * @return if the PostgresServerUser has a password set * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the PostgresServerUser is not found * * @see PostgresServerUser#arePasswordsSet * @see #setPostgresServerUserPassword * @see PostgresServerUser */ public boolean isPostgresServerUserPasswordSet( String username, String postgresServer, String aoServer ) throws IllegalArgumentException, IOException, SQLException { return getPostgresServerUser(aoServer, postgresServer, username).arePasswordsSet()==PasswordProtected.ALL; } /** * Determines if a EmailDomain is available. * * @param domain the domain * @param aoServer the hostname of the server * * @return true if the EmailDomain is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the EmailDomain is invalid * * @see AOServer#isEmailDomainAvailable * @see #addEmailDomain * @see EmailDomain */ public boolean isEmailDomainAvailable( String domain, String aoServer ) throws IllegalArgumentException, IOException, SQLException { checkEmailDomain(domain); return getAOServer(aoServer).isEmailDomainAvailable(domain); } /** * Determines if a name is available for use as a HttpdSharedTomcat. * * @param name the name * * @return true if the name is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * * @see HttpdSharedTomcatTable#isSharedTomcatNameAvailable * @see #generateSharedTomcatName * @see HttpdSharedTomcat */ public boolean isSharedTomcatNameAvailable( String name ) throws IOException, SQLException{ return connector.getHttpdSharedTomcats().isSharedTomcatNameAvailable(name); } /** * Determines if a site name is available. * * @param siteName the site name * * @return true if the site name is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the site name is invalid * * @see HttpdSiteTable#isSiteNameAvailable */ public boolean isSiteNameAvailable( String siteName ) throws IllegalArgumentException, IOException, SQLException { checkSiteName(siteName); return connector.getHttpdSites().isSiteNameAvailable(siteName); } /** * Determines if a Username is available. * * @param username the username * * @return true if the Username is available * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if the Username is invalid * * @see UsernameTable#isUsernameAvailable * @see #addUsername * @see Username */ public boolean isUsernameAvailable( String username ) throws IllegalArgumentException, IOException, SQLException { checkUsername(username); return connector.getUsernames().isUsernameAvailable(username); } /** * Kills a Ticket. Once killed, a Ticket may not be modified in * any way. * * @param ticket_id the pkey of the Ticket * @param business_administrator the username of the BusinessAdministrator * making the change * @param comments the details of the change * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Ticket, * TicketType, or BusinessAdministrator * * @see Ticket#actKillTicket * @see #addTicket * @see Action */ /* public void killTicket( int ticket_id, String business_administrator, String comments ) throws IllegalArgumentException, IOException, SQLException { Ticket ti=connector.getTickets().get(ticket_id); if(ti==null) throw new IllegalArgumentException("Unable to find Ticket: "+ticket_id); BusinessAdministrator pe=connector.getBusinessAdministrators().get(business_administrator); if(pe==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+business_administrator); ti.actKillTicket(pe, comments); }*/ /** * Moves all resources for one Business from one Server * to another Server. * * @param business the accounting code of the Business * @param from the hostname of the Server to get all the resources from * @param to the hostname of the Server to place all the resources on * @param out an optional PrintWriter to send diagnostic output to * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Business or either * of the Servers * * @see Business#move */ public void moveBusiness( AccountingCode business, String from, String to, TerminalWriter out ) throws IllegalArgumentException, IOException, SQLException { getBusiness(business).move(getAOServer(from), getAOServer(to), out); } /** * Moves an IPAddress from one Server to another. * * @param ip_address the IP address to move * @param to_server the destination server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the IPAddress or * the Server * * @see IPAddress#moveTo */ public void moveIPAddress( InetAddress ip_address, String from_server, String from_net_device, String to_server ) throws IllegalArgumentException, IOException, SQLException { getIPAddress(from_server, from_net_device, ip_address).moveTo(getServer(to_server)); } /** * Times the latency of the communication with the server. * * @return the latency of the communication in milliseconds * * @see AOServConnector#ping */ public int ping() throws IOException, SQLException { return connector.ping(); } /** * Prints the contents of a DNSZone as used by the named process. * * @param zone the name of the DNSZone * @param out the PrintWriter to write to * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the DNSZone * * @see DNSZone#printZoneFile * @see #addDNSZone */ public void printZoneFile( String zone, PrintWriter out ) throws IllegalArgumentException, SQLException, IOException { getDNSZone(zone).printZoneFile(out); } /** * Reactivates a Ticket that is in the hold state. * * @param ticket_id the pkey of the Ticket * @param business_administrator the username of the BusinessAdministrator * making the change * @param comments the details of the change * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Ticket, * TicketType, or BusinessAdministrator * * @see Ticket#actReactivateTicket * @see #addTicket * @see Action */ /* public void reactivateTicket( int ticket_id, String business_administrator, String comments ) throws IllegalArgumentException, IOException, SQLException { Ticket ti=connector.getTickets().get(ticket_id); if(ti==null) throw new IllegalArgumentException("Unable to find Ticket: "+ticket_id); BusinessAdministrator pe=connector.getBusinessAdministrators().get(business_administrator); if(pe==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+business_administrator); ti.actReactivateTicket(pe, comments); }*/ /** * Refreshes the time window for SMTP server access by resetting the expiration to 24 hours from the current time. * * @param pkey the pkey of the EmailSmtpRelay * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailSmtpRelay * * @see EmailSmtpRelay#refresh * @see #addEmailSmtpRelay * @see EmailSmtpRelay */ public void refreshEmailSmtpRelay( int pkey, long minDuration ) throws IllegalArgumentException, IOException, SQLException { EmailSmtpRelay sr=connector.getEmailSmtpRelays().get(pkey); if(sr==null) throw new IllegalArgumentException("Unable to find EmailSmtpRelay: "+pkey); sr.refresh(minDuration); } /** * Removes a BlackholeEmailAddress from the system. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailDomain, * EmailAddress, or BlackholeEmailAddress * * @see BlackholeEmailAddress#remove */ public void removeBlackholeEmailAddress( String address, DomainName domain, String aoServer ) throws IllegalArgumentException, IOException, SQLException { EmailAddress addr=getEmailAddress(aoServer, domain, address); BlackholeEmailAddress bea=addr.getBlackholeEmailAddress(); if(bea==null) throw new IllegalArgumentException("Unable to find BlackholeEmailAddress: "+address+'@'+domain+" on "+aoServer); bea.remove(); if(addr.getCannotRemoveReasons().isEmpty() && !addr.isUsed()) addr.remove(); } /** * Removes a BusinessAdministrator from the system. * * @param username the username of the BusinessAdministrator * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username or * BusinessAdministrator * * @see BusinessAdministrator#remove * @see #addBusinessAdministrator */ public void removeBusinessAdministrator( String username ) throws IllegalArgumentException, IOException, SQLException { Username un=getUsername(username); BusinessAdministrator ba=un.getBusinessAdministrator(); if(ba==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+username); ba.remove(); } /** * Revokes a Businesses access to a Server. The server * must not have any resources allocated for the business, and the server must not * be the default server for the business. * * @param accounting the accounting code of the business * @param server the hostname of the server * * @exception IOException if unable to communicate with the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the business or server * * @see BusinessServer * @see BusinessServer#remove * @see #addBusinessServer * @see #setDefaultBusinessServer */ public void removeBusinessServer( AccountingCode accounting, String server ) throws IllegalArgumentException, IOException, SQLException { Business bu=getBusiness(accounting); Server se=getServer(server); BusinessServer bs=bu.getBusinessServer(se); if(bs==null) throw new IllegalArgumentException("Unable to find BusinessServer: accounting="+accounting+" and server="+server); bs.remove(); } /** * Removes a CreditCard. * * @param pkey the pkey of the CreditCard to remove * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the CreditCard * * @see CreditCard#remove */ public void removeCreditCard( int pkey ) throws IllegalArgumentException, SQLException, IOException { CreditCard cc=connector.getCreditCards().get(pkey); if(cc==null) throw new IllegalArgumentException("Unable to find CreditCard: "+pkey); cc.remove(); } /** * Removes a CvsRepository. * * @param aoServer the hostname of the Server * @param path the path of the repository * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or * CvsRepository * * @see CvsRepository#remove * @see #addCvsRepository * @see CvsRepository */ public void removeCvsRepository( String aoServer, String path ) throws IllegalArgumentException, IOException, SQLException { AOServer ao=getAOServer(aoServer); CvsRepository cr=ao.getCvsRepository(path); if(cr==null) throw new IllegalArgumentException("Unable to find CvsRepository: "+path+" on "+aoServer); cr.remove(); } /** * Removes one record from a DNSZone. * * @param pkey the pkey of the DNSRecord to remove * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the DNSRecord * * @see DNSRecord#remove * @see #addDNSRecord * @see DNSRecord */ public void removeDNSRecord( int pkey ) throws IllegalArgumentException, IOException, SQLException { DNSRecord nr=connector.getDnsRecords().get(pkey); if(nr==null) throw new IllegalArgumentException("Unable to find DNSRecord: "+pkey); nr.remove(); } public void removeDNSRecord( String zone, String domain, String type, String destination ) throws IllegalArgumentException, IOException, SQLException { DNSZone nz=getDNSZone(zone); // Must be a valid type DNSType nt=connector.getDnsTypes().get(type); if(nt==null) throw new IllegalArgumentException("Unable to find DNSType: "+type); // Must have a valid destination type nt.checkDestination(destination); // Find the record matching all four fields, should be one and *only* one DNSRecord found = null; for(DNSRecord record : nz.getDNSRecords(domain, nt)) { if(record.getDestination().equals(destination)) { if(found != null) throw new AssertionError("Duplicate DNSRecord: (" + zone + ", " + domain + ", " + type + ", " + destination + ")"); found = record; } } if(found == null) throw new AssertionError("Unable to find DNSRecord: (" + zone + ", " + domain + ", " + type + ", " + destination + ")"); found.remove(); } /** * Completely removes a DNSZone from the servers. * * @param zone the name of the DNSZone to remove * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the DNSZone * * @see DNSZone#remove * @see #addDNSZone * @see DNSZone */ public void removeDNSZone( String zone ) throws IllegalArgumentException, IOException, SQLException { getDNSZone(zone).remove(); } /** * Completely removes a DNSZone from the servers. * * @param zone the name of the DNSZone to remove * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the DNSZone * * @see DNSZone#remove * @see #addDNSZone * @see DNSZone */ public void setDNSZoneTTL( String zone, int ttl ) throws IllegalArgumentException, IOException, SQLException { getDNSZone(zone).setTTL(ttl); } /** * Removes an EmailAddress from the system. If the EmailAddress is used * by other resources, such as EmailListAddresses, those resources are also removed. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailDomain or * EmailAddress * * @see EmailAddress#remove * @see #addEmailForwarding * @see #addEmailListAddress * @see #addEmailPipeAddress * @see #addLinuxAccAddress */ public void removeEmailAddress( String address, DomainName domain, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getEmailAddress(aoServer, domain, address).remove(); } /** * Removes an EmailForwarding from the system. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * @param aoServer the hostname of the server that hosts this domain * @param destination the destination of the email forwarding * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailDomain, * EmailAddress, or EmailForwarding * * @see EmailForwarding#remove * @see #addEmailForwarding */ public void removeEmailForwarding( String address, DomainName domain, String aoServer, String destination ) throws IllegalArgumentException, IOException, SQLException { EmailAddress addr=getEmailAddress(aoServer, domain, address); EmailForwarding ef=addr.getEmailForwarding(destination); if(ef==null) throw new IllegalArgumentException("Unable to find EmailForwarding: "+address+'@'+domain+"->"+destination+" on "+aoServer); ef.remove(); if(addr.getCannotRemoveReasons().isEmpty() && !addr.isUsed()) addr.remove(); } /** * Removes an EmailList from the system. All EmailAddresses that are directed * to the list are also removed. The file that stores the list contents is removed from the file system. * * @param path the path of the EmailList to remove * @param aoServer the server that hosts this list * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailList * * @see EmailList#remove * @see #addEmailList */ public void removeEmailList( String path, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getEmailList(aoServer, path).remove(); } /** * Removes an EmailListAddress from the system. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * @param path the list the emails are sent to * @param aoServer the hostname of the server hosting the list * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailDomain, * EmailAddress, EmailList, or * EmailListAddress * * @see EmailListAddress#remove * @see #addEmailListAddress */ public void removeEmailListAddress( String address, DomainName domain, String path, String aoServer ) throws IllegalArgumentException, IOException, SQLException { EmailAddress addr=getEmailAddress(aoServer, domain, address); EmailList el=getEmailList(aoServer, path); EmailListAddress ela=addr.getEmailListAddress(el); if(ela==null) throw new IllegalArgumentException("Unable to find EmailListAddress: "+address+'@'+domain+"->"+path+" on "+aoServer); ela.remove(); if(addr.getCannotRemoveReasons().isEmpty() && !addr.isUsed()) addr.remove(); } /** * Removes an EmailPipe from the system. All EmailAddresses that are directed * to the pipe are also removed. * * @param pkey the pkey of the EmailPipe to remove * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailPipe * * @see EmailPipe#remove * @see #addEmailPipe */ public void removeEmailPipe( int pkey ) throws IllegalArgumentException, IOException, SQLException { EmailPipe ep=connector.getEmailPipes().get(pkey); if(ep==null) throw new IllegalArgumentException("Unable to find EmailPipe: "+pkey); ep.remove(); } /** * Removes an EmailPipeAddress from the system. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * @param pipe the pkey of the email pipe * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailDomain, * EmailAddress, EmailPipe, or * EmailPipeAddress * * @see EmailPipeAddress#remove * @see #addEmailPipeAddress */ public void removeEmailPipeAddress( String address, DomainName domain, int pipe ) throws IllegalArgumentException, IOException, SQLException { EmailPipe ep=connector.getEmailPipes().get(pipe); if(ep==null) throw new IllegalArgumentException("Unable to find EmailPipe: "+pipe); AOServer ao=ep.getAOServer(); EmailDomain sd=ao.getEmailDomain(domain); if(sd==null) throw new IllegalArgumentException("Unable to find EmailDomain: "+domain+" on "+ao.getHostname()); EmailAddress addr=connector.getEmailAddresses().getEmailAddress(address, sd); if(addr==null) throw new IllegalArgumentException("Unable to find EmailAddress: "+address+"@"+domain+" on "+ao.getHostname()); EmailPipeAddress epa=addr.getEmailPipeAddress(ep); if(epa==null) throw new IllegalArgumentException("Unable to find EmailPipeAddress: "+address+"@"+domain+"->"+ep); epa.remove(); if(addr.getCannotRemoveReasons().isEmpty() && !addr.isUsed()) addr.remove(); } /** * Removes the FTPGuestUser flag from a LinuxAccount, allowing access * to the server root directory. * * @param username the username of the FTPGuestUser * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the FTPGuestUser * * @see FTPGuestUser#remove * @see #addFTPGuestUser */ public void removeFTPGuestUser( String username ) throws IllegalArgumentException, IOException, SQLException { FTPGuestUser ftpUser=connector.getFtpGuestUsers().get(username); if(ftpUser==null) throw new IllegalArgumentException("Unable to find FTPGuestUser: "+username); ftpUser.remove(); } /** * Completely removes a HttpdSharedTomcat from the servers. * * @param name the name of the site * @param aoServer the server the site runs on * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the HttpdSharedTomcat * * @see HttpdSharedTomcat#remove * @see HttpdSharedTomcat */ public void removeHttpdSharedTomcat( String name, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getHttpdSharedTomcat(aoServer, name).remove(); } /** * Completely removes a HttpdSite from the servers. * * @param name the name of the site * @param aoServer the server the site runs on * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the HttpdSite * * @see HttpdSite#remove * @see HttpdSite */ public void removeHttpdSite( String name, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getHttpdSite(aoServer, name).remove(); } /** * Removes a HttpdSiteURL from the servers. * * @param pkey the pkey of the site URL * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the HttpdSiteURL * * @see HttpdSiteURL#remove */ public void removeHttpdSiteURL( int pkey ) throws IllegalArgumentException, IOException, SQLException { HttpdSiteURL hsu=connector.getHttpdSiteURLs().get(pkey); if(hsu==null) throw new IllegalArgumentException("Unable to find HttpdSiteURL: "+pkey); hsu.remove(); } /** * Removes a HttpdTomcatContext from the servers. * * @param pkey the pkey of the context * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the HttpdTomcatContext * * @see HttpdTomcatContext#remove */ public void removeHttpdTomcatContext( int pkey ) throws IllegalArgumentException, IOException, SQLException { HttpdTomcatContext htc=connector.getHttpdTomcatContexts().get(pkey); if(htc==null) throw new IllegalArgumentException("Unable to find HttpdTomcatContext: "+pkey); htc.remove(); } /** * Removes a HttpdTomcatDataSource from a HttpdTomcatContext. * * @param pkey the pkey of the data source * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the HttpdTomcatDataSource * * @see HttpdTomcatContext#remove */ public void removeHttpdTomcatDataSource( int pkey ) throws IllegalArgumentException, IOException, SQLException { HttpdTomcatDataSource htds=connector.getHttpdTomcatDataSources().get(pkey); if(htds==null) throw new IllegalArgumentException("Unable to find HttpdTomcatDataSource: "+pkey); htds.remove(); } /** * Removes a HttpdTomcatParameter from a HttpdTomcatContext. * * @param pkey the pkey of the parameter * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the HttpdTomcatParameter * * @see HttpdTomcatContext#remove */ public void removeHttpdTomcatParameter( int pkey ) throws IllegalArgumentException, IOException, SQLException { HttpdTomcatParameter htp=connector.getHttpdTomcatParameters().get(pkey); if(htp==null) throw new IllegalArgumentException("Unable to find HttpdTomcatParameter: "+pkey); htp.remove(); } /** * Removes a LinuxAccAddress from the system. * * @param address the part of the email address before the @ * @param domain the part of the email address after the @ * @param username the account the emails are sent to * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailDomain, * EmailAddress, Username, * LinuxAccount, or LinuxAccAddress * * @see LinuxAccAddress#remove * @see #addLinuxAccAddress */ public void removeLinuxAccAddress( String address, DomainName domain, String aoServer, String username ) throws IllegalArgumentException, IOException, SQLException { EmailAddress addr=getEmailAddress(aoServer, domain, address); LinuxServerAccount lsa=getLinuxServerAccount(aoServer, username); LinuxAccAddress laa=addr.getLinuxAccAddress(lsa); if(laa==null) throw new IllegalArgumentException("Unable to find LinuxAccAddress: "+address+'@'+domain+"->"+username+" on "+aoServer); laa.remove(); if(addr.getCannotRemoveReasons().isEmpty() && !addr.isUsed()) addr.remove(); } /** * Removes a LinuxAccount and all related data from the system. * * @param username the username of the LinuxAccount to remove * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxAccount * * @see LinuxAccount#remove * @see #addLinuxAccount */ public void removeLinuxAccount( String username ) throws IllegalArgumentException, IOException, SQLException { getLinuxAccount(username).remove(); } /** * Removes a LinuxGroup and all related data from the system. * * @param name the name of the LinuxGroup to remove * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxGroup * * @see LinuxGroup#remove * @see #addLinuxGroup */ public void removeLinuxGroup( String name ) throws IllegalArgumentException, IOException, SQLException { getLinuxGroup(name).remove(); } /** * Removes a LinuxAccount's access to a LinuxGroup. * * @param group the name of the LinuxGroup to remove access to * @param username the username of the LinuxAccount to remove access from * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxGroup, * LinuxAccount, or LinuxGroupAccount * * @see LinuxGroupAccount#remove * @see #addLinuxGroupAccount * @see #addLinuxGroup * @see #addLinuxAccount */ public void removeLinuxGroupAccount( String group, String username ) throws IllegalArgumentException, IOException, SQLException { LinuxGroup lg=getLinuxGroup(group); LinuxAccount la=getLinuxAccount(username); LinuxGroupAccount lga=connector.getLinuxGroupAccounts().getLinuxGroupAccount(group, username); if(lga==null) throw new IllegalArgumentException(username+" is not part of the "+group+" group"); lga.remove(); } /** * Removes a LinuxServerAccount from a Server. * * @param username the username of the LinuxServerAccount to remove * @param aoServer the hostname of the Server to remove the account from * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxAccount, * Server, or LinuxServerAccount * * @see LinuxServerAccount#remove * @see #addLinuxServerAccount */ public void removeLinuxServerAccount( String username, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getLinuxServerAccount(aoServer, username).remove(); } /** * Removes a LinuxServerGroup from a Server. * * @param group the name of the LinuxServerGroup to remove * @param aoServer the hostname of the AOServer * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxGroup, * Server, or LinuxServerGroup * * @see LinuxServerGroup#remove * @see #addLinuxServerGroup */ public void removeLinuxServerGroup( String group, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getLinuxServerGroup(aoServer, group).remove(); } /** * Removes a MySQLDatabase from the system. All related * MySQLDBUsers are also removed, and all data is removed * from the MySQL server. The data is not dumped or backed-up during * the removal, if a backup is desired, use dumpMySQLDatabase. * * @param name the name of the database * @param aoServer the server the database is hosted on * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or * MySQLDatabase * * @see MySQLDatabase#remove * @see #addMySQLDatabase * @see #dumpMySQLDatabase */ public void removeMySQLDatabase( String name, String mysqlServer, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getMySQLDatabase(aoServer, mysqlServer, name).remove(); } /** * Removes a MySQLDBUser from the system. The MySQLUser is * no longer allowed to access the MySQLDatabase. * * @param name the name of the MySQLDatabase * @param aoServer the hostname of the AOServer * @param username the username of the MySQLUser * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server, * MySQLDatabase, MySQLServerUser, or * MySQLDBUser * * @see MySQLDBUser#remove * @see #addMySQLDBUser */ public void removeMySQLDBUser( String name, String mysqlServer, String aoServer, String username ) throws IllegalArgumentException, IOException, SQLException { MySQLDatabase md=getMySQLDatabase(aoServer, mysqlServer, name); MySQLServerUser msu=getMySQLServerUser(aoServer, mysqlServer, username); MySQLDBUser mdu=md.getMySQLDBUser(msu); if(mdu==null) throw new IllegalArgumentException("Unable to find MySQLDBUser on MySQLServer "+mysqlServer+" on AOServer "+aoServer+" for MySQLDatabase named "+name+" and MySQLServerUser named "+username); mdu.remove(); } /** * Removes a MySQLServerUser from a the system.. The MySQLUser is * no longer allowed to access the Server. * * @param username the username of the MySQLServerUser * @param aoServer the hostname of the Server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or * MySQLServerUser * * @see MySQLServerUser#remove * @see #addMySQLServerUser */ public void removeMySQLServerUser( String username, String mysqlServer, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getMySQLServerUser(aoServer, mysqlServer, username).remove(); } /** * Removes a MySQLUser from a the system. All of the associated * MySQLServerUsers and MySQLDBUsers are also removed. * * @param username the username of the MySQLUser * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the MySQLUser * * @see MySQLUser#remove * @see #addMySQLUser * @see #removeMySQLServerUser */ public void removeMySQLUser( String username ) throws IllegalArgumentException, IOException, SQLException { getMySQLUser(username).remove(); } /** * Removes a NetBind from a the system. * * @param pkey the primary key of the NetBind * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the NetBind * * @see NetBind#remove */ public void removeNetBind( int pkey ) throws IllegalArgumentException, IOException, SQLException { getNetBind(pkey).remove(); } /** * Removes a PostgresDatabase from the system. All data is removed * from the PostgreSQL server. The data is not dumped or backed-up during * the removal, if a backup is desired, use dumpPostgresDatabase. * * @param name the name of the database * @param postgresServer the name of the PostgreSQL server * @param aoServer the server the database is hosted on * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or * PostgresDatabase * * @see PostgresDatabase#remove * @see #addPostgresDatabase * @see #dumpPostgresDatabase */ public void removePostgresDatabase( String name, String postgresServer, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getPostgresDatabase(aoServer, postgresServer, name).remove(); } /** * Removes a PostgresServerUser from a the system.. The PostgresUser is * no longer allowed to access the Server. * * @param username the username of the PostgresServerUser * @param postgresServer the name of the PostgreSQL server * @param aoServer the hostname of the Server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server or * PostgresServerUser * * @see PostgresServerUser#remove */ public void removePostgresServerUser( String username, String postgresServer, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getPostgresServerUser(aoServer, postgresServer, username).remove(); } /** * Removes a PostgresUser from a the system.. All of the associated * PostgresServerUsers are also removed. * * @param username the username of the PostgresUser * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the PostgresUser * * @see PostgresUser#remove * @see #addPostgresUser * @see #removePostgresServerUser */ public void removePostgresUser( String username ) throws IllegalArgumentException, IOException, SQLException { getPostgresUser(username).remove(); } /** * Removes an EmailDomain and all of its EmailAddresses. * * @param domain the name of the EmailDomain * @param aoServer the server hosting this domain * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailDomain * * @see EmailDomain#remove * @see #addEmailDomain * @see #removeEmailAddress */ public void removeEmailDomain( DomainName domain, String aoServer ) throws IllegalArgumentException, IOException, SQLException { getEmailDomain(aoServer, domain).remove(); } /** * Removes an EmailSMTPRelay from the system, revoking access to the SMTP * server from one IP address. * * @param pkey the pkey of the EmailDomain * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailSmtpRelay * * @see EmailSmtpRelay#remove * @see #addEmailSmtpRelay * @see #refreshEmailSmtpRelay */ public void removeEmailSmtpRelay( int pkey ) throws IllegalArgumentException, IOException, SQLException { EmailSmtpRelay sr=connector.getEmailSmtpRelays().get(pkey); if(sr==null) throw new IllegalArgumentException("Unable to find EmailSmtpRelay: "+pkey); sr.remove(); } /** * Removes a FileBackupSetting from the system. * * @param replication the pkey of the FailoverFileReplication * @param path the path of the setting * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the FailoverFileReplication or FileBackupSetting * * @see FileBackupSetting#remove * @see #addFileBackupSetting */ public void removeFileBackupSetting( int replication, String path ) throws IllegalArgumentException, IOException, SQLException { FailoverFileReplication ffr = getConnector().getFailoverFileReplications().get(replication); if(ffr==null) throw new IllegalArgumentException("Unable to find FailoverFileReplication: "+replication); FileBackupSetting fbs=ffr.getFileBackupSetting(path); if(fbs==null) throw new IllegalArgumentException("Unable to find FileBackupSetting: "+path+" on "+replication); fbs.remove(); } /** * Removes a MajordomoServer and all of its MajordomoLists. * * @param domain the name of the MajordomoServer * @param aoServer the server hosting the list * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server, * EmailDomain or MajordomoServer * * @see MajordomoServer#remove * @see #addMajordomoServer */ public void removeMajordomoServer( DomainName domain, String aoServer ) throws IllegalArgumentException, IOException, SQLException { EmailDomain sd=getEmailDomain(aoServer, domain); MajordomoServer ms=sd.getMajordomoServer(); if(ms==null) throw new IllegalArgumentException("Unable to find MajordomoServer: "+domain+" on "+aoServer); ms.remove(); } /** * Removes a Username from the system. * * @param username the username of the Username * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username * * @see Username#remove * @see #addUsername */ public void removeUsername( String username ) throws IllegalArgumentException, IOException, SQLException { getUsername(username).remove(); } /** * Restarts the Apache web server. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#restartApache */ public void restartApache(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).restartApache(); } /** * Restarts the cron doggie. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#restartCron */ public void restartCron(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).restartCron(); } /** * Restarts the MySQL database server. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see MySQLServer#restartMySQL */ public void restartMySQL(String mysqlServer, String aoServer) throws IllegalArgumentException, IOException, SQLException { getMySQLServer(aoServer, mysqlServer).restartMySQL(); } /** * Restarts the PostgreSQL database server. * * @param postgresServer the name of the PostgreSQL server * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see PostgresServer#restartPostgreSQL */ public void restartPostgreSQL(String postgresServer, String aoServer) throws IllegalArgumentException, IOException, SQLException { getPostgresServer(aoServer, postgresServer).restartPostgreSQL(); } /** * Restarts the X Font Server. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#restartXfs */ public void restartXfs(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).restartXfs(); } /** * Restarts the X Virtual Frame Buffer. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#restartXvfb */ public void restartXvfb(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).restartXvfb(); } /** * Sets the autoresponder behavior for a Linux server account. * * @param username the username of the account * @param aoServer the server the account is on * @param address the address part of the email address * @param domain the domain of the email address * @param subject the subject of the email * @param content the content of the email * @param enabled if the autoresponder is enabled or not * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailAddress or * the LinuxServerAccount * * @see LinuxServerAccount#setAutoresponder */ public void setAutoresponder( String username, String aoServer, String address, DomainName domain, String subject, String content, boolean enabled ) throws IllegalArgumentException, IOException, SQLException { LinuxServerAccount lsa=getLinuxServerAccount(aoServer, username); if(address==null) address=""; EmailDomain sd; EmailAddress ea; if(domain==null) { sd=null; if(address.length()>0) throw new IllegalArgumentException("Cannot have an address without a domain: "+address); ea=null; } else { sd=getEmailDomain(aoServer, domain); ea=sd.getEmailAddress(address); if(ea==null) throw new IllegalArgumentException("Unable to find EmailAddress: "+address+'@'+domain+" on "+aoServer); } if(subject!=null && subject.length()==0) subject=null; if(content!=null && content.length()==0) content=null; LinuxAccAddress laa=ea.getLinuxAccAddress(lsa); if(laa==null) throw new IllegalArgumentException("Unable to find LinuxAccAddress: "+address+" on "+aoServer); lsa.setAutoresponder(laa, subject, content, enabled); } /** * Sets the accounting code for the business. The accounting code is the value that uniquely * identifies an account within the system. * * @param oldAccounting the old accounting code * @param newAccounting the new accounting code * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Business or * the requested accounting code is not valid * * @see Business#setAccounting */ public void setBusinessAccounting( AccountingCode oldAccounting, AccountingCode newAccounting ) throws IllegalArgumentException, IOException, SQLException { getBusiness(oldAccounting).setAccounting(newAccounting); } /** * Sets the password for a BusinessAdministrator. This password must pass the security * checks provided by checkBusinessAdministratorPassword. * * @param username the username of the BusinessAdministrator * @param password the new password * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the BusinessAdministrator * * @see BusinessAdministrator#setPassword * @see #addBusinessAdministrator */ public void setBusinessAdministratorPassword( String username, String password ) throws IllegalArgumentException, IOException, SQLException { BusinessAdministrator pe=connector.getBusinessAdministrators().get(username); if(pe==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+username); pe.setPassword(password); } /** * Sets the profile of a BusinessAdministrator, which is all of their contact * information and other details. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the BusinessAdministrator * * @see BusinessAdministrator#setProfile * @see #addBusinessAdministrator */ public void setBusinessAdministratorProfile( String username, String name, String title, Date birthday, boolean isPrivate, String workPhone, String homePhone, String cellPhone, String fax, String email, String address1, String address2, String city, String state, String country, String zip ) throws IllegalArgumentException, IOException, SQLException { BusinessAdministrator business_administrator=connector.getBusinessAdministrators().get(username); if(business_administrator==null) throw new IllegalArgumentException("Unable to find BusinessAdministrator: "+username); business_administrator.setProfile( name, title, birthday, isPrivate, workPhone, homePhone, cellPhone, fax, email, address1, address2, city, state, country, zip ); } /** * Sets a user's cron table on one server. * * @param username the username of the LinuxAccount * @param aoServer the server to get the data from * @param cronTable the new cron table * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the source LinuxServerAccount * * @see LinuxServerAccount#setCronTable * @see #getCronTable * @see #addLinuxServerAccount * @see #removeLinuxServerAccount */ public void setCronTable( String username, String aoServer, String cronTable ) throws IOException, SQLException { getLinuxServerAccount(aoServer, username).setCronTable(cronTable); } /** * Sets the permissions for a CVS repository directory. * * @param aoServer the server the repository exists on * @param path the path of the server * @param mode the permission bits * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the source CvsRepository * * @see CvsRepository#setMode * @see #addCvsRepository * @see #removeCvsRepository */ public void setCvsRepositoryMode( String aoServer, String path, long mode ) throws IOException, SQLException { AOServer ao=getAOServer(aoServer); CvsRepository cr=ao.getCvsRepository(path); if(cr==null) throw new IllegalArgumentException("Unable to find CvsRepository: "+path+" on "+aoServer); cr.setMode(mode); } /** * Sets the default Server for a Business. * * @param accounting the accounting code of the business * @param server the hostname of the server * * @exception IOException if unable to communicate with the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the business or server * * @see BusinessServer * @see BusinessServer#setAsDefault * @see #addBusinessServer * @see #removeBusinessServer */ public void setDefaultBusinessServer( AccountingCode accounting, String server ) throws IllegalArgumentException, SQLException, IOException { Business bu=getBusiness(accounting); Server se=getServer(server); BusinessServer bs=bu.getBusinessServer(se); if(bs==null) throw new IllegalArgumentException("Unable to find BusinessServer: accounting="+accounting+" and server="+server); bs.setAsDefault(); } /** * Sets the list of addresses that an EmailList will forward messages * to. * * @param path the path of the EmailList * @param aoServer the server hosting the list * @param addresses the list of addresses, one address per line * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the EmailList * * @see EmailList#setAddressList * @see #getEmailListAddressList * @see #addEmailList */ public void setEmailListAddressList( String path, String aoServer, String addresses ) throws IllegalArgumentException, IOException, SQLException { getEmailList(aoServer, path).setAddressList(addresses); } /** * Sets the settings contained by one FileBackupSetting * * @param replication the hostname of the FailoverFileReplication * @param path the path of the setting * @param backupEnabled the enabled flag for the prefix * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the FailoverFileReplication or FileBackupSetting * * @see FileBackupSetting#setSettings * @see #addFileBackupSetting */ public void setFileBackupSetting( int replication, String path, boolean backupEnabled, boolean required ) throws IllegalArgumentException, IOException, SQLException { FailoverFileReplication ffr = getConnector().getFailoverFileReplications().get(replication); if(ffr==null) throw new IllegalArgumentException("Unable to find FailoverFileReplication: "+replication); FileBackupSetting fbs=ffr.getFileBackupSetting(path); if(fbs==null) throw new IllegalArgumentException("Unable to find FileBackupSetting: "+path+" on "+replication); fbs.setSettings( path, backupEnabled, required ); } /** * Sets the is_manual flag for a HttpdSharedTomcat * * @param name the name of the JVM * @param aoServer the hostname of the AOServer * @param isManual the new flag * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the AOServer or HttpdSharedTomcat * * @see HttpdSharedTomcat#setIsManual */ public void setHttpdSharedTomcatIsManual( String name, String aoServer, boolean isManual ) throws IllegalArgumentException, IOException, SQLException { getHttpdSharedTomcat(aoServer, name).setIsManual(isManual); } /** * Sets the is_manual flag for a HttpdSiteBind * * @param pkey the primary key of the HttpdSiteBind * @param isManual the new flag * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the HttpdSiteBind * * @see HttpdSiteBind#setIsManual */ public void setHttpdSiteBindIsManual( int pkey, boolean isManual ) throws IllegalArgumentException, IOException, SQLException { HttpdSiteBind hsb=connector.getHttpdSiteBinds().get(pkey); if(hsb==null) throw new IllegalArgumentException("Unable to find HttpdSiteBind: "+pkey); hsb.setIsManual(isManual); } /** * Sets the redirect_to_primary_hostname flag for a HttpdSiteBind * * @param pkey the primary key of the HttpdSiteBind * @param redirectToPrimaryHostname the new flag * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the HttpdSiteBind * * @see HttpdSiteBind#setRedirectToPrimaryHostname */ public void setHttpdSiteBindRedirectToPrimaryHostname( int pkey, boolean redirectToPrimaryHostname ) throws IllegalArgumentException, IOException, SQLException { HttpdSiteBind hsb=connector.getHttpdSiteBinds().get(pkey); if(hsb==null) throw new IllegalArgumentException("Unable to find HttpdSiteBind: "+pkey); hsb.setRedirectToPrimaryHostname(redirectToPrimaryHostname); } /** * Sets the is_manual flag for a HttpdSite * * @param siteName the name of the site * @param aoServer the hostname of the AOServer * @param isManual the new flag * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the AOServer or HttpdSite * * @see HttpdSite#setIsManual */ public void setHttpdSiteIsManual( String siteName, String aoServer, boolean isManual ) throws IllegalArgumentException, IOException, SQLException { getHttpdSite(aoServer, siteName).setIsManual(isManual); } /** * Sets the administrative email address for a HttpdSite. * * @param siteName the name of the HttpdSite * @param aoServer the hostname of the server that hosts the site * @param emailAddress the new adminstrative email address * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the AOServer or HttpdSite, * or the email address is not in a valid format * * @see HttpdSite#setServerAdmin */ public void setHttpdSiteServerAdmin( String siteName, String aoServer, String emailAddress ) throws IllegalArgumentException, IOException, SQLException { if(!EmailAddress.isValidEmailAddress(emailAddress)) throw new IllegalArgumentException("Invalid email address: "+emailAddress); getHttpdSite(aoServer, siteName).setServerAdmin(emailAddress); } /** * Sets the attributes for a HttpdTomcatContext. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the AOServer, HttpdSite, * or HttpdTomcatSite */ public void setHttpdTomcatContextAttributes( String siteName, String aoServer, String oldPath, String className, boolean cookies, boolean crossContext, String docBase, boolean override, String newPath, boolean privileged, boolean reloadable, boolean useNaming, String wrapperClass, int debug, String workDir ) throws IllegalArgumentException, IOException, SQLException { HttpdSite hs=getHttpdSite(aoServer, siteName); HttpdTomcatSite hts=hs.getHttpdTomcatSite(); if(hts==null) throw new IllegalArgumentException("Unable to find HttpdTomcatSite: "+siteName+" on "+aoServer); HttpdTomcatContext htc=hts.getHttpdTomcatContext(oldPath); if(htc==null) throw new IllegalArgumentException("Unable to find HttpdTomcatContext: "+siteName+" on "+aoServer+" path='"+oldPath+'\''); htc.setAttributes( className, cookies, crossContext, docBase, override, newPath, privileged, reloadable, useNaming, wrapperClass, debug, workDir ); } /** * Sets the hostname of an IPAddress. * * @param ipAddress the IPAddress being modified * @param hostname the new hostname * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the IPAddress or * hostname is not valid format * * @see IPAddress#setHostname * @see EmailDomain#isValidFormat */ public void setIPAddressHostname( InetAddress ipAddress, String server, String net_device, DomainName hostname ) throws IllegalArgumentException, IOException, SQLException { getIPAddress(server, net_device, ipAddress).setHostname(hostname); } /** * Sets the IP address of a DHCP-enabled IPAddress. * * @param ipAddress the pkey of the IPAddress * @param dhcpAddress the new IP address * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the IPAddress or * DHCP address is not valid format * * @see IPAddress#setDHCPAddress * @see EmailDomain#isValidFormat */ public void setIPAddressDHCPAddress( int ipAddress, InetAddress dhcpAddress ) throws IllegalArgumentException, IOException, SQLException { IPAddress ia=connector.getIpAddresses().get(ipAddress); if(ia==null) throw new IllegalArgumentException("Unable to find IPAddress: "+ipAddress); ia.setDHCPAddress(dhcpAddress); } /** * Sets the ownership of a IPAddress. The Package may only be set * if the IPAddress is not being used by any resources. * * @param ipAddress the IPAddress being modified * @param newPackage the name of the Package * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the IPAddress or * Package * * @see IPAddress#setPackage * @see #addPackage */ public void setIPAddressPackage( InetAddress ipAddress, String server, String net_device, String newPackage ) throws IllegalArgumentException, IOException, SQLException { getIPAddress(server, net_device, ipAddress).setPackage(getPackage(newPackage)); } /** * Sets the home phone number associated with a LinuxAccount. * * @param username the username of the LinuxAccount * @param phone the new office phone * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxAccount * * @see LinuxAccount#setHomePhone * @see #addLinuxAccount */ public void setLinuxAccountHomePhone( String username, Gecos phone ) throws IllegalArgumentException, IOException, SQLException { getLinuxAccount(username).setHomePhone(phone); } /** * Sets the full name associated with a LinuxAccount. * * @param username the username of the LinuxAccount * @param name the new full name for the account * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the name is not in a valid format or unable to * find the LinuxAccount * * @see LinuxAccount#setName * @see LinuxAccount#checkGECOS * @see #addLinuxAccount */ public void setLinuxAccountName( String username, Gecos name ) throws IllegalArgumentException, IOException, SQLException { getLinuxAccount(username).setName(name); } /** * Sets the office location associated with a LinuxAccount. * * @param username the username of the LinuxAccount * @param location the new office location * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxAccount * * @see LinuxAccount#setOfficeLocation * @see #addLinuxAccount */ public void setLinuxAccountOfficeLocation( String username, Gecos location ) throws IllegalArgumentException, IOException, SQLException { getLinuxAccount(username).setOfficeLocation(location); } /** * Sets the office phone number associated with a LinuxAccount. * * @param username the username of the LinuxAccount * @param phone the new office phone * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxAccount * * @see LinuxAccount#setOfficePhone * @see #addLinuxAccount */ public void setLinuxAccountOfficePhone( String username, Gecos phone ) throws IllegalArgumentException, IOException, SQLException { getLinuxAccount(username).setOfficePhone(phone); } /** * Sets the password for a LinuxAccount by setting the password * for each one of its LinuxServerAccounts. * * @param username the username of the LinuxAccount * @param password the new password * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxAccount * * @see LinuxAccount#setPassword * @see #addLinuxAccount */ public void setLinuxAccountPassword( String username, String password ) throws IllegalArgumentException, IOException, SQLException { getLinuxAccount(username).setPassword(password); } /** * Sets the shell used by a LinuxAccount. * * @param username the username of the LinuxAccount * @param path the full path of the shell * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the LinuxAccount or Shell * * @see LinuxAccount#setShell * @see #addLinuxAccount */ public void setLinuxAccountShell( String username, String path ) throws IllegalArgumentException, IOException, SQLException { LinuxAccount la=getLinuxAccount(username); Shell sh=connector.getShells().get(path); if(sh==null) throw new IllegalArgumentException("Unable to find Shell: "+path); la.setShell(sh); } /** * Sets the password for a LinuxServerAccount. * * @param username the username of the LinuxServerAccount * @param aoServer the hostname of the AOServer * @param password the new password * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Server, AOServer or * LinuxServerAccount * * @see LinuxServerAccount#setPassword * @see #addLinuxServerAccount */ public void setLinuxServerAccountPassword( String username, String aoServer, String password ) throws IllegalArgumentException, IOException, SQLException { getLinuxServerAccount(aoServer, username).setPassword(password); } /** * Sets the number of days junk email is kept. * * @param username the username of the LinuxServerAccount * @param aoServer the hostname of the Server * @param days the new number of days, -1 causes the junk to not be automatically removed * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the Server or LinuxServerAccount * * @see LinuxServerAccount#setJunkEmailRetention * @see #addLinuxServerAccount */ public void setLinuxServerAccountJunkEmailRetention( String username, String aoServer, int days ) throws IllegalArgumentException, IOException, SQLException { getLinuxServerAccount(aoServer, username).setJunkEmailRetention(days); } /** * Sets the SpamAssassin integration mode for an email account. * * @param username the username of the LinuxServerAccount * @param aoServer the hostname of the Server * @param mode the new mode * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the Server, LinuxServerAccount, or EmailSpamAssassinIntegrationMode * * @see LinuxServerAccount#setEmailSpamAssassinIntegrationMode * @see #addLinuxServerAccount * @see EmailSpamAssassinIntegrationMode */ public void setLinuxServerAccountSpamAssassinIntegrationMode( String username, String aoServer, String mode ) throws IllegalArgumentException, IOException, SQLException { getLinuxServerAccount(aoServer, username).setEmailSpamAssassinIntegrationMode(getEmailSpamAssassinIntegrationMode(mode)); } /** * Sets the SpamAssassin required score for an email account. * * @param username the username of the LinuxServerAccount * @param aoServer the hostname of the Server * @param required_score the new required score * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the Server or LinuxServerAccount * * @see LinuxServerAccount#setSpamAssassinRequiredScore * @see #addLinuxServerAccount */ public void setLinuxServerAccountSpamAssassinRequiredScore( String username, String aoServer, float required_score ) throws IllegalArgumentException, IOException, SQLException { getLinuxServerAccount(aoServer, username).setSpamAssassinRequiredScore(required_score); } /** * Sets the number of days trash email is kept. * * @param username the username of the LinuxServerAccount * @param aoServer the hostname of the Server * @param days the new number of days, -1 causes the trash to not be automatically removed * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the Server or LinuxServerAccount * * @see LinuxServerAccount#setTrashEmailRetention * @see #addLinuxServerAccount */ public void setLinuxServerAccountTrashEmailRetention( String username, String aoServer, int days ) throws IllegalArgumentException, IOException, SQLException { getLinuxServerAccount(aoServer, username).setTrashEmailRetention(days); } /** * Sets the use_inbox flag on a LinuxServerAccount. * * @param username the username of the LinuxServerAccount * @param aoServer the hostname of the Server * @param useInbox the new flag * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the Server or LinuxServerAccount * * @see LinuxServerAccount#setUseInbox * @see LinuxServerAccount#useInbox * @see #addLinuxServerAccount */ public void setLinuxServerAccountUseInbox( String username, String aoServer, boolean useInbox ) throws IllegalArgumentException, IOException, SQLException { getLinuxServerAccount(aoServer, username).setUseInbox(useInbox); } /** * Sets the info file for a MajordomoList. * * @param domain the domain of the MajordomoServer * @param aoServer the hostname of the Server * @param listName the name of the new list * @param file the new file contents * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if the name is not valid or unable to find the * Server, code>EmailDomain, * MajordomoServer, or MajordomoList * * @see MajordomoList#setInfoFile * @see #addMajordomoList * @see #removeEmailList */ public void setMajordomoInfoFile( DomainName domain, String aoServer, String listName, String file ) throws IllegalArgumentException, IOException, SQLException { EmailDomain ed=getEmailDomain(aoServer, domain); MajordomoServer ms=ed.getMajordomoServer(); if(ms==null) throw new IllegalArgumentException("Unable to find MajordomoServer: "+domain+" on "+aoServer); MajordomoList ml=ms.getMajordomoList(listName); if(ml==null) throw new IllegalArgumentException("Unable to find MajordomoList: "+listName+'@'+domain+" on "+aoServer); ml.setInfoFile(file); } /** * Sets the intro file for a MajordomoList. * * @param domain the domain of the MajordomoServer * @param aoServer the hostname of the AOServer * @param listName the name of the new list * @param file the new file contents * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data * integrity violation occurs * @exception IllegalArgumentException if the name is not valid or unable to find the * Server, code>EmailDomain, * MajordomoServer, or MajordomoList * * @see MajordomoList#setIntroFile * @see #addMajordomoList * @see #removeEmailList */ public void setMajordomoIntroFile( DomainName domain, String aoServer, String listName, String file ) throws IllegalArgumentException, IOException, SQLException { EmailDomain ed=getEmailDomain(aoServer, domain); MajordomoServer ms=ed.getMajordomoServer(); if(ms==null) throw new IllegalArgumentException("Unable to find MajordomoServer: "+domain+" on "+aoServer); MajordomoList ml=ms.getMajordomoList(listName); if(ml==null) throw new IllegalArgumentException("Unable to find MajordomoList: "+listName+'@'+domain+" on "+aoServer); ml.setIntroFile(file); } /** * Sets the password for a MySQLServerUser. * * @param username the username of the MySQLServerUser * @param aoServer the hostname of the AOServer * @param password the new password * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the MySQLUser, * Server, or MySQLServerUser * * @see MySQLServerUser#setPassword */ public void setMySQLServerUserPassword( String username, String mysqlServer, String aoServer, String password ) throws IllegalArgumentException, IOException, SQLException { getMySQLServerUser(aoServer, mysqlServer, username).setPassword(password==null || password.length()==0?null:password); } /** * Sets the password for a MySQLUser by settings the password for * all of its MySQLServerUsers. * * @param username the username of the MySQLUser * @param password the new password * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the MySQLUser * * @see MySQLUser#setPassword */ public void setMySQLUserPassword( String username, String password ) throws IllegalArgumentException, IOException, SQLException { getMySQLUser(username).setPassword(password==null || password.length()==0?null:password); } /** * Sets the firewall status for a NetBind * * @param pkey the pkey of the NetBind * @param open_firewall the new firewall state * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the NetBind * * @see NetBind#setOpenFirewall */ public void setNetBindOpenFirewall( int pkey, boolean open_firewall ) throws IllegalArgumentException, IOException, SQLException { getNetBind(pkey).setOpenFirewall(open_firewall); } /** * Sets the monitoring status for a NetBind * * @param pkey the pkey of the NetBind * @param enabled the new monitoring state * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity violation occurs * @exception IllegalArgumentException if unable to find the NetBind * * @see NetBind#setMonitoringEnabled */ public void setNetBindMonitoringEnabled( int pkey, boolean enabled ) throws IllegalArgumentException, IOException, SQLException { getNetBind(pkey).setMonitoringEnabled(enabled); } /** * Sets the password for a PostgresServerUser. * * @param username the username of the PostgresServerUser * @param postgresServer the name of the PostgreSQL server * @param aoServer the hostname of the Server * @param password the new password * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the PostgresUser, * Server, or PostgresServerUser * * @see PostgresServerUser#setPassword */ public void setPostgresServerUserPassword( String username, String postgresServer, String aoServer, String password ) throws IllegalArgumentException, IOException, SQLException { getPostgresServerUser(aoServer, postgresServer, username).setPassword(password==null || password.length()==0?null:password); } /** * Sets the password for a PostgresUser by settings the password for * all of its PostgresServerUsers. * * @param username the username of the PostgresUser * @param password the new password * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the PostgresUser * * @see PostgresUser#setPassword */ public void setPostgresUserPassword( String username, String password ) throws IllegalArgumentException, IOException, SQLException { getPostgresUser(username).setPassword(password==null || password.length()==0?null:password); } /** * Sets the primary URL for a HttpdSiteBind. * * @param pkey the pkey of the HttpdSiteURL * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the HttpdSiteURL * * @see HttpdSiteURL#setAsPrimary() */ public void setPrimaryHttpdSiteURL( int pkey ) throws IllegalArgumentException, IOException, SQLException { HttpdSiteURL hsu=connector.getHttpdSiteURLs().get(pkey); if(hsu==null) throw new IllegalArgumentException("Unable to find HttpdSiteURL: "+pkey); hsu.setAsPrimary(); } /** * Sets the primary group for a LinuxAccount. * * @param group_name the name of the LinuxGroup * @param username the username of the LinuxAccount * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if the name is not in a valid format or unable to * find the LinuxAccount * * @see LinuxAccount#setPrimaryLinuxGroup */ public void setPrimaryLinuxGroupAccount( String group_name, String username ) throws IllegalArgumentException, IOException, SQLException { getLinuxAccount(username).setPrimaryLinuxGroup(getLinuxGroup(group_name)); } /** * Sets the password for a Username. This password must pass the security * checks provided by checkUsernamePassword. * * @param username the username * @param password the new password * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the Username * * @see Username#setPassword * @see #checkUsernamePassword * @see #addUsername */ public void setUsernamePassword( String username, String password ) throws IllegalArgumentException, IOException, SQLException { getUsername(username).setPassword(password); } /** * Starts the Apache web server if it is not already running. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#startApache */ public void startApache(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).startApache(); } /** * Starts the cron process if it is not already running. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#startCron */ public void startCron(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).startCron(); } /** * Starts the distribution on a server and/or changes the setting of the user file scanning. * * @param aoServer the public hostname of the AOServer to start the scan on * @param includeUser the flag indicating whether to include user files * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server * * @see AOServer#startDistro */ public void startDistro(String aoServer, boolean includeUser) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).startDistro(includeUser); } /** * Starts and/or restarts the Tomcat or JBoss Java VM for the provided site. * * @param siteName the name of the site, which is the directory name under /www/ * @param aoServer the public hostname of the AOServer the site is hosted on * * @return an error message if the Java VM cannot currently be restarted or * null on success * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the AOServer, * HttpdSite, or HttpdTomcatSite * * @see HttpdTomcatSite#startJVM * @see #addHttpdTomcatStdSite */ public String startJVM(String siteName, String aoServer) throws IllegalArgumentException, IOException, SQLException { HttpdSite site=getHttpdSite(aoServer, siteName); HttpdTomcatSite tomcatSite=site.getHttpdTomcatSite(); if(tomcatSite==null) throw new IllegalArgumentException("HttpdSite "+siteName+" on "+aoServer+" is not a HttpdTomcatSite"); return tomcatSite.startJVM(); } /** * Starts the MySQL database server if it is not already running. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see MySQLServer#startMySQL */ public void startMySQL(String mysqlServer, String aoServer) throws IllegalArgumentException, IOException, SQLException { getMySQLServer(aoServer, mysqlServer).startMySQL(); } /** * Starts the PostgreSQL database server if it is not already running. * * @param postgresServer the name of the PostgreSQL server * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see PostgresServer#startPostgreSQL */ public void startPostgreSQL(String postgresServer, String aoServer) throws IllegalArgumentException, IOException, SQLException { getPostgresServer(aoServer, postgresServer).startPostgreSQL(); } /** * Starts the X Font Server if it is not already running. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#startXfs */ public void startXfs(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).startXfs(); } /** * Starts the X Virtual Frame Buffer if it is not already running. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#startXvfb */ public void startXvfb(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).startXvfb(); } /** * Stops the Apache web server if it is running. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#stopApache */ public void stopApache(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).stopApache(); } /** * Stops the cron daemon if it is running. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#stopCron */ public void stopCron(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).stopCron(); } /** * Stops the Tomcat or JBoss Java VM for the provided site. * * @param siteName the name of the site, which is the directory name under /www/ * @param aoServer the public hostname of the AOServer the site is hosted on * * @return an error message if the Java VM cannot currently be stopped * null on success * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the AOServer, * HttpdSite, or HttpdTomcatSite * * @see HttpdTomcatSite#stopJVM * @see #addHttpdTomcatStdSite */ public String stopJVM(String siteName, String aoServer) throws IllegalArgumentException, IOException, SQLException { HttpdSite site=getHttpdSite(aoServer, siteName); HttpdTomcatSite tomcatSite=site.getHttpdTomcatSite(); if(tomcatSite==null) throw new IllegalArgumentException("HttpdSite "+siteName+" on "+aoServer+" is not a HttpdTomcatSite"); return tomcatSite.stopJVM(); } /** * Stops the MySQL database server if it is running. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see MySQLServer#stopMySQL */ public void stopMySQL(String mysqlServer, String aoServer) throws IllegalArgumentException, IOException, SQLException { getMySQLServer(aoServer, mysqlServer).stopMySQL(); } /** * Stops the PostgreSQL database server if it is running. * * @param postgresServer the name of the PostgreSQL server * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see PostgresServer#stopPostgreSQL */ public void stopPostgreSQL(String postgresServer, String aoServer) throws IllegalArgumentException, IOException, SQLException { getPostgresServer(aoServer, postgresServer).stopPostgreSQL(); } /** * Stops the X Font Server if it is running. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#stopXfs */ public void stopXfs(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).stopXfs(); } /** * Stops the X Virtual Frame Buffer if it is running. * * @param aoServer the public hostname of the AOServer * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#stopXvfb */ public void stopXvfb(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).stopXvfb(); } /** * Updates a HttpdTomcatContext data source. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server, HttpdSite, * HttpdTomcatSite or HttpdTomcatContext. */ public void updateHttpdTomcatDataSource( String siteName, String aoServer, String path, String oldName, String newName, String driverClassName, String url, String username, String password, int maxActive, int maxIdle, int maxWait, String validationQuery ) throws IllegalArgumentException, IOException, SQLException { HttpdSite hs=getHttpdSite(aoServer, siteName); HttpdTomcatSite hts=hs.getHttpdTomcatSite(); if(hts==null) throw new IllegalArgumentException("Unable to find HttpdTomcatSite: "+siteName+" on "+aoServer); HttpdTomcatContext htc=hts.getHttpdTomcatContext(path); if(htc==null) throw new IllegalArgumentException("Unable to find HttpdTomcatContext: "+siteName+" on "+aoServer+" path='"+path+'\''); HttpdTomcatDataSource htds=htc.getHttpdTomcatDataSource(oldName); if(htds==null) throw new IllegalArgumentException("Unable to find HttpdTomcatDataSource: "+siteName+" on "+aoServer+" path='"+path+"' name='"+oldName+'\''); htds.update( newName, driverClassName, url, username, password, maxActive, maxIdle, maxWait, validationQuery ); } /** * Updates a HttpdTomcatContext parameter. * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server, HttpdSite, * HttpdTomcatSite or HttpdTomcatContext. */ public void updateHttpdTomcatParameter( String siteName, String aoServer, String path, String oldName, String newName, String value, boolean override, String description ) throws IllegalArgumentException, IOException, SQLException { HttpdSite hs=getHttpdSite(aoServer, siteName); HttpdTomcatSite hts=hs.getHttpdTomcatSite(); if(hts==null) throw new IllegalArgumentException("Unable to find HttpdTomcatSite: "+siteName+" on "+aoServer); HttpdTomcatContext htc=hts.getHttpdTomcatContext(path); if(htc==null) throw new IllegalArgumentException("Unable to find HttpdTomcatContext: "+siteName+" on "+aoServer+" path='"+path+'\''); HttpdTomcatParameter htp=htc.getHttpdTomcatParameter(oldName); if(htp==null) throw new IllegalArgumentException("Unable to find HttpdTomcatParameter: "+siteName+" on "+aoServer+" path='"+path+"' name='"+oldName+'\''); htp.update( newName, value, override, description ); } /** * Waits for any processing or pending updates of the Apache configurations to complete. * * @param aoServer the hostname of the AOServer to wait for * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#waitForHttpdSiteRebuild * @see #addHttpdTomcatStdSite */ public void waitForHttpdSiteRebuild(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).waitForHttpdSiteRebuild(); } /** * Waits for any processing or pending updates of the Linux account configurations to complete. * * @param aoServer the hostname of the AOServer to wait for * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#waitForLinuxAccountRebuild */ public void waitForLinuxAccountRebuild(String aoServer) throws IOException, SQLException { getAOServer(aoServer).waitForLinuxAccountRebuild(); } /** * Waits for any processing or pending updates of the MySQL configurations to complete. * * @param aoServer the hostname of the AOServer to wait for * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#waitForMySQLDatabaseRebuild */ public void waitForMySQLDatabaseRebuild(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).waitForMySQLDatabaseRebuild(); } /** * Waits for any processing or pending updates of the MySQL configurations to complete. * * @param aoServer the hostname of the AOServer to wait for * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#waitForMySQLDBUserRebuild */ public void waitForMySQLDBUserRebuild(String aoServer) throws IOException, SQLException { getAOServer(aoServer).waitForMySQLDBUserRebuild(); } /** * Waits for any processing or pending updates of the MySQL server configurations to complete. * * @param aoServer the hostname of the AOServer to wait for * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#waitForMySQLServerRebuild */ public void waitForMySQLServerRebuild(String aoServer) throws IOException, SQLException { getAOServer(aoServer).waitForMySQLServerRebuild(); } /** * Waits for any processing or pending updates of the MySQL configurations to complete. * * @param aoServer the hostname of the AOServer to wait for * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#waitForMySQLUserRebuild */ public void waitForMySQLUserRebuild(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).waitForMySQLUserRebuild(); } /** * Waits for any processing or pending updates of the PostgreSQL configurations to complete. * * @param aoServer the hostname of the AOServer to wait for * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#waitForPostgresDatabaseRebuild */ public void waitForPostgresDatabaseRebuild(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).waitForPostgresDatabaseRebuild(); } /** * Waits for any processing or pending updates of the PostgreSQL server configurations to complete. * * @param aoServer the hostname of the AOServer to wait for * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#waitForPostgresServerRebuild */ public void waitForPostgresServerRebuild(String aoServer) throws IllegalArgumentException, IOException, SQLException { getAOServer(aoServer).waitForPostgresServerRebuild(); } /** * Waits for any processing or pending updates of the PostgreSQL configurations to complete. * * @param aoServer the hostname of the AOServer to wait for * * @exception IOException if not able to communicate with the server * @exception SQLException if not able to access the database * @exception IllegalArgumentException if unable to find the Server or AOServer * * @see AOServer#waitForPostgresUserRebuild */ public void waitForPostgresUserRebuild(String aoServer) throws IOException, SQLException { getAOServer(aoServer).waitForPostgresUserRebuild(); } /** * @see VirtualServer#create() * * @param virtualServer the pkey, package/name, or hostname of the virtual server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or VirtualServer */ public String createVirtualServer( String virtualServer ) throws IllegalArgumentException, IOException, SQLException { return getVirtualServer(virtualServer).create(); } /** * @see VirtualServer#reboot() * * @param virtualServer the pkey, package/name, or hostname of the virtual server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or VirtualServer */ public String rebootVirtualServer( String virtualServer ) throws IllegalArgumentException, IOException, SQLException { return getVirtualServer(virtualServer).reboot(); } /** * @see VirtualServer#shutdown() * * @param virtualServer the pkey, package/name, or hostname of the virtual server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or VirtualServer */ public String shutdownVirtualServer( String virtualServer ) throws IllegalArgumentException, IOException, SQLException { return getVirtualServer(virtualServer).shutdown(); } /** * @see VirtualServer#destroy() * * @param virtualServer the pkey, package/name, or hostname of the virtual server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or VirtualServer */ public String destroyVirtualServer( String virtualServer ) throws IllegalArgumentException, IOException, SQLException { return getVirtualServer(virtualServer).destroy(); } /** * @see VirtualServer#pause() * * @param virtualServer the pkey, package/name, or hostname of the virtual server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or VirtualServer */ public String pauseVirtualServer( String virtualServer ) throws IllegalArgumentException, IOException, SQLException { return getVirtualServer(virtualServer).pause(); } /** * @see VirtualServer#unpause() * * @param virtualServer the pkey, package/name, or hostname of the virtual server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or VirtualServer */ public String unpauseVirtualServer( String virtualServer ) throws IllegalArgumentException, IOException, SQLException { return getVirtualServer(virtualServer).unpause(); } /** * @see VirtualServer#getStatus() * * @param virtualServer the pkey, package/name, or hostname of the virtual server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or VirtualServer */ public int getVirtualServerStatus( String virtualServer ) throws IllegalArgumentException, IOException, SQLException { return getVirtualServer(virtualServer).getStatus(); } /** * @see IpReputationSet#addReputation(int, com.aoindustries.aoserv.client.IpReputationSet.ConfidenceType, com.aoindustries.aoserv.client.IpReputationSet.ReputationType, short) * * @param identifier the unique identifier of the set * @param host the dotted-quad (A.B.C.D) format IPv4 address * @param confidence either "uncertain" or "definite" * @param reputationType either "good" or "bad" * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the IpReputationSet or unable to parse parameters */ public void addIpReputation( String identifier, String host, String confidence, String reputationType, short score ) throws IllegalArgumentException, IOException, SQLException { IpReputationSet set = getIpReputationSet(identifier); int hostIp = IPAddress.getIntForIPAddress(host); set.addReputation( hostIp, IpReputationSet.ConfidenceType.valueOf(confidence.toUpperCase(Locale.ROOT)), IpReputationSet.ReputationType.valueOf(reputationType.toUpperCase(Locale.ROOT)), score ); } /** * Begins a verification of the redundancy of the virtual disk. * * @param virtualServer the pkey, package/name, or hostname of the virtual server * @param device the device identifier (xvda, xvdb, ...) * * @return The time the verification began, which may be in the past if a verification was already in progress * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database or a data integrity * violation occurs * @exception IllegalArgumentException if unable to find the VirtualServer or * VirtualDisk * * @see VirtualDisk#verify() */ public long verifyVirtualDisk( String virtualServer, String device ) throws IllegalArgumentException, IOException, SQLException { return getVirtualDisk(virtualServer, device).verify(); } /** * @see VirtualServer#getPrimaryPhysicalServer() * * @param virtualServer the pkey, package/name, or hostname of the virtual server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or VirtualServer */ public String getPrimaryVirtualServer( String virtualServer ) throws IllegalArgumentException, IOException, SQLException { return getVirtualServer(virtualServer) .getPrimaryPhysicalServer() .toString() ; } /** * @see VirtualServer#getSecondaryPhysicalServer() * * @param virtualServer the pkey, package/name, or hostname of the virtual server * * @exception IOException if unable to contact the server * @exception SQLException if unable to access the database * @exception IllegalArgumentException if unable to find the Server or VirtualServer */ public String getSecondaryVirtualServer( String virtualServer ) throws IllegalArgumentException, IOException, SQLException { return getVirtualServer(virtualServer) .getSecondaryPhysicalServer() .toString() ; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy