⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savebusiness.java

📁 OpenWeb-UDDI是UDDI V2标准的实现
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   SaveBusiness.java

package org.huihoo.openweb.uddiserver.publish;

import java.io.IOException;
import java.io.PrintStream;
import java.net.*;
import java.sql.*;
import java.util.Enumeration;
import org.huihoo.openweb.uddi.*;
import org.huihoo.openweb.uddiserver.util.JavaUUIDGenerator;
import org.huihoo.openweb.uddiserver.util.SqlConnection;
import org.huihoo.openweb.uddiserver.util.validate_values;

// Referenced classes of package org.huihoo.openweb.uddiserver.publish:
//            SaveService, SaveCategory

public class SaveBusiness
{

    Connection con;

    public SaveBusiness(Connection c)
    {
        con = c;
    }

    public UddiObject getData(Save_Business save_b)
        throws SQLException, UDDIXmlException, MalformedURLException, ClassNotFoundException, IOException
    {
        System.out.println("xixixiixixxixixix");
        org.huihoo.openweb.uddi.AuthInfo authinfo = save_b.getAuthInfo();
        DispositionReport dr = new DispositionReport();
        BusinessDetail businessDetail = new BusinessDetail();
        if(authinfo == null || authinfo.getValue() == null || authinfo.getValue().equals(""))
        {
            Result result = Result.getResult(10120, "No auth token given");
            dr.setResult(result);
            return dr;
        }
		System.out.println("xixixiixixxixixix0");
        String authenticationtoken = authinfo.getValue();
        if(!SqlConnection.isPresent("authentiTokens", "keys", authenticationtoken))
        {
            Result result = Result.getResult(10120, "Auth token is not valid");
            dr.setResult(result);
            return dr;
        }
		System.out.println("xixixiixixxixixix1");
		//调用validate_values
		//sky加,2005-10-13
		boolean isValid=validate_values.performValidValues(save_b.getBusinessEntities()); 
//		boolean isValid=true;
		System.out.println("isValid: "+isValid);
		System.out.println("xixixiixixxixixix1111");
		if(!isValid){
			Result result = Result.getResult(20210, "keyValue provided is not valid ");
			dr.setResult(result);
			return dr;
		}
		System.out.println("xixixiixixxixixix2");
        
        for(Enumeration enum = save_b.getBusinessEntities(); enum.hasMoreElements();)
        {
            BusinessEntity businessEntity = (BusinessEntity)enum.nextElement();
            UddiObject obj = null;
            try
            {
                obj = getData(authenticationtoken, businessEntity);
                BusinessEntity bEntity = (BusinessEntity)obj;
                businessDetail.addElement(bEntity);
            }
            catch(ClassCastException e)
            {
                return obj;
            }
        }

		System.out.println("xixixiixixxixixix3");
        return businessDetail;
    }

    public UddiObject getData(String authenticationtoken, BusinessEntity entity)
        throws SQLException, UDDIXmlException, MalformedURLException, ClassNotFoundException
    {
        int counter = 0;
        Statement stmt = con.createStatement();
        String query = "select * from authentiTokens where  keys='" + authenticationtoken + "'";
        ResultSet rs = stmt.executeQuery(query);
        String userid = "";
        if(rs.next())
            userid = rs.getString("userid");
        stmt.close();
        if(userid.length() == 0)
        {
            Result result = Result.getResult(10120, "authinfo value provided is not valid ");
            return errorOccured(result);
        }
        //调用validate_values
		//sky加,2005-10-4
		DispositionReport dr = new DispositionReport();

        System.out.println("saveBusiness getData two parameter 1111111111111111111");
        String authorizedname = authenticationtoken;
        String operator = "www.huihoo.com";
        String businesskey = entity.getBusinessKey();
        if(businesskey == null){
            JavaUUIDGenerator generator = new JavaUUIDGenerator();
            businesskey = JavaUUIDGenerator.uuidgen();
            entity.setBusinessKey(new BusinessKey(businesskey));
        } else{
            Statement stmt0 = con.createStatement();
            String query1 = "select * from BusinessDetails where businesskey='" + businesskey + "'";
            ResultSet rs0 = stmt0.executeQuery(query1);
            if(rs0.next() && !rs0.getString("userid").equals(userid)){
                Result result = Result.getResult(10120, "Auth token is not valid(Userid has bot be matched)");
                dr.setResult(result);
                return dr;
            }
            stmt0.close();
        }
        System.out.println("saveBusiness getData two parameter 22222222222222222222222222");
        String businessname = "";
        for(Enumeration business = entity.getBusinessName(); business.hasMoreElements();)
            businessname = ((UddiObject)business.nextElement()).getValue();

        String businessdescription = "";
        if(entity.getDescription() != null)
        {
            for(Enumeration description = entity.getDescription(); description.hasMoreElements();)
                businessdescription = ((UddiObject)description.nextElement()).getValue();

        }
        System.out.println("desc ok!");
        Statement stmt1 = con.createStatement();
        String query1 = "select * from BusinessDetails where businesskey='" + businesskey + "'and userid ='" + userid + "'";
        for(ResultSet rs1 = stmt1.executeQuery(query1); rs1.next();)
            counter++;

        System.out.println(counter);
        Statement stmt2 = con.createStatement();
        String insertquery = "insert into BusinessDetails values('" + businesskey + "','" + authorizedname + "','" + operator + "','" + businessname + "','" + userid + "','" + businessdescription + "')";
        String updatequery = "update BusinessDetails set authorizedname='" + authorizedname + "',operator='" + operator + "',name='" + businessname + "',userid='" + userid + "',description='" + businessdescription + "'    where businesskey='" + businesskey + "'";
        if(counter == 0)
            stmt2.executeUpdate(insertquery);
        else
        if(counter == 1)
            stmt2.executeUpdate(updatequery);
        counter = 0;
        Statement stmt3 = con.createStatement();
        String query2 = "select * from DiscoveryURLs where businesskey='" + businesskey + "'";
        for(ResultSet rs2 = stmt3.executeQuery(query2); rs2.next();)
            counter++;

        Statement stmt4 = con.createStatement();
        org.huihoo.openweb.uddi.DiscoveryUrls dicoveryurls = null;
        String usetype = "businessEntity";
        if(counter == 0)
            try
            {
                InetAddress ip = InetAddress.getLocalHost();
                System.out.println(ip.getHostAddress());
                String urllink = "http://" + ip.getHostAddress().toString() + ":8080/openwebuddi/getbusiness.jsp?businesskey=" + businesskey;
                String discoveryinsert = "insert into DiscoveryURLs values('" + businesskey + "','" + urllink + "','" + usetype + "')";
                stmt4.executeUpdate(discoveryinsert);
                stmt4.close();
            }
            catch(UnknownHostException unknownhostexception) { }
        counter = 0;
        Statement stmt5 = con.createStatement();
        System.out.println("saveBusiness getData two parameter 2222222233333333");
        String query5 = "select * from Contacts where businesskey='" + businesskey + "'";
        System.out.println("saveBusiness getData two parameter 3333333333333333333");
        ResultSet rs5 = stmt5.executeQuery(query5);
        System.out.println("saveBusiness getData two parameter 444444444444444444");
        while(rs5.next()) 
            counter++;
        rs5.close();
        stmt5.close();
        Statement stmt6 = con.createStatement();
        System.out.println("saveBusiness getData two parameter 55555555555555555");
        Contacts contacts = null;
        if(entity.getContacts() != null)
            contacts = entity.getContacts();
        if(contacts != null)
        {
            for(Enumeration cont = contacts.getContacts(); cont.hasMoreElements();)
            {
                Contact contact = (Contact)cont.nextElement();
                String personname = contact.getPersonName();
                String descriptions = "";
                if(contact.getDescription() != null)
                    descriptions = contact.getDescription();
                String phoneusetype = "";
                String phoneno = "";
                if(contact.getPhone() != null)
                {
                    Enumeration ph = contact.getPhone();
                    ContactPhone phone = null;
                    if(ph.hasMoreElements())
                        phone = (ContactPhone)ph.nextElement();
                    if(phone != null)
                    {
                        phoneusetype = phone.getUseType();
                        phoneno = phone.getValue();
                    }
                }
                String emailusetype = "";
                String emailid = "";
                if(contact.getEmail() != null)
                {
                    ContactEmail email = contact.getEmail();
                    if(email != null)
                    {
                        emailusetype = email.getUseType();
                        emailid = email.getValue();
                    }
                }
                String add = "";
                System.out.println("1111111111111");
                if(contact.getAddress() != null)
                {
                    ContactAddress address = contact.getAddress();
                    if(address != null && address.getAddressLine() != null)
                    {
                        for(Enumeration addr = address.getAddressLine(); addr.hasMoreElements();)
                        {
                            ContactAddressLine Ca = (ContactAddressLine)addr.nextElement();
                            add = add + Ca.getValue();
                        }

                    }
                }
                String contactinsert = "insert into Contacts values('" + businesskey + "','" + personname + "','" + phoneusetype + "','" + phoneno + "','" + emailusetype + "','" + emailid + "','" + add + "')";
                String contactupdate = "update Contacts set businesskey='" + businesskey + "',personname='" + personname + "',phoneusetype='" + phoneusetype + "',phone='" + phoneno + "',emailusetype='" + emailusetype + "',email='" + emailid + "',address='" + add + "' where businesskey ='" + businesskey + "'";
                if(counter == 0)
                    stmt6.executeUpdate(contactinsert);
                else
                if(counter == 1)
                    stmt6.executeUpdate(contactupdate);
            }

        }
        counter = 0;
        BusinessServices services = entity.getBusinessServices();
        if(services != null)
        {
            for(Enumeration serviceenum = services.getBusinessService(); serviceenum.hasMoreElements();)
            {
                BusinessService service = (BusinessService)serviceenum.nextElement();
                SaveService saveservice = new SaveService(con);
                service.setBusinessKey(new BusinessKey(businesskey));
                UddiObject result = saveservice.save(service);
                if(result instanceof DispositionReport)
                    return result;
                result = (ServiceDetail)result;
            }

        }
        org.huihoo.openweb.uddi.CategoryBag categorybag = entity.getCategoryBag();
        if(categorybag != null)
        {
            SaveCategory category = new SaveCategory(categorybag, con, businesskey);
            category.save();
        }
        stmt1.close();
        stmt2.close();
        stmt3.close();
        stmt5.close();
        stmt6.close();
        return entity;
    }

    public UddiObject errorOccured(Result result)
        throws SQLException, ClassNotFoundException
    {
        con.close();
        DispositionReport pr = new DispositionReport();
        pr.setResult(result);
        return pr;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -