2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1999 by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A *
2N/A */
2N/A
2N/A// SLPV1SSrvTypeMsg.java: SLPV1 Compatibility SrvType message
2N/A// Author: James Kempf
2N/A// Created On: Mon Sep 14 10:49:05 1998
2N/A// Last Modified By: James Kempf
2N/A// Last Modified On: Tue Oct 27 10:57:39 1998
2N/A// Update Count: 11
2N/A//
2N/A
2N/A
2N/Apackage com.sun.slp;
2N/A
2N/Aimport java.util.*;
2N/Aimport java.io.*;
2N/A
2N/A
2N/A/**
2N/A * The SLPV1SSrvTypeMsg class models the SLPv1 service type request message.
2N/A *
2N/A * @author James Kempf
2N/A */
2N/A
2N/A
2N/Aclass SLPV1SSrvTypeMsg extends SSrvTypeMsg {
2N/A
2N/A // Construct a SLPV1SSrvTypeMsg from the byte input stream. This will be
2N/A // a SrvTypeRqst.
2N/A
2N/A SLPV1SSrvTypeMsg(SrvLocHeader hdr, DataInputStream dis)
2N/A throws ServiceLocationException, IOException {
2N/A
2N/A super(hdr, dis);
2N/A
2N/A }
2N/A
2N/A void initialize(DataInputStream dis)
2N/A throws ServiceLocationException, IOException {
2N/A
2N/A SLPHeaderV1 hdr = (SLPHeaderV1)getHeader();
2N/A StringBuffer buf = new StringBuffer();
2N/A
2N/A // First get the previous responder.
2N/A
2N/A hdr.parsePreviousRespondersIn(dis);
2N/A
2N/A // Now get naming authority.
2N/A
2N/A namingAuthority = parseNamingAuthorityIn(hdr, dis, hdr.charCode);
2N/A
2N/A // If it's IANA, make it be null.
2N/A
2N/A if (namingAuthority.equalsIgnoreCase(ServiceType.IANA)) {
2N/A namingAuthority = "";
2N/A
2N/A }
2N/A
2N/A // Finally get scope.
2N/A
2N/A buf.setLength(0);
2N/A
2N/A hdr.getString(buf, dis);
2N/A
2N/A String scope = buf.toString().trim().toLowerCase();
2N/A
2N/A hdr.validateScope(scope);
2N/A
2N/A // Change unscoped to default.
2N/A
2N/A if (scope.length() <= 0) {
2N/A scope = Defaults.DEFAULT_SCOPE;
2N/A
2N/A }
2N/A
2N/A hdr.scopes = new Vector();
2N/A hdr.scopes.addElement(scope);
2N/A
2N/A // Construct description.
2N/A
2N/A hdr.constructDescription("SrvTypeRqst",
2N/A " naming authority=``" +
2N/A namingAuthority + "''\n");
2N/A }
2N/A
2N/A // Construct a SSrvTypeMsg from the arguments. This will be a
2N/A // SrvTypeRply for transmission to client.
2N/A
2N/A SrvLocMsg makeReply(Vector typeNames)
2N/A throws ServiceLocationException {
2N/A
2N/A SLPHeaderV1 hdr =
2N/A ((SLPHeaderV1)getHeader()).makeReplyHeader();
2N/A
2N/A // Construct payload.
2N/A
2N/A ByteArrayOutputStream baos = new ByteArrayOutputStream();
2N/A
2N/A // Edit service type names to remove nonService: and abstract types.
2N/A
2N/A int i;
2N/A
2N/A for (i = 0; i < typeNames.size(); i++) {
2N/A String name = (String)typeNames.elementAt(i);
2N/A ServiceType type = new ServiceType(name);
2N/A
2N/A if (type.isAbstractType() || !type.isServiceURL()) {
2N/A typeNames.removeElement(name);
2N/A
2N/A }
2N/A }
2N/A
2N/A hdr.iNumReplies = typeNames.size();
2N/A
2N/A hdr.putStringVector(typeNames, baos);
2N/A
2N/A hdr.payload = baos.toByteArray();
2N/A
2N/A hdr.constructDescription("SrvTypeRply",
2N/A " types=``" + typeNames + "''\n");
2N/A
2N/A return hdr;
2N/A }
2N/A}