List of usage examples for java.lang InternalError InternalError
public InternalError(Throwable cause)
From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractAuthenticationController.java
@RequestMapping({ "/login", "/portal", "/" }) public String login(HttpServletRequest request, ModelMap map, HttpSession session) { logger.debug("###Entering in login(req,map,session) method"); boolean loginFailed = request.getParameter(LOGIN_FAILED_PARAM) != null; if (!loginFailed && request.getUserPrincipal() != null) { map.clear();// w w w .ja va 2s .c om return "redirect:/portal/home"; } if (session.getAttribute("email_verified") != null) { map.addAttribute("email_verified", session.getAttribute("email_verified")); session.removeAttribute("email_verified"); } String showSuffixControl = "false"; String suffixControlType = "textbox"; List<String> suffixList = null; if (config.getValue(Names.com_citrix_cpbm_username_duplicate_allowed).equals("true")) { showSuffixControl = "true"; if (config.getValue(Names.com_citrix_cpbm_login_screen_tenant_suffix_dropdown_enabled).equals("true")) { suffixControlType = "dropdown"; suffixList = tenantService.getSuffixList(); } } map.addAttribute("showSuffixControl", showSuffixControl); map.addAttribute("suffixControlType", suffixControlType); map.addAttribute("suffixList", suffixList); if (config.getBooleanValue(Configuration.Names.com_citrix_cpbm_portal_directory_service_enabled) && config.getValue(Names.com_citrix_cpbm_directory_mode).equals("pull")) { map.addAttribute("directoryServiceAuthenticationEnabled", "true"); } if (config.getValue(Names.com_citrix_cpbm_public_catalog_display).equals("true") && channelService.getDefaultServiceProviderChannel() != null) { map.addAttribute("showAnonymousCatalogBrowsing", "true"); } map.addAttribute("showLanguageSelection", "true"); map.addAttribute("supportedLocaleList", this.getLocaleDisplayName(listSupportedLocales())); map.addAttribute("selected_language", request.getParameter("lang")); String redirect = null; boolean loggedOut = request.getParameter(LOGOUT_PARAM) != null; final Throwable ex = (Throwable) session.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); // capture previous CAPTCHA position Boolean captchaRequiredSessionObj = (Boolean) session .getAttribute(CaptchaAuthenticationFilter.CAPTCHA_REQUIRED); // Get last user String username = (String) session .getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY); // this as spring does a text-escape when it saves this attribute final String uUsername = HtmlUtils.htmlUnescape(username); if (loginFailed) { String error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); try { User user = privilegeService.runAsPortal(new PrivilegedAction<User>() { @Override public User run() { User user = userService.getUserByParam("username", uUsername, false); // All user writes here. // Every time there is a login failure but not invalid CAPTCHA, // we update failed login attempts for the user if (!(ex instanceof CaptchaValidationException) && !(ex instanceof LockedException) && !(ex instanceof IpRangeValidationException)) { user.setFailedLoginAttempts(user.getFailedLoginAttempts() + 1); } int attempts = user.getFailedLoginAttempts(); // Also locking the root user and quite easily too. Clearly this // needs an eye! if (attempts >= config.getIntValue( Names.com_citrix_cpbm_accountManagement_security_logins_lockThreshold)) { user.setEnabled(false); } return user; } }); int attempts = user.getFailedLoginAttempts(); if (attempts >= config .getIntValue(Names.com_citrix_cpbm_accountManagement_security_logins_captchaThreshold)) { session.setAttribute(CaptchaAuthenticationFilter.CAPTCHA_REQUIRED, true); } } catch (NoSuchUserException e) { // map.addAttribute("showCaptcha", true); } captchaRequiredSessionObj = (Boolean) session .getAttribute(CaptchaAuthenticationFilter.CAPTCHA_REQUIRED); map.addAttribute("loginFailed", loginFailed); String lastUsername = uUsername; if (config.getValue(Names.com_citrix_cpbm_username_duplicate_allowed).equals("true")) { if (!lastUsername.equals("root") && !lastUsername.equals("")) { lastUsername = lastUsername.substring(0, lastUsername.lastIndexOf('@')); } } map.addAttribute("lastUser", lastUsername); // Compose error string if (ex instanceof DisabledException) { error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); } else if (ex instanceof CaptchaValidationException) { error = " " + messageSource.getMessage("error.auth.captcha.invalid", null, request.getLocale()); } else if (ex instanceof IpRangeValidationException) { error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); } else if (ex instanceof LockedException) { error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); } else if (ex instanceof BadCredentialsException) { if (ex.getMessage() != null && ex.getMessage().length() > 0) { // error = " " + ex.getMessage(); error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); } } else if (ex instanceof AuthenticationException) { error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); } else { logger.error("Error occurred in authentication", ex); error = " " + messageSource.getMessage("error.auth.unknown", null, request.getLocale()); } if (captchaRequiredSessionObj != null && captchaRequiredSessionObj == true && !(ex instanceof CaptchaValidationException) && !(ex instanceof LockedException)) { error += " " + messageSource.getMessage("error.auth.account.may.locked", null, request.getLocale()); } map.addAttribute("error", error); } if (loggedOut) { map.addAttribute("logout", loggedOut); } // This could come from session or from user if (captchaRequiredSessionObj != null && captchaRequiredSessionObj.booleanValue() && !Boolean.valueOf(config.getValue(Names.com_citrix_cpbm_use_intranet_only))) { map.addAttribute("showCaptcha", true); map.addAttribute("recaptchaPublicKey", config.getRecaptchaPublicKey()); } map.addAttribute(TIME_OUT, request.getParameter(TIME_OUT) != null); map.addAttribute(VERIFY, request.getParameter(VERIFY) != null); logger.debug("###Exiting login(req,map,session) method"); if (config.getAuthenticationService().compareToIgnoreCase(CAS) == 0) { try { redirect = StringUtils.isEmpty(config.getCasLoginUrl()) ? null : config.getCasLoginUrl() + "?service=" + URLEncoder.encode(config.getCasServiceUrl(), "UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("Exception encoding: " + redirect, e); } if (redirect == null) { throw new InternalError("CAS authentication required, but login url not set"); } } return redirect == null ? "auth.login" : "redirect:" + redirect; }
From source file:org.projectforge.core.AbstractBaseDO.java
/** * //ww w .j a v a 2 s . com * @param srcClazz * @param src * @param dest * @param ignoreFields * @return true, if any modifications are detected, otherwise false; */ @SuppressWarnings("unchecked") private static ModificationStatus copyDeclaredFields(final Class<?> srcClazz, final BaseDO<?> src, final BaseDO<?> dest, final String... ignoreFields) { final Field[] fields = srcClazz.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); ModificationStatus modificationStatus = null; for (final Field field : fields) { final String fieldName = field.getName(); if ((ignoreFields != null && ArrayUtils.contains(ignoreFields, fieldName) == true) || accept(field) == false) { continue; } try { final Object srcFieldValue = field.get(src); final Object destFieldValue = field.get(dest); if (field.getType().isPrimitive() == true) { if (ObjectUtils.equals(destFieldValue, srcFieldValue) == false) { field.set(dest, srcFieldValue); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } continue; } else if (srcFieldValue == null) { if (field.getType() == String.class) { if (StringUtils.isNotEmpty((String) destFieldValue) == true) { field.set(dest, null); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } } else if (destFieldValue != null) { field.set(dest, null); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } else { // dest was already null } } else if (srcFieldValue instanceof Collection) { Collection<Object> destColl = (Collection<Object>) destFieldValue; final Collection<Object> srcColl = (Collection<Object>) srcFieldValue; final Collection<Object> toRemove = new ArrayList<Object>(); if (srcColl != null && destColl == null) { if (srcColl instanceof TreeSet) { destColl = new TreeSet<Object>(); } else if (srcColl instanceof HashSet) { destColl = new HashSet<Object>(); } else if (srcColl instanceof List) { destColl = new ArrayList<Object>(); } else if (srcColl instanceof PersistentSet) { destColl = new HashSet<Object>(); } else { log.error("Unsupported collection type: " + srcColl.getClass().getName()); } field.set(dest, destColl); } for (final Object o : destColl) { if (srcColl.contains(o) == false) { toRemove.add(o); } } for (final Object o : toRemove) { if (log.isDebugEnabled() == true) { log.debug("Removing collection entry: " + o); } destColl.remove(o); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } for (final Object srcEntry : srcColl) { if (destColl.contains(srcEntry) == false) { if (log.isDebugEnabled() == true) { log.debug("Adding new collection entry: " + srcEntry); } destColl.add(srcEntry); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } else if (srcEntry instanceof BaseDO) { final PFPersistancyBehavior behavior = field.getAnnotation(PFPersistancyBehavior.class); if (behavior != null && behavior.autoUpdateCollectionEntries() == true) { BaseDO<?> destEntry = null; for (final Object entry : destColl) { if (entry.equals(srcEntry) == true) { destEntry = (BaseDO<?>) entry; break; } } Validate.notNull(destEntry); final ModificationStatus st = destEntry.copyValuesFrom((BaseDO<?>) srcEntry); modificationStatus = getModificationStatus(modificationStatus, st); } } } } else if (srcFieldValue instanceof BaseDO) { final Serializable srcFieldValueId = HibernateUtils.getIdentifier((BaseDO<?>) srcFieldValue); if (srcFieldValueId != null) { if (destFieldValue == null || ObjectUtils.equals(srcFieldValueId, ((BaseDO<?>) destFieldValue).getId()) == false) { field.set(dest, srcFieldValue); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } } else { log.error( "Can't get id though can't copy the BaseDO (see error message above about HHH-3502)."); } } else if (srcFieldValue instanceof java.sql.Date) { if (destFieldValue == null) { field.set(dest, srcFieldValue); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } else { final DayHolder srcDay = new DayHolder((Date) srcFieldValue); final DayHolder destDay = new DayHolder((Date) destFieldValue); if (srcDay.isSameDay(destDay) == false) { field.set(dest, srcDay.getSQLDate()); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } } } else if (srcFieldValue instanceof Date) { if (destFieldValue == null || ((Date) srcFieldValue).getTime() != ((Date) destFieldValue).getTime()) { field.set(dest, srcFieldValue); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } } else if (srcFieldValue instanceof BigDecimal) { if (destFieldValue == null || ((BigDecimal) srcFieldValue).compareTo((BigDecimal) destFieldValue) != 0) { field.set(dest, srcFieldValue); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } } else if (ObjectUtils.equals(destFieldValue, srcFieldValue) == false) { field.set(dest, srcFieldValue); modificationStatus = getModificationStatus(modificationStatus, src, fieldName); } } catch (final IllegalAccessException ex) { throw new InternalError("Unexpected IllegalAccessException: " + ex.getMessage()); } } final Class<?> superClazz = srcClazz.getSuperclass(); if (superClazz != null) { final ModificationStatus st = copyDeclaredFields(superClazz, src, dest, ignoreFields); modificationStatus = getModificationStatus(modificationStatus, st); } return modificationStatus; }
From source file:org.shredzone.cilla.view.FeedView.java
/** * Builds a taxonomy URL.// ww w. j a va 2 s . c om * * @param prefix * URI prefix for this web site * @param type * feed type (e.g. "author") * @param id * unique id String of the feed's entity * @return generated URI */ private String buildTaxonomyUri(String prefix, String type, String id) { try { return prefix + type + '-' + URLEncoder.encode(id, "utf-8"); } catch (UnsupportedEncodingException ex) { throw new InternalError("utf-8 missing"); } }
From source file:com.commsen.apropos.core.PropertiesManager.java
/** * Updates existing {@link Property} called <code>oldPropertyName</code> in * {@link PropertyPackage} called <code>packageName</code> with values from * <code>property</code>. The actual update is handled by * {@link PropertyPackage#updateProperty(Property)}. * //from w ww. ja v a 2 s .c o m * @param packageName the name of the package. Can not be <code>null</code> or empty. * @param oldPropertyName the name of the property to be updated * @param property the {@link Property} object to get the values from. Can not be * <code>null</code> * @return a new clone of the {@link PropertyPackage} made after the property is updated * @throws PropertiesException if no package called <code>packageName</code> found or if no * such {@link Property} exists in this package * @throws IllegalArgumentException if any of the arguments is <code>null</code> */ public static synchronized PropertyPackage updateProperty(String packageName, String oldPropertyName, Property property) throws PropertiesException { if (StringUtils.isBlank(packageName)) throw new IllegalArgumentException("package name can not be null nor empty string"); if (property == null) throw new IllegalArgumentException("property can not be null"); if (!allPackages.containsKey(packageName)) throw new PropertiesException("No package called " + packageName + " found "); PropertyPackage propertyPackage = allPackages.get(packageName); try { propertyPackage.updateProperty(oldPropertyName, (Property) property.clone()); save(); return (PropertyPackage) propertyPackage.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.toString()); } }
From source file:org.apache.tajo.master.exec.DDLExecutor.java
/** * Drop a given named table/*from ww w . ja va 2s . c om*/ * * @param tableName to be dropped * @param purge Remove all data if purge is true. */ public void dropTable(QueryContext queryContext, String tableName, boolean ifExists, boolean purge) throws TajoException { String databaseName; String simpleTableName; if (IdentifierUtil.isFQTableName(tableName)) { String[] splitted = IdentifierUtil.splitFQTableName(tableName); databaseName = splitted[0]; simpleTableName = splitted[1]; } else { databaseName = queryContext.getCurrentDatabase(); simpleTableName = tableName; } String qualifiedName = IdentifierUtil.buildFQName(databaseName, simpleTableName); boolean exists = catalog.existsTable(qualifiedName); if (!exists) { if (ifExists) { // DROP TABLE IF EXISTS LOG.info("relation \"" + qualifiedName + "\" is already exists."); return; } else { // Otherwise, it causes an exception. throw new UndefinedTableException(qualifiedName); } } TableDesc tableDesc = catalog.getTableDesc(qualifiedName); catalog.dropTable(qualifiedName); if (purge) { try { TablespaceManager.get(tableDesc.getUri()).purgeTable(tableDesc); } catch (IOException e) { throw new InternalError(e.getMessage()); } } LOG.info(String.format("relation \"%s\" is " + (purge ? " purged." : " dropped."), qualifiedName)); }
From source file:FullThreadDump.java
private void parseMBeanInfo() throws IOException { try {//from w ww. ja va2 s .c o m MBeanOperationInfo[] mopis = server.getMBeanInfo(objname).getOperations(); // look for findDeadlockedThreads operations; boolean found = false; for (MBeanOperationInfo op : mopis) { if (op.getName().equals(findDeadlocksMethodName)) { found = true; break; } } if (!found) { // if findDeadlockedThreads operation doesn't exist, // the target VM is running on JDK 5 and details about // synchronizers and locks cannot be dumped. findDeadlocksMethodName = "findMonitorDeadlockedThreads"; canDumpLocks = false; } } catch (IntrospectionException e) { InternalError ie = new InternalError(e.getMessage()); ie.initCause(e); throw ie; } catch (InstanceNotFoundException e) { InternalError ie = new InternalError(e.getMessage()); ie.initCause(e); throw ie; } catch (ReflectionException e) { InternalError ie = new InternalError(e.getMessage()); ie.initCause(e); throw ie; } }
From source file:edu.cornell.med.icb.goby.modes.DiscoverSequenceVariantsMode.java
/** * Configure./*from ww w . j a v a 2 s. c om*/ * * @param args command line arguments * @return this object for chaining * @throws java.io.IOException error parsing * @throws com.martiansoftware.jsap.JSAPException * error parsing */ @Override public AbstractCommandLineMode configure(final String[] args) throws IOException, JSAPException { final JSAPResult jsapResult = parseJsapArguments(args); inputFilenames = jsapResult.getStringArray("input"); String outputFile = jsapResult.getString("output"); outputInfo = new OutputInfo(outputFile); String groupsDefinition = jsapResult.getString("groups"); String groupsDefinitionFile = jsapResult.getString("group-file"); if (groupsDefinition != null && groupsDefinitionFile != null) { System.err.println( "--groups and --groups-file are mutually exclusive. Please provide only once such parameter."); System.exit(1); } if (groupsDefinitionFile != null) { groupsDefinition = parseGroupFile(groupsDefinitionFile, inputFilenames); } String compare = jsapResult.getString("compare"); /*if (compare == null) { // make default groups and group definitions. Each sample becomes its own group, compare group1 and group2. compare = "group1/group2"; MutableString buffer = new MutableString(); int groupIndex = 1; for (String inputFilename : inputFilenames) { buffer.append("group").append(String.valueOf(groupIndex++)); buffer.append("="); buffer.append(AlignmentReaderImpl.getBasename(inputFilename)); buffer.append('/'); } groupsDefinition = buffer.substring(0, buffer.length() - 1).toString(); System.out.println(groupsDefinition); } else { groupsAreDefined = true; } */ deAnalyzer.parseGroupsDefinition(groupsDefinition, deCalculator, inputFilenames); groupComparisonsList = deAnalyzer.parseCompare(compare); boolean parallel = jsapResult.getBoolean("parallel", false); deAnalyzer.setRunInParallel(parallel); Map<String, String> sampleToGroupMap = deCalculator.getSampleToGroupMap(); readerIndexToGroupIndex = new int[inputFilenames.length]; groups = deAnalyzer.getGroups(); numberOfGroups = groups.length; IndexedIdentifier groupIds = new IndexedIdentifier(); for (String group : groups) { groupIds.registerIdentifier(new MutableString(group)); } maxThresholdPerSite = jsapResult.getInt("max-coverage-per-site"); minimumVariationSupport = jsapResult.getInt("minimum-variation-support"); thresholdDistinctReadIndices = jsapResult.getInt("threshold-distinct-read-indices"); CompactAlignmentToAnnotationCountsMode.parseEval(jsapResult, deAnalyzer); for (String sample : sampleToGroupMap.keySet()) { final String group = sampleToGroupMap.get(sample); System.out.printf("sample: %s group %s%n", sample, group); for (int readerIndex = 0; readerIndex < inputFilenames.length; readerIndex++) { if (AlignmentReaderImpl.getBasename(inputFilenames[readerIndex]).endsWith(sample)) { readerIndexToGroupIndex[readerIndex] = groupIds.get(new MutableString(group)); } } } File statFile = jsapResult.getFile("variation-stats"); if (statFile != null) { loadStatFile(statFile); } else { if (deAnalyzer.eval("within-groups")) { System.err.println( "To evaluate statistics within-groups you must provide a --variation-stats argument."); System.exit(1); } } callIndels = jsapResult.getBoolean("call-indels"); diploid = jsapResult.getBoolean("diploid"); realignmentFactory = configureProcessor(jsapResult); final String formatString = jsapResult.getString("format"); final OutputFormat format = OutputFormat.valueOf(formatString.toUpperCase()); SequenceVariationOutputFormat formatter = null; switch (format) { case VARIANT_DISCOVERY: case BETWEEN_GROUPS: stopWhenDefaultGroupOptions(); formatter = new BetweenGroupSequenceVariationOutputFormat(); break; case COMPARE_GROUPS: stopWhenDefaultGroupOptions(); formatter = new CompareGroupsVCFOutputFormat(); break; case ALLELE_FREQUENCIES: stopWhenDefaultGroupOptions(); formatter = new AlleleFrequencyOutputFormat(); break; case GENOTYPES: formatter = new GenotypesOutputFormat(); break; case METHYLATION_REGIONS: formatter = new MethylationRegionsOutputFormat(); methylFormat((MethylationFormat) formatter); break; case METHYLATION: formatter = new MethylationRateVCFOutputFormat(); methylFormat((MethylationFormat) formatter); break; case INDEL_COUNTS: formatter = new IndelCountOutputFormat(); callIndels = true; break; default: ObjectArrayList<OutputFormat> values = ObjectArrayList.wrap(OutputFormat.values()); System.err.printf("The format argument is not recognized. Allowed values include %s", values.toString()); System.exit(1); } // set base filters according to output format: genotypeFilters = new ObjectArrayList<GenotypeFilter>(); switch (format) { case METHYLATION: case METHYLATION_REGIONS: // no filters at all for methylation. It seems that in some dataset quality scores are much lower for //bases that are not methylated and therefore converted. We don't want to filter these bases and therefore // do not install the quality score filter. if (callIndels) { genotypeFilters.add(new RemoveIndelArtifactsFilter()); } break; case COMPARE_GROUPS: case ALLELE_FREQUENCIES: case BETWEEN_GROUPS: case VARIANT_DISCOVERY: genotypeFilters.add(new QualityScoreFilter()); genotypeFilters.add(new LeftOverFilter()); if (callIndels) { genotypeFilters.add(new RemoveIndelArtifactsFilter()); } if (!disableAtLeastQuarterFilter && callIndels) { System.out.println("Active: AtLeastAQuarterFilter."); genotypeFilters.add(new AtLeastAQuarterFilter()); } if (diploid) { genotypeFilters.add(new DiploidFilter()); } break; case GENOTYPES: genotypeFilters.add(new QualityScoreFilter()); genotypeFilters.add(new LeftOverFilter()); if (callIndels) { genotypeFilters.add(new RemoveIndelArtifactsFilter()); } if (!disableAtLeastQuarterFilter) { genotypeFilters.add(new AtLeastAQuarterFilter()); } if (diploid) { genotypeFilters.add(new DiploidFilter()); } break; case INDEL_COUNTS: genotypeFilters.add(new QualityScoreFilter()); genotypeFilters.add(new LeftOverFilter()); genotypeFilters.add(new RemoveIndelArtifactsFilter()); if (!disableAtLeastQuarterFilter) { genotypeFilters.add(new AtLeastAQuarterFilter()); } if (diploid) { genotypeFilters.add(new DiploidFilter()); } break; default: throw new InternalError("Filters must be configured for new output format."); } System.out.println("Filtering reads that have these criteria:"); for (final GenotypeFilter filter : genotypeFilters) { System.out.println(filter.describe()); } final RandomAccessSequenceInterface genome = configureGenome(testGenome, jsapResult); final int startFlapSize = jsapResult.getInt("start-flap-size", 100); if (callIndels) { System.err.println("Indel calling was activated."); } formatConfigurator.configureFormatter(formatter); sortedPositionIterator = new DiscoverVariantIterateSortedAlignments(formatter); sortedPositionIterator.setCallIndels(callIndels); sortedPositionIterator.setGenome(genome); sortedPositionIterator.setStartFlapLength(startFlapSize); sortedPositionIterator.parseIncludeReferenceArgument(jsapResult); sortedPositionIterator.setMinimumVariationSupport(minimumVariationSupport); sortedPositionIterator.setThresholdDistinctReadIndices(thresholdDistinctReadIndices); return this; }
From source file:net.sf.gazpachoquest.rest.auth.TokenStore.java
/** * Creates a byte array of entry from the current state of the system: * <ul>//w w w .j a v a 2 s .co m * <li>The current system time in milliseconds since the epoch</li> * <li>The number of nanoseconds since system startup</li> * <li>The name, size and last modification time of the files in the * <code>java.io.tmpdir</code> folder.</li> * </ul> * <p> * <b>NOTE</b> This method generates entropy fast but not necessarily * secure enough for seeding the random number generator. * * @return bytes of entropy */ private static byte[] getFastEntropy() { final MessageDigest md; try { md = MessageDigest.getInstance("SHA"); } catch (NoSuchAlgorithmException nsae) { throw new InternalError("internal error: SHA-1 not available."); } // update with XorShifted time values update(md, System.currentTimeMillis()); update(md, System.nanoTime()); // scan the temp file system File file = new File(System.getProperty("java.io.tmpdir")); File[] entries = file.listFiles(); if (entries != null) { for (File entry : entries) { md.update(entry.getName().getBytes()); update(md, entry.lastModified()); update(md, entry.length()); } } return md.digest(); }
From source file:com.clustercontrol.winevent.dialog.WinEventDialog.java
/** * ????//from ww w . ja v a 2 s . c o m * * @param parent ? */ @Override protected void customizeDialog(Composite parent) { super.customizeDialog(parent); // shell.setText(Messages.getString("dialog.winevent.create.modify")); // ???? Label label = null; // ???? GridData gridData = null; /* * ???? */ Group groupCheckRule = new Group(groupRule, SWT.NONE); WidgetTestUtil.setTestId(this, "checkrule", groupCheckRule); GridLayout layout = new GridLayout(1, true); layout.marginWidth = 5; layout.marginHeight = 5; layout.numColumns = BASIC_UNIT; groupCheckRule.setLayout(layout); gridData = new GridData(); gridData.horizontalSpan = BASIC_UNIT; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; groupCheckRule.setLayoutData(gridData); groupCheckRule.setText(Messages.getString("check.rule")); /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "wineventlevel", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("winevent.level") + " : "); // (?) this.levelCritical = new Button(groupCheckRule, SWT.CHECK); WidgetTestUtil.setTestId(this, "criticalcheck", levelCritical); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.levelCritical.setLayoutData(gridData); this.levelCritical.setText(Messages.getString("winevent.level.critical")); // () this.levelWarning = new Button(groupCheckRule, SWT.CHECK); WidgetTestUtil.setTestId(this, "warningcheck", levelWarning); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.levelWarning.setLayoutData(gridData); this.levelWarning.setText(Messages.getString("winevent.level.warning")); // () this.levelVerbose = new Button(groupCheckRule, SWT.CHECK); WidgetTestUtil.setTestId(this, "verbosecheck", levelVerbose); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.levelVerbose.setLayoutData(gridData); this.levelVerbose.setText(Messages.getString("winevent.level.verbose")); // () this.levelError = new Button(groupCheckRule, SWT.CHECK); WidgetTestUtil.setTestId(this, "errorcheck", levelError); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.levelError.setLayoutData(gridData); this.levelError.setText(Messages.getString("winevent.level.error")); // () this.levelInformational = new Button(groupCheckRule, SWT.CHECK); WidgetTestUtil.setTestId(this, "infomationalcheck", levelInformational); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.levelInformational.setLayoutData(gridData); this.levelInformational.setText(Messages.getString("winevent.level.informational")); /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "wineveltlog", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("winevent.log") + " : "); // this.logName = new Text(groupCheckRule, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "logname", logName); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.logName.setLayoutData(gridData); this.logName.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "wineventsource", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("winevent.source") + " : "); // this.source = new Text(groupCheckRule, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "source", source); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.source.setLayoutData(gridData); this.source.setMessage(Messages.getString("message.winevent.1")); /* * ID */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "wineventid", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("winevent.id") + " : "); // this.eventId = new Text(groupCheckRule, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "eventid", eventId); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.eventId.setLayoutData(gridData); this.eventId.setMessage(Messages.getString("message.winevent.2")); /* * ? */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "wineventcategory", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("winevent.category") + " : "); // this.category = new Text(groupCheckRule, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "category", category); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.category.setLayoutData(gridData); this.category.setMessage(Messages.getString("message.winevent.3")); /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "keywords", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("winevent.keywords") + " : "); // this.keywords = new Text(groupCheckRule, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "keywords", keywords); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.keywords.setLayoutData(gridData); this.keywords.setMessage(Messages.getString("message.winevent.4")); // ????? this.m_monitorRule.setRunIntervalEnabled(false); // this.adjustDialog(); // ? MonitorInfo info = null; if (this.monitorId == null) { // ??? info = new MonitorInfo(); this.setInfoInitialValue(info); } else { // ???? try { MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName); info = wrapper.getMonitor(this.monitorId); } catch (InvalidRole_Exception e) { // ?????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); throw new InternalError(e.getMessage()); } catch (Exception e) { // ? m_log.warn("customizeDialog(), " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); throw new InternalError(e.getMessage()); } } this.setInputData(info); this.update(); }
From source file:org.projectforge.framework.configuration.ConfigXml.java
/** * Copies only not null values of the configuration. *///w w w . ja v a 2s . c o m private static void copyDeclaredFields(final String prefix, final Class<?> srcClazz, final Object src, final Object dest, final String... ignoreFields) { final Field[] fields = srcClazz.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); for (final Field field : fields) { if (ignoreFields != null && ArrayUtils.contains(ignoreFields, field.getName()) == false && accept(field)) { try { final Object srcFieldValue = field.get(src); if (srcFieldValue == null) { // Do nothing } else if (srcFieldValue instanceof ConfigurationData) { final Object destFieldValue = field.get(dest); Validate.notNull(destFieldValue); final StringBuffer buf = new StringBuffer(); if (prefix != null) { buf.append(prefix); } String alias = null; if (field.isAnnotationPresent(XmlField.class)) { final XmlField xmlFieldAnn = field.getAnnotation(XmlField.class); if (xmlFieldAnn != null) { alias = xmlFieldAnn.alias(); } } if (alias != null) { buf.append(alias); } else { buf.append(field.getClass().getName()); } buf.append("."); copyDeclaredFields(buf.toString(), srcFieldValue.getClass(), srcFieldValue, destFieldValue, ignoreFields); } else if (PLUGIN_CONFIGS_FIELD_NAME.equals(field.getName()) == true) { // Do nothing. } else { field.set(dest, srcFieldValue); if (field.isAnnotationPresent(ConfigXmlSecretField.class) == true) { log.info(StringUtils.defaultString(prefix) + field.getName() + " = " + SECRET_PROPERTY_STRING); } else { log.info(StringUtils.defaultString(prefix) + field.getName() + " = " + srcFieldValue); } } } catch (final IllegalAccessException ex) { throw new InternalError("Unexpected IllegalAccessException: " + ex.getMessage()); } } } final Class<?> superClazz = srcClazz.getSuperclass(); if (superClazz != null) { copyDeclaredFields(prefix, superClazz, src, dest, ignoreFields); } }