List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS
boolean IS_OS_WINDOWS
To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.
Click Source Link
Is true
if this is Windows.
The field will return false
if OS_NAME
is null
.
From source file:de.adv_online.aaa.katalogtool.KatalogDialog.java
public void actionPerformed(ActionEvent e) { if (startButton == e.getSource()) { startTransformation();/*from w ww . j a va 2 s. c om*/ } else if (e.getSource() == viewLogButton) { try { if (Desktop.isDesktopSupported()) Desktop.getDesktop().open(logfile); else if (SystemUtils.IS_OS_WINDOWS) Runtime.getRuntime().exec("cmd /c start " + logfile.getPath()); else Runtime.getRuntime().exec("open " + logfile.getPath()); } catch (Exception e1) { e1.printStackTrace(); System.exit(1); } } else if (e.getSource() == exitButton) { closeDialog(); } }
From source file:com.topsec.tsm.sim.sysconfig.web.SystemConfigController.java
/** * Agent?// www . j a v a 2 s. com * @param request * @param response * @return * @throws Exception */ @RequestMapping(value = "downloadAgentFile") public Object downloadAgentFile(HttpServletRequest request, HttpServletResponse response) throws Exception { String filename = (String) request.getParameter("ftpfilepath"); if (filename.equals("action.rar") || filename.equals("agent.rar")) { response.setHeader("Content-Type", "application/octet-stream"); response.setContentType("text/html;charset=UTF-8"); response.setHeader("Content-Disposition", "attachment; filename=" + filename); CommonUtils.setHeaders4Download(response); String serverHome = System.getProperty("jboss.server.home.dir"); String downPath = (String) FtpConfigUtil.getInstance().getFTPConfigByKey("agent").get("downPath"); if (SystemUtils.IS_OS_WINDOWS) { downPath = StringUtils.replace(downPath, "/", File.separator); } else { downPath = StringUtils.replace(downPath, "\\", File.separator); } String savaLogPathfile = new StringBuilder(serverHome).append(downPath).append(filename).toString(); File file = new File(savaLogPathfile); BufferedInputStream bis = null; BufferedOutputStream bos = null; try { bis = new BufferedInputStream(new FileInputStream(file)); bos = new BufferedOutputStream(response.getOutputStream()); byte[] buff = new byte[2048]; int bytesRead; while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) { bos.write(buff, 0, bytesRead); } bos.flush(); } catch (ClientAbortException e) { //? } catch (Exception e) { log.error("...."); log.error(e.getMessage()); } finally { ObjectUtils.close(bis); ObjectUtils.close(bos); } } return null; }
From source file:de.sub.goobi.helper.GoobiScript.java
/** * Imagepfad in den Metadaten neu setzen (evtl. vorhandene zunchst * lschen).//from w w w . j av a2 s .co m */ public void updateImagePath(List<Process> inProzesse) { for (Process proz : inProzesse) { try { Fileformat myRdf = serviceManager.getProcessService().readMetadataFile(proz); MetadataType mdt = UghHelper.getMetadataType(proz, "pathimagefiles"); List<? extends ugh.dl.Metadata> alleImagepfade = myRdf.getDigitalDocument().getPhysicalDocStruct() .getAllMetadataByType(mdt); if (alleImagepfade.size() > 0) { for (Metadata md : alleImagepfade) { myRdf.getDigitalDocument().getPhysicalDocStruct().getAllMetadata().remove(md); } } Metadata newmd = new Metadata(mdt); if (SystemUtils.IS_OS_WINDOWS) { newmd.setValue("file:/" + serviceManager.getFileService().getImagesDirectory(proz) + proz.getTitle() + DIRECTORY_SUFFIX); } else { newmd.setValue("file://" + serviceManager.getFileService().getImagesDirectory(proz) + proz.getTitle() + DIRECTORY_SUFFIX); } myRdf.getDigitalDocument().getPhysicalDocStruct().addMetadata(newmd); serviceManager.getFileService().writeMetadataFile(myRdf, proz); Helper.setMeldung("kitodoScriptfield", "ImagePath updated: ", proz.getTitle()); } catch (ugh.exceptions.DocStructHasNoTypeException e) { Helper.setFehlerMeldung("DocStructHasNoTypeException", e.getMessage()); } catch (UghHelperException e) { Helper.setFehlerMeldung("UghHelperException", e.getMessage()); } catch (MetadataTypeNotAllowedException e) { Helper.setFehlerMeldung("MetadataTypeNotAllowedException", e.getMessage()); } catch (Exception e) { Helper.setFehlerMeldung("kitodoScriptfield", "Error while updating imagepath", e); } } Helper.setMeldung("kitodoScriptfield", "", "updateImagePath finished"); }
From source file:de.sub.goobi.forms.ProzesskopieForm.java
/** * Anlegen des Prozesses und save der Metadaten. *//* w w w. j a v a 2s .c o m*/ public String createNewProcess() throws ReadException, IOException, PreferencesException, DAOException, WriteException { Helper.getHibernateSession().evict(this.prozessKopie); this.prozessKopie.setId(null); if (!isContentValid()) { return NAVI_FIRST_PAGE; } addProperties(); for (Task step : this.prozessKopie.getTasks()) { /* * always save date and user for each step */ step.setProcessingTime(this.prozessKopie.getCreationDate()); step.setEditTypeEnum(TaskEditType.AUTOMATIC); LoginForm loginForm = (LoginForm) Helper.getManagedBeanValue("#{LoginForm}"); if (loginForm != null) { step.setProcessingUser(loginForm.getMyBenutzer()); } /* * only if its done, set edit start and end date */ if (step.getProcessingStatusEnum() == TaskStatus.DONE) { step.setProcessingBegin(this.prozessKopie.getCreationDate()); // this concerns steps, which are set as done right on creation // bearbeitungsbeginn is set to creation timestamp of process // because the creation of it is basically begin of work Date myDate = new Date(); step.setProcessingTime(myDate); step.setProcessingEnd(myDate); } } try { this.prozessKopie.setSortHelperImages(this.guessedImages); serviceManager.getProcessService().save(this.prozessKopie); serviceManager.getProcessService().refresh(this.prozessKopie); } catch (DataException e) { logger.error(e); logger.error("error on save: ", e); return null; } /* * wenn noch keine RDF-Datei vorhanden ist (weil keine Opac-Abfrage * stattfand, dann jetzt eine anlegen */ if (this.myRdf == null) { createNewFileformat(); } /* * wenn eine RDF-Konfiguration vorhanden ist (z.B. aus dem Opac-Import, * oder frisch angelegt), dann diese ergnzen */ if (this.myRdf != null) { // there must be at least one non-anchor level doc struct // if missing, insert logical doc structs until you reach it DocStruct populizer = null; try { populizer = myRdf.getDigitalDocument().getLogicalDocStruct(); if (populizer.getAnchorClass() != null && populizer.getAllChildren() == null) { Prefs ruleset = serviceManager.getRulesetService().getPreferences(prozessKopie.getRuleset()); while (populizer.getType().getAnchorClass() != null) { populizer = populizer.createChild(populizer.getType().getAllAllowedDocStructTypes().get(0), myRdf.getDigitalDocument(), ruleset); } } } catch (NullPointerException | IndexOutOfBoundsException e) { // if // getAllAllowedDocStructTypes() // returns null Helper.setFehlerMeldung("DocStrctType is configured as anchor but has no allowedchildtype.", populizer != null && populizer.getType() != null ? populizer.getType().getName() : null); } catch (UGHException catchAll) { Helper.setFehlerMeldung(catchAll.getMessage()); } for (AdditionalField field : this.additionalFields) { if (field.isUghbinding() && field.getShowDependingOnDoctype()) { /* welches Docstruct */ DocStruct myTempStruct = this.myRdf.getDigitalDocument().getLogicalDocStruct(); DocStruct myTempChild = null; if (field.getDocstruct().equals("firstchild")) { try { myTempStruct = this.myRdf.getDigitalDocument().getLogicalDocStruct().getAllChildren() .get(0); } catch (RuntimeException e) { /* * das Firstchild unterhalb des Topstructs konnte * nicht ermittelt werden */ } } /* * falls topstruct und firstchild das Metadatum bekommen * sollen */ if (!field.getDocstruct().equals("firstchild") && field.getDocstruct().contains("firstchild")) { try { myTempChild = this.myRdf.getDigitalDocument().getLogicalDocStruct().getAllChildren() .get(0); } catch (RuntimeException e) { logger.error(e); } } if (field.getDocstruct().equals("boundbook")) { myTempStruct = this.myRdf.getDigitalDocument().getPhysicalDocStruct(); } /* welches Metadatum */ try { /* * bis auf die Autoren alle additionals in die Metadaten * bernehmen */ if (!field.getMetadata().equals("ListOfCreators")) { MetadataType mdt = UghHelper.getMetadataType(serviceManager.getRulesetService() .getPreferences(this.prozessKopie.getRuleset()), field.getMetadata()); Metadata md = UghHelper.getMetadata(myTempStruct, mdt); if (md != null) { md.setValue(field.getValue()); } /* * wenn dem Topstruct und dem Firstchild der Wert * gegeben werden soll */ if (myTempChild != null) { md = UghHelper.getMetadata(myTempChild, mdt); if (md != null) { md.setValue(field.getValue()); } } } } catch (Exception e) { Helper.setFehlerMeldung(e); } } // end if ughbinding } // end for /* * Metadata inheritance and enrichment */ if (ConfigCore.getBooleanParameter(Parameters.USE_METADATA_ENRICHMENT, false)) { DocStruct enricher = myRdf.getDigitalDocument().getLogicalDocStruct(); Map<String, Map<String, Metadata>> higherLevelMetadata = new HashMap<>(); while (enricher.getAllChildren() != null) { // save higher level metadata for lower enrichment List<Metadata> allMetadata = enricher.getAllMetadata(); if (allMetadata == null) { allMetadata = Collections.emptyList(); } for (Metadata available : allMetadata) { Map<String, Metadata> availableMetadata = higherLevelMetadata .containsKey(available.getType().getName()) ? higherLevelMetadata.get(available.getType().getName()) : new HashMap<>(); if (!availableMetadata.containsKey(available.getValue())) { availableMetadata.put(available.getValue(), available); } higherLevelMetadata.put(available.getType().getName(), availableMetadata); } // enrich children with inherited metadata for (DocStruct nextChild : enricher.getAllChildren()) { enricher = nextChild; for (Entry<String, Map<String, Metadata>> availableHigherMetadata : higherLevelMetadata .entrySet()) { String enrichable = availableHigherMetadata.getKey(); boolean addable = false; List<MetadataType> addableTypesNotNull = enricher.getAddableMetadataTypes(); if (addableTypesNotNull == null) { addableTypesNotNull = Collections.emptyList(); } for (MetadataType addableMetadata : addableTypesNotNull) { if (addableMetadata.getName().equals(enrichable)) { addable = true; break; } } if (!addable) { continue; } there: for (Entry<String, Metadata> higherElement : availableHigherMetadata.getValue() .entrySet()) { List<Metadata> amNotNull = enricher.getAllMetadata(); if (amNotNull == null) { amNotNull = Collections.emptyList(); } for (Metadata existentMetadata : amNotNull) { if (existentMetadata.getType().getName().equals(enrichable) && existentMetadata.getValue().equals(higherElement.getKey())) { continue there; } } try { enricher.addMetadata(higherElement.getValue()); } catch (UGHException didNotWork) { logger.info(didNotWork); } } } } } } /* * Collectionen hinzufgen */ DocStruct colStruct = this.myRdf.getDigitalDocument().getLogicalDocStruct(); try { addCollections(colStruct); /* * falls ein erstes Kind vorhanden ist, sind die Collectionen * dafr */ colStruct = colStruct.getAllChildren().get(0); addCollections(colStruct); } catch (RuntimeException e) { /* * das Firstchild unterhalb des Topstructs konnte nicht * ermittelt werden */ } /* * Imagepfad hinzufgen (evtl. vorhandene zunchst lschen) */ try { MetadataType mdt = UghHelper.getMetadataType(this.prozessKopie, "pathimagefiles"); List<? extends Metadata> alleImagepfade = this.myRdf.getDigitalDocument().getPhysicalDocStruct() .getAllMetadataByType(mdt); if (alleImagepfade != null && alleImagepfade.size() > 0) { for (Metadata md : alleImagepfade) { this.myRdf.getDigitalDocument().getPhysicalDocStruct().getAllMetadata().remove(md); } } Metadata newmd = new Metadata(mdt); if (SystemUtils.IS_OS_WINDOWS) { newmd.setValue("file:/" + serviceManager.getFileService().getImagesDirectory(this.prozessKopie) + this.prozessKopie.getTitle().trim() + DIRECTORY_SUFFIX); } else { newmd.setValue("file://" + serviceManager.getFileService().getImagesDirectory(this.prozessKopie) + this.prozessKopie.getTitle().trim() + DIRECTORY_SUFFIX); } this.myRdf.getDigitalDocument().getPhysicalDocStruct().addMetadata(newmd); /* Rdf-File schreiben */ serviceManager.getFileService().writeMetadataFile(this.myRdf, this.prozessKopie); /* * soll der Prozess als Vorlage verwendet werden? */ if (this.useTemplates && this.prozessKopie.isInChoiceListShown()) { serviceManager.getFileService().writeMetadataAsTemplateFile(this.myRdf, this.prozessKopie); } } catch (ugh.exceptions.DocStructHasNoTypeException e) { Helper.setFehlerMeldung("DocStructHasNoTypeException", e.getMessage()); logger.error("creation of new process throws an error: ", e); } catch (UghHelperException e) { Helper.setFehlerMeldung("UghHelperException", e.getMessage()); logger.error("creation of new process throws an error: ", e); } catch (MetadataTypeNotAllowedException e) { Helper.setFehlerMeldung("MetadataTypeNotAllowedException", e.getMessage()); logger.error("creation of new process throws an error: ", e); } } // Create configured directories serviceManager.getProcessService().createProcessDirs(this.prozessKopie); // Adding process to history if (!HistoryAnalyserJob.updateHistoryForProcess(this.prozessKopie)) { Helper.setFehlerMeldung("historyNotUpdated"); return null; } else { try { serviceManager.getProcessService().save(this.prozessKopie); } catch (DataException e) { logger.error(e); logger.error("error on save: ", e); return null; } } serviceManager.getProcessService().readMetadataFile(this.prozessKopie); /* damit die Sortierung stimmt nochmal einlesen */ Helper.getHibernateSession().refresh(this.prozessKopie); List<Task> tasks = serviceManager.getProcessService().getById(prozessKopie.getId()).getTasks(); for (Task t : tasks) { if (t.getProcessingStatus() == 1 && t.isTypeAutomatic()) { TaskScriptThread myThread = new TaskScriptThread(t); myThread.start(); } } return "/pages/NewProcess/Page3"; }
From source file:edu.isi.wings.catalog.component.api.impl.kb.ComponentReasoningKB.java
public ComponentInvocation getComponentInvocation(ComponentPacket details) { HashMap<String, KBObject> omap = this.objPropMap; HashMap<String, KBObject> dmap = this.dataPropMap; // Extract info from details object ComponentVariable c = details.getComponent(); Map<Variable, Role> varMap = details.getVariableMap(); // Get Component KBObject comp = this.kb.getResource(c.getBinding().getID()); String exepath = this.getComponentLocation(comp.getID()); String exedir = null;//from w w w .j ava 2s. c om if (exepath != null) { File f = new File(exepath); if (f.isDirectory()) { exedir = exepath; File shexef = new File(exepath + File.separator + "run"); File winexef = new File(exepath + File.separator + "run.bat"); if (SystemUtils.IS_OS_WINDOWS && winexef.exists()) exepath = winexef.getAbsolutePath(); else exepath = shexef.getAbsolutePath(); } } ComponentInvocation invocation = new ComponentInvocation(); invocation.setComponentId(comp.getID()); invocation.setComponentLocation(exepath); invocation.setComponentDirectory(exedir); ArrayList<KBObject> inputs = this.kb.getPropertyValues(comp, omap.get("hasInput")); ArrayList<KBObject> outputs = this.kb.getPropertyValues(comp, omap.get("hasOutput")); ArrayList<KBObject> args = new ArrayList<KBObject>(inputs); args.addAll(outputs); for (KBObject arg : args) { KBObject argid = this.kb.getDatatypePropertyValue(arg, dmap.get("hasArgumentID")); String role = (String) argid.getValue(); for (Variable var : varMap.keySet()) { Role r = varMap.get(var); if (r.getRoleId().equals(role)) setInvocationArguments(invocation, arg, var, inputs.contains(arg)); } } return invocation; }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManagerResource.java
private void createDataFileLink(File entityFile, String dataToken) throws Exception { String msg = null;// w w w .jav a2s .c o m /* * Create a link from the path of the data entity for * this revision to the path of the data entity for the * prior revision. */ String dataTokenPathStr = String.format("%s/%s", this.tmpDir, dataToken); FileSystem fileSystem = FileSystems.getDefault(); String entityPathStr = entityFile.getAbsolutePath(); java.nio.file.Path entityPath = fileSystem.getPath(entityPathStr); java.nio.file.Path dataTokenPath = fileSystem.getPath(dataTokenPathStr); String createLinkMsg = String.format("Creating link from %s to %s", dataTokenPathStr, entityPathStr); logger.warn(createLinkMsg); try { if (SystemUtils.IS_OS_WINDOWS) { Files.createLink(dataTokenPath, entityPath); } else { Files.createSymbolicLink(dataTokenPath, entityPath); } } catch (FileAlreadyExistsException e) { // this is okay, just issue a warning msg = String.format("Failed to create link from %s to %s: %s", dataTokenPathStr, entityPathStr, e.getMessage()); logger.warn(msg); } catch (Exception e) { msg = String.format("Error creating link from %s to %s: %s", dataTokenPathStr, entityPathStr, e.getMessage()); logger.error(msg); throw (e); } }
From source file:com.vmware.identity.idm.server.IdentityManager.java
private static String getComputerName() { String computerName = LOCAL_OS_STATIC_ALIAS; // this is "localos" if (SystemUtils.IS_OS_WINDOWS) { IIdmClientLibrary client = IdmClientLibraryFactory.getInstance().getLibrary(); computerName = client.getComputerName(); }//from w w w.j a va 2s. c o m return computerName; }
From source file:net.sourceforge.vulcan.git.GitRepository.java
public void clone(File workDir, BuildDetailCallback buildDetailCallback) throws RepositoryException { if (!isRemoteRepositoryConfigured()) { throw new RepositoryException("hg.errors.no.repo.and.no.remote", null, workDir); }/*from w ww. j a v a 2 s. c om*/ buildDetailCallback.setDetailMessage("hg.activity.clone", null); List<String> args = new ArrayList<String>(); args.add("--progress"); args.add("-v"); if (SystemUtils.IS_OS_WINDOWS) { args.add("\"" + settings.getRemoteRepositoryUrl() + "\""); args.add("\"" + workDir.getAbsolutePath() + "\""); } else { args.add(settings.getRemoteRepositoryUrl()); args.add(workDir.getAbsolutePath()); } tryInvoke(Command.clone, args.toArray(new String[args.size()])); }
From source file:net.sourceforge.vulcan.git.GitRepository.java
public void pull(BuildDetailCallback buildDetailCallback) throws RepositoryException { if (!isRemoteRepositoryConfigured()) { return;// w w w .j a va 2s. co m } List<String> args = new ArrayList<String>(); args.add("--progress"); args.add("-v"); if (SystemUtils.IS_OS_WINDOWS) { args.add("\"origin\""); } else { args.add("origin"); } if (buildDetailCallback != null) { buildDetailCallback.setDetailMessage("hg.activity.pull", null); } tryInvoke(Command.pull, args.toArray(new String[args.size()])); }
From source file:net.ssehub.easy.instantiation.core.model.buildlangModel.BuildlangExecution.java
/** * Processes the {@link LoadProperties}. * //from w w w. j av a 2s . co m * @param script the script to process the properties for * @param base the base path to make relative paths absolute * @throws VilException in case that something goes wrong */ protected void processProperties(Script script, File base) throws VilException { Properties loaded = new Properties(); for (int p = 0; p < script.getPropertiesCount(); p++) { LoadProperties prop = script.getProperties(p); String path = prop.getPath(); path = StringReplacer.substitute(path, new Resolver(environment), getExpressionParser(), this, null); File file = absolute(path, base); loadProperties(file, loaded, null); if (SystemUtils.IS_OS_MAC) { loadProperties(file, loaded, "macos"); } else if (SystemUtils.IS_OS_UNIX) { loadProperties(file, loaded, "unix"); } else if (SystemUtils.IS_OS_WINDOWS) { loadProperties(file, loaded, "win"); } } for (int v = 0; v < script.getVariableDeclarationCount(); v++) { VariableDeclaration var = script.getVariableDeclaration(v); String value = loaded.getProperty(var.getName(), null); if (null != value) { if (var.isConstant() && null != var.getExpression()) { throw new VilException("constant '" + var.getName() + "' is already assigned a value", VilException.ID_IS_CONSTANT); } Object actValue = evaluateExternalValue(var, value); environment.setValue(var, actValue); tracer.valueDefined(var, null, actValue); } } }