Package org.wso2.carbon.registry.resource.ui.clients

Examples of org.wso2.carbon.registry.resource.ui.clients.ResourceServiceClient


        String cookie = (String) request.
                getSession().getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

        try {
            ResourceServiceClient client =
                    new ResourceServiceClient(cookie, config, request.getSession());
            client.addRemoteLink(parentPath, name, instance, targetPath);
        } catch (Exception e) {
            String msg = "Failed to add symbolic link "+ name + "to the parent collection "
                    + parentPath + ". " + e.getMessage();
            log.error(msg, e);
            throw new UIException(e);
View Full Code Here


        String cookie = (String) request.
                getSession().getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

        try {
            ResourceServiceClient client =
                    new ResourceServiceClient(cookie, config, request.getSession());
            client.moveResource(parentPath, oldResourcePath, destinationPath, resourceName);

        } catch (Exception e) {
            String msg = "Failed to move resource " + oldResourcePath +
                    " to the path " + destinationPath + ". " + e.getMessage();
            log.error(msg, e);
View Full Code Here

                                        URLEncoder.encode(msg, "UTF-8"));
                    }
                    return false;
                }
            }
            ResourceServiceClient client =
                    new ResourceServiceClient(cookie, serverURL, configurationContext);

            String parentPath = null;
            if (formFieldsMap.get("path") != null) {
                parentPath = formFieldsMap.get("path").get(0);
            }
            String resourceName = null;
            if (formFieldsMap.get("filename") != null) {
                resourceName = formFieldsMap.get("filename").get(0);
            }
            String mediaType = null;
            if (formFieldsMap.get("mediaType") != null) {
                mediaType = formFieldsMap.get("mediaType").get(0);
            }
            String description = null;
            if (formFieldsMap.get("description") != null) {
                description = formFieldsMap.get("description").get(0);
            }
            String redirect = null;
            if (formFieldsMap.get("redirect") != null) {
                redirect = formFieldsMap.get("redirect").get(0);
            }
            String symlinkLocation = null;
            if (formFieldsMap.get("symlinkLocation") != null) {
                symlinkLocation = formFieldsMap.get("symlinkLocation").get(0);
            }
            IServerAdmin adminClient =
                    (IServerAdmin) CarbonUIUtil.
                            getServerProxy(new ServerAdminClient(configurationContext,
                                    serverURL, cookie, session), IServerAdmin.class, session);
            ServerData data = null;
            String chroot = "";
            try {
                data = adminClient.getServerData();
            } catch (Exception ignored) {
                // If we can't get server data the chroot cannot be determined.
                chroot = null;
            }
            if (data != null && data.getRegistryType() != null &&
                    data.getRegistryType().equals("remote") &&
                    data.getRemoteRegistryChroot() != null &&
                    !data.getRemoteRegistryChroot().equals(RegistryConstants.PATH_SEPARATOR)) {
                chroot = data.getRemoteRegistryChroot();
                if (!chroot.startsWith(RegistryConstants.PATH_SEPARATOR)) {
                    chroot = RegistryConstants.PATH_SEPARATOR + chroot;
                }
                if (chroot.endsWith(RegistryConstants.PATH_SEPARATOR)) {
                    chroot = chroot.substring(0, chroot.length() - RegistryConstants.PATH_SEPARATOR.length());
                }
            }
            if (chroot == null) {
                symlinkLocation = null;
                log.debug("Unable to determine chroot. Symbolic Link cannot be created");
            }
            if (symlinkLocation != null) {
                symlinkLocation = chroot + symlinkLocation;
            }

            FileItemData fileItemData = fileItemsMap.get("upload").get(0);

            if ((fileItemData == null) || (fileItemData.getFileItem().getSize() == 0)) {
                String msg = "Failed add resource. Resource content is empty.";
                log.error(msg);

                buildUIError(request, response, webContext, errorRedirect, msg);
                return false;
            }
            DataHandler dataHandler = fileItemData.getDataHandler();

            client.addResource(
                    calcualtePath(parentPath, resourceName), mediaType, description, dataHandler,
                    symlinkLocation);

            response.setContentType("text/html; charset=utf-8");
            String msg = "Successfully uploaded content.";
View Full Code Here

        String cookie = (String) request.
                getSession().getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

        try {
            ResourceServiceClient client =
                    new ResourceServiceClient(cookie, config, request.getSession());
            client.copyResource(parentPath, oldResourcePath, destinationPath, resourceName);

        } catch (Exception e) {
            String msg = "Failed to copy resource " + oldResourcePath +
                    " to the path " + destinationPath + ". " + e.getMessage();
            log.error(msg, e);
View Full Code Here

         String cookie = (String) request.
                getSession().getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

        try {
            ResourceServiceClient client =
                    new ResourceServiceClient(cookie, config, request.getSession());
            client.updateTextContent(resourcePath, contentText);

        } catch (Exception e) {
            String msg = "Failed to update text content of the resource " +
                    resourcePath + ". " + e.getMessage();
            log.error(msg, e);
View Full Code Here

                                 ServletConfig config, String resourcePath, String parentId)
            throws UIException {
        String cookie = (String) request.
                getSession().getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

        ResourceServiceClient client;
        try {
            client = new ResourceServiceClient(cookie, config, request.getSession());
        } catch (Exception e) {
            String msg = "Failed to initialize the resource service client " +
                    "to get resource tree data. " + e.getMessage();
            log.error(msg, e);
            throw new UIException(msg, e);
View Full Code Here

        String cookie = (String) request.
                getSession().getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

        try {
            ResourceServiceClient client =
                    new ResourceServiceClient(cookie, config, request.getSession());
            client.restoreVersion(versionPath);

        } catch (Exception e) {
            String msg = "Failed to restore the resource " + versionPath + ". " + e.getMessage();
            log.error(msg, e);
            throw new UIException(msg, e);
View Full Code Here

        String cookie = (String) request.
                getSession().getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

        try {
            ResourceServiceClient client =
                    new ResourceServiceClient(cookie, config, request.getSession());
            client.addCollection(parentPath, collectionName, mediaType, description);
        } catch (Exception e) {
            String msg = "Failed to add new collection " + collectionName +
                    " to the parent collection " + parentPath + ". " + e.getMessage();
            log.error(msg, e);
            throw new UIException(msg, e);
View Full Code Here

        String cookie = (String) request.
                getSession().getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

        try {
            ResourceServiceClient client =
                    new ResourceServiceClient(cookie, config, request.getSession());
            client.renameResource(parentPath, oldResourcePath, newName);
           
        } catch (Exception e) {
            String msg = "Failed to rename resource " + oldResourcePath +
                    " to the name " + newName + ". " + e.getMessage();
            log.error(msg, e);
View Full Code Here

    public static void getContent(HttpServletRequest request, HttpServletResponse response, ServletConfig config)
            throws Exception {

        try {
            ResourceServiceClient client = new ResourceServiceClient(config, request.getSession());
            String path = request.getParameter("path");
            if (path == null) {
                String msg = "Could not get the resource content. Path is not specified.";
                log.error(msg);
                response.setStatus(400);
                return;
            }

            ContentDownloadBean bean = client.getContentDownloadBean(path);

            InputStream contentStream = null;
            if (bean.getContent() != null) {
                contentStream = bean.getContent().getInputStream();
            } else {
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.resource.ui.clients.ResourceServiceClient

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.