List of usage examples for java.util EnumSet of
@SafeVarargs public static <E extends Enum<E>> EnumSet<E> of(E first, E... rest)
From source file:ch.cyberduck.core.s3.S3MultipartCopyFeatureTest.java
@Test public void testCopy() throws Exception { final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials( System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret"))); final S3Session session = new S3Session(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final byte[] content = new RandomStringGenerator.Builder().build().generate(1000).getBytes(); final TransferStatus status = new TransferStatus().length(content.length); status.setChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), status)); final OutputStream out = new S3WriteFeature(session).write(test, status, new DisabledConnectionCallback()); assertNotNull(out);//w ww . j a v a 2s. c o m new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out); out.close(); test.attributes().setSize(content.length); final Path copy = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final S3MultipartCopyFeature feature = new S3MultipartCopyFeature(session, new S3AccessControlListFeature(session)); feature.copy(test, copy, status, new DisabledConnectionCallback()); assertTrue(new S3FindFeature(session).find(test)); assertEquals(content.length, new S3AttributesFinderFeature(session).find(test).getSize()); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); assertTrue(new S3FindFeature(session).find(copy)); assertEquals(content.length, new S3AttributesFinderFeature(session).find(copy).getSize()); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(copy), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:net.rgielen.actionframeworks.springmvc.ApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.register(ApplicationConfig.class); servletContext.addListener(new ContextLoaderListener(context)); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter);/*from w w w .j ava 2s . c o m*/ characterEncoding.addMappingForUrlPatterns(dispatcherTypes, false, "/*"); ServletRegistration.Dynamic registration = servletContext.addServlet("dispatcher", new DispatcherServlet(context)); registration.setLoadOnStartup(1); registration.addMapping("/"); }
From source file:musite.prediction.feature.disorder.DisorderTest.java
public void extractDisorder() throws IOException { // String xml = "testData/musite-test.xml"; String xml = "H:\\Phosphorylation Study\\Soybean\\combined\\site-report.with.disorder.xml"; ProteinsXMLReader reader = DisorderUtil.getDisorderXMLReader(); Proteins proteins = MusiteIOUtil.read(reader, xml); List<Double> list = new ArrayList<Double>(); PTM ptm = PTM.PHOSPHORYLATION;//from w w w. j a v a 2 s . com Set<AminoAcid> aas = EnumSet.of(AminoAcid.SERINE, AminoAcid.THREONINE); // Set<AminoAcid> aas = EnumSet.of(AminoAcid.TYROSINE); Iterator<Protein> it = proteins.proteinIterator(); while (it.hasNext()) { Protein protein = it.next(); List<Double> dis = DisorderUtil.extractDisorder(protein, ptm, aas); if (dis != null) list.addAll(dis); } System.out.println(list.toString()); }
From source file:com.github.fge.jsonschema.core.keyword.syntax.checkers.helpers.DependenciesSyntaxChecker.java
/** * Protected constructor// w w w . j a v a 2s. c o m * * @param depTypes valid types for one dependency value */ protected DependenciesSyntaxChecker(final NodeType... depTypes) { super("dependencies", NodeType.OBJECT); dependencyTypes = EnumSet.of(NodeType.OBJECT, depTypes); }
From source file:com.github.sshw.config.RootApplicationConfig.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(RootApplicationContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext)); dispatcher.setLoadOnStartup(1);/*from w w w. ja v a 2 s . co m*/ dispatcher.setAsyncSupported(true); dispatcher.addMapping("/"); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter); characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy()); security.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); servletContext.addListener(new ContextLoaderListener(rootContext)); }
From source file:ch.cyberduck.core.shared.DefaultFindFeatureTest.java
@Test public void testFind() throws Exception { final B2Session session = new B2Session(new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(), new Credentials(System.getProperties().getProperty("b2.user"), System.getProperties().getProperty("b2.key")))); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path file = new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new B2TouchFeature(session).touch(file, new TransferStatus()); // Find without version id set in attributes new DefaultFindFeature(session).find(file); new B2DeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close();/* w w w .j av a2 s . c o m*/ }
From source file:ch.cyberduck.core.shared.DefaultHomeFinderService.java
@Override public Path find(final Path root, final String path) { if (path.startsWith(String.valueOf(Path.DELIMITER))) { // Mount absolute path final String normalized = this.normalize(path, true); return new Path(normalized, normalized.equals(String.valueOf(Path.DELIMITER)) ? EnumSet.of(Path.Type.volume, Path.Type.directory) : EnumSet.of(Path.Type.directory)); } else {/*from ww w. j ava2 s . co m*/ if (path.startsWith(Path.HOME)) { // Relative path to the home directory return new Path(root, this.normalize(StringUtils.removeStart(StringUtils.removeStart(path, Path.HOME), String.valueOf(Path.DELIMITER)), false), EnumSet.of(Path.Type.directory)); } else { // Relative path return new Path(root, this.normalize(path, false), EnumSet.of(Path.Type.directory)); } } }
From source file:ch.cyberduck.core.s3.S3AccessControlListFeatureTest.java
@Test public void testReadContainer() throws Exception { final S3Session session = new S3Session(new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")))); session.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path container = new Path("test-acl-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Acl acl = new S3AccessControlListFeature(session).getPermission(container); assertTrue(acl.containsKey(new Acl.GroupUser("http://acs.amazonaws.com/groups/s3/LogDelivery"))); assertTrue(acl.get(new Acl.GroupUser("http://acs.amazonaws.com/groups/s3/LogDelivery")) .contains(new Acl.Role(Acl.Role.WRITE))); assertTrue(acl.get(new Acl.GroupUser("http://acs.amazonaws.com/groups/s3/LogDelivery")) .contains(new Acl.Role("READ_ACP"))); assertTrue(acl.containsKey(//www . jav a2s. c o m new Acl.CanonicalUser("80b9982b7b08045ee86680cc47f43c84bf439494a89ece22b5330f8a49477cf6"))); assertTrue( acl.get(new Acl.CanonicalUser("80b9982b7b08045ee86680cc47f43c84bf439494a89ece22b5330f8a49477cf6")) .contains(new Acl.Role(Acl.Role.FULL))); session.close(); }
From source file:com.rakesh.rp3599.config.WebAppInitializer.java
public void onStartup(ServletContext container) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(AppContext.class); /** Dispatcher Servlet **/ ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(rootContext)); dispatcher.setLoadOnStartup(1);/*w ww. j av a 2 s. c om*/ dispatcher.setAsyncSupported(true); dispatcher.addMapping("/"); /** Dispatcher Types Enum **/ EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); /** UTF-8 Filter **/ FilterRegistration.Dynamic characterEncoding = container.addFilter("characterEncoding", characterEncodingFilter); characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); /** Context Listener **/ container.addListener(new ContextLoaderListener(rootContext)); }
From source file:ch.cyberduck.core.sds.SDSDirectoryFeature.java
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try {// w ww . ja v a 2 s . c om if (containerService.isContainer(folder)) { final CreateRoomRequest roomRequest = new CreateRoomRequest(); final UserAccountWrapper user = session.userAccount(); roomRequest.addAdminIdsItem(user.getId()); roomRequest.setAdminGroupIds(null); roomRequest.setName(folder.getName()); final Node r = new NodesApi(session.getClient()).createRoom(StringUtils.EMPTY, null, roomRequest); return new Path(folder.getParent(), folder.getName(), EnumSet.of(Path.Type.directory, Path.Type.volume), new PathAttributes(folder.attributes())); } else { final CreateFolderRequest folderRequest = new CreateFolderRequest(); folderRequest.setParentId(Long.parseLong(new SDSNodeIdProvider(session) .getFileid(folder.getParent(), new DisabledListProgressListener()))); folderRequest.setName(folder.getName()); final Node f = new NodesApi(session.getClient()).createFolder(StringUtils.EMPTY, folderRequest, null); return new Path(folder.getParent(), folder.getName(), folder.getType(), new PathAttributes(folder.attributes())); } } catch (ApiException e) { throw new SDSExceptionMappingService().map("Cannot create folder {0}", e, folder); } }