19439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly/*
29439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * Copyright (c) 2008-2009, Motorola, Inc.
39439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
49439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * All rights reserved.
59439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
69439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * Redistribution and use in source and binary forms, with or without
79439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * modification, are permitted provided that the following conditions are met:
89439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
99439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * - Redistributions of source code must retain the above copyright notice,
109439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * this list of conditions and the following disclaimer.
119439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
129439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * - Redistributions in binary form must reproduce the above copyright notice,
139439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * this list of conditions and the following disclaimer in the documentation
149439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * and/or other materials provided with the distribution.
159439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
169439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * - Neither the name of the Motorola, Inc. nor the names of its contributors
179439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * may be used to endorse or promote products derived from this software
189439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * without specific prior written permission.
199439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly *
209439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
219439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
229439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
239439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
249439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
259439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
269439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
279439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
289439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
299439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
309439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * POSSIBILITY OF SUCH DAMAGE.
319439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly */
329439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
339439a7fe517b858bc5e5c654b459315e4722feb2Nick Pellypackage javax.obex;
349439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
359439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly/**
3605ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * The <code>ServerRequestHandler</code> class defines an event listener that
3705ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * will respond to OBEX requests made to the server.
389439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * <P>
3905ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * The <code>onConnect()</code>, <code>onSetPath()</code>,
4005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * <code>onDelete()</code>, <code>onGet()</code>, and <code>onPut()</code>
4105ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * methods may return any response code defined in the
4205ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * <code>ResponseCodes</code> class except for <code>OBEX_HTTP_CONTINUE</code>.
4305ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * If <code>OBEX_HTTP_CONTINUE</code> or a value not defined in the
4405ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * <code>ResponseCodes</code> class is returned, the server implementation will
4505ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * send an <code>OBEX_HTTP_INTERNAL_ERROR</code> response to the client.
469439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * <P>
479439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * <STRONG>Connection ID and Target Headers</STRONG>
489439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * <P>
499439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * According to the IrOBEX specification, a packet may not contain a Connection
5005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * ID and Target header. Since the Connection ID header is managed by the
519439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * implementation, it will not send a Connection ID header, if a Connection ID
5205ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * was specified, in a packet that has a Target header. In other words, if an
5305ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * application adds a Target header to a <code>HeaderSet</code> object used in
5405ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * an OBEX operation and a Connection ID was specified, no Connection ID will be
5505ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * sent in the packet containing the Target header.
569439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * <P>
579439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * <STRONG>CREATE-EMPTY Requests</STRONG>
589439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * <P>
599439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly * A CREATE-EMPTY request allows clients to create empty objects on the server.
6005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * When a CREATE-EMPTY request is received, the <code>onPut()</code> method will
6105ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * be called by the implementation. To differentiate between a normal PUT
6205ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * request and a CREATE-EMPTY request, an application must open the
6305ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * <code>InputStream</code> from the <code>Operation</code> object passed to the
6405ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * <code>onPut()</code> method. For a PUT request, the application will be able
6505ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * to read Body data from this <code>InputStream</code>. For a CREATE-EMPTY
6605ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * request, there will be no Body data to read. Therefore, a call to
6705ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun * <code>InputStream.read()</code> will return -1.
682e0da96e757a977154063f980d3f4e1abd41cf09Nick Pelly * @hide
699439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly */
709439a7fe517b858bc5e5c654b459315e4722feb2Nick Pellypublic class ServerRequestHandler {
719439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
723998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun    private long mConnectionId;
739439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
749439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    /**
7505ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * Creates a <code>ServerRequestHandler</code>.
7605ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     */
779439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    protected ServerRequestHandler() {
789439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        /*
799439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly         * A connection ID of -1 implies there is no conenction ID
809439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly         */
813998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        mConnectionId = -1;
829439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
839439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
849439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    /**
859439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * Sets the connection ID header to include in the reply packets.
8605ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * @param connectionId the connection ID to use; -1 if no connection ID
8705ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        should be sent
8805ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * @throws IllegalArgumentException if <code>id</code> is not in the range
8905ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         -1 to 2<sup>32</sup>-1
909439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     */
913998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun    public void setConnectionId(final long connectionId) {
923998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        if ((connectionId < -1) || (connectionId > 0xFFFFFFFFL)) {
939439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly            throw new IllegalArgumentException("Illegal Connection ID");
949439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        }
953998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        mConnectionId = connectionId;
969439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
979439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
989439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    /**
999439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * Retrieves the connection ID that is being used in the present connection.
1009439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * This method will return -1 if no connection ID is being used.
1019439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @return the connection id being used or -1 if no connection ID is being
10205ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         used
1039439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     */
1043998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun    public long getConnectionId() {
1053998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun        return mConnectionId;
1069439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
1079439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1089439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    /**
1099439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * Called when a CONNECT request is received.
1109439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
11105ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * If this method is not implemented by the class that extends this class,
11205ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * <code>onConnect()</code> will always return an <code>OBEX_HTTP_OK</code>
11305ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * response code.
1149439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
1159439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * The headers received in the request can be retrieved from the
11605ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * <code>request</code> argument. The headers that should be sent in the
11705ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * reply must be specified in the <code>reply</code> argument.
1189439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param request contains the headers sent by the client;
11905ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>request</code> will never be <code>null</code>
1209439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param reply the headers that should be sent in the reply;
12105ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>reply</code> will never be <code>null</code>
12205ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * @return a response code defined in <code>ResponseCodes</code> that will
12305ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         be returned to the client; if an invalid response code is
12405ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         provided, the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code
12505ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         will be used
1269439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     */
1279439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public int onConnect(HeaderSet request, HeaderSet reply) {
1289439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        return ResponseCodes.OBEX_HTTP_OK;
1299439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
1309439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1319439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    /**
1329439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * Called when a DISCONNECT request is received.
1339439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
1349439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * The headers received in the request can be retrieved from the
13505ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * <code>request</code> argument. The headers that should be sent in the
13605ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * reply must be specified in the <code>reply</code> argument.
1379439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param request contains the headers sent by the client;
13805ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>request</code> will never be <code>null</code>
1399439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param reply the headers that should be sent in the reply;
14005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>reply</code> will never be <code>null</code>
1419439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     */
1429439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public void onDisconnect(HeaderSet request, HeaderSet reply) {
1439439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
1449439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1459439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    /**
1469439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * Called when a SETPATH request is received.
1479439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
14805ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * If this method is not implemented by the class that extends this class,
14905ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * <code>onSetPath()</code> will always return an
1509439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <code>OBEX_HTTP_NOT_IMPLEMENTED</code> response code.
1519439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
1529439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * The headers received in the request can be retrieved from the
15305ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * <code>request</code> argument. The headers that should be sent in the
15405ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * reply must be specified in the <code>reply</code> argument.
1559439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param request contains the headers sent by the client;
15605ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>request</code> will never be <code>null</code>
1579439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param reply the headers that should be sent in the reply;
15805ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>reply</code> will never be <code>null</code>
1599439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param backup <code>true</code> if the client requests that the server
16005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        back up one directory before changing to the path described by
16105ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>name</code>; <code>false</code> to apply the request to the
16205ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        present path
1639439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param create <code>true</code> if the path should be created if it does
16405ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        not already exist; <code>false</code> if the path should not be
16505ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        created if it does not exist and an error code should be returned
16605ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * @return a response code defined in <code>ResponseCodes</code> that will
16705ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         be returned to the client; if an invalid response code is
16805ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         provided, the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code
16905ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         will be used
1709439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     */
1719439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public int onSetPath(HeaderSet request, HeaderSet reply, boolean backup, boolean create) {
1729439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1739439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED;
1749439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
1759439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
1769439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    /**
1779439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * Called when a DELETE request is received.
1789439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
17905ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * If this method is not implemented by the class that extends this class,
18005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * <code>onDelete()</code> will always return an
1819439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <code>OBEX_HTTP_NOT_IMPLEMENTED</code> response code.
1829439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
1839439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * The headers received in the request can be retrieved from the
18405ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * <code>request</code> argument. The headers that should be sent in the
18505ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * reply must be specified in the <code>reply</code> argument.
1869439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param request contains the headers sent by the client;
18705ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>request</code> will never be <code>null</code>
1889439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param reply the headers that should be sent in the reply;
18905ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>reply</code> will never be <code>null</code>
19005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * @return a response code defined in <code>ResponseCodes</code> that will
19105ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         be returned to the client; if an invalid response code is
19205ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         provided, the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code
19305ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         will be used
1949439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     */
1959439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public int onDelete(HeaderSet request, HeaderSet reply) {
1968258ebdf128ef70a96fcaaa294167e39f1b5e94eLixin Yue        return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED;
1978258ebdf128ef70a96fcaaa294167e39f1b5e94eLixin Yue    }
1988258ebdf128ef70a96fcaaa294167e39f1b5e94eLixin Yue
1998258ebdf128ef70a96fcaaa294167e39f1b5e94eLixin Yue    /**
2008258ebdf128ef70a96fcaaa294167e39f1b5e94eLixin Yue     * Called when a ABORT request is received.
2018258ebdf128ef70a96fcaaa294167e39f1b5e94eLixin Yue     */
2028258ebdf128ef70a96fcaaa294167e39f1b5e94eLixin Yue    public int onAbort(HeaderSet request, HeaderSet reply) {
2039439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED;
2049439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
2059439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
2069439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    /**
2079439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * Called when a PUT request is received.
2089439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
20905ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * If this method is not implemented by the class that extends this class,
21005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * <code>onPut()</code> will always return an
2119439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <code>OBEX_HTTP_NOT_IMPLEMENTED</code> response code.
2129439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
2139439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * If an ABORT request is received during the processing of a PUT request,
2149439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <code>op</code> will be closed by the implementation.
2153998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     * @param operation contains the headers sent by the client and allows new
21605ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        headers to be sent in the reply; <code>op</code> will never be
21705ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>null</code>
21805ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * @return a response code defined in <code>ResponseCodes</code> that will
21905ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         be returned to the client; if an invalid response code is
22005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         provided, the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code
22105ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         will be used
2229439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     */
2233998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun    public int onPut(Operation operation) {
2249439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED;
2259439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
2269439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
2279439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    /**
2289439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * Called when a GET request is received.
2299439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
23005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * If this method is not implemented by the class that extends this class,
23105ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * <code>onGet()</code> will always return an
2329439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <code>OBEX_HTTP_NOT_IMPLEMENTED</code> response code.
2339439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
2349439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * If an ABORT request is received during the processing of a GET request,
2359439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <code>op</code> will be closed by the implementation.
2363998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     * @param operation contains the headers sent by the client and allows new
23705ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        headers to be sent in the reply; <code>op</code> will never be
23805ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>null</code>
23905ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     * @return a response code defined in <code>ResponseCodes</code> that will
24005ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         be returned to the client; if an invalid response code is
24105ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         provided, the <code>OBEX_HTTP_INTERNAL_ERROR</code> response code
24205ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *         will be used
2439439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     */
2443998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun    public int onGet(Operation operation) {
2459439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly        return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED;
2469439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
2479439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
2489439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    /**
2499439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * Called when this object attempts to authenticate a client and the
2509439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * authentication request fails because the response digest in the
2519439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * authentication response header was wrong.
2529439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * <P>
2539439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * If this method is not implemented by the class that extends this class,
2549439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * this method will do nothing.
2559439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     * @param userName the user name returned in the authentication response;
25605ff98bbefda39b9ff26f8bca132cfd0248745c6Tao Liejun     *        <code>null</code> if no user name was provided in the response
2579439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly     */
2589439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public void onAuthenticationFailure(byte[] userName) {
2599439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
2609439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
2613998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun    /**
2623998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     * Called by ServerSession to update the status of current transaction
2633998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     * <P>
2643998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     * If this method is not implemented by the class that extends this class,
2653998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     * this method will do nothing.
2663998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     */
2679439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public void updateStatus(String message) {
2689439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
2699439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly
2703998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun    /**
2713998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     * Called when session is closed.
2723998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     * <P>
2733998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     * If this method is not implemented by the class that extends this class,
2743998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     * this method will do nothing.
2753998bf009acaf8cde4d7f837f8b8e41ae0a65141Tao Liejun     */
2769439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    public void onClose() {
2779439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly    }
2789439a7fe517b858bc5e5c654b459315e4722feb2Nick Pelly}
279