com.aoindustries.aoserv.client.HttpdSharedTomcatTable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aoserv-client Show documentation
Show all versions of aoserv-client Show documentation
Java client for the AOServ Platform.
/*
* aoserv-client - Java client for the AOServ platform.
* Copyright (C) 2001-2012, 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.io.CompressedDataInputStream;
import com.aoindustries.io.CompressedDataOutputStream;
import com.aoindustries.io.TerminalWriter;
import com.aoindustries.util.IntList;
import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* @see HttpdSharedTomcat
*
* @author AO Industries, Inc.
*/
final public class HttpdSharedTomcatTable extends CachedTableIntegerKey {
protected HttpdSharedTomcatTable(AOServConnector connector) {
super(connector, HttpdSharedTomcat.class);
}
private static final OrderBy[] defaultOrderBy = {
new OrderBy(HttpdSharedTomcat.COLUMN_NAME_name, ASCENDING),
new OrderBy(HttpdSharedTomcat.COLUMN_AO_SERVER_name+'.'+AOServer.COLUMN_HOSTNAME_name, ASCENDING)
};
@Override
OrderBy[] getDefaultOrderBy() {
return defaultOrderBy;
}
int addHttpdSharedTomcat(
final String name,
final AOServer aoServer,
HttpdTomcatVersion version,
final LinuxServerAccount lsa,
final LinuxServerGroup lsg,
final boolean isSecure,
final boolean isOverflow
) throws IOException, SQLException {
final int tvPkey = version.getTechnologyVersion(connector).getPkey();
return connector.requestResult(
true,
new AOServConnector.ResultRequest() {
int pkey;
IntList invalidateList;
@Override
public void writeRequest(CompressedDataOutputStream out) throws IOException {
out.writeCompressedInt(AOServProtocol.CommandID.ADD.ordinal());
out.writeCompressedInt(SchemaTable.TableID.HTTPD_SHARED_TOMCATS.ordinal());
out.writeUTF(name);
out.writeCompressedInt(aoServer.pkey);
out.writeCompressedInt(tvPkey);
out.writeUTF(lsa.username);
out.writeUTF(lsg.name);
out.writeBoolean(isSecure);
out.writeBoolean(isOverflow);
}
@Override
public void readResponse(CompressedDataInputStream in) throws IOException, SQLException {
int code=in.readByte();
if(code==AOServProtocol.DONE) {
pkey=in.readCompressedInt();
invalidateList=AOServConnector.readInvalidateList(in);
} else {
AOServProtocol.checkResult(code, in);
throw new IOException("Unexpected response code: "+code);
}
}
@Override
public Integer afterRelease() {
connector.tablesUpdated(invalidateList);
return pkey;
}
}
);
}
public String generateSharedTomcatName(String template) throws IOException, SQLException {
return connector.requestStringQuery(true, AOServProtocol.CommandID.GENERATE_SHARED_TOMCAT_NAME, template);
}
@Override
public HttpdSharedTomcat get(int pkey) throws SQLException, IOException {
return getUniqueRow(HttpdSharedTomcat.COLUMN_PKEY, pkey);
}
HttpdSharedTomcat getHttpdSharedTomcat(HttpdWorker hw) throws SQLException, IOException {
return getUniqueRow(HttpdSharedTomcat.COLUMN_TOMCAT4_WORKER, hw.pkey);
}
HttpdSharedTomcat getHttpdSharedTomcatByShutdownPort(NetBind nb) throws SQLException, IOException {
return getUniqueRow(HttpdSharedTomcat.COLUMN_TOMCAT4_SHUTDOWN_PORT, nb.pkey);
}
List getHttpdSharedTomcats(LinuxServerAccount lsa) throws IOException, SQLException {
return getIndexedRows(HttpdSharedTomcat.COLUMN_LINUX_SERVER_ACCOUNT, lsa.pkey);
}
List getHttpdSharedTomcats(Package pk) throws IOException, SQLException {
String pkname=pk.name;
List cached=getRows();
int size=cached.size();
List matches=new ArrayList<>(size);
for(int c=0;c getHttpdSharedTomcats(AOServer ao) throws IOException, SQLException {
return getIndexedRows(HttpdSharedTomcat.COLUMN_AO_SERVER, ao.pkey);
}
HttpdSharedTomcat getHttpdSharedTomcat(String name, AOServer ao) throws IOException, SQLException {
// Use the index first
List cached=getHttpdSharedTomcats(ao);
int size=cached.size();
for(int c=0;c
© 2015 - 2024 Weber Informatics LLC | Privacy Policy