Package org.wso2.carbon

Examples of org.wso2.carbon.CarbonException


    public void jsSet_mediaType(Object mediaType) throws CarbonException {
        if (mediaType instanceof String) {
            this.resource.setMediaType((String) mediaType);
        } else {
            throw new CarbonException("Invalid property type for mediaType");
        }
    }
View Full Code Here


                return new NativeArray((String[])result);
            } else {
                return Context.toObject(result, this);
            }
        } catch (RegistryException e) {
            throw new CarbonException("Registry Exception while reading content property", e);
        }
    }
View Full Code Here

    public void jsSet_content(Object content) throws CarbonException {
        if (content instanceof String) {
            try {
                this.resource.setContent((String) content);
            } catch (RegistryException e) {
                throw new CarbonException("Registry Exception while setting content property", e);
            }
        } else if (content instanceof XML) {
            try {
                this.resource.setContent(((XML)content).getAxiomFromXML());
            } catch (RegistryException e) {
                throw new CarbonException("Registry Exception while setting content property", e);
            }
        } else {
            throw new CarbonException("Invalid property type for content");
        }
    }
View Full Code Here

    public void jsSet_description(Object description) throws CarbonException {
        if (description instanceof String) {
            this.resource.setDescription((String) description);
        } else {
            throw new CarbonException("Invalid property type for description");
        }
    }
View Full Code Here

                getCurrentMessageContext().
                getConfigurationContext().getProperty("WORK_DIR") + File.separator + "extra" +
                                   File.separator + uuid + File.separator;
        File dirs = new File(extraFileLocation);
        if (!dirs.exists() && !dirs.mkdirs()) {
            throw new CarbonException("Unable to create directory " + dirs.getName());
        }
        File outFile = new File(extraFileLocation, uuid + suffix);
        return new FileInfo(uuid, outFile);
    }
View Full Code Here

                    Util.generateTryit(xmlSource, result, paramMap);

                    return WSDL2FormGenerator.SUCCESS;
                } else {
                    throw new CarbonException(WSDL2FormGenerator.SERVICE_INACTIVE);
                }
            } else {
                throw new CarbonException(WSDL2FormGenerator.SERVICE_NOT_FOUND);
            }
        } catch (MalformedURLException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (OMException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (ParserConfigurationException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (TransformerException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (AxisFault e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        }
    }
View Full Code Here

                builder.setBaseUri(getBaseURI(tryitWSDL));
            } else {
                String msg =
                        WSDL2FormGenerator.class.getName() + " standard WSDL document is not found";
                log.error(msg);
                throw new CarbonException(msg);
            }

            axisService = builder.populateService();
            updateMockProxyServiceGroup(axisService, MessageContext.getCurrentMessageContext()
                    .getConfigurationContext().getAxisConfiguration());
            List<String> exposeTxList = new ArrayList<String>();
            exposeTxList.add(ServerConstants.HTTP_TRANSPORT);
            axisService.setExposedTransports(exposeTxList);
            ByteArrayOutputStream wsdl2Bos = new ByteArrayOutputStream();
            if (hostName == null || hostName.length() == 0) {
                hostName = NetworkUtils.getLocalHostname();
            }

            // Endpoints are changed to those of proxy before printing WSDL to generate tryit.
            Map endpointMap = axisService.getEndpoints();
            HashMap<String, String> origUrlMap = new HashMap<String, String>();
            Set endKeySet = endpointMap.keySet();

            // Calculate endpoint for proxy service.
            TransportInDescription inDescription =
                    configCtx.getAxisConfiguration().getTransportIn(ServerConstants.HTTP_TRANSPORT);
            Parameter proxyParameter = inDescription.getParameter("proxyPort");

            String proxyEndpointPrefix = ServerConstants.HTTP_TRANSPORT + "://" + hostName;
            String proxyEndpointPort = ":" + inDescription.getParameter(PORT).getValue();

            // We check whether there is a proxyPort specified in the http Endpoint. If there is
            // one we need to use that port, but if its 80 we just ignore it.
            if (proxyParameter != null && !"-1".equals(proxyParameter.getValue())) {
                if (!"80".equals(proxyParameter.getValue())) {
                    proxyEndpointPort = ":" + proxyParameter.getValue();
                } else {
                    proxyEndpointPort = "";
                }
            }
            String serviceContextRoot = configCtx.getServiceContextPath();
            if (!serviceContextRoot.endsWith("/")) {
                serviceContextRoot = serviceContextRoot + "/";
            }
            String proxyEndpoint = proxyEndpointPrefix + proxyEndpointPort + serviceContextRoot +
                    axisService.getName() + "/";

            // Update all endpoints of proxy service.
            for (Object anEndKeySet : endKeySet) {
                String key = (String) anEndKeySet;
                AxisEndpoint ep = (AxisEndpoint) endpointMap.get(key);
                origUrlMap.put(key, ep.getEndpointURL());
                ep.setEndpointURL(proxyEndpoint);
            }


            // Original endpoints are restored in order to make call from proxy.
            for (Object anEndKeySet : endKeySet) {
                String key = (String) anEndKeySet;
                AxisEndpoint ep = (AxisEndpoint) endpointMap.get(key);
                ep.setEndpointURL(origUrlMap.get(key));
            }
            axisService.printWSDL2(wsdl2Bos, hostName);

            return generateTryitExternal(configCtx, wsdl2Bos, serviceName, operationName,
                    endpointName, fileResourcesMap, tryitWSDL.substring(0, tryitWSDL.lastIndexOf("/") + 1), fullPage, false);
        } catch (IOException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (XMLStreamException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (OMException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (ParserConfigurationException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (TransformerException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } finally {
            if (inXMLStream != null) {
                try {
                    inXMLStream.close();
                } catch (IOException e) {
View Full Code Here

                    Util.generateMockit(xmlSource, result, paramMap);

                    return WSDL2FormGenerator.SUCCESS;
                } else {
                    throw new CarbonException(WSDL2FormGenerator.SERVICE_INACTIVE);
                }
            } else {
                throw new CarbonException(WSDL2FormGenerator.SERVICE_NOT_FOUND);
            }
        } catch (MalformedURLException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (OMException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (ParserConfigurationException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (TransformerException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (AxisFault e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        }
    }
View Full Code Here

            return WSDL2FormGenerator.SUCCESS;

        } catch (IOException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (OMException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (ParserConfigurationException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (TransformerException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        }
    }
View Full Code Here

                        type = "application/javascript";
                    } else if (language.equalsIgnoreCase("e4x")) {
                        parameterMap.put("e4x", "true");
                        type = "text/javascript";
                    } else {
                        throw new CarbonException(WSDL2FormGenerator.UNSUPPORTED_LANG);
                    }

                    if (contentType != null && !"".equals(contentType.trim())) {
                        type = contentType;
                    }
                    type += "; charset=utf-8";
                    // Handling the localhost parameter. If set to true the stub will use localhost instead of the IP.
                    // Needed when stubs are needed fir inclusion in a mashup.
                    if (localhost != null && "true".equals(localhost)) {
                        parameterMap.put("localhost-endpoints", "true");
                    }
                    Util.generateStub(xmlSource, result, parameterMap);
                    return type;

                } else {
                    throw new CarbonException(WSDL2FormGenerator.SERVICE_INACTIVE);
                }
            } else {
                throw new CarbonException(WSDL2FormGenerator.SERVICE_NOT_FOUND);
            }
        } catch (OMException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (ParserConfigurationException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (TransformerException e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        } catch (AxisFault e) {
            log.error(e.getMessage(), e);
            throw new CarbonException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.CarbonException

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.