Examples of IssueTrackerClient


Examples of org.wso2.carbon.issue.tracker.ui.IssueTrackerClient

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

        HttpSession httpSession = request.getSession();


        IssueTrackerClient issueTrackerClient = new IssueTrackerClient(cookie, serverURL, configurationContext);
        AttachmentData[] attachmentDataArray = new AttachmentData[0];

        // Retrieve the set of FileItems
        List<FileItemData> fileItems = fileItemsMap.get("attachmentName");


        List<AttachmentData> attachmentDataList = new ArrayList<AttachmentData>();

        if (null != fileItems) {
            for (FileItemData fileItemData : fileItems) {

                String filename = getFileName(fileItemData.getFileItem().getName());

//                try {
//                    checkServiceFileExtensionValidity(filename, ALLOWED_FILE_EXTENSIONS);
                AttachmentData attachmentData = new AttachmentData();
                attachmentData.setFileName(filename);
                attachmentData.setDataHandler(fileItemData.getDataHandler());
                attachmentDataList.add(attachmentData);
//                } catch (FileUploadException e) {
//                    log.error("File upload failed. " + e.getMessage());
//                    CarbonUIMessage.sendCarbonUIMessage("File upload failed. " + e.getMessage(), CarbonUIMessage.ERROR, request,
//                            response, getContextRoot(request) + "/" + webContext + "/issue/newIssue.jsp");
//                    return true;
//                }


            }

            attachmentDataArray = attachmentDataList.toArray(new AttachmentData[attachmentDataList.size()]);
        }

        //get form fields
        List<String> account = formFieldsMap.get("accountName");
        List<String> issueKeys = formFieldsMap.get("issueKey");

        // get credentials from the registry

        AccountInfo accountInfo = issueTrackerClient.getAccount(account.get(0));
        GenericCredentials credentials = accountInfo.getCredentials();
        String token = null;

        //login
        try {
            token = issueTrackerClient.login(credentials);
        } catch (IssueTrackerExceptionException e) {
            String msg = "Error loging to JIRA from account " + account.get(0);
            log.error(msg);

            CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request,
                    response, getContextRoot(request) + "/" + webContext + "/issue/newIssue.jsp");
            return false;
        }

        String issueKey = null;
        if (null != issueKeys && !"".equals(issueKeys.get(0))) {
            issueKey = issueKeys.get(0);
            try {
                issueTrackerClient.uploadAttachments(token, issueKey, attachmentDataArray, credentials.getUrl());

            } catch (Exception e) {
                log.error("File upload failed.Attached file seems to be corrupted.Please recheck. " + e.getMessage());
                CarbonUIMessage.sendCarbonUIMessage("File upload failed.Attached file seems to be corrupted.Please recheck."
                        + e.getMessage(), CarbonUIMessage.ERROR, request,
View Full Code Here

Examples of org.wso2.carbon.issue.tracker.ui.IssueTrackerClient

        String serverURL = (String) request.getAttribute(CarbonConstants.SERVER_URL);
        String cookie = (String) request.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

        HttpSession httpSession = request.getSession();

        IssueTrackerClient issueTrackerClient = new IssueTrackerClient(cookie, serverURL, configurationContext);
        AttachmentData[] attachmentDataArray = new AttachmentData[0];

        // Retrieve the set of FileItems
        List<FileItemData> fileItems = fileItemsMap.get("attachmentName");

        List<AttachmentData> attachmentDataList = new ArrayList<AttachmentData>();

        if (null != fileItems) {
            for (FileItemData fileItemData : fileItems) {

                String filename = getFileName(fileItemData.getFileItem().getName());

//                try {
//                    checkServiceFileExtensionValidity(filename, ALLOWED_FILE_EXTENSIONS);
                AttachmentData attachmentData = new AttachmentData();
                attachmentData.setFileName(filename);
                attachmentData.setDataHandler(fileItemData.getDataHandler());
                attachmentDataList.add(attachmentData);
//                } catch (FileUploadException e) {
//                    log.error("File upload failed. " + e.getMessage());
//                    CarbonUIMessage.sendCarbonUIMessage("File upload failed. " + e.getMessage(), CarbonUIMessage.ERROR, request,
//                            response, getContextRoot(request) + "/" + webContext + "/issue/newIssue.jsp");
//                    return true;
//                }


            }

            attachmentDataArray = attachmentDataList.toArray(new AttachmentData[attachmentDataList.size()]);
        }


        //get form fields
        List<String> account = formFieldsMap.get("accountNames");
        List<String> project = formFieldsMap.get("projectList");
        List<String> summary = formFieldsMap.get("summary");
        List<String> priority = formFieldsMap.get("priority");
        List<String> description = formFieldsMap.get("description");
        List<String> type = formFieldsMap.get("type");
        List<String> dueDate = formFieldsMap.get("due");
        List<String> issueKeys = formFieldsMap.get("issueKey");
        List<String> bundleInfoFile = formFieldsMap.get("bundleInfo");
        List<String> threadDump = formFieldsMap.get("threadDump");
        List<String> logFile = formFieldsMap.get("log");

        // get credentials from the registry

        AccountInfo accountInfo = issueTrackerClient.getAccount(account.get(0));

        GenericCredentials credentials;

        credentials = accountInfo.getCredentials();


        String token = null;

        //login
        try {
            token = issueTrackerClient.login(credentials);
        } catch (IssueTrackerExceptionException e) {
            String msg = "Error loging to JIRA from account " + account.get(0);
            log.error(msg);

            CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request,
                    response, getContextRoot(request) + "/" + webContext + "/issue/newIssue.jsp");
            return false;
        }

        String issueKey = null;

        //if issue key is available,attach files to the same issue. else create a new issue and attach files.

        // report issue
        GenericIssue issue = new GenericIssue();
        issue.setProjectKey(project.get(0));

        if (!"--Select--".equals(type.get(0))) {
            issue.setType(type.get(0));

        }

        issue.setSummary(summary.get(0).trim());

        if (!"--Select--".equals(priority.get(0))) {
            issue.setPriority(priority.get(0));
        }

        issue.setDescription(description.get(0).trim());

        // setting due date

        String due = dueDate.get(0);


        if (null != due && !("".equals(due))) {
            DateFormat formatter;
            Date date;
            formatter = new SimpleDateFormat("MM/dd/yyyy");
            try {
                date = (Date) formatter.parse(due);
            } catch (ParseException e) {
                String msg = "Incorrect due date " + due;
                log.error(msg);

                CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request,
                        response, getContextRoot(request) + "/" + webContext + "/issue/newIssue.jsp");
                return false;
            }
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);

            issue.setDueDate(cal);

        }

        issueKey = issueTrackerClient.createIssue(issue, token, credentials.getUrl());

        issue.setIssueKey(issueKey);
        httpSession.setAttribute("selectedAccount", account.get(0));
        httpSession.setAttribute("issue", issue);

        String msg = "Issue " + issueKey + " is successfully created";


        // attach bundle.info file

        if (null != bundleInfoFile && "on".equals(bundleInfoFile.get(0))) {

            issueTrackerClient.uploadBundleInfo(token, issueKey, credentials.getUrl());

        }


        //attach thread dump

        if (null != threadDump && "on".equals(threadDump.get(0))) {
            issueTrackerClient.uploadThreadDump(token, issueKey, credentials.getUrl());
        }

        //attach log file

        if (null != logFile && "on".equals(logFile.get(0))) {
            issueTrackerClient.uploadLogFile(token, issueKey, credentials.getUrl());
        }


        // attach files

        if (null != issueKey && !"".equals(issueKey)) {

            try {
                issueTrackerClient.uploadAttachments(token, issueKey, attachmentDataArray, credentials.getUrl());

            } catch (Exception e) {
                log.error(e.getMessage() + "Attached files seems to be corrupted.Please recheck and attach them again. ");
                CarbonUIMessage.sendCarbonUIMessage(e.getMessage() + "Attached files seems to be corrupted.Please recheck and attach them again."
                        , CarbonUIMessage.ERROR, request,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.