List of usage examples for java.lang ClassNotFoundException printStackTrace
public void printStackTrace()
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * Reads metadata from the Metadata Catalog and returns it as a String. The * specified user must be authorized to read the metadata resource. * /* ww w.j av a 2 s . com*/ * @param scope * The scope of the metadata document. * @param identifier * The identifier of the metadata document. * @param revision * The revision of the metadata document. * @param user * The user name value * @param authToken * The AuthToken object * @return The metadata document, an XML string. */ public File getMetadataFile(String scope, Integer identifier, String revision, String user, AuthToken authToken) throws ClassNotFoundException, SQLException, ClientProtocolException, IOException, Exception { String entityId = null; File levelOneEMLFile = null; boolean hasDataPackage = false; Integer revisionInt = new Integer(revision); String metadataId = composeResourceId(ResourceType.metadata, scope, identifier, revisionInt, entityId); try { DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); hasDataPackage = dataPackageRegistry.hasDataPackage(scope, identifier, revision); if (hasDataPackage) { /* * If we have the data package but it was previously deleted (i.e. * de-activated) * * Note: This logic is no longer valid as of Ticket #912: * https://trac.lternet.edu/trac/NIS/ticket/912 * * boolean isDeactivatedDataPackage = dataPackageRegistry .isDeactivatedDataPackage(scope, identifier); if (isDeactivatedDataPackage) { String message = "Attempting to read a metadata document that was " + "previously deleted from PASTA: " + metadataId; throw new ResourceDeletedException(message); } */ /* * Check whether user is authorized to read the data package metadata */ Authorizer authorizer = new Authorizer(dataPackageRegistry); boolean isAuthorized = authorizer.isAuthorized(authToken, metadataId, Rule.Permission.read); if (!isAuthorized) { String message = "User " + user + " does not have permission to read this metadata document: " + metadataId; throw new UnauthorizedException(message); } EmlPackageIdFormat emlPackageIdFormat = new EmlPackageIdFormat(); EmlPackageId emlPackageId = emlPackageIdFormat.parse(scope, identifier.toString(), revision); DataPackageMetadata dataPackageMetadata = new DataPackageMetadata(emlPackageId); if (dataPackageMetadata != null) { boolean evaluateMode = false; levelOneEMLFile = dataPackageMetadata.getMetadata(evaluateMode); } } } catch (ClassNotFoundException e) { logger.error("Error connecting to Data Package Registry: " + e.getMessage()); e.printStackTrace(); throw (e); } catch (SQLException e) { logger.error("Error connecting to Data Package Registry: " + e.getMessage()); e.printStackTrace(); throw (e); } return levelOneEMLFile; }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * Delete a data package in PASTA based on its scope and identifier values * // w ww . j a v a 2 s . co m * @param scope * The scope value of the data package to be deleted * @param identifier * The identifier value of the data package to be deleted * @param user * The user value * @param authToken * The authentication token object */ public boolean deleteDataPackage(String scope, Integer identifier, String user, AuthToken authToken) throws ClassNotFoundException, SQLException, ClientProtocolException, IOException, Exception { boolean hasDataPackage = false; boolean deleted = false; Integer revision = getNewestRevision(scope, identifier); try { /* * Do we have this data package in PASTA? */ DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); hasDataPackage = dataPackageRegistry.hasDataPackage(scope, identifier); /* * Check whether user is authorized to delete the data package */ String entityId = null; String resourceId = composeResourceId(ResourceType.dataPackage, scope, identifier, revision, entityId); Authorizer authorizer = new Authorizer(dataPackageRegistry); boolean isAuthorized = authorizer.isAuthorized(authToken, resourceId, Rule.Permission.write); if (!isAuthorized) { String message = "User " + user + " does not have permission to delete this data package: " + resourceId; throw new UnauthorizedException(message); } /* * If we do have this data package in PASTA, first check to see whether it * was previously deleted */ if (hasDataPackage) { boolean isDeactivatedDataPackage = dataPackageRegistry.isDeactivatedDataPackage(scope, identifier); if (isDeactivatedDataPackage) { String docid = EMLDataPackage.composeDocid(scope, identifier); String message = "Attempting to delete a data package that was previously deleted from PASTA: " + docid; throw new ResourceDeletedException(message); } /* * Delete the metadata from the Metadata Catalog */ MetadataCatalog solrCatalog = new SolrMetadataCatalog(solrUrl); EmlPackageIdFormat emlPackageIdFormat = new EmlPackageIdFormat(); EmlPackageId emlPackageId = emlPackageIdFormat.parse(scope, identifier.toString(), revision.toString()); solrCatalog.deleteEmlDocument(emlPackageId); /* * Delete the data package from the resource registry */ deleted = dataPackageRegistry.deleteDataPackage(scope, identifier); } } catch (ClassNotFoundException e) { logger.error("Error connecting to Data Package Registry: " + e.getMessage()); e.printStackTrace(); throw (e); } catch (SQLException e) { logger.error("Error connecting to Data Package Registry: " + e.getMessage()); e.printStackTrace(); throw (e); } return deleted; }
From source file:fr.insalyon.creatis.vip.vipcoworkapplet.Cowork.java
/** Initializes the applet Main */ @Override/*from ww w .j ava2s .com*/ public void init() { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Cowork.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Cowork.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Cowork.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Cowork.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the applet */ try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { try { sessionId = getParameter("sessionId"); email = getParameter("email"); endpoint = getCodeBase().toString() + "/fr.insalyon.creatis.vip.portal.Main/coworkservice"; DesignFrame frame = new DesignFrame(true); frame.setAppletParams(endpoint, email, sessionId); String home = System.getProperty("user.home"); File config = new File(home + File.separator + ".cowork/config"); PropertiesConfiguration pc = new PropertiesConfiguration(config); String password = (String) pc.getProperty("password"), login = (String) pc.getProperty("login"); PasswordDialog p = new PasswordDialog(null, "Please login to the knowledge base"); while (password == null || login == null) { if (p.showDialog()) { login = p.getName(); password = p.getPass(); } if (login != null && password != null) { if (JOptionPane.showConfirmDialog(null, "Remember credentials (unencrypted)?", "Rememeber?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { pc.setProperty("password", password); pc.setProperty("login", login); pc.save(); } } } KnowledgeBase kb = new KnowledgeBase("jdbc:mysql://" + getCodeBase().getHost() + "/cowork", login, password, "http://cowork.i3s.cnrs.fr/"); frame.setKB(kb); frame.setVisible(true); } catch (ConfigurationException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, ExceptionUtils.getStackTrace(ex), "Error", JOptionPane.ERROR_MESSAGE); } catch (SQLException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, ExceptionUtils.getStackTrace(ex), "Error", JOptionPane.ERROR_MESSAGE); } } }); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, ExceptionUtils.getStackTrace(ex), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:com.example.sensingapp.SensingApp.java
/** Called when the activity is first created. */ @Override//w ww . ja v a2 s.c o m public void onCreate(Bundle savedInstanceState) { int i; Location location = null; super.onCreate(savedInstanceState); if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } try { Class.forName("android.os.AsyncTask"); } catch (ClassNotFoundException e) { e.printStackTrace(); } m_smSurScan = (SensorManager) getSystemService(SENSOR_SERVICE); PackageManager pm = getPackageManager(); m_riHome = pm.resolveActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), 0); m_nBufferSize = AudioRecord.getMinBufferSize(m_nAudioSampleRate, AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT); m_tmCellular = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); checkSensorAvailability(); //Get Existing Project Name and Existing User Name preconfigSetting(); /* When the power button is pressed and the screen goes off, the sensors will stop work by default, * Here keep the CPU on to keep sensor alive and also use SCREEN_OFF notification to re-enable GPS/WiFi */ PowerManager pwrManager = (PowerManager) getSystemService(Context.POWER_SERVICE); m_wakeLock = pwrManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(m_ScreenOffReceiver, filter); show_screen1(); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @param cls//from w ww. ja va 2s. c o m * @return an initialized instance of the appropriate OjbectAttachmentIFace implementation. */ protected ObjectAttachmentIFace<? extends DataModelObjBase> getAttachmentObject(final Class<?> cls) { ObjectAttachmentIFace<? extends DataModelObjBase> result = null; // Redesigned to handle anytime of Attachment upload Exception ex = null; String className = cls.getName() + "Attachment"; try { Class<?> createClass = Class.forName(className); result = (ObjectAttachmentIFace<?>) createClass.newInstance(); if (result != null) { ((DataModelObjBase) result).initialize(); } } catch (ClassNotFoundException e) { ex = e; e.printStackTrace(); } catch (InstantiationException e) { ex = e; e.printStackTrace(); } catch (IllegalAccessException e) { ex = e; e.printStackTrace(); } if (ex != null) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(Uploader.class, ex); } return result; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java
/** * @param className//from ww w .ja va2 s. co m * @param iconName * @param tooltipKey */ protected void createPlugin(final String className, final String iconName, final String tooltipKey) { try { final Class<?> wbPluginCls = Class.forName(className); final WorkBenchPluginIFace wbPlugin = (WorkBenchPluginIFace) wbPluginCls.newInstance(); workBenchPlugins.put(wbPluginCls, wbPlugin); wbPlugin.setWorkbenchPaneSS(this); wbPlugin.setSpreadSheet(spreadSheet); wbPlugin.setWorkbench(workbench); workBenchPluginSSBtns.addAll(wbPlugin.getSSButtons()); workBenchPluginFormBtns.addAll(wbPlugin.getFormButtons()); // List<String> missingFields = wbPlugin.getMissingFieldsForPlugin(); // if (missingFields != null && missingFields.size() > 0) // { // btn.setEnabled(false); // String ttText = "<p>" + getResourceString("WB_ADDITIONAL_FIELDS_REQD") + ":<ul>"; // for (String reqdField : missingFields) // { // ttText += "<li>" + reqdField + "</li>"; // } // ttText += "</ul>"; // String origTT = btn.getToolTipText(); // btn.setToolTipText("<html>" + origTT + ttText); // } // else // { // btn.setEnabled(true); // } // } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:com.genscript.gsscm.product.service.ProductService.java
/** * ?Product/*from www.j ava 2s . c o m*/ * * @param productDTO * @return */ public Product saveProduct(ProductDTO productDTO, Integer userId, String ruleId, String path) { boolean isAdd = false; if (productDTO.getProductId() == null || productDTO.getProductId() == 0) { isAdd = true; } Product product = this.dozer.map(productDTO, Product.class); Product dbProduct = this.productDao.findUniqueBy("catalogNo", product.getCatalogNo()); if (dbProduct != null && (product.getProductId() == null || !(product.getProductId().equals(dbProduct.getProductId())))) { System.out.println("ruleId:" + ruleId); if (ruleId != null && !ruleId.equals("") && !ruleId.equals("null")) { System.out.println("ruleId:" + ruleId); this.saveCatalogNoRules(Integer.valueOf(ruleId)); } // this.productDao.getSession().evict(dbProduct); throw new BussinessException(BussinessException.ERR_PRODUCT_CATALOGNO_UNIQUE); } this.productDao.getSession().evict(dbProduct); Integer objectId = product.getProductId();// for approved. Date now = new Date(); product.setModifiedBy(userId); if (product.getProductId() == null) { product.setCreatedBy(userId); product.setCreationDate(now); } product.setModifyDate(now); if (product.getDimUom() == null) { product.setDimUom("inches"); } this.productDao.save(product); if (ruleId != null && !ruleId.equals("") && !ruleId.equals("null")) { System.out.println("ruleId:" + ruleId); this.saveCatalogNoRules(Integer.valueOf(ruleId)); } this.attachShipCondition(product, productDTO.getShipCondition(), userId); this.attachStorageCondition(product, productDTO.getStorageCondition(), userId); this.attachPdtRestrictShip(product, productDTO.getRestrictShipList(), productDTO.getDelRestrictShipIdList(), userId); this.attachPdtIntmd(product, productDTO.getIntmdList(), productDTO.getDelIntmdIdList(), userId); this.attachPdtComponent(product, productDTO.getComponentList(), productDTO.getDelComIdList(), userId); this.attachPdtSpecialPrice(product, productDTO.getSpecialPriceList(), productDTO.getDelSpecialPriceIdList(), userId); this.attachPdtSupplier(product, productDTO.getVendorProductList(), productDTO.getDelVendorProductIdList(), userId); this.attachPdtRelation(product, productDTO.getPdtRelationList(), userId); this.attachPdtRoyalty(product, productDTO.getRoyaltyProduct(), userId); this.attachProductMoreInfo(productDTO.getProductExtendedInfo(), userId, product.getProductId()); this.attachPdtPrice(dbProduct, productDTO.getPriceList(), product.getProductId(), productDTO.getDelPriceIdList(), userId); this.attachProductReference(productDTO.getProductReferenceList(), product.getProductId(), userId, productDTO.getDelReferenceList()); String productType = productDTO.getType(); if (productType != null) { productType = productType.toLowerCase(); Integer productId = product.getProductId(); if ("peptide".equals(productType)) { this.attachPdtOfPeptide(productId, productDTO.getPeptide(), userId); } else if ("antibody".equals(productType)) { this.attachPdtOfAntibody(productId, productDTO.getAntibody(), userId); } else if ("enzyme".equals(productType)) { this.attachPdtOfEnzyme(productId, productDTO.getEnzyme(), userId); } else if ("gene".equals(productType)) { this.attachPdtOfGene(productId, productDTO.getGene(), userId); } else if ("kit".equals(productType)) { this.attachPdtOfKit(productId, productDTO.getKit(), userId); } else if ("oligo".equals(productType)) { this.attachPdtOfOligo(productId, productDTO.getOligo(), userId); } else if ("protein".equals(productType)) { this.attachPdtOfProtein(productId, productDTO.getProtein(), userId); } else if ("molecule".equals(productType)) { this.attachPdtOfMolecule(productId, productDTO.getMolecule(), userId); } else if ("chemicals".equals(productType)) { this.attachPdtOfChemical(productId, productDTO.getChemical(), userId); } } // with lifeng's approved module. Integer requestId = null; productApproved(productDTO, userId, product, objectId, requestId); Integer priceRequestId = null; if (productDTO.getPriceList() != null && productDTO.getPriceList().size() > 0) { for (ProductPriceDTO priceDTO : productDTO.getPriceList()) { Integer objectPriceId = priceDTO.getPriceId(); productPriceApproved(productDTO, userId, priceDTO, objectPriceId, priceRequestId); } } String wordString = ""; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String s = sdf.format(new Date()); if (path != null && !path.equals("")) { try { if (product.getProductClsId().equals(2)) {// Peptide Rp? String readPath = path + "wordModel//Emodel.doc"; wordString = WordPOIUtil.readWordFileToString(readPath); Peptide peptide = this.peptideDao.getById(product.getProductId()); if (peptide != null) { if (peptide.getPhoenixpeptideCatNo() == null) { wordString = wordString.replaceAll("catalogNo", " "); } else { wordString = wordString.replaceAll("catalogNo", " " + product.getCatalogNo()); } if (peptide.getMolecularFormula() == null) { wordString = wordString.replaceAll("productformula", " "); } else { wordString = wordString.replaceAll("productformula", " " + peptide.getMolecularFormula()); } if (peptide.getSequenceShortening() == null) { wordString = wordString.replaceAll("tttttt", ""); } else { wordString = wordString.replaceAll("tttttt", " " + peptide.getSequenceShortening()); } if (peptide.getCasNo() == null) { wordString = wordString.replaceAll("ssaaa", " "); } else { wordString = wordString.replaceAll("ssaaa", " " + peptide.getCasNo()); } if (peptide.getMolecularWeight() == null) { wordString = wordString.replaceAll("productmw", " "); } else { wordString = wordString.replaceAll("productmw", " " + peptide.getMolecularWeight()); } if (peptide.getSpecificity() == null) { wordString = wordString.replaceAll("ag", ""); } else { wordString = wordString.replaceAll("ag", "" + peptide.getSpecificity()); } if (peptide.getPurity() == null) { wordString = wordString.replaceAll("productPurity", " "); } else { wordString = wordString.replaceAll("productPurity", " " + peptide.getPurity()); } if (peptide.getSequence() == null) { wordString = wordString.replaceAll("productsequence", " "); } else { wordString = wordString.replaceAll("productsequence", " " + peptide.getSequence()); } if (peptide.getCterminal() == null) { wordString = wordString.replaceAll("productcterminal", " "); } else { wordString = wordString.replaceAll("productcterminal", " " + peptide.getCterminal()); } if (peptide.getNterminal() == null) { wordString = wordString.replaceAll("productnterminal", " "); } else { wordString = wordString.replaceAll("productnterminal", " " + peptide.getNterminal()); } if (peptide.getConcentration() == null) { wordString = wordString.replaceAll("productchemicalbridge", ""); } else { wordString = wordString.replaceAll("productchemicalbridge", "" + peptide.getConcentration()); } if (peptide.getSpecificActivity() == null) { wordString = wordString.replaceAll("bbbb", " "); } else { wordString = wordString.replaceAll("bbbb", " " + peptide.getSpecificActivity()); } if (peptide.getEndotoxinLevel() == null) { wordString = wordString.replaceAll("productendotoxinlevel", " "); } else { wordString = wordString.replaceAll("productendotoxinlevel", " " + peptide.getEndotoxinLevel()); } if (peptide.getConcentration() == null) { wordString = wordString.replaceAll("productconcentration", " "); } else { wordString = wordString.replaceAll("productconcentration", " " + peptide.getConcentration()); } if (peptide.getQualityControl() == null) { wordString = wordString.replaceAll("productqualitycontrol", " "); } else { wordString = wordString.replaceAll("productqualitycontrol", " " + peptide.getQualityControl()); } if (productDTO.getStorageCondition().getComment() == null) { wordString = wordString.replaceAll("productstorage", " "); } else { wordString = wordString.replaceAll("productstorage", " " + productDTO.getStorageCondition().getComment()); } if (product.getShortDesc() == null) { wordString = wordString.replaceAll("productnotes", " "); } else { wordString = wordString.replaceAll("productnotes", " " + product.getShortDesc()); } } else { wordString = wordString.replaceAll("productformula", " "); wordString = wordString.replaceAll("ssaaa", " "); wordString = wordString.replaceAll("tttttt", " "); wordString = wordString.replaceAll("productmw", " "); wordString = wordString.replaceAll("productPurity", " "); wordString = wordString.replaceAll("bbbb", ""); wordString = wordString.replaceAll("productsequence", " "); wordString = wordString.replaceAll("productcterminal", " "); wordString = wordString.replaceAll("ag", " "); wordString = wordString.replaceAll("productendotoxinlevel", " "); wordString = wordString.replaceAll("productconcentration", " "); wordString = wordString.replaceAll("productqualitycontrol", " "); wordString = wordString.replaceAll("productstorage", " "); wordString = wordString.replaceAll("productnotes", " "); } if (product.getSize() == null) { wordString = wordString.replaceAll("sizes", " "); } else { String size = " " + product.getSize().toString() + " " + product.getUom(); if (product.getAltSize() != null) { size += " or " + product.getAltSize().toString() + " " + product.getAltUom(); } wordString = wordString.replaceAll("sizes", size); } if (product.getName() == null) { wordString = wordString.replaceAll("name", " "); } else { wordString = wordString.replaceAll("name", " " + product.getName()); } if (product.getCatalogNo() == null) { wordString = wordString.replaceAll("catalogNo", " "); } else { wordString = wordString.replaceAll("catalogNo", " " + product.getCatalogNo()); } if (productDTO.getStorageCondition().getComment() == null) { wordString = wordString.replaceAll("productstorage", " "); } else { wordString = wordString.replaceAll("productstorage", " " + productDTO.getStorageCondition().getComment()); } SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String dateStr = df.format(new Date()); wordString = wordString.replaceAll("datetime", " Version: " + dateStr); String writeP = this.fileService.getUploadPath(); String writePath = writeP + "productFile_notes/" + product.getCatalogNo() + "_" + s + ".doc"; System.out.println(writePath); WordPOIUtil.writeWordFile(writePath, wordString); } if (product.getProductClsId().equals(6)) {// Antibody String readPath = path + "wordModel//Amodel.doc"; wordString = WordPOIUtil.readWordFileToString(readPath); Antibody antibody = this.antibodyDao.getById(product.getProductId()); ProductExtendedInfo productExtendedInfo = this.pdtExtInfoDao.getById(product.getProductId()); if (product.getName() == null) { wordString = wordString.replaceAll("name", " "); } else { wordString = wordString.replaceAll("name", " " + product.getName()); } if (product.getCatalogNo() == null) { wordString = wordString.replaceAll("catalogNo", " "); } else { wordString = wordString.replaceAll("catalogNo", " " + product.getCatalogNo()); } if (product.getSize() == null) { wordString = wordString.replaceAll("productSize", " "); } else { String size = " " + product.getSize().toString() + " " + product.getUom(); if (product.getAltSize() != null) { size += " or " + product.getAltSize().toString() + " " + product.getAltUom(); } wordString = wordString.replaceAll("productSize", size); } if (product.getSellingNote() == null) { wordString = wordString.replaceAll("sellingNote", " "); } else { wordString = wordString.replaceAll("sellingNote", " " + product.getSellingNote()); } if (antibody != null) { if (antibody.getHostSpecies() == null) { wordString = wordString.replaceAll("hostSpecies", " "); } else { wordString = wordString.replaceAll("hostSpecies", " " + antibody.getHostSpecies()); } if (antibody.getConjugation() == null) { wordString = wordString.replaceAll("productConjugation", " "); } else { wordString = wordString.replaceAll("productConjugation", " " + antibody.getConjugation()); } if (antibody.getImmunogen() == null) { wordString = wordString.replaceAll("productImmunogen", " "); } else { wordString = wordString.replaceAll("productImmunogen", " " + antibody.getImmunogen()); } if (antibody.getAntigenSpecies() == null) { wordString = wordString.replaceAll("antigenSpecies", " "); } else { wordString = wordString.replaceAll("antigenSpecies", " " + antibody.getAntigenSpecies()); } if (antibody.getSpeciesReactivity() == null) { wordString = wordString.replaceAll("speciesReactivity", " "); } else { wordString = wordString.replaceAll("speciesReactivity", " " + antibody.getSpeciesReactivity()); } if (antibody.getSubclass() == null) { wordString = wordString.replaceAll("productSubclass", " "); } else { wordString = wordString.replaceAll("productSubclass", " " + antibody.getSubclass()); } if (antibody.getPurification() == null) { wordString = wordString.replaceAll("productPurification", " "); } else { wordString = wordString.replaceAll("productPurification", " " + antibody.getPurification()); } if (antibody.getConcentration() == null) { wordString = wordString.replaceAll("productConcentration", " "); } else { wordString = wordString.replaceAll("productConcentration", " " + antibody.getConcentration()); } if (antibody.getConcentration() == null) { wordString = wordString.replaceAll("productSpecificity", " "); } else { wordString = wordString.replaceAll("productSpecificity", " " + antibody.getSpecificity()); } } else { wordString = wordString.replaceAll("hostSpecies", " "); wordString = wordString.replaceAll("productImmunogen", " "); wordString = wordString.replaceAll("antigenSpecies", " "); wordString = wordString.replaceAll("speciesReactivity", " "); wordString = wordString.replaceAll("productSubclass", " "); wordString = wordString.replaceAll("productPurification", " "); wordString = wordString.replaceAll("productConcentration", " "); } if (productDTO.getStorageCondition().getTemperature() == null) { wordString = wordString.replaceAll("temperature", " "); } else { String str = "Store at " + productDTO.getStorageCondition().getTemperature().toString() + " C"; if (productDTO.getStorageCondition().getComment() != null) { str += "/ " + productDTO.getStorageCondition().getComment(); } wordString = wordString.replaceAll("temperature", str); } if (productExtendedInfo != null) { if (productExtendedInfo.getApplications() == null) { wordString = wordString.replaceAll("productApplication", " "); } else { wordString = wordString.replaceAll("productApplication", " " + productExtendedInfo.getApplications()); } } else { wordString = wordString.replaceAll("productApplication", " "); } } if (product.getProductClsId().equals(3)) { String readPath = path + "wordModel//Zmodel.doc"; wordString = WordPOIUtil.readWordFileToString(readPath); Protein protein = this.proteinDao.getById(product.getProductId()); if (protein != null) { if (product.getName() == null) { wordString = wordString.replaceAll("measuredMolecularWeight", " "); } else { wordString = wordString.replaceAll("measuredMolecularWeight", " " + protein.getMolecularWeight()); } if (product.getName() == null) { wordString = wordString.replaceAll("productPurty", " "); } else { wordString = wordString.replaceAll("productPurty", " " + protein.getPurity()); } if (product.getName() == null) { wordString = wordString.replaceAll("proudctEndotoxinLevel", " "); } else { wordString = wordString.replaceAll("proudctEndotoxinLevel", " " + protein.getEndotoxinLevel()); } if (product.getName() == null) { wordString = wordString.replaceAll("productQuantitation", " "); } else { wordString = wordString.replaceAll("productQuantitation", " " + protein.getQuantitation()); } if (product.getName() == null) { wordString = wordString.replaceAll("productSpecificActivity", " "); } else { wordString = wordString.replaceAll("productSpecificActivity", " " + protein.getSpecificActivity()); } if (product.getName() == null) { wordString = wordString.replaceAll("productFormulation", " "); } else { wordString = wordString.replaceAll("productFormulation", " " + protein.getFormulation()); } if (product.getName() == null) { wordString = wordString.replaceAll("productReconstitution", " "); } else { wordString = wordString.replaceAll("productReconstitution", " " + protein.getReconstitution()); } if (product.getName() == null) { wordString = wordString.replaceAll("productSequence", " "); } else { wordString = wordString.replaceAll("productSequence", " " + protein.getSequence()); } if (product.getName() == null) { wordString = wordString.replaceAll("productDimers", " "); } else { wordString = wordString.replaceAll("productDimers", " " + protein.getDimers()); } if (product.getName() == null) { wordString = wordString.replaceAll("productSequencAnalysis", " "); } else { wordString = wordString.replaceAll("productSequencAnalysis", " " + protein.getSequenceAnalysis()); } if (product.getName() == null) { wordString = wordString.replaceAll("productSource", " "); } else { wordString = wordString.replaceAll("productSource", " " + protein.getSource()); } } else { wordString = wordString.replaceAll("measuredMolecularWeight", " "); wordString = wordString.replaceAll("productPurty", " "); wordString = wordString.replaceAll("proudctEndotoxinLevel", " "); wordString = wordString.replaceAll("productQuantitation", " "); wordString = wordString.replaceAll("productSpecificActivity", " "); wordString = wordString.replaceAll("productFormulation", " "); wordString = wordString.replaceAll("productReconstitution", " "); wordString = wordString.replaceAll("productSequence", " "); wordString = wordString.replaceAll("productDimers", " "); wordString = wordString.replaceAll("productSequencAnalysis", " "); wordString = wordString.replaceAll("productSource", " "); } if (product.getName() == null) { wordString = wordString.replaceAll("name", " "); } else { wordString = wordString.replaceAll("name", " " + product.getName()); } if (product.getCatalogNo() == null) { wordString = wordString.replaceAll("catalogNo", " "); } else { wordString = wordString.replaceAll("catalogNo", " " + product.getCatalogNo()); } if (product.getName() == null) { wordString = wordString.replaceAll("productDescription", " "); } else { wordString = wordString.replaceAll("productDescription", " " + product.getShortDesc()); } if (product.getName() == null) { wordString = wordString.replaceAll("productStorage", " "); } else { wordString = wordString.replaceAll("productStorage", " " + productDTO.getStorageCondition().getComment()); } } } catch (IOException e) { e.printStackTrace(); } SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String dateStr = df.format(new Date()); wordString = wordString.replaceAll("datetime", " Version: " + dateStr); String writeP = this.fileService.getUploadPath(); String writePath = writeP + "productFile_notes/" + product.getCatalogNo() + "_" + s + ".doc"; WordPOIUtil.writeWordFile(writePath, wordString); Integer loginUserId = SessionUtil.getUserId(); df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); Documents document = null; if (product.getProductId() != null && !"".equals(product.getProductId())) { // Documents?? document = this.documentdao.getByProductId(product.getProductId()); String dates = ""; dates = df.format(now); String filePath = "productFile_notes/" + product.getCatalogNo() + "_" + s + ".doc"; String docname = product.getCatalogNo() + "_" + s + ".doc"; if (document.getDocId() != null) { DocumentVersion ver = this.dozer.map(document, DocumentVersion.class); ver.setVersion(document.getVersion()); ver.setDocFilePath(filePath); ver.setDocId(document.getDocId()); ver.setCreatedBy(userId); ver.setCreationDate(now); ver.setModifiedBy(userId); ver.setModifyDate(now); this.documentVersionDao.save(ver); String sql = ""; sql = "update `product`.`documents` set doc_name='" + docname + "',version='" + format.format(now) + "',doc_type='Document-DATASHEET'," + "doc_file_type='DOC',doc_file_name='" + docname + "'," + "doc_file_path='" + filePath + "',description='new document for datesheet !',old_flag='4'," + "internal_flag='1',validate_flag='1',creation_date='" + dates + "',created_by='" + loginUserId + "',modify_date='" + dates + "',modified_by='" + loginUserId + "' where doc_id=" + document.getDocId(); System.out.println(sql); ClassPathResource cr = new ClassPathResource("application.properties"); Properties pros = new Properties(); try { pros.load(cr.getInputStream()); } catch (IOException e3) { e3.printStackTrace(); } String user = pros.getProperty("jdbc.username"); String password = pros.getProperty("jdbc.password"); String url = pros.getProperty("jdbc.url"); String driver = pros.getProperty("jdbc.driver"); Connection con = null; Statement stmt = null; int s1 = 0; try { Class.forName(driver); con = DriverManager.getConnection(url, user, password); stmt = con.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY); s1 = stmt.executeUpdate(sql); if (s1 != -1) { System.out.println(" create it ok ~"); } } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (SQLException e2) { e2.printStackTrace(); } finally { try { if (stmt != null) stmt.close(); if (con != null) con.close(); } catch (SQLException e) { System.out.println(e.toString()); } } } else { Documents entity = new Documents(); entity.setCreatedBy(loginUserId); entity.setCreationDate(now); entity.setModifiedBy(userId); entity.setModifyDate(now); entity.setDocFileName(docname); entity.setDocFilePath(filePath); entity.setDocFileType("DOC"); entity.setDocName(docname); entity.setInternalFlag("1"); entity.setValidateFlag("1"); entity.setOldFlag("4"); entity.setDocType("Document-DATASHEET"); entity.setDescription("new document for datesheet !"); this.documentDao.save(entity); ProductDocuments pd = new ProductDocuments(); pd.setCreatedBy(userId); pd.setCreationDate(now); pd.setModifiedBy(userId); pd.setModifyDate(now); pd.setDocId(entity.getDocId()); pd.setProductId(product.getProductId()); this.productDocumentDao.save(pd); } } } if (isAdd) { ApplicationEvent evt = new NewPartEvent(this, productDTO); context.publishEvent(evt); } else { ApplicationEvent evt = new NewPartEvent(this, productDTO); context.publishEvent(evt); } return product; }
From source file:com.zb.app.biz.service.TravelCompanyServiceTest.java
@Test public void testAdd() { String JDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; // SQL?/*from w w w .j a va 2 s .com*/ String connectDB = "jdbc:sqlserver://202.91.242.116:1314;DatabaseName=TravelDB"; // ?? ?????? // ? try { // ??? Class.forName(JDriver); } catch (ClassNotFoundException e) { // e.printStackTrace(); System.out.println("?"); System.exit(0); } System.out.println("??"); try { String user = "sa"; // ?????????? String password = "zhangwenjin@123"; Connection con = DriverManager.getConnection(connectDB, user, password); // ? System.out.println("??"); Statement stmt = con.createStatement(); Statement stmt2 = con.createStatement(); // SQL // // System.out.println(""); // SQL? // String query= "create table TABLE1(ID NCHAR(2),NAME NCHAR(10))"; // stmt.executeUpdate(query);//SQL // System.out.println("?"); // // //? // System.out.println("??"); // String a1="INSERT INTO TABLE1 VALUES('1','')"; // //??SQL? // String a2="INSERT INTO TABLE1 VALUES('2','')"; // String a3="INSERT INTO TABLE1 VALUES('3','')"; // stmt.executeUpdate(a1);//SQL // stmt.executeUpdate(a2); // stmt.executeUpdate(a3); // System.out.println("???"); // ?? System.out.println("??"); ResultSet rs = stmt.executeQuery("SELECT * FROM TRAVEL_COMPANY");// SQL?(?) // ?? while (rs.next()) { // ? System.out.println(rs.getString("C_ID") + "\t" + rs.getString("C_NAME")); TravelCompanyDO travelCompanyDO = new TravelCompanyDO(); if (rs.getInt("C_TYPE") == 0) { travelCompanyDO.setcType(3); } else { travelCompanyDO.setcType(rs.getInt("C_TYPE")); } travelCompanyDO.setcName(rs.getString("C_NAME")); travelCompanyDO.setcProvince(rs.getString("C_Province")); travelCompanyDO.setcCity(rs.getString("C_City")); travelCompanyDO.setcCounty(rs.getString("C_County")); travelCompanyDO.setcCustomname(rs.getString("C_CustomName")); travelCompanyDO.setcLogo(rs.getString("C_Logo")); travelCompanyDO.setcQQ(rs.getString("C_QQ")); travelCompanyDO.setcEmail(rs.getString("C_Email")); travelCompanyDO.setcTel(rs.getString("C_Tel")); travelCompanyDO.setcFax(rs.getString("C_Fax")); travelCompanyDO.setcMobile(rs.getString("C_Mobile")); travelCompanyDO.setcAddress(rs.getString("C_Address")); travelCompanyDO.setcAboutus(rs.getString("C_AboutUs")); travelCompanyDO.setcContact(rs.getString("C_Contact")); travelCompanyDO.setcDefaultCity(rs.getString("C_DefaultCity")); travelCompanyDO.setcCityTop(rs.getString("C_CityTop")); travelCompanyDO.setcCityList(rs.getString("C_CityList")); travelCompanyDO.setcBank(rs.getString("C_Bank")); travelCompanyDO.setcCorporation(rs.getString("C_Referrer")); travelCompanyDO.setcRecommend(rs.getString("C_Corporation")); travelCompanyDO.setcLoginTime(rs.getDate("C_LoginTime")); travelCompanyDO.setcState(1); travelCompanyDO.setcSpell(PinyinParser.converterToFirstSpell(travelCompanyDO.getcName())); service.insert(travelCompanyDO); ResultSet rsMember = stmt2 .executeQuery("SELECT * FROM TRAVEL_MEMBER WHERE C_ID = " + rs.getInt("C_ID")); TravelMemberDO travelMemberDO = new TravelMemberDO(); while (rsMember.next()) { System.out.println(rsMember.getString("M_ID") + "\t" + rsMember.getString("M_Password")); travelMemberDO.setcId(travelCompanyDO.getcId()); travelMemberDO.setmUserName(StringUtils.lowerCase(rsMember.getString("M_UserName"))); travelMemberDO .setmPassword(EncryptBuilder.getInstance().encrypt(rsMember.getString("M_Password"))); travelMemberDO.setmName(rsMember.getString("M_Name")); travelMemberDO.setmSex(rsMember.getInt("M_Sex")); travelMemberDO.setmMobile(rsMember.getString("M_Mobile")); travelMemberDO.setmTel(rsMember.getString("M_Tel")); travelMemberDO.setmEmail(rsMember.getString("M_Email")); travelMemberDO.setmFax(rsMember.getString("M_Fax")); travelMemberDO.setmQQ(rsMember.getString("M_QQ")); travelMemberDO.setmType(rsMember.getInt("M_Type")); // travelMemberDO.setmRole(rsMember.getString("M_Role")); travelMemberDO.setmState(rsMember.getInt("M_State")); memberService.insert(travelMemberDO); } } // stmt.close();// stmt2.close(); ; con.close();// ? } catch (SQLException e) { e.printStackTrace(); System.out.print(e.getErrorCode()); // System.out.println("?"); System.exit(0); } }
From source file:org.apache.xml.security.Init.java
/** * Initialise the library from a configuration file */// w w w.ja v a 2s. c om private static void fileInit(InputStream is) { try { /* read library configuration file */ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setValidating(false); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(is); Node config = doc.getFirstChild(); for (; config != null; config = config.getNextSibling()) { if ("Configuration".equals(config.getLocalName())) { break; } } if (config == null) { log.error("Error in reading configuration file - Configuration element not found"); return; } for (Node el = config.getFirstChild(); el != null; el = el.getNextSibling()) { if (el == null || Node.ELEMENT_NODE != el.getNodeType()) { continue; } String tag = el.getLocalName(); if (tag.equals("ResourceBundles")) { Element resource = (Element) el; /* configure internationalization */ Attr langAttr = resource.getAttributeNode("defaultLanguageCode"); Attr countryAttr = resource.getAttributeNode("defaultCountryCode"); String languageCode = (langAttr == null) ? null : langAttr.getNodeValue(); String countryCode = (countryAttr == null) ? null : countryAttr.getNodeValue(); I18n.init(languageCode, countryCode); } if (tag.equals("CanonicalizationMethods")) { Element[] list = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "CanonicalizationMethod"); for (int i = 0; i < list.length; i++) { String URI = list[i].getAttributeNS(null, "URI"); String JAVACLASS = list[i].getAttributeNS(null, "JAVACLASS"); try { Canonicalizer.register(URI, JAVACLASS); if (log.isDebugEnabled()) { log.debug("Canonicalizer.register(" + URI + ", " + JAVACLASS + ")"); } } catch (ClassNotFoundException e) { Object exArgs[] = { URI, JAVACLASS }; log.error(I18n.translate("algorithm.classDoesNotExist", exArgs)); } } } if (tag.equals("TransformAlgorithms")) { Element[] tranElem = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "TransformAlgorithm"); for (int i = 0; i < tranElem.length; i++) { String URI = tranElem[i].getAttributeNS(null, "URI"); String JAVACLASS = tranElem[i].getAttributeNS(null, "JAVACLASS"); try { Transform.register(URI, JAVACLASS); if (log.isDebugEnabled()) { log.debug("Transform.register(" + URI + ", " + JAVACLASS + ")"); } } catch (ClassNotFoundException e) { Object exArgs[] = { URI, JAVACLASS }; log.error(I18n.translate("algorithm.classDoesNotExist", exArgs)); } catch (NoClassDefFoundError ex) { log.warn("Not able to found dependencies for algorithm, I'll keep working."); } } } if ("JCEAlgorithmMappings".equals(tag)) { Node algorithmsNode = ((Element) el).getElementsByTagName("Algorithms").item(0); if (algorithmsNode != null) { Element[] algorithms = XMLUtils.selectNodes(algorithmsNode.getFirstChild(), CONF_NS, "Algorithm"); for (int i = 0; i < algorithms.length; i++) { Element element = algorithms[i]; String id = element.getAttribute("URI"); JCEMapper.register(id, new JCEMapper.Algorithm(element)); } } } if (tag.equals("SignatureAlgorithms")) { Element[] sigElems = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "SignatureAlgorithm"); for (int i = 0; i < sigElems.length; i++) { String URI = sigElems[i].getAttributeNS(null, "URI"); String JAVACLASS = sigElems[i].getAttributeNS(null, "JAVACLASS"); /** $todo$ handle registering */ try { SignatureAlgorithm.register(URI, JAVACLASS); if (log.isDebugEnabled()) { log.debug("SignatureAlgorithm.register(" + URI + ", " + JAVACLASS + ")"); } } catch (ClassNotFoundException e) { Object exArgs[] = { URI, JAVACLASS }; log.error(I18n.translate("algorithm.classDoesNotExist", exArgs)); } } } if (tag.equals("ResourceResolvers")) { Element[] resolverElem = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver"); for (int i = 0; i < resolverElem.length; i++) { String JAVACLASS = resolverElem[i].getAttributeNS(null, "JAVACLASS"); String Description = resolverElem[i].getAttributeNS(null, "DESCRIPTION"); if ((Description != null) && (Description.length() > 0)) { if (log.isDebugEnabled()) { log.debug("Register Resolver: " + JAVACLASS + ": " + Description); } } else { if (log.isDebugEnabled()) { log.debug("Register Resolver: " + JAVACLASS + ": For unknown purposes"); } } try { ResourceResolver.register(JAVACLASS); } catch (Throwable e) { log.warn("Cannot register:" + JAVACLASS + " perhaps some needed jars are not installed", e); } } } if (tag.equals("KeyResolver")) { Element[] resolverElem = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver"); List<String> classNames = new ArrayList<String>(resolverElem.length); for (int i = 0; i < resolverElem.length; i++) { String JAVACLASS = resolverElem[i].getAttributeNS(null, "JAVACLASS"); String Description = resolverElem[i].getAttributeNS(null, "DESCRIPTION"); if ((Description != null) && (Description.length() > 0)) { if (log.isDebugEnabled()) { log.debug("Register Resolver: " + JAVACLASS + ": " + Description); } } else { if (log.isDebugEnabled()) { log.debug("Register Resolver: " + JAVACLASS + ": For unknown purposes"); } } classNames.add(JAVACLASS); } KeyResolver.registerClassNames(classNames); } if (tag.equals("PrefixMappings")) { if (log.isDebugEnabled()) { log.debug("Now I try to bind prefixes:"); } Element[] nl = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "PrefixMapping"); for (int i = 0; i < nl.length; i++) { String namespace = nl[i].getAttributeNS(null, "namespace"); String prefix = nl[i].getAttributeNS(null, "prefix"); if (log.isDebugEnabled()) { log.debug("Now I try to bind " + prefix + " to " + namespace); } ElementProxy.setDefaultPrefix(namespace, prefix); } } } } catch (Exception e) { log.error("Bad: ", e); e.printStackTrace(); } }
From source file:org.apache.hadoop.hive.metastore.MyXid.java
public static Connection openConnect(String url, String user, String pass) throws SQLException, MetaStoreConnectException { try {/* ww w. j a va2 s .co m*/ Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { LOG.error(" get org.postgresql.Driver failed "); e.printStackTrace(); throw new MetaStoreConnectException(e.getMessage()); } Connection conn = null; DriverManager.setLoginTimeout(timeout); // DriverManager.setLoginTimeout(10); conn = DriverManager.getConnection(url, user, pass); LOG.debug(" get Connection ok: " + url); return conn; }