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

com.liferay.portal.sharepoint.SharepointWebServicesServlet Maven / Gradle / Ivy

There is a newer version: 7.4.3.112-ga112
Show newest version
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library 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 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library 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.
 */

package com.liferay.portal.sharepoint;

import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.servlet.HttpHeaders;
import com.liferay.portal.kernel.servlet.ServletResponseUtil;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.StringBundler;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Bruno Farache
 */
public class SharepointWebServicesServlet extends HttpServlet {

	@Override
	protected void doPost(
		HttpServletRequest request, HttpServletResponse response) {

		if (_log.isInfoEnabled()) {
			_log.info(
				StringBundler.concat(
					request.getHeader(HttpHeaders.USER_AGENT), " ",
					request.getMethod(), " ", request.getRequestURI()));
		}

		try {
			String uri = request.getRequestURI();

			if (uri.equals("/_vti_bin/webs.asmx")) {
				vtiBinWebsAsmx(request, response);
			}
		}
		catch (Exception e) {
			_log.error(e, e);
		}
	}

	protected void vtiBinWebsAsmx(
			HttpServletRequest request, HttpServletResponse response)
		throws Exception {

		StringBundler sb = new StringBundler(12);

		String url = StringBundler.concat(
			"http://", request.getLocalAddr(), ":",
			String.valueOf(request.getServerPort()), "/sharepoint");

		sb.append("");
		sb.append("");
		sb.append("");
		sb.append("");
		sb.append("");
		sb.append(url);
		sb.append("");
		sb.append("");
		sb.append("");
		sb.append("");

		response.setContentType(ContentTypes.TEXT_XML_UTF8);

		ServletResponseUtil.write(response, sb.toString());
	}

	private static final Log _log = LogFactoryUtil.getLog(
		SharepointWebServicesServlet.class);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy