Package com.imaginea.mongodb.services.impl

Examples of com.imaginea.mongodb.services.impl.GridFSServiceImpl


    @Path("create")
    public String createGridFSStore(@PathParam("dbName") final String dbName, @PathParam("bucketName") final String bucketName,
                                    @QueryParam("connectionId") final String connectionId, @Context final HttpServletRequest request) {
        String response = new ResponseTemplate().execute(logger, connectionId, request, new ResponseCallback() {
            public Object execute() throws Exception {
                GridFSService gridFSService = new GridFSServiceImpl(connectionId);
                return gridFSService.createStore(dbName, bucketName);
            }
        });
        return response;
    }
View Full Code Here


    @Path("/count")
    public String getCount(@PathParam("dbName") final String dbName, @PathParam("bucketName") final String bucketName,
                           @QueryParam("connectionId") final String connectionId, @Context final HttpServletRequest request) {
        String response = new ResponseTemplate().execute(logger, connectionId, request, new ResponseCallback() {
            public Object execute() throws Exception {
                GridFSService gridFSService = new GridFSServiceImpl(connectionId);
                return gridFSService.getCount(dbName, bucketName);
            }
        });
        return response;
    }
View Full Code Here

                              @QueryParam("sortBy") final String sortBy,
                              @QueryParam("connectionId") final String connectionId,
                              @Context final HttpServletRequest request) {
        String response = new ResponseTemplate().execute(logger, connectionId, request, new ResponseCallback() {
            public Object execute() throws Exception {
                GridFSService gridFSService = new GridFSServiceImpl(connectionId);
                int startIndex = query.indexOf("("), endIndex = query.lastIndexOf(")");
                String cmdStr = query.substring(0, startIndex);
                int lastIndexOfDot = cmdStr.lastIndexOf(".");
                if (lastIndexOfDot + 1 == cmdStr.length()) {
                    // In this case the cmsStr = db.gridFSName.
                    throw new InvalidMongoCommandException(ErrorCodes.COMMAND_EMPTY, "Command is empty");
                }
                int firstIndexOfDot = cmdStr.indexOf(".");
                int indexOfDotAtCollectionName = cmdStr.lastIndexOf(".", lastIndexOfDot - 1);
                String bucket = cmdStr.substring(firstIndexOfDot + 1, indexOfDotAtCollectionName);
                String collectionName = cmdStr.substring(indexOfDotAtCollectionName + 1, lastIndexOfDot);
                String command = cmdStr.substring(lastIndexOfDot + 1, cmdStr.length());
                if (firstIndexOfDot != lastIndexOfDot) {
                    // when commands are of the form db.bucketName.find
                } else {
                    throw new InvalidMongoCommandException(ErrorCodes.INVALID_COMMAND, "Invalid command");
                }
                String jsonStr = query.substring(startIndex + 1, endIndex);
                return gridFSService.executeQuery(dbName, bucket, collectionName, command, jsonStr, skip, limit, sortBy);
            }
        });
        return response.replace("\\", "").replace("\"{", "{").replace("}\"", "}");
    }
View Full Code Here

     */
    @GET
    @Path("getfile")
    public Response getFile(@PathParam("dbName") final String dbName, @PathParam("bucketName") final String bucketName, @QueryParam("id") final String id,
                            @QueryParam("download") final boolean download, @QueryParam("connectionId") final String connectionId) throws ApplicationException {
        GridFSService gridFSService = new GridFSServiceImpl(connectionId);
        File fileObject = null;
        try {
            fileObject = gridFSService.getFile(dbName, bucketName, id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        String contentType = ApplicationUtils.getContentType(fileObject);
        Response.ResponseBuilder response = Response.ok(fileObject, contentType);
View Full Code Here

                             @FormDataParam("files") final InputStream inputStream,
                             @QueryParam("connectionId") final String connectionId, @Context final HttpServletRequest request) {

        String response = new ResponseTemplate().execute(logger, connectionId, request, new ResponseCallback() {
            public Object execute() throws Exception {
                GridFSService gridFSService = new GridFSServiceImpl(connectionId);
                return gridFSService.insertFile(dbName, bucketName, connectionId, inputStream, formData);
            }
        }, false);
        return response;
    }
View Full Code Here

                           @QueryParam("id") final String _id, @QueryParam("connectionId") final String connectionId,
                           @Context final HttpServletRequest request) {

        String response = new ResponseTemplate().execute(logger, connectionId, request, new ResponseCallback() {
            public Object execute() throws Exception {
                GridFSService gridFSService = new GridFSServiceImpl(connectionId);
                String result = null;
                if ("".equals(_id)) {
                    ApplicationException e = new DocumentException(ErrorCodes.DOCUMENT_DOES_NOT_EXIST, "File Data Missing in Request Body");
                    result = formErrorResponse(logger, e);
                } else {
                    result = gridFSService.deleteFile(dbName, bucketName, _id);
                }
                return result;
            }
        });
        return response;
View Full Code Here

    @Path("dropbucket")
    public String dropBucket(@PathParam("dbName") final String dbName, @PathParam("bucketName") final String bucketName,
                             @QueryParam("connectionId") final String connectionId, @Context final HttpServletRequest request) {
        String response = new ResponseTemplate().execute(logger, connectionId, request, new ResponseCallback() {
            public Object execute() throws Exception {
                GridFSService gridFSService = new GridFSServiceImpl(connectionId);
                return gridFSService.dropBucket(dbName, bucketName);
            }
        });
        return response;
    }
View Full Code Here

TOP

Related Classes of com.imaginea.mongodb.services.impl.GridFSServiceImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.