Browse Source

session为空判断

huangzhiyong 8 years ago
parent
commit
efb3413d89

+ 3 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/ServiceFlowService.java

@ -349,6 +349,7 @@ public class ServiceFlowService {
                    return true;
                }
                System.out.println("post error,url: "+brokerServer.getURL() + path);
                return false;
            }
@ -359,6 +360,7 @@ public class ServiceFlowService {
                    logger.debug(body);
                    return true;
                }
                System.out.println("put error,url: "+brokerServer.getURL() + path);
                return false;
            }
@ -371,6 +373,7 @@ public class ServiceFlowService {
                    logger.debug(body);
                    return true;
                }
                System.out.println("delete error,url: "+brokerServer.getURL() + path);
                return false;
            }

+ 9 - 0
hos-broker/pom.xml

@ -138,6 +138,15 @@
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <!-- camel end -->
        <dependency>
            <groupId>com.yihu.hos</groupId>
            <artifactId>hos-core</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>

+ 10 - 5
hos-broker/src/main/java/com/yihu/hos/broker/services/camel/CamelCompiler.java

@ -4,7 +4,6 @@ import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import javax.tools.*;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
@ -19,20 +18,22 @@ import java.util.List;
public class CamelCompiler {
    private static final Logger logger = LoggerFactory.getLogger(CamelCompiler.class);
    public static boolean compile(String sourcePath, String targetPath) throws IOException {
    public static boolean compile(String sourcePath, String targetPath) {
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        boolean success =false;
        try {
        // 建立DiagnosticCollector对象
        DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
        StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, Charset.forName("UTF-8"));
        // 建立源文件对象,根据java模板文件生成要加载的java类
        Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjects(sourcePath);
        Iterable<String> options = Arrays.asList("-d", targetPath, "-sourcepath", targetPath);// 指定的路径一定要存在,javac不会自己创建文件夹
        Iterable<String> options = Arrays.asList("-d", targetPath, "-sourcepath", targetPath , "-target","1.8");// 指定的路径一定要存在,javac不会自己创建文件夹
        JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, options, null, compilationUnits);
        // 编译源程序
        boolean success = task.call();
         success = task.call();
        fileManager.close();
        if (!success) {
            logger.error("compile source file failed.");
            //错误信息打印
            List diagnosticList = diagnostics.getDiagnostics();
            for (Object aDiagnosticList : diagnosticList) {
@ -43,7 +44,11 @@ public class CamelCompiler {
            System.out.println("编译成功"+sourcePath);
        }
        }catch (Exception e){
            e.printStackTrace();
        }
        return success;
    }

+ 12 - 1
hos-broker/src/main/java/com/yihu/hos/broker/services/camel/ESBCamelService.java

@ -79,6 +79,7 @@ public class ESBCamelService {
                });
                if (!created[0]) {
                    System.out.println("onServiceFlowAdd ,生成processor文件失败,");
                    return Result.error("服务流程启动失败!");
                }
@ -91,6 +92,7 @@ public class ESBCamelService {
                    }
                });
                if (!created[0]) {
                    System.out.println("onServiceFlowAdd ,生成route文件失败,");
                    return Result.error("服务流程启动失败!");
                }
            } else {
@ -233,7 +235,6 @@ public class ESBCamelService {
            if (serviceFlowValid.is()) return Result.error("必要的入参数据不正确,请检查!");
            ServiceFlow serviceFlow = serviceFlowValid.getServiceFlow();
            String routeCode = serviceFlow.getRouteCode();
            ArrayList<ServiceFlow.HandleFile> handleFiles = serviceFlowValid.getHandleFiles();
            if ("java".equals(serviceFlowValid.getServiceFlow().getFlowType())) {
@ -249,7 +250,10 @@ public class ESBCamelService {
                });
                if (!created[0]) {
                    System.out.println("processor 生成失败!");
                    return Result.error("服务流程启动失败!");
                }else {
                    System.out.println("processor 生成成功!");
                }
                handleFiles.stream().filter(handleFile -> ServiceFlowConstant.FLOW_TYPE_ROUTE.equals(handleFile.getUsage())).forEach(handleFile -> {
@ -261,7 +265,10 @@ public class ESBCamelService {
                    }
                });
                if (!created[0]) {
                    System.out.println("route文件 生成失败!");
                    return Result.error("服务流程启动失败!");
                }else {
                    System.out.println("route文件 生成成功!");
                }
            } else {
                for (ServiceFlow.HandleFile handleFile : handleFiles) {
@ -325,6 +332,7 @@ public class ESBCamelService {
    private boolean generateClassFile(ServiceFlow.HandleFile handleFile) throws Exception {
        if (handleFile == null) {
            System.out.println("=====handleFile is null...");
            return false;
        }
        SystemCamelContext.putClassMapping(handleFile.getRouteCode(), handleFile.getPackageName(), handleFile.getUsage(), handleFile.getClassName());
@ -335,6 +343,7 @@ public class ESBCamelService {
        String sourcePath = ClassFileUtil.downFile(downUrl, resource, handleFile.getPackageName(), handleFile.getClassName(), ClassFileUtil.JAVA_FILE);
        if (sourcePath == null) {
            System.out.println("下载java文件失败,downUrl:"+downUrl);
            return false;
        }
@ -349,6 +358,8 @@ public class ESBCamelService {
            String fileName = handleFile.getClassName() + ClassFileUtil.CLASS_FILE;
            String uploadUrl = fsUrl + "/" + handleFile.getFilePath();
            ClassFileUtil.uploadFile(uploadUrl, new File(classPath), fileName);
        }else {
            System.out.println("编译失败,sourcePath:"+sourcePath);
        }
        return succ;
    }

+ 5 - 2
src/main/java/com/yihu/hos/common/CommonPageController.java

@ -143,10 +143,13 @@ public class CommonPageController extends BaseController {
    public String index(HttpServletRequest request, Model model) {
        HttpSession session = request.getSession();
        SystemUser user = (SystemUser) session.getAttribute("userInfo");
        TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION);
        if (session.getAttribute(ContextAttributes.TENANT_SESSION)!=null){
            TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION);
            model.addAttribute("tenant", tenantSession.getTenant());
        }
;
        model.addAttribute("userName", user.getUserName());
        model.addAttribute("tenant", tenantSession.getTenant());
        //获取菜单
        String menu = "[{id: 1, text: '任务管理',icon:'${staticRoot}/images/index/menu2_icon.png'},\n" +
                "        {id: 11, pid: 1, text: '任务跟踪', url: '${contextRoot}/datacollect/trackJob',targetType:'1'},\n" +

+ 1 - 0
src/main/java/com/yihu/hos/standard/service/adapter/AdapterMetadataService.java

@ -120,6 +120,7 @@ public class AdapterMetadataService extends SQLGeneralDAO {
            result.setTotalCount(count);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            return DetailModelResult.error("获取适配数据元列表失败");
        }
    }