List of usage examples for java.lang RuntimeException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.sejda.sambox.pdmodel.graphics.color.PDICCBased.java
/** * Load the ICC profile, or init alternateColorSpace color space. *//*from w ww . j a v a2 s . co m*/ private void loadICCProfile() throws IOException { InputStream input = null; try { input = this.stream.createInputStream(); // if the embedded profile is sRGB then we can use Java's built-in profile, which // results in a large performance gain as it's our native color space, see PDFBOX-2587 ICC_Profile profile; synchronized (LOG) { profile = ICC_Profile.getInstance(input); } if (is_sRGB(profile)) { awtColorSpace = (ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_sRGB); iccProfile = awtColorSpace.getProfile(); } else { awtColorSpace = new ICC_ColorSpace(profile); iccProfile = profile; } // set initial colour float[] initial = new float[getNumberOfComponents()]; for (int c = 0; c < getNumberOfComponents(); c++) { initial[c] = Math.max(0, getRangeForComponent(c).getMin()); } initialColor = new PDColor(initial, this); // create a color in order to trigger a ProfileDataException // or CMMException due to invalid profiles, see PDFBOX-1295 and PDFBOX-1740 new Color(awtColorSpace, new float[getNumberOfComponents()], 1f); } catch (RuntimeException e) { if (e instanceof ProfileDataException || e instanceof CMMException || e instanceof IllegalArgumentException) { // fall back to alternateColorSpace color space awtColorSpace = null; alternateColorSpace = getAlternateColorSpace(); LOG.error("Can't read embedded ICC profile (" + e.getLocalizedMessage() + "), using alternate color space: " + alternateColorSpace.getName()); initialColor = alternateColorSpace.getInitialColor(); } else { throw e; } } finally { IOUtils.closeQuietly(input); } }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.editor.TaskDetailFragment.java
private void setShareIntent(final String text) { if (mShareActionProvider != null && taskText != null) { int titleEnd = text.indexOf("\n"); if (titleEnd < 0) { titleEnd = text.length();/*from w w w. j a v a2 s . c o m*/ } try { // Todo fix for support library version /*mShareActionProvider.setShareIntent(new Intent(Intent.ACTION_SEND).setType ("text/plain").putExtra(Intent.EXTRA_TEXT, text).putExtra(Intent .EXTRA_SUBJECT, text.substring(0, titleEnd)));*/ } catch (RuntimeException e) { // Can crash when too many transactions overflow the buffer Log.d("nononsensenotes", e.getLocalizedMessage()); } } }
From source file:com.xdyou.sanguo.GameSanGuo.java
@Override protected void onResume() { Log.d("SGAPP", "onResume"); super.onResume(); //MM: FB/*from w ww.j a v a 2s. co m*/ com.facebook.AppEventsLogger.activateApp(this, APP_ID); //start sponsor try { SponsorPay.start("637a0987b77b1277eaa099e92f31787e", null, null, this); } catch (RuntimeException e) { Log.d("SGAPP", e.getLocalizedMessage()); } TalkingDataGA.onResume(this); //MM: AdvertiserSDK 2014.11.26 Tracker.conversionTrack(this, "zywx_sgyxlm_hk_mo_tw"); //GA GameAnalytics.startSession(this); // hasoffers mobileAppTracker.setReferralSources(this); mobileAppTracker.measureSession(); }
From source file:edu.unc.lib.dl.services.BatchIngestTask.java
@Override public void run() { startTime = System.currentTimeMillis(); if (ingestProperties.getSubmitterGroups() != null) { GroupsThreadStore.storeGroups(new AccessGroupSet(ingestProperties.getSubmitterGroups())); log.debug("Groups loaded to thread from in run: " + GroupsThreadStore.getGroupString()); } else {/* w w w.j a v a 2 s . c om*/ GroupsThreadStore.clearStore(); } while (this.state != STATE.FINISHED) { log.debug("Batch ingest: state=" + this.state.name() + ", dir=" + this.getBaseDir().getName()); if (Thread.interrupted()) { log.debug("halting ingest task due to interrupt, in run method"); this.halting = true; } if (this.halting && (this.state != STATE.SEND_MESSAGES && this.state != STATE.CLEANUP)) { log.debug("Halting this batch ingest task: state=" + this.state + ", dir=" + this.getBaseDir()); break; // stop immediately as long as not sending msgs or cleaning up. } try { try { switch (this.state) { case CHECK: checkDestination(); break; case INGEST: // ingest the next foxml file, until none left ingestNextObject(); break; case INGEST_WAIT: // poll for last ingested pid (and fedora availability) waitForLastIngest(); break; case INGEST_VERIFY_CHECKSUMS: // match local checksums against those generated by Fedora verifyLastIngestChecksums(); break; case CONTAINER_UPDATES: // update parent container object updateNextContainer(); break; case SEND_MESSAGES: // send cdr JMS and email for this AIP ingest sendIngestMessages(); break; case CLEANUP: this.finishedTime = System.currentTimeMillis(); this.ingestProperties.setFinishedTime(this.finishedTime); this.ingestProperties.setStartTime(this.startTime); this.ingestProperties.save(); GroupsThreadStore.clearStore(); deleteDataFiles(); handleFinishedDir(); this.state = STATE.FINISHED; break; } } catch (RuntimeException e) { throw fail("Unexpected RuntimeException", e); } } catch (BatchFailedException e) { log.error("Batch Ingest Task failed: " + e.getLocalizedMessage(), e); return; } } }
From source file:com.ning.metrics.collector.endpoint.resources.ScribeEventRequestHandler.java
private Event extractThriftEnvelopeEvent(final String category, final String message) throws TException { Event event;// w w w .ja v a2 s .c om final String[] payload = StringUtils.split(message, ":"); if (payload == null || payload.length != 2) { // Invalid API throw new TException("Expected payload separator ':'"); } Long eventDateTime = null; try { eventDateTime = Long.parseLong(payload[0]); } catch (RuntimeException e) { log.debug("Event DateTime not specified, defaulting to NOW()"); } // The payload is Base64 encoded final byte[] thrift = new Base64().decode(payload[1].getBytes()); // Assume a ThriftEnvelopeEvent from the eventtracker (uses Java serialization). // This is bigger on the wire, but the interface is portable. Serialize using TBinaryProtocol // if you care about size (see below). ObjectInputStream objectInputStream = null; try { objectInputStream = new ObjectInputStream(new BufferedInputStream(new ByteArrayInputStream(thrift))); event = new ThriftEnvelopeEvent(); event.readExternal(objectInputStream); if (event.getName().equals(category)) { return event; } } catch (Exception e) { log.debug(String.format("Payload is not a ThriftEvent: %s", e.getLocalizedMessage())); } finally { try { if (objectInputStream != null) { objectInputStream.close(); } } catch (IOException e) { log.warn("Unable to close stream when deserializing thrift events", e); } } // Not a ThriftEvent, probably native Thrift serialization (TBinaryProtocol) try { if (eventDateTime == null) { event = ThriftToThriftEnvelopeEvent.extractEvent(category, thrift); } else { event = ThriftToThriftEnvelopeEvent.extractEvent(category, new DateTime(eventDateTime), thrift); } } catch (TException e) { log.debug("Event doesn't look like a Thrift, assuming plain text"); if (eventDateTime == null) { event = StringToThriftEnvelopeEvent.extractEvent(category, payload[1]); } else { event = StringToThriftEnvelopeEvent.extractEvent(category, new DateTime(eventDateTime), payload[1]); } } return event; }
From source file:org.rhq.enterprise.server.discovery.DiscoveryBossBean.java
@NotNull public MergeResourceResponse manuallyAddResource(Subject user, ResourceType resourceType, int parentResourceId, Configuration pluginConfiguration) throws InvalidPluginConfigurationClientException, PluginContainerException { if (!this.authorizationManager.hasResourcePermission(user, Permission.CREATE_CHILD_RESOURCES, parentResourceId)) {//from www . j a v a2s .c o m throw new PermissionException("You do not have permission on resource with id " + parentResourceId + " to manually add child resources."); } MergeResourceResponse mergeResourceResponse; try { Resource parentResource = this.resourceManager.getResourceById(user, parentResourceId); AgentClient agentClient = this.agentManager.getAgentClient(parentResource.getAgent()); mergeResourceResponse = agentClient.getDiscoveryAgentService().manuallyAddResource(resourceType, parentResourceId, pluginConfiguration, user.getId()); } catch (RuntimeException e) { throw new RuntimeException("Error adding " + resourceType.getName() + " resource to inventory as a child of the resource with id " + parentResourceId + " - cause: " + e.getLocalizedMessage(), e); } return mergeResourceResponse; }
From source file:org.openconcerto.sql.PropsConfiguration.java
protected SQLServer createServer() { final String wanAddr = getProperty("server.wan.addr"); final String wanPort = getProperty("server.wan.port"); if (!hasWANProperties(wanAddr, wanPort)) return doCreateServer(); // if wanAddr is specified, always include it in ID, that way if we connect through the LAN // or through the WAN we have the same ID final String serverID = "tunnel to " + wanAddr + ":" + wanPort + " then " + getProperty("server.ip"); final Logger log = Log.get(); Exception origExn = null;//w ww . j ava 2 s. c o m final SQLServer defaultServer; if (!"true".equals(getProperty("server.wan.only"))) { try { defaultServer = doCreateServer(serverID); // works since all ds params are provided by doCreateServer() defaultServer.getSystemRoot(getSystemRootName()); // ok log.config("using " + defaultServer); return defaultServer; } catch (final RuntimeException e) { origExn = e; // on essaye par SSL log.config(e.getLocalizedMessage()); } assert origExn != null; } this.openSSLConnection(wanAddr, Integer.valueOf(wanPort)); this.isUsingSSH = true; log.info("ssl connection to " + this.conn.getHost() + ":" + this.conn.getPort()); final int localPort = NetUtils.findFreePort(5436); try { // TODO add and use server.port final String[] serverAndPort = getProperty("server.ip").split(":"); log.info("ssl tunnel from local port " + localPort + " to remote " + serverAndPort[0] + ":" + serverAndPort[1]); this.conn.setPortForwardingL(localPort, serverAndPort[0], Integer.valueOf(serverAndPort[1])); } catch (final Exception e1) { throw new IllegalStateException( "Impossible de crer la liaison scurise. Vrifier que le logiciel n'est pas dj lanc.", e1); } final SQLServer serverThruSSL = doCreateServer("localhost:" + localPort, null, serverID); try { serverThruSSL.getSystemRoot(getSystemRootName()); } catch (final Exception e) { this.closeSSLConnection(); throw new IllegalStateException("Couldn't connect through SSL : " + e.getLocalizedMessage(), origExn); } return serverThruSSL; }
From source file:org.kitodo.production.forms.ProzesskopieForm.java
private void processAdditionalField(AdditionalField field) { // which DocStruct LegacyDocStructHelperInterface tempStruct = this.rdf.getDigitalDocument().getLogicalDocStruct(); LegacyDocStructHelperInterface tempChild = null; String fieldDocStruct = field.getDocStruct(); if (fieldDocStruct.equals(FIRST_CHILD)) { try {/*www. j a v a 2 s . co m*/ tempStruct = this.rdf.getDigitalDocument().getLogicalDocStruct().getAllChildren().get(0); } catch (RuntimeException e) { Helper.setErrorMessage( e.getMessage() + " The first child below the top structure could not be determined!", logger, e); } } // if topstruct and first child should get the metadata if (!fieldDocStruct.equals(FIRST_CHILD) && fieldDocStruct.contains(FIRST_CHILD)) { try { tempChild = this.rdf.getDigitalDocument().getLogicalDocStruct().getAllChildren().get(0); } catch (RuntimeException e) { Helper.setErrorMessage(e.getLocalizedMessage(), logger, e); } } if (fieldDocStruct.equals(BOUND_BOOK)) { tempStruct = this.rdf.getDigitalDocument().getPhysicalDocStruct(); } // which Metadata try { processAdditionalFieldWhichMetadata(field, tempStruct, tempChild); } catch (RuntimeException e) { Helper.setErrorMessage(e.getLocalizedMessage(), logger, e); } }
From source file:edu.harvard.iq.dataverse.DatasetPage.java
private String init(boolean initFull) { //System.out.println("_YE_OLDE_QUERY_COUNTER_"); // for debug purposes this.maxFileUploadSizeInBytes = systemConfig.getMaxFileUploadSize(); setDataverseSiteUrl(systemConfig.getDataverseSiteUrl()); guestbookResponse = new GuestbookResponse(); String nonNullDefaultIfKeyNotFound = ""; protocol = settingsWrapper.getValueForKey(SettingsServiceBean.Key.Protocol, nonNullDefaultIfKeyNotFound); authority = settingsWrapper.getValueForKey(SettingsServiceBean.Key.Authority, nonNullDefaultIfKeyNotFound); separator = settingsWrapper.getValueForKey(SettingsServiceBean.Key.DoiSeparator, nonNullDefaultIfKeyNotFound); if (dataset.getId() != null || versionId != null || persistentId != null) { // view mode for a dataset DatasetVersionServiceBean.RetrieveDatasetVersionResponse retrieveDatasetVersionResponse = null; // --------------------------------------- // Set the workingVersion and Dataset // --------------------------------------- if (persistentId != null) { logger.fine("initializing DatasetPage with persistent ID " + persistentId); // Set Working Version and Dataset by PersistentID dataset = datasetService.findByGlobalId(persistentId); if (dataset == null) { logger.warning("No such dataset: " + persistentId); return permissionsWrapper.notFound(); }/*w ww . j a va 2 s . c o m*/ logger.fine("retrieved dataset, id=" + dataset.getId()); retrieveDatasetVersionResponse = datasetVersionService.selectRequestedVersion(dataset.getVersions(), version); //retrieveDatasetVersionResponse = datasetVersionService.retrieveDatasetVersionByPersistentId(persistentId, version); this.workingVersion = retrieveDatasetVersionResponse.getDatasetVersion(); logger.fine("retrieved version: id: " + workingVersion.getId() + ", state: " + this.workingVersion.getVersionState()); } else if (dataset.getId() != null) { // Set Working Version and Dataset by Datasaet Id and Version dataset = datasetService.find(dataset.getId()); if (dataset == null) { logger.warning("No such dataset: " + dataset); return permissionsWrapper.notFound(); } //retrieveDatasetVersionResponse = datasetVersionService.retrieveDatasetVersionById(dataset.getId(), version); retrieveDatasetVersionResponse = datasetVersionService.selectRequestedVersion(dataset.getVersions(), version); this.workingVersion = retrieveDatasetVersionResponse.getDatasetVersion(); logger.info("retreived version: id: " + workingVersion.getId() + ", state: " + this.workingVersion.getVersionState()); } else if (versionId != null) { // TODO: 4.2.1 - this method is broken as of now! // Set Working Version and Dataset by DatasaetVersion Id //retrieveDatasetVersionResponse = datasetVersionService.retrieveDatasetVersionByVersionId(versionId); } if (retrieveDatasetVersionResponse == null) { return permissionsWrapper.notFound(); } //this.dataset = this.workingVersion.getDataset(); // end: Set the workingVersion and Dataset // --------------------------------------- // Is the DatasetVersion or Dataset null? // if (workingVersion == null || this.dataset == null) { return permissionsWrapper.notFound(); } // Is the Dataset harvested? if (dataset.isHarvested()) { // if so, we'll simply forward to the remote URL for the original // source of this harvested dataset: String originalSourceURL = dataset.getRemoteArchiveURL(); if (originalSourceURL != null && !originalSourceURL.equals("")) { logger.fine("redirecting to " + originalSourceURL); try { FacesContext.getCurrentInstance().getExternalContext().redirect(originalSourceURL); } catch (IOException ioex) { // must be a bad URL... // we don't need to do anything special here - we'll redirect // to the local 404 page, below. logger.warning("failed to issue a redirect to " + originalSourceURL); } return originalSourceURL; } return permissionsWrapper.notFound(); } // Check permisisons if (!(workingVersion.isReleased() || workingVersion.isDeaccessioned()) && !this.canViewUnpublishedDataset()) { return permissionsWrapper.notAuthorized(); } if (!retrieveDatasetVersionResponse.wasRequestedVersionRetrieved()) { //msg("checkit " + retrieveDatasetVersionResponse.getDifferentVersionMessage()); JsfHelper.addWarningMessage(retrieveDatasetVersionResponse.getDifferentVersionMessage());//JH.localize("dataset.message.metadataSuccess")); } // init the citation displayCitation = dataset.getCitation(true, workingVersion); if (initFull) { // init the list of FileMetadatas if (workingVersion.isDraft() && canUpdateDataset()) { readOnly = false; } else { // an attempt to retreive both the filemetadatas and datafiles early on, so that // we don't have to do so later (possibly, many more times than necessary): datafileService.findFileMetadataOptimizedExperimental(dataset); } fileMetadatasSearch = workingVersion.getFileMetadatasSorted(); ownerId = dataset.getOwner().getId(); datasetNextMajorVersion = this.dataset.getNextMajorVersionString(); datasetNextMinorVersion = this.dataset.getNextMinorVersionString(); datasetVersionUI = datasetVersionUI.initDatasetVersionUI(workingVersion, false); updateDatasetFieldInputLevels(); setExistReleasedVersion(resetExistRealeaseVersion()); //moving setVersionTabList to tab change event //setVersionTabList(resetVersionTabList()); //setReleasedVersionTabList(resetReleasedVersionTabList()); //SEK - lazymodel may be needed for datascroller in future release // lazyModel = new LazyFileMetadataDataModel(workingVersion.getId(), datafileService ); // populate MapLayerMetadata this.loadMapLayerMetadataLookup(); // A DataFile may have a related MapLayerMetadata object this.guestbookResponse = guestbookResponseService.initGuestbookResponseForFragment(dataset, null, session); this.getFileDownloadHelper().setGuestbookResponse(guestbookResponse); logger.fine("Checking if rsync support is enabled."); if (DataCaptureModuleUtil.rsyncSupportEnabled( settingsWrapper.getValueForKey(SettingsServiceBean.Key.UploadMethods))) { try { ScriptRequestResponse scriptRequestResponse = commandEngine.submit( new RequestRsyncScriptCommand(dvRequestService.getDataverseRequest(), dataset)); logger.fine("script: " + scriptRequestResponse.getScript()); if (scriptRequestResponse.getScript() != null && !scriptRequestResponse.getScript().isEmpty()) { setHasRsyncScript(true); setRsyncScript(scriptRequestResponse.getScript()); rsyncScriptFilename = "upload-" + workingVersion.getDataset().getIdentifier() + ".bash"; } else { setHasRsyncScript(false); } } catch (RuntimeException ex) { logger.warning("Problem getting rsync script: " + ex.getLocalizedMessage()); } catch (CommandException cex) { logger.warning( "Problem getting rsync script (Command Exception): " + cex.getLocalizedMessage()); } } } } else if (ownerId != null) { // create mode for a new child dataset readOnly = false; editMode = EditMode.CREATE; dataset.setOwner(dataverseService.find(ownerId)); dataset.setProtocol(protocol); dataset.setAuthority(authority); dataset.setDoiSeparator(separator); //Wait until the create command before actually getting an identifier //dataset.setIdentifier(datasetService.generateDatasetIdentifier(protocol, authority, separator)); if (dataset.getOwner() == null) { return permissionsWrapper.notFound(); } else if (!permissionService.on(dataset.getOwner()).has(Permission.AddDataset)) { return permissionsWrapper.notAuthorized(); } dataverseTemplates = dataverseService.find(ownerId).getTemplates(); if (!dataverseService.find(ownerId).isTemplateRoot()) { dataverseTemplates.addAll(dataverseService.find(ownerId).getParentTemplates()); } defaultTemplate = dataverseService.find(ownerId).getDefaultTemplate(); if (defaultTemplate != null) { selectedTemplate = defaultTemplate; for (Template testT : dataverseTemplates) { if (defaultTemplate.getId().equals(testT.getId())) { selectedTemplate = testT; } } workingVersion = dataset.getEditVersion(selectedTemplate); updateDatasetFieldInputLevels(); } else { workingVersion = dataset.getCreateVersion(); updateDatasetFieldInputLevels(); } if (settingsWrapper.isTrueForKey(SettingsServiceBean.Key.PublicInstall, false)) { JH.addMessage(FacesMessage.SEVERITY_WARN, BundleUtil.getStringFromBundle("dataset.message.publicInstall")); } resetVersionUI(); // FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Add New Dataset", " - Enter metadata to create the dataset's citation. You can add more metadata about this dataset after it's created.")); } else { return permissionsWrapper.notFound(); } try { privateUrl = commandEngine .submit(new GetPrivateUrlCommand(dvRequestService.getDataverseRequest(), dataset)); if (privateUrl != null) { JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle( "dataset.privateurl.infoMessageAuthor", Arrays.asList(getPrivateUrlLink(privateUrl)))); } } catch (CommandException ex) { // No big deal. The user simply doesn't have access to create or delete a Private URL. } if (session.getUser() instanceof PrivateUrlUser) { PrivateUrlUser privateUrlUser = (PrivateUrlUser) session.getUser(); if (dataset != null && dataset.getId().equals(privateUrlUser.getDatasetId())) { JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.privateurl.infoMessageReviewer")); } } // Various info messages, when the dataset is locked (for various reasons): if (dataset.isLocked()) { if (dataset.isLockedFor(DatasetLock.Reason.Workflow)) { JH.addMessage(FacesMessage.SEVERITY_WARN, BundleUtil.getStringFromBundle("dataset.locked.message"), BundleUtil.getStringFromBundle("dataset.publish.workflow.inprogress")); } if (dataset.isLockedFor(DatasetLock.Reason.InReview)) { JH.addMessage(FacesMessage.SEVERITY_WARN, BundleUtil.getStringFromBundle("dataset.locked.inReview.message"), BundleUtil.getStringFromBundle("dataset.inreview.infoMessage")); } if (dataset.isLockedFor(DatasetLock.Reason.DcmUpload)) { JH.addMessage(FacesMessage.SEVERITY_WARN, BundleUtil.getStringFromBundle("file.rsyncUpload.inProgressMessage.summary"), BundleUtil.getStringFromBundle("file.rsyncUpload.inProgressMessage.details")); } } allTools = externalToolService.findAll(); return null; }