@Test public void beanstoxml() throws Exception { FileBean fbean = new FileBean(); fbean.setFile(ValueObjectUtil.getClassPathFile("org/frameworkset/soa/datasource-sql.xml")); ArrayBean bean = new ArrayBean(); String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<esb>" + "<call>" + "<!-- 调度中心需要的数据开始 -->" + "<property name=\"soamethodcall\" " + "class=\"org.frameworkset.soa.SOAMethodCall\" " + "f:requestor=\"requestor\" " + "f:requestid=\"1000000\" " + "f:password=\"requestpassword\" " + "f:encypt=\"encrypt\" " + "f:encyptalgorithem=\"algorithm\" " + "f:serviceid=\"hilaryserviceid\" " + "f:issynchronized=\"true\" >" + "<!-- 调度中心需要的数据结束 -->" + "<!-- 调度中心提交给服务提供方的服务方法信息 -->" + "<property name=\"soamethodinfo\" class=\"org.frameworkset.soa.SOAMethodInfo\" " + "f:methodName=\"methodname\">" + "<property name=\"paramTypes\">" + "<array componentType=\"Class\">" + "<property >String</property>" + "<property >String</property>" + "<property >String[]</property>" + "</array>" + "</property>" + "<property name=\"params\">" + "<array componentType=\"object\">" + "<property name=\"condition\">1=1</property>" + "<property name=\"orderby\">order by ${A}</property>" + "<property>" + " <array componentType=\"String\">" + "<property>A</property>" + "<property>B</property>" + "</array>" + "</property>" + "</array>" + "</property>" + "</property>" + "</property>" + "</call>" + "</esb>"; bean.setArrays(content.getBytes()); List beans = new ArrayList(); beans.add(fbean); beans.add(bean); String xmlcontent = ObjectSerializable.convertBeanObjectToXML("listObject", beans, List.class); System.out.println(xmlcontent); List copybeans = ObjectSerializable.convertXMLToBeanObject("listObject", xmlcontent, List.class); System.out.println(copybeans.size()); }
@Test public void filebeantoxml() throws Exception { FileBean bean = new FileBean(); bean.setFile(ValueObjectUtil.getClassPathFile("org/frameworkset/soa/datasource-sql.xml")); String xmlcontent = ObjectSerializable.convertBeanObjectToXML("beanfile", bean, bean.getClass()); System.out.println(xmlcontent); FileBean bean1 = ObjectSerializable.convertXMLToBeanObject("beanfile", xmlcontent, FileBean.class); // System.out.println(ValueObjectUtil.getFileContent(bean1.getFile(),"UTF-8")); }
public void filePropsLoaded( final PageParameter pageParameter, final Map<String, Object> dataBinding, final List<String> visibleToggleSelector, final List<String> readonlySelector, final List<String> disabledSelector) { final ComponentParameter nComponentParameter = FilePagerUtils.getComponentParameter(pageParameter); final IFilePagerHandle handle = (IFilePagerHandle) nComponentParameter.getComponentHandle(); final FileBean fileBean = handle.getEntityBeanByRequest(nComponentParameter); if (fileBean != null) { dataBinding.put("file_topic", fileBean.getTopic()); dataBinding.put("file_description", fileBean.getDescription()); } }
public void printNearlyFolders(List<FileBean> list) { List<FileBean> result = new ArrayList<FileBean>(); for (int i = 0; i < list.size(); i++) { FileBean beanA = list.get(i); String nameA = getFirstHalf(beanA.getName()); result.add(beanA); for (int j = i + 1; j < list.size(); j++) { FileBean beanB = list.get(j); String nameB = getFirstHalf(beanB.getName()); if (nameA.equals(nameB)) { result.add(beanB); list.remove(j); j--; } } if (result.size() != 1) { printResult(result); } result = new ArrayList<FileBean>(); } }
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { UserService userService = UserServiceFactory.getUserService(); String retUrl = req.getParameter("url"); if (retUrl == null) retUrl = "/"; String pathInfo = req.getPathInfo(); if (pathInfo.equals("/current")) { User user = userService.getCurrentUser(); if (user == null) { res.setStatus(401); res.setContentType("text/plain; charset=utf-8"); res.getWriter().write("Not login"); return; } UserBean ub = getByEmail(user.getEmail()); res.setContentType("application/json; charset=utf-8"); res.setHeader("Cache-control", "no-cache"); res.getWriter().write("{\"email\":\"" + user.getEmail() + "\""); if (ub != null) { res.getWriter().write(",\"nickName\":\"" + ub.getNickName() + "\""); res.getWriter().write(",\"isRegister\":true"); } else { String nn = user.getNickname(); if (nn == null) nn = user.getEmail(); res.getWriter().write(",\"nickName\":\"" + nn + "\""); res.getWriter().write(",\"isRegister\":false"); } res.getWriter().write("}"); } else if (pathInfo.equals("/login")) { String url = userService.createLoginURL(retUrl); res.sendRedirect(url); } else if (pathInfo.equals("/logout")) { String url = userService.createLogoutURL(retUrl); res.sendRedirect(url); } else if (pathInfo.equals("/register")) { User user = userService.getCurrentUser(); if (user == null) { res.setStatus(401); res.setContentType("text/plain; charset=utf-8"); res.getWriter().write("Not login"); return; } String nickName = req.getParameter("nickName"); UserBean ub = getByNeckName(nickName); if (ub != null) { res.setStatus(403); res.setContentType("text/plain; charset=utf-8"); res.getWriter().write("ニックネーム(" + nickName + ")は既に使われています。"); return; } ub = new UserBean(); ub.setEmail(user.getEmail()); ub.setNickName(nickName); usbs.put(user.getEmail(), ub); ursbs.put(nickName, ub); FileBean fb = new FileBean(); fb.setParentName(""); fb.setLastName(nickName); fb.setDirectory(true); fb.setLastModified(System.currentTimeMillis()); fb.setOwner(user.getEmail()); fb.setNickName(nickName); sbs.put("/" + nickName, fb); res.sendRedirect(retUrl); } }