List of usage examples for java.io File pathSeparatorChar
char pathSeparatorChar
To view the source code for java.io File pathSeparatorChar.
Click Source Link
From source file:org.apache.hama.bsp.YARNBSPJobClient.java
@Override protected RunningJob launchJob(BSPJobID jobId, BSPJob normalJob, Path submitJobFile, FileSystem pFs) throws IOException { YARNBSPJob job = (YARNBSPJob) normalJob; LOG.info("Submitting job..."); if (getConf().get("bsp.child.mem.in.mb") == null) { LOG.warn("BSP Child memory has not been set, YARN will guess your needs or use default values."); }//from ww w. jav a 2 s . c o m FileSystem fs = pFs; if (fs == null) { fs = FileSystem.get(getConf()); } if (getConf().get("bsp.user.name") == null) { String s = getUnixUserName(); getConf().set("bsp.user.name", s); LOG.debug("Retrieved username: " + s); } yarnClient.start(); try { YarnClusterMetrics clusterMetrics = yarnClient.getYarnClusterMetrics(); LOG.info("Got Cluster metric info from ASM" + ", numNodeManagers=" + clusterMetrics.getNumNodeManagers()); List<NodeReport> clusterNodeReports = yarnClient.getNodeReports(NodeState.RUNNING); LOG.info("Got Cluster node info from ASM"); for (NodeReport node : clusterNodeReports) { LOG.info("Got node report from ASM for" + ", nodeId=" + node.getNodeId() + ", nodeAddress" + node.getHttpAddress() + ", nodeRackName" + node.getRackName() + ", nodeNumContainers" + node.getNumContainers()); } QueueInfo queueInfo = yarnClient.getQueueInfo("default"); LOG.info("Queue info" + ", queueName=" + queueInfo.getQueueName() + ", queueCurrentCapacity=" + queueInfo.getCurrentCapacity() + ", queueMaxCapacity=" + queueInfo.getMaximumCapacity() + ", queueApplicationCount=" + queueInfo.getApplications().size() + ", queueChildQueueCount=" + queueInfo.getChildQueues().size()); List<QueueUserACLInfo> listAclInfo = yarnClient.getQueueAclsInfo(); for (QueueUserACLInfo aclInfo : listAclInfo) { for (QueueACL userAcl : aclInfo.getUserAcls()) { LOG.info("User ACL Info for Queue" + ", queueName=" + aclInfo.getQueueName() + ", userAcl=" + userAcl.name()); } } // Get a new application id YarnClientApplication app = yarnClient.createApplication(); // Create a new ApplicationSubmissionContext //ApplicationSubmissionContext appContext = Records.newRecord(ApplicationSubmissionContext.class); ApplicationSubmissionContext appContext = app.getApplicationSubmissionContext(); id = appContext.getApplicationId(); // set the application name appContext.setApplicationName(job.getJobName()); // Create a new container launch context for the AM's container ContainerLaunchContext amContainer = Records.newRecord(ContainerLaunchContext.class); // Define the local resources required Map<String, LocalResource> localResources = new HashMap<String, LocalResource>(); // Lets assume the jar we need for our ApplicationMaster is available in // HDFS at a certain known path to us and we want to make it available to // the ApplicationMaster in the launched container if (job.getJar() == null) { throw new IllegalArgumentException("Jar must be set in order to run the application!"); } Path jarPath = new Path(job.getJar()); jarPath = fs.makeQualified(jarPath); getConf().set("bsp.jar", jarPath.makeQualified(fs.getUri(), jarPath).toString()); FileStatus jarStatus = fs.getFileStatus(jarPath); LocalResource amJarRsrc = Records.newRecord(LocalResource.class); amJarRsrc.setType(LocalResourceType.FILE); amJarRsrc.setVisibility(LocalResourceVisibility.APPLICATION); amJarRsrc.setResource(ConverterUtils.getYarnUrlFromPath(jarPath)); amJarRsrc.setTimestamp(jarStatus.getModificationTime()); amJarRsrc.setSize(jarStatus.getLen()); // this creates a symlink in the working directory localResources.put(YARNBSPConstants.APP_MASTER_JAR_PATH, amJarRsrc); // add hama related jar files to localresources for container List<File> hamaJars; if (System.getProperty("hama.home.dir") != null) hamaJars = localJarfromPath(System.getProperty("hama.home.dir")); else hamaJars = localJarfromPath(getConf().get("hama.home.dir")); String hamaPath = getSystemDir() + "/hama"; for (File fileEntry : hamaJars) { addToLocalResources(fs, fileEntry.getCanonicalPath(), hamaPath, fileEntry.getName(), localResources); } // Set the local resources into the launch context amContainer.setLocalResources(localResources); // Set up the environment needed for the launch context Map<String, String> env = new HashMap<String, String>(); // Assuming our classes or jars are available as local resources in the // working directory from which the command will be run, we need to append // "." to the path. // By default, all the hadoop specific classpaths will already be available // in $CLASSPATH, so we should be careful not to overwrite it. StringBuilder classPathEnv = new StringBuilder(ApplicationConstants.Environment.CLASSPATH.$()) .append(File.pathSeparatorChar).append("./*"); for (String c : yarnConf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH, YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) { classPathEnv.append(File.pathSeparatorChar); classPathEnv.append(c.trim()); } env.put(YARNBSPConstants.HAMA_YARN_LOCATION, jarPath.toUri().toString()); env.put(YARNBSPConstants.HAMA_YARN_SIZE, Long.toString(jarStatus.getLen())); env.put(YARNBSPConstants.HAMA_YARN_TIMESTAMP, Long.toString(jarStatus.getModificationTime())); env.put(YARNBSPConstants.HAMA_LOCATION, hamaPath); env.put("CLASSPATH", classPathEnv.toString()); amContainer.setEnvironment(env); // Set the necessary command to execute on the allocated container Vector<CharSequence> vargs = new Vector<CharSequence>(5); vargs.add("${JAVA_HOME}/bin/java"); vargs.add("-cp " + classPathEnv + ""); vargs.add(ApplicationMaster.class.getCanonicalName()); vargs.add(submitJobFile.makeQualified(fs.getUri(), fs.getWorkingDirectory()).toString()); vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/hama-appmaster.stdout"); vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/hama-appmaster.stderr"); // Get final commmand StringBuilder command = new StringBuilder(); for (CharSequence str : vargs) { command.append(str).append(" "); } List<String> commands = new ArrayList<String>(); commands.add(command.toString()); amContainer.setCommands(commands); LOG.debug("Start command: " + command); Resource capability = Records.newRecord(Resource.class); // we have at least 3 threads, which comsumes 1mb each, for each bsptask and // a base usage of 100mb capability.setMemory(3 * job.getNumBspTask() + getConf().getInt("hama.appmaster.memory.mb", 100)); LOG.info("Set memory for the application master to " + capability.getMemory() + "mb!"); // Set the container launch content into the ApplicationSubmissionContext appContext.setResource(capability); // Setup security tokens if (UserGroupInformation.isSecurityEnabled()) { // Note: Credentials class is marked as LimitedPrivate for HDFS and MapReduce Credentials credentials = new Credentials(); String tokenRenewer = yarnConf.get(YarnConfiguration.RM_PRINCIPAL); if (tokenRenewer == null || tokenRenewer.length() == 0) { throw new IOException("Can't get Master Kerberos principal for the RM to use as renewer"); } // For now, only getting tokens for the default file-system. final Token<?> tokens[] = fs.addDelegationTokens(tokenRenewer, credentials); if (tokens != null) { for (Token<?> token : tokens) { LOG.info("Got dt for " + fs.getUri() + "; " + token); } } DataOutputBuffer dob = new DataOutputBuffer(); credentials.writeTokenStorageToStream(dob); ByteBuffer fsTokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength()); amContainer.setTokens(fsTokens); } appContext.setAMContainerSpec(amContainer); // Create the request to send to the ApplicationsManager ApplicationId appId = appContext.getApplicationId(); yarnClient.submitApplication(appContext); return monitorApplication(appId) ? new NetworkedJob() : null; } catch (YarnException e) { e.printStackTrace(); return null; } }
From source file:org.broadinstitute.gatk.tools.CatVariantsIntegrationTest.java
@Test(dataProvider = "MismatchedExtensionsTest", expectedExceptions = IOException.class) public void testMismatchedExtensions2(final String extension1, final String extension2) throws IOException { String cmdLine = String.format("java -cp \"%s\" %s -R %s -V %s -V %s -out %s", StringUtils.join(RuntimeUtils.getAbsoluteClassPaths(), File.pathSeparatorChar), CatVariants.class.getCanonicalName(), BaseTest.b37KGReference, new File(CatVariantsDir, "CatVariantsTest1" + extension1), new File(CatVariantsDir, "CatVariantsTest2" + extension2), BaseTest.createTempFile("CatVariantsTest", ".vcf")); ProcessController pc = ProcessController.getThreadLocal(); ProcessSettings ps = new ProcessSettings(Utils.escapeExpressions(cmdLine)); pc.execAndCheck(ps);//from w w w . j a va 2s . com }
From source file:org.apache.helix.provisioning.yarn.AppLauncher.java
public boolean launch() throws Exception { LOG.info("Running Client"); yarnClient.start();// ww w.j a v a 2s . c o m // Get a new application id YarnClientApplication app = yarnClient.createApplication(); GetNewApplicationResponse appResponse = app.getNewApplicationResponse(); // TODO get min/max resource capabilities from RM and change memory ask if needed // If we do not have min/max, we may not be able to correctly request // the required resources from the RM for the app master // Memory ask has to be a multiple of min and less than max. // Dump out information about cluster capability as seen by the resource manager int maxMem = appResponse.getMaximumResourceCapability().getMemory(); LOG.info("Max mem capabililty of resources in this cluster " + maxMem); // set the application name ApplicationSubmissionContext appContext = app.getApplicationSubmissionContext(); _appId = appContext.getApplicationId(); _appMasterConfig.setAppId(_appId.getId()); String appName = _applicationSpec.getAppName(); _appMasterConfig.setAppName(appName); _appMasterConfig.setApplicationSpecFactory(_applicationSpecFactory.getClass().getCanonicalName()); appContext.setApplicationName(appName); // Set up the container launch context for the application master ContainerLaunchContext amContainer = Records.newRecord(ContainerLaunchContext.class); LOG.info("Copy Application archive file from local filesystem and add to local environment"); // Copy the application master jar to the filesystem // Create a local resource to point to the destination jar path FileSystem fs = FileSystem.get(_conf); // get packages for each component packages Map<String, URI> packages = new HashMap<String, URI>(); packages.put(AppMasterConfig.AppEnvironment.APP_MASTER_PKG.toString(), appMasterArchive.toURI()); packages.put(AppMasterConfig.AppEnvironment.APP_SPEC_FILE.toString(), _yamlConfigFile.toURI()); for (String serviceName : _applicationSpec.getServices()) { packages.put(serviceName, _applicationSpec.getServicePackage(serviceName)); } Map<String, Path> hdfsDest = new HashMap<String, Path>(); Map<String, String> classpathMap = new HashMap<String, String>(); for (String name : packages.keySet()) { URI uri = packages.get(name); Path dst = copyToHDFS(fs, name, uri); hdfsDest.put(name, dst); String classpath = generateClasspathAfterExtraction(name, new File(uri)); classpathMap.put(name, classpath); _appMasterConfig.setClasspath(name, classpath); String serviceMainClass = _applicationSpec.getServiceMainClass(name); if (serviceMainClass != null) { _appMasterConfig.setMainClass(name, serviceMainClass); } } // Get YAML files describing all workflows to immediately start Map<String, URI> workflowFiles = new HashMap<String, URI>(); List<TaskConfig> taskConfigs = _applicationSpec.getTaskConfigs(); if (taskConfigs != null) { for (TaskConfig taskConfig : taskConfigs) { URI configUri = taskConfig.getYamlURI(); if (taskConfig.name != null && configUri != null) { workflowFiles.put(taskConfig.name, taskConfig.getYamlURI()); } } } // set local resources for the application master // local files or archives as needed // In this scenario, the jar file for the application master is part of the local resources Map<String, LocalResource> localResources = new HashMap<String, LocalResource>(); LocalResource appMasterPkg = setupLocalResource(fs, hdfsDest.get(AppMasterConfig.AppEnvironment.APP_MASTER_PKG.toString())); LocalResource appSpecFile = setupLocalResource(fs, hdfsDest.get(AppMasterConfig.AppEnvironment.APP_SPEC_FILE.toString())); localResources.put(AppMasterConfig.AppEnvironment.APP_MASTER_PKG.toString(), appMasterPkg); localResources.put(AppMasterConfig.AppEnvironment.APP_SPEC_FILE.toString(), appSpecFile); for (String name : workflowFiles.keySet()) { URI uri = workflowFiles.get(name); Path dst = copyToHDFS(fs, name, uri); LocalResource taskLocalResource = setupLocalResource(fs, dst); localResources.put(AppMasterConfig.AppEnvironment.TASK_CONFIG_FILE.toString() + "_" + name, taskLocalResource); } // Set local resource info into app master container launch context amContainer.setLocalResources(localResources); // Set the necessary security tokens as needed // amContainer.setContainerTokens(containerToken); // Add AppMaster.jar location to classpath // At some point we should not be required to add // the hadoop specific classpaths to the env. // It should be provided out of the box. // For now setting all required classpaths including // the classpath to "." for the application jar StringBuilder classPathEnv = new StringBuilder(Environment.CLASSPATH.$()).append(File.pathSeparatorChar) .append("./*").append(File.pathSeparatorChar); classPathEnv.append(classpathMap.get(AppMasterConfig.AppEnvironment.APP_MASTER_PKG.toString())); for (String c : _conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH, YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) { classPathEnv.append(File.pathSeparatorChar); classPathEnv.append(c.trim()); } classPathEnv.append(File.pathSeparatorChar).append("./log4j.properties"); // add the runtime classpath needed for tests to work if (_conf.getBoolean(YarnConfiguration.IS_MINI_YARN_CLUSTER, false)) { classPathEnv.append(':'); classPathEnv.append(System.getProperty("java.class.path")); } LOG.info("\n\n Setting the classpath to launch AppMaster:\n\n"); // Set the env variables to be setup in the env where the application master will be run Map<String, String> env = new HashMap<String, String>(_appMasterConfig.getEnv()); env.put("CLASSPATH", classPathEnv.toString()); amContainer.setEnvironment(env); // Set the necessary command to execute the application master Vector<CharSequence> vargs = new Vector<CharSequence>(30); // Set java executable command LOG.info("Setting up app master launch command"); vargs.add(Environment.JAVA_HOME.$() + "/bin/java"); int amMemory = 4096; // Set Xmx based on am memory size vargs.add("-Xmx" + amMemory + "m"); // Set class name vargs.add(AppMasterLauncher.class.getCanonicalName()); // Set params for Application Master // vargs.add("--num_containers " + String.valueOf(numContainers)); vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stdout"); vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stderr"); // Get final commmand StringBuilder command = new StringBuilder(); for (CharSequence str : vargs) { command.append(str).append(" "); } LOG.info("Completed setting up app master command " + command.toString()); List<String> commands = new ArrayList<String>(); commands.add(command.toString()); amContainer.setCommands(commands); // Set up resource type requirements // For now, only memory is supported so we set memory requirements Resource capability = Records.newRecord(Resource.class); capability.setMemory(amMemory); appContext.setResource(capability); // Service data is a binary blob that can be passed to the application // Not needed in this scenario // amContainer.setServiceData(serviceData); // Setup security tokens if (UserGroupInformation.isSecurityEnabled()) { Credentials credentials = new Credentials(); String tokenRenewer = _conf.get(YarnConfiguration.RM_PRINCIPAL); if (tokenRenewer == null || tokenRenewer.length() == 0) { throw new IOException("Can't get Master Kerberos principal for the RM to use as renewer"); } // For now, only getting tokens for the default file-system. final Token<?> tokens[] = fs.addDelegationTokens(tokenRenewer, credentials); if (tokens != null) { for (Token<?> token : tokens) { LOG.info("Got dt for " + fs.getUri() + "; " + token); } } DataOutputBuffer dob = new DataOutputBuffer(); credentials.writeTokenStorageToStream(dob); ByteBuffer fsTokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength()); amContainer.setTokens(fsTokens); } appContext.setAMContainerSpec(amContainer); // Set the priority for the application master Priority pri = Records.newRecord(Priority.class); int amPriority = 0; // TODO - what is the range for priority? how to decide? pri.setPriority(amPriority); appContext.setPriority(pri); String amQueue = "default"; // Set the queue to which this application is to be submitted in the RM appContext.setQueue(amQueue); LOG.info("Submitting application to YARN Resource Manager"); ApplicationId applicationId = yarnClient.submitApplication(appContext); LOG.info("Submitted application with applicationId:" + applicationId); return true; }
From source file:hudson.FilePath.java
/** * Checks if the remote path is Unix.// w w w .j a va 2 s. com */ private boolean isUnix() { // if the path represents a local path, there' no need to guess. if (!isRemote()) return File.pathSeparatorChar != ';'; // note that we can't use the usual File.pathSeparator and etc., as the OS of // the machine where this code runs and the OS that this FilePath refers to may be different. // Windows absolute path is 'X:\...', so this is usually a good indication of Windows path if (remote.length() > 3 && remote.charAt(1) == ':' && remote.charAt(2) == '\\') return false; // Windows can handle '/' as a path separator but Unix can't, // so err on Unix side return remote.indexOf("\\") == -1; }
From source file:org.apache.openmeetings.servlet.outputhandler.BackupImportController.java
public void performImport(InputStream is) throws Exception { File working_dir = OmFileHelper.getUploadImportDir(); if (!working_dir.exists()) { working_dir.mkdir();/*from w ww.j ava 2s . c om*/ } File f = OmFileHelper.getNewDir(working_dir, "import_" + CalendarPatterns.getTimeForStreamId(new Date())); log.debug("##### WRITE FILE TO: " + f); ZipInputStream zipinputstream = new ZipInputStream(is); ZipEntry zipentry = zipinputstream.getNextEntry(); while (zipentry != null) { String fName = zipentry.getName(); if (File.pathSeparatorChar != '\\' && fName.indexOf('\\') > -1) { fName = fName.replace('\\', '/'); } // for each entry to be extracted File fentry = new File(f, fName); File dir = fentry.isDirectory() ? fentry : fentry.getParentFile(); dir.mkdirs(); if (fentry.isDirectory()) { zipentry = zipinputstream.getNextEntry(); continue; } FileHelper.copy(zipinputstream, fentry); zipinputstream.closeEntry(); zipentry = zipinputstream.getNextEntry(); } zipinputstream.close(); /* * ##################### Import Organizations */ Serializer simpleSerializer = new Persister(); { List<Organisation> list = readList(simpleSerializer, f, "organizations.xml", "organisations", Organisation.class); for (Organisation o : list) { long oldId = o.getOrganisation_id(); o.setOrganisation_id(null); Long newId = organisationManager.addOrganisationObj(o); organisationsMap.put(oldId, newId); } } log.info("Organizations import complete, starting user import"); /* * ##################### Import Users */ { List<User> list = readUserList(f, "users.xml", "users"); for (User u : list) { OmTimeZone tz = u.getOmTimeZone(); if (tz == null || tz.getJname() == null) { String jNameTimeZone = configurationDao.getConfValue("default.timezone", String.class, "Europe/Berlin"); OmTimeZone omTimeZone = omTimeZoneDaoImpl.getOmTimeZone(jNameTimeZone); u.setOmTimeZone(omTimeZone); u.setForceTimeZoneCheck(true); } else { u.setForceTimeZoneCheck(false); } u.setStarttime(new Date()); long userId = u.getUser_id(); u.setUser_id(null); if (u.getSipUser() != null && u.getSipUser().getId() != 0) { u.getSipUser().setId(0); } usersDao.update(u, -1L); usersMap.put(userId, u.getUser_id()); } } log.info("Users import complete, starting room import"); /* * ##################### Import Rooms */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions Serializer serializer = new Persister(strategy, matcher); matcher.bind(Long.class, LongTransform.class); matcher.bind(Integer.class, IntegerTransform.class); registry.bind(User.class, new UserConverter(usersDao, usersMap)); registry.bind(RoomType.class, new RoomTypeConverter(roomManager)); List<Room> list = readList(serializer, f, "rooms.xml", "rooms", Room.class); for (Room r : list) { Long roomId = r.getRooms_id(); // We need to reset ids as openJPA reject to store them otherwise r.setRooms_id(null); if (r.getModerators() != null) { for (Iterator<RoomModerator> i = r.getModerators().iterator(); i.hasNext();) { RoomModerator rm = i.next(); if (rm.getUser().getUser_id() == null) { i.remove(); } } } r = roomDao.update(r, null); roomsMap.put(roomId, r.getRooms_id()); } } log.info("Room import complete, starting room organizations import"); /* * ##################### Import Room Organisations */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(Organisation.class, new OrganisationConverter(orgDao, organisationsMap)); registry.bind(Room.class, new RoomConverter(roomDao, roomsMap)); List<RoomOrganisation> list = readList(serializer, f, "rooms_organisation.xml", "room_organisations", RoomOrganisation.class); for (RoomOrganisation ro : list) { if (!ro.getDeleted()) { // We need to reset this as openJPA reject to store them otherwise ro.setRooms_organisation_id(null); roomManager.addRoomOrganisation(ro); } } } log.info("Room organizations import complete, starting appointement import"); /* * ##################### Import Appointements */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(AppointmentCategory.class, new AppointmentCategoryConverter(appointmentCategoryDaoImpl)); registry.bind(User.class, new UserConverter(usersDao, usersMap)); registry.bind(AppointmentReminderTyps.class, new AppointmentReminderTypeConverter(appointmentReminderTypDaoImpl)); registry.bind(Room.class, new RoomConverter(roomDao, roomsMap)); registry.bind(Date.class, DateConverter.class); List<Appointment> list = readList(serializer, f, "appointements.xml", "appointments", Appointment.class); for (Appointment a : list) { Long appId = a.getAppointmentId(); // We need to reset this as openJPA reject to store them otherwise a.setAppointmentId(null); if (a.getUserId() != null && a.getUserId().getUser_id() == null) { a.setUserId(null); } Long newAppId = appointmentDao.addAppointmentObj(a); appointmentsMap.put(appId, newAppId); } } log.info("Appointement import complete, starting meeting members import"); /* * ##################### Import MeetingMembers * * Reminder Invitations will be NOT send! */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(User.class, new UserConverter(usersDao, usersMap)); registry.bind(Appointment.class, new AppointmentConverter(appointmentDao, appointmentsMap)); List<MeetingMember> list = readList(serializer, f, "meetingmembers.xml", "meetingmembers", MeetingMember.class); for (MeetingMember ma : list) { if (ma.getUserid() != null && ma.getUserid().getUser_id() == null) { ma.setUserid(null); } if (!ma.getDeleted()) { // We need to reset this as openJPA reject to store them otherwise ma.setMeetingMemberId(null); meetingMemberDao.addMeetingMemberByObject(ma); } } } log.info("Meeting members import complete, starting ldap config import"); /* * ##################### Import LDAP Configs */ { List<LdapConfig> list = readList(simpleSerializer, f, "ldapconfigs.xml", "ldapconfigs", LdapConfig.class, true); for (LdapConfig c : list) { ldapConfigDao.addLdapConfigByObject(c); } } log.info("Ldap config import complete, starting recordings import"); /* * ##################### Import Recordings */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions Serializer serializer = new Persister(strategy, matcher); matcher.bind(Long.class, LongTransform.class); matcher.bind(Integer.class, IntegerTransform.class); registry.bind(Date.class, DateConverter.class); List<FlvRecording> list = readList(serializer, f, "flvRecordings.xml", "flvrecordings", FlvRecording.class, true); for (FlvRecording fr : list) { fr.setFlvRecordingId(0); if (fr.getRoom_id() != null) { fr.setRoom_id(roomsMap.get(fr.getRoom_id())); } if (fr.getOwnerId() != null) { fr.setOwnerId(usersMap.get(fr.getOwnerId())); } if (fr.getFlvRecordingMetaData() != null) { for (FlvRecordingMetaData meta : fr.getFlvRecordingMetaData()) { meta.setFlvRecordingMetaDataId(0); meta.setFlvRecording(fr); } } flvRecordingDao.addFlvRecordingObj(fr); } } log.info("FLVrecording import complete, starting private message folder import"); /* * ##################### Import Private Message Folders */ { List<PrivateMessageFolder> list = readList(simpleSerializer, f, "privateMessageFolder.xml", "privatemessagefolders", PrivateMessageFolder.class, true); for (PrivateMessageFolder p : list) { Long folderId = p.getPrivateMessageFolderId(); PrivateMessageFolder storedFolder = privateMessageFolderDao.getPrivateMessageFolderById(folderId); if (storedFolder == null) { p.setPrivateMessageFolderId(0); Long newFolderId = privateMessageFolderDao.addPrivateMessageFolderObj(p); messageFoldersMap.put(folderId, newFolderId); } } } log.info("Private message folder import complete, starting user contacts import"); /* * ##################### Import User Contacts */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(User.class, new UserConverter(usersDao, usersMap)); List<UserContact> list = readList(serializer, f, "userContacts.xml", "usercontacts", UserContact.class, true); for (UserContact uc : list) { Long ucId = uc.getUserContactId(); UserContact storedUC = userContactsDao.getUserContacts(ucId); if (storedUC == null && uc.getContact() != null && uc.getContact().getUser_id() != null) { uc.setUserContactId(0); Long newId = userContactsDao.addUserContactObj(uc); userContactsMap.put(ucId, newId); } } } log.info("Usercontact import complete, starting private messages item import"); /* * ##################### Import Private Messages */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(User.class, new UserConverter(usersDao, usersMap)); registry.bind(Room.class, new RoomConverter(roomDao, roomsMap)); registry.bind(Date.class, DateConverter.class); List<PrivateMessage> list = readList(serializer, f, "privateMessages.xml", "privatemessages", PrivateMessage.class, true); for (PrivateMessage p : list) { p.setPrivateMessageId(0); p.setPrivateMessageFolderId(getNewId(p.getPrivateMessageFolderId(), Maps.MESSAGEFOLDERS)); p.setUserContactId(getNewId(p.getUserContactId(), Maps.USERCONTACTS)); if (p.getRoom() != null && p.getRoom().getRooms_id() == null) { p.setRoom(null); } if (p.getTo() != null && p.getTo().getUser_id() == null) { p.setTo(null); } if (p.getFrom() != null && p.getFrom().getUser_id() == null) { p.setFrom(null); } if (p.getOwner() != null && p.getOwner().getUser_id() == null) { p.setOwner(null); } privateMessagesDao.addPrivateMessageObj(p); } } log.info("Private message import complete, starting file explorer item import"); /* * ##################### Import File-Explorer Items */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions Serializer serializer = new Persister(strategy, matcher); matcher.bind(Long.class, LongTransform.class); matcher.bind(Integer.class, IntegerTransform.class); registry.bind(Date.class, DateConverter.class); List<FileExplorerItem> list = readList(serializer, f, "fileExplorerItems.xml", "fileExplorerItems", FileExplorerItem.class, true); for (FileExplorerItem file : list) { // We need to reset this as openJPA reject to store them otherwise file.setFileExplorerItemId(0); Long roomId = file.getRoom_id(); file.setRoom_id(roomsMap.containsKey(roomId) ? roomsMap.get(roomId) : null); fileExplorerItemDao.addFileExplorerItem(file); } } log.info("File explorer item import complete, starting file poll import"); /* * ##################### Import Room Polls */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(User.class, new UserConverter(usersDao, usersMap)); registry.bind(Room.class, new RoomConverter(roomDao, roomsMap)); registry.bind(PollType.class, new PollTypeConverter(pollManager)); registry.bind(Date.class, DateConverter.class); List<RoomPoll> list = readList(serializer, f, "roompolls.xml", "roompolls", RoomPoll.class, true); for (RoomPoll rp : list) { pollManager.savePollBackup(rp); } } log.info("Poll import complete, starting configs import"); /* * ##################### Import Configs */ { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions Serializer serializer = new Persister(strategy, matcher); matcher.bind(Long.class, LongTransform.class); registry.bind(Date.class, DateConverter.class); registry.bind(User.class, new UserConverter(usersDao, usersMap)); List<Configuration> list = readList(serializer, f, "configs.xml", "configs", Configuration.class, true); for (Configuration c : list) { Configuration cfg = configurationDao.get(c.getConf_key()); c.setConfiguration_id(cfg == null ? null : cfg.getConfiguration_id()); if (c.getUser() != null && c.getUser().getUser_id() == null) { c.setUser(null); } if ("crypt_ClassName".equals(c.getConf_key())) { try { Class.forName(c.getConf_value()); } catch (ClassNotFoundException e) { c.setConf_value(MD5Implementation.class.getCanonicalName()); } } configurationDao.update(c, -1L); } } log.info("Configs import complete, starting copy of files and folders"); /* * ##################### Import real files and folders */ importFolders(f); log.info("File explorer item import complete, clearing temp files"); FileHelper.removeRec(f); }
From source file:com.dearho.cs.subscriber.action.register.SubscriberRegisterTwoAction.java
public String mobileUpload() { if (upload == null) { result = new JSONObject().element("result", "").element("state", 500) .element("message", "?!").toString(); return SUCCESS; }/*from w ww. j a v a2 s. c o m*/ if (getSession().getAttribute(Constants.SESSION_SUBSCRIBER) == null) { result = new JSONObject().element("result", "").element("state", 500) .element("message", "?!").toString(); return SUCCESS; } try { String imageName = ImageHelper.uploadPic(upload, uploadFileName, uploadContentType, maxUploadSize, uploadPath); result = new JSONObject().element("result", uploadPath + File.pathSeparatorChar + imageName) .element("state", 200).element("message", "?").toString(); } catch (Exception e) { logger.error(e); result = new JSONObject().element("result", "").element("state", 500) .element("message", "!").toString(); return ERROR; } return SUCCESS; }
From source file:hudson.Functions.java
public static boolean isWindows() { return File.pathSeparatorChar == ';'; }
From source file:net.sourceforge.vulcan.maven.MavenBuildTool.java
static String getEndorsedClassPath(String javaHome, String mavenHome) throws IOException { final StringBuffer buf = new StringBuffer(); buf.append(new File(javaHome, MAVEN1_ENDORSED_DIR).getCanonicalPath()); buf.append(File.pathSeparatorChar); buf.append(new File(mavenHome, MAVEN1_ENDORSED_DIR).getCanonicalPath()); if (new File(OSX_ENDORSED_DIR).isDirectory()) { buf.append(File.pathSeparatorChar); buf.append(OSX_ENDORSED_DIR);/*from w w w . j a va 2 s . c o m*/ } return buf.toString(); }
From source file:com.dal.unity.Config.java
private String readClasspath(String classpathFile) { StringBuilder result = new StringBuilder(128); try (InputStream is = Config.class.getClassLoader().getResourceAsStream(classpathFile); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr);) { String line;/* w w w . java2s . c o m*/ while (null != (line = br.readLine())) { if (result.length() > 0 && File.pathSeparatorChar != result.charAt(result.length() - 1)) { result.append(File.pathSeparatorChar); } result.append(line); } } catch (IOException x) { LOG.error("Failure attempting to read classpath file {}", classpathFile, x); } return result.toString(); }
From source file:org.broadinstitute.gatk.tools.CatVariantsIntegrationTest.java
@Test(dataProvider = "IndexDataProvider") public void testCatVariantsVCFIndexCreation(VCFIndexCreatorTest testSpec) throws IOException { String cmdLine = String.format( "java -cp \"%s\" %s -R %s -V %s -V %s --variant_index_type %s --variant_index_parameter %s -out %s", StringUtils.join(RuntimeUtils.getAbsoluteClassPaths(), File.pathSeparatorChar), CatVariants.class.getCanonicalName(), BaseTest.b37KGReference, CatVariantsVcf1, CatVariantsVcf2, testSpec.type, testSpec.parameter, BaseTest.createTempFile("CatVariantsVCFIndexCreationTest", ".vcf")); ProcessController pc = ProcessController.getThreadLocal(); ProcessSettings ps = new ProcessSettings(Utils.escapeExpressions(cmdLine)); pc.execAndCheck(ps);/*w w w . j a va 2s . c o m*/ }