/*
(non-Javadoc)

@see
com.emc.ecs.nfsclient.nfs.NfsFile#makeMkdirRequest(com.emc.ecs.nfsclient.
nfs.NfsSetAttributes)
13479
public NfsMkdirRequest makeMkdirRequest(NfsSetAttributes attributes) throws IOException {
        return getNfs().makeMkdirRequest(getParentFile().getFileHandle(), getName(), attributes);
    }
1203091
private void sendDirectory(final YokeRequest request, final String dir, final Handler<Object> next) {
        final FileSystem fileSystem = vertx().fileSystem();

        fileSystem.readDir(dir, new AsyncResultHandler<List<String>>() {
            @Override
            public void handle(AsyncResult<List<String>> asyncResult) {
                if (asyncResult.failed()) {
                    next.handle(asyncResult.cause());
                } else {
                    String accept = request.getHeader("accept", "text/plain");

                    if (accept.contains("html")) {
                        String normalizedDir = dir.substring(root.length());
                        if (!normalizedDir.endsWith("/")) {
                            normalizedDir += "/";
                        }

                        String file;
                        StringBuilder files = new StringBuilder("<ul id=\"files\">");

                        for (String s : asyncResult.result()) {
                            file = s.substring(s.lastIndexOf('/') + 1);
                            // skip dot files
                            if (!includeHidden && file.charAt(0) == '.') {
                                continue;
                            }
                            files.append("<li><a href=\"");
                            files.append(normalizedDir);
                            files.append(file);
                            files.append("\" title=\"");
                            files.append(file);
                            files.append("\">");
                            files.append(file);
                            files.append("</a></li>");
                        }

                        files.append("</ul>");

                        StringBuilder directory = new StringBuilder();
                        // define access to root
                        directory.append("<a href=\"/\">/</a> ");

                        StringBuilder expandingPath = new StringBuilder();
                        String[] dirParts = normalizedDir.split("/");
                        for (int i = 1; i < dirParts.length; i++) {
                            // dynamic expansion
                            expandingPath.append("/");
                            expandingPath.append(dirParts[i]);
                            // anchor building
                            if (i > 1) {
                                directory.append(" / ");
                            }
                            directory.append("<a href=\"");
                            directory.append(expandingPath.toString());
                            directory.append("\">");
                            directory.append(dirParts[i]);
                            directory.append("</a>");
                        }

                        request.response().setContentType("text/html");
                        request.response().end(
                                directoryTemplate.replace("{title}", (String) request.get("title")).replace("{directory}", normalizedDir)
                                        .replace("{linked-path}", directory.toString())
                                        .replace("{files}", files.toString()));
                    } else if (accept.contains("json")) {
                        String file;
                        JsonArray json = new JsonArray();

                        for (String s : asyncResult.result()) {
                            file = s.substring(s.lastIndexOf('/') + 1);
                            // skip dot files
                            if (!includeHidden && file.charAt(0) == '.') {
                                continue;
                            }
                            json.add(file);
                        }

                        request.response().end(json);
                    } else {
                        String file;
                        StringBuilder buffer = new StringBuilder();

                        for (String s : asyncResult.result()) {
                            file = s.substring(s.lastIndexOf('/') + 1);
                            // skip dot files
                            if (!includeHidden && file.charAt(0) == '.') {
                                continue;
                            }
                            buffer.append(file);
                            buffer.append('\n');
                        }

                        request.response().setContentType("text/plain");
                        request.response().end(buffer.toString());
                    }
                }
            }
        });
    }
197324
public Nfs3CreateResponse wrapped_sendCreate(NfsCreateRequest request) throws IOException {
        NfsResponseHandler<Nfs3CreateResponse> responseHandler = new NfsResponseHandler<Nfs3CreateResponse>() {

            /* (non-Javadoc)
             * @see com.emc.ecs.nfsclient.rpc.RpcResponseHandler#makeNewResponse()
             */
            protected Nfs3CreateResponse makeNewResponse() {
                return new Nfs3CreateResponse();
            }

        };
        _rpcWrapper.callRpcWrapped(request, responseHandler);
        return responseHandler.getResponse();
    }
821017
public static Map<String, FileItem[]> getRequestFileItems(final HttpServletRequest request) {
		if (request.getAttribute(REQUEST_PROCESSED_KEY) == null) {
			setupRequestParameters(request);
		}
		return (Map<String, FileItem[]>) request.getAttribute(REQUEST_FILES_KEY);
	}
1142535
public Nfs3SymlinkResponse sendSymlink(NfsSymlinkRequest request) throws IOException {
        Nfs3SymlinkResponse response = new Nfs3SymlinkResponse();
        _rpcWrapper.callRpcNaked(request, response);
        return response;
    }
1234552
public Request createRequest(String name, Map<String, Object> attributes) {
        return getInstance().create().request(name, this, attributes);
    }
1107695
public Nfs3CreateResponse sendCreate(NfsCreateRequest request) throws IOException {
        Nfs3CreateResponse response = new Nfs3CreateResponse();
        _rpcWrapper.callRpcNaked(request, response);
        return response;
    }
762224
public NfsRmdirResponse rmdir() throws IOException {
        NfsRmdirResponse response = getNfs().wrapped_sendRmdir(makeRmdirRequest());
        setFileHandle(null);
        return response;
    }
1329429
public NfsWriteRequest makeWriteRequest(long offset, List<ByteBuffer> payload, int syncType) throws IOException {
        return getNfs().makeWriteRequest(getFileHandle(), offset, payload, syncType);
    }
643080
public NfsMknodRequest makeMknodRequest(NfsType type, NfsSetAttributes attributes, long[] rdev) throws IOException {
        return getNfs().makeMknodRequest(getParentFile().getFileHandle(), getName(), type, attributes, rdev);
    }
191964
public TrmClientAttachRequest createNewTrmClientAttachRequest() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewTrmClientAttachRequest");
    TrmClientAttachRequest msg = null;
    try {
      msg = new TrmClientAttachRequestImpl();
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewTrmClientAttachRequest");
    return msg;
  }
1241601
public static Map<String, Object> createRequestAttributesMap(HttpServletRequest request) {
        Map<String, Object> attributesMap = new HashMap<>();
        for (Enumeration attributeNameEnum = request.getAttributeNames(); attributeNameEnum.hasMoreElements(); ) {
            String attributeName = (String)attributeNameEnum.nextElement();

            attributesMap.put(attributeName, request.getAttribute(attributeName));
        }

        return attributesMap;
    }
1081020
public Nfs3SetAttrResponse setAttr(NfsSetAttrRequest request) throws IOException {
        Nfs3SetAttrResponse response = new Nfs3SetAttrResponse();
        _rpcWrapper.callRpcNaked(request, response);
        return response;
    }
660031
public NfsCommitRequest makeCommitRequest(long offsetToCommit, int dataSizeToCommit) throws IOException {
        return getNfs().makeCommitRequest(getFileHandle(), offsetToCommit, dataSizeToCommit);
    }
672848
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    NameNode.getNameNodeMetrics().numFileDataServletDoGet.inc();
    final UnixUserGroupInformation ugi = getUGI(request);
    final ClientProtocol nnproxy = createNameNodeProxy(ugi);

    try {
      final String path = request.getPathInfo() != null
        ? request.getPathInfo() : "/";
      FileStatus info = nnproxy.getFileInfo(path);
      if ((info != null) && !info.isDir()) {
        response.sendRedirect(createUri(info, ugi, nnproxy,
              request).toURL().toString());
      } else if (info == null){
        response.sendError(400, "cat: File not found " + path);
      } else {
        response.sendError(400, "cat: " + path + ": is a directory");
      }
    } catch (URISyntaxException e) {
      response.getWriter().println(e.toString());
    } catch (IOException e) {
      response.sendError(400, e.getMessage());
    }
  }
484955
@Override
	public CEMILData request(final KNXAddress dst, final Configuration c)
	{
		if (!(dst instanceof GroupAddress))
			return null;
		final DatapointModel<?> m = c.getDatapointModel();
		if (m != null) {
			final Datapoint dp = m.get((GroupAddress) dst);
			if (dp == null || dp.isStateBased())
				return null;
		}
		synchronized (indicationKeys) {
			for (final Iterator<CacheObject> i = indicationKeys.iterator(); i.hasNext();) {
				final CacheObject co = i.next();
				if (co.getKey().equals(dst)) {
					i.remove();
					return ((LDataObjectQueue) co).getItem().getFrame();
				}
			}
		}
		return null;
	}
1288755
public static Message buildRequest(ByteBuffer request) {
    Request req = Request.newBuilder()
                         .setRequest(ByteString.copyFrom(request))
                         .build();

    return Message.newBuilder().setType(MessageType.REQUEST)
                               .setRequest(req)
                               .build();
  }