Package org.wso2.carbon.issue.tracker.ui

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


* TODO: class description
*/
public final class Util {

    public static void checkAccess(String ownerTenantDomain, int ownerTenantId) {
        CarbonContext carbonContext = getCarbonContext();
        String callerTenantDomain = carbonContext.getTenantDomain();
        if (callerTenantDomain == null) {
            throw new IllegalStateException("Caller tenant domain cannot be null");
        }
        int callerTenantId = carbonContext.getTenantId();
        if (callerTenantId == MultitenantConstants.INVALID_TENANT_ID) {
            throw new IllegalStateException("Caller Tenant ID cannot be " + MultitenantConstants.INVALID_TENANT_ID);
        }

        if (callerTenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME) &&
View Full Code Here


                                        "],[" + callerTenantId + "]}");
        }
    }

    private static CarbonContext getCarbonContext() {
        CarbonContext carbonContext = CarbonContext.getThreadLocalCarbonContext();
        if (carbonContext == null) {
            throw new IllegalStateException("CarbonContext cannot be null");
        }
        return carbonContext;
    }
View Full Code Here

            PrivilegedCarbonContext.endTenantFlow();
        }
    }

    private void setTenantCredentialsInCarbonContext() {
        PrivilegedCarbonContext cc = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        cc.setTenantId(ownerTenantId);
        cc.setTenantDomain(ownerTenantDomain);
    }
View Full Code Here

        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

        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

        }

        public void run() {
            try {
                MessageContext msgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
                Event<MessageContext> event = new Event(msgCtx);
                subscriptions = subscriptionManager.getMatchingSubscriptions(event);
            } catch (EventException e) {
                handleException("Matching subscriptions fetching error", e);
            }
View Full Code Here

     * @throws EventException event
     */
    private void processGetStatusRequest(MessageContext mc,
                                         ResponseMessageBuilder messageBuilder)
            throws AxisFault, EventException {
        Subscription subscription =
                SubscriptionMessageBuilder.createGetStatusMessage(mc);
        if (log.isDebugEnabled()) {
            log.debug("GetStatus request recived for SynapseSubscription ID : " +
                    subscription.getId());
        }
        subscription = subscriptionManager.getSubscription(subscription.getId());
        if (subscription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Sending GetStatus responce for SynapseSubscription ID : " +
                        subscription.getId());
            }
            //send the responce
            SOAPEnvelope soapEnvelope = messageBuilder.genGetStatusResponse(subscription);
            dispatchResponse(soapEnvelope, EventingConstants.WSE_GET_STATUS_RESPONSE,
                    mc, false);
View Full Code Here

            // Adding static subscriptions
            List<Subscription> staticSubscriptionList =
                    eventSource.getSubscriptionManager().getStaticSubscriptions();
            for (Iterator<Subscription> iterator = staticSubscriptionList.iterator();
                 iterator.hasNext();) {
                Subscription staticSubscription = iterator.next();
                OMElement staticSubElem =
                        fac.createOMElement("subscription", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                staticSubElem.addAttribute(
                        fac.createOMAttribute("id", nullNS, staticSubscription.getId()));
                OMElement filterElem =
                        fac.createOMElement("filter", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                filterElem.addAttribute(fac.createOMAttribute("source", nullNS,
                        (String) staticSubscription.getFilterValue()));
                filterElem.addAttribute(fac.createOMAttribute("dialect", nullNS,
                        (String) staticSubscription.getFilterDialect()));
                staticSubElem.addChild(filterElem);
                OMElement endpointElem =
                        fac.createOMElement("endpoint", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                OMElement addressElem =
                        fac.createOMElement("address", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                addressElem.addAttribute(
                        fac.createOMAttribute("uri", nullNS, staticSubscription.getEndpointUrl()));
                endpointElem.addChild(addressElem);
                staticSubElem.addChild(endpointElem);
                if (staticSubscription.getExpires() != null) {
                    OMElement expiresElem =
                            fac.createOMElement("expires", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                    fac.createOMText(expiresElem,
                            ConverterUtil.convertToString(staticSubscription.getExpires()));
                    staticSubElem.addChild(expiresElem);
                }
                evenSourceElem.addChild(staticSubElem);
            }
View Full Code Here


    public SynapseSubscription() {
        this.setId(UIDGenerator.generateURNString());
        this.setDeliveryMode(EventingConstants.WSE_DEFAULT_DELIVERY_MODE);
        SubscriptionData subscriptionData = new SubscriptionData();
        subscriptionData.setProperty(SynapseEventingConstants.STATIC_ENTRY, "false");
        this.setSubscriptionData(subscriptionData);
    }
View Full Code Here

                    .getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "class"));
            if (clazz != null) {
                String className = clazz.getAttributeValue();
                try {
                    Class subscriptionManagerClass = Class.forName(className);
                    SubscriptionManager manager =
                            (SubscriptionManager) subscriptionManagerClass.newInstance();
                    Iterator itr = subscriptionManagerElem.getChildrenWithName(PROPERTIES_QNAME);
                    while (itr.hasNext()) {
                        OMElement propElem = (OMElement) itr.next();
                        String propName =
                                propElem.getAttribute(new QName("name")).getAttributeValue();
                        String propValue =
                                propElem.getAttribute(new QName("value")).getAttributeValue();
                        if (propName != null && !"".equals(propName.trim()) &&
                                propValue != null && !"".equals(propValue.trim())) {

                            propName = propName.trim();
                            propValue = propValue.trim();

                            PasswordManager passwordManager =
                                    PasswordManager.getInstance();
                            String key = eventSource.getName() + "." + propName;

                            if (passwordManager.isInitialized()
                                    && passwordManager.isTokenProtected(key)) {
                                eventSource.putConfigurationProperty(propName, propValue);
                                propValue = passwordManager.resolve(propValue);
                            }

                            manager.addProperty(propName, propValue);
                        }
                    }
                    eventSource.setSubscriptionManager(manager);
                    eventSource.getSubscriptionManager()
                            .init(); // Initialise before doing further processing, required for static subscriptions
View Full Code Here

TOP

Related Classes of org.wso2.carbon.issue.tracker.ui.IssueTrackerClient

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.