当前位置: 首页>>代码示例>>Java>>正文


Java MultipartForm类代码示例

本文整理汇总了Java中org.jboss.resteasy.annotations.providers.multipart.MultipartForm的典型用法代码示例。如果您正苦于以下问题:Java MultipartForm类的具体用法?Java MultipartForm怎么用?Java MultipartForm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MultipartForm类属于org.jboss.resteasy.annotations.providers.multipart包,在下文中一共展示了MultipartForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: info

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@POST
@Path("/info")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@ApiOperation("Provides a summary of the connector as it would be built using a ConnectorTemplate identified by the provided `connector-template-id` and the data given in `connectorSettings`")
public ConnectorSummary info(@MultipartForm final CustomConnectorFormData connectorFormData) {
    try {
        final String specification;
        try (BufferedSource source = Okio.buffer(Okio.source(connectorFormData.getSpecification()))) {
            specification = source.readUtf8();
        }

        final ConnectorSettings connectorSettings = new ConnectorSettings.Builder()
            .createFrom(connectorFormData.getConnectorSettings())
            .putConfiguredProperty("specification", specification)
            .build();

        return withGeneratorAndTemplate(connectorSettings.getConnectorTemplateId(),
            (generator, template) -> generator.info(template, connectorSettings));
    } catch (IOException e) {
        throw SyndesisServerException.launderThrowable("Failed to read specification", e);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:24,代码来源:CustomConnectorHandler.java

示例2: uploadComponent

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@ApiOperation(value = "Upload a single component",
    //TODO: NEXUS-15443 remove this parameter when ready to ship with ui upload enabled
    hidden = true,
    notes = "This API takes a multi-part form whose schema varies by repository type, therefore it's virtually " +
        "impossible to be described by the generated documentation. Instead, here's a couple of examples using curl.\n\n" +
        "curl -X POST http://nexus.local/service/rest/beta/components?repository=raw -F directory=example -F [email protected] -F asset.filename=readme.md\n\n" +
        "curl -X POST http://nexus.local/service/rest/beta/components?repository=nuget -F [email protected]\n\n" +
        "curl -X POST http://nexus.local/service/rest/beta/components?repository=maven -F [email protected] -F file.extension=jar -F groupId=aopalliance -F artifactId=aopalliance -F version=1.0\n\n" +
        "curl -X POST http://nexus.local/service/rest/beta/components?repository=maven -F [email protected] -F pom.extension=pom -F [email protected] -F sources.classifier=sources -F sources.extension=jar -F asset=aopalliance-1.0.jar -F asset.extension=jar\n\n"
)
@ApiResponses(value = {
    @ApiResponse(code = 403, message = "Insufficient permissions to upload a component"),
    @ApiResponse(code = 422, message = "Parameter 'repository' is required")
})
void uploadComponent(
    @ApiParam(value = "Name of the repository to which you would like to upload the component", required = true)
    final String repository,
    @ApiParam(value = "Form containing the component") @MultipartForm MultipartInput multipartInput)
    throws IOException;
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:ComponentsResourceDoc.java

示例3: loginOrRenewSession

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
@PUT
@Path("session")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces("application/json")
public String loginOrRenewSession(@HeaderParam("sessionid") String sessionId, @MultipartForm LoginForm multipart)
        throws KeyException, SchedulerRestException, LoginException, NotConnectedRestException {
    if (sessionId == null || !sessionStore.exists(sessionId)) {
        return loginWithCredential(multipart);
    }

    try {
        sessionStore.renewSession(sessionId);
        return sessionId;
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:22,代码来源:SchedulerStateRest.java

示例4: loginWithCredential

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@Override
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("login")
@Produces("application/json")
public String loginWithCredential(@MultipartForm LoginForm multipart) throws ActiveObjectCreationException,
        NodeException, KeyException, IOException, LoginException, RMException {

    Session session;
    if (multipart.getCredential() != null) {
        session = sessionStore.createUnnamedSession();
        Credentials credentials = Credentials.getCredentials(multipart.getCredential());
        session.connectToRM(credentials);
    } else {
        session = sessionStore.create(multipart.getUsername());
        CredData credData = new CredData(CredData.parseLogin(multipart.getUsername()),
                                         CredData.parseDomain(multipart.getUsername()),
                                         multipart.getPassword(),
                                         multipart.getSshKey());
        session.connectToRM(credData);

    }

    return session.getSessionId();
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:26,代码来源:RMRest.java

示例5: deployAgent

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@POST
@Consumes("multipart/form-data")
@Path("/deployagent")
public Response deployAgent(@MultipartForm MyMultipartForm form) {
	String output;
	try {
		URL location = DeploymentWS.class.getProtectionDomain().getCodeSource().getLocation();
		System.out.println(location.getFile());
		String folderurl = location.toString().substring(5) + "/tmp/";
		String fileName = folderurl + form.getMasterNodeAddress() + "_" + form.getApplicationName() + ".jar";
		saveFile(form.getFileInput(), folderurl, fileName);
		output = "File saved to server location : " + fileName;
		// File file = new File(fileName);
		// InetAddress addr = InetAddress.getByName(form.getMasterNodeAddress());
		// Deployment.deploy(addr, file, form.getApplicationName());
		return Response.status(200).entity(output).build();
	} catch (Exception e) {
		output = "Error";
		logger.log(Level.INFO, "Error while deploying agent.", e);
		return Response.status(400).entity(output).build();
	}

}
 
开发者ID:gcvt,项目名称:siebog,代码行数:24,代码来源:DeploymentWS.java

示例6: update

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@PUT
@Path(value = "/{id}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void update(@NotNull @PathParam("id") @ApiParam(required = true) String id, @MultipartForm ConnectorFormData connectorFormData) {
    if (connectorFormData.getConnector() == null) {
        throw new IllegalArgumentException("Missing connector parameter");
    }

    Connector connectorToUpdate = connectorFormData.getConnector();

    if (connectorFormData.getIconInputStream() != null) {
        try(BufferedInputStream iconStream = new BufferedInputStream(connectorFormData.getIconInputStream())) {
            // URLConnection.guessContentTypeFromStream resets the stream after inspecting the media type so
            // can continue to be used, rather than being consumed.
            String guessedMediaType = URLConnection.guessContentTypeFromStream(iconStream);
            if (!guessedMediaType.startsWith("image/")) {
                throw new IllegalArgumentException("Invalid file contents for an image");
            }
            MediaType mediaType = MediaType.valueOf(guessedMediaType);
            Icon.Builder iconBuilder = new Icon.Builder().mediaType(mediaType.toString());

            Icon icon = getDataManager().create(iconBuilder.build());
            iconDao.write(icon.getId().get(), iconStream);
            connectorToUpdate = connectorToUpdate.builder().icon("db:" + icon.getId().get()).build();
        } catch (IOException e) {
            throw new IllegalArgumentException("Error while reading multipart request", e);
        }
    }

    getDataManager().update(connectorToUpdate);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:32,代码来源:ConnectorHandler.java

示例7: post

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@POST
@Secured
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public String post(@MultipartForm FileUploaderPOJO form) throws IOException {
	return new br.org.otus.rest.Response().buildSuccess(facade.upload(form)).toJson();
}
 
开发者ID:ccem-dev,项目名称:otus-api,代码行数:8,代码来源:FileUploaderResource.java

示例8: post

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@POST
@Secured
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String post(@MultipartForm DataSourceFormPOJO form){
	DataSource dataSource = new DataSource(form.getId(), form.getName(), new CsvToJson(form.getDelimiter(), form.getFile()).execute());
	dataSourceFacade.create(dataSource);
	return new Response().buildSuccess().toJson();
}
 
开发者ID:ccem-dev,项目名称:otus-api,代码行数:9,代码来源:DataSourceResource.java

示例9: uploadFile

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@POST
@Path("/upload")
@Consumes("multipart/form-data")
@Produces(MediaType.APPLICATION_JSON)
public Response uploadFile(@MultipartForm AplicacionFile form) throws BusinessException {
    LOGGER.info("Recibido: " + form);
    Aplicacion a = appBussines.newAplicacionFileUpload(form, null);
    return Response.ok(a).build();
}
 
开发者ID:jokoframework,项目名称:notification-server,代码行数:10,代码来源:AplicacionService.java

示例10: uploadFileUpdate

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@PUT
@Path("/upload/{id}")
@Consumes("multipart/form-data")
@Produces(MediaType.APPLICATION_JSON)
public Response uploadFileUpdate(@MultipartForm AplicacionFile form, @PathParam(value = "id") String id)
        throws BusinessException {
    Aplicacion a = appBussines.newAplicacionFileUpload(form, Long.valueOf(id));
    return Response.ok(a).build();
}
 
开发者ID:jokoframework,项目名称:notification-server,代码行数:10,代码来源:AplicacionService.java

示例11: getCreateCredential

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
/**
 * generates a credential file from user provided credentials
 *
 * @return the credential file generated by the scheduler
 * @throws LoginException
 * @throws SchedulerRestException
 */
@Override
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("createcredential")
@Produces("*/*")
public byte[] getCreateCredential(@MultipartForm LoginForm multipart)
        throws LoginException, SchedulerRestException {

    String username = multipart.getUsername();
    String password = multipart.getPassword();
    byte[] privKey = multipart.getSshKey();

    try {
        String url = PortalConfiguration.SCHEDULER_URL.getValueAsString();
        SchedulerAuthenticationInterface auth = SchedulerConnection.join(url);
        PublicKey pubKey = auth.getPublicKey();
        sessionStore.create(username);
        Credentials cred = Credentials.createCredentials(new CredData(CredData.parseLogin(username),
                                                                      CredData.parseDomain(username),
                                                                      password,
                                                                      privKey),
                                                         pubKey);
        return cred.getBase64();
    } catch (ConnectionException | KeyException e) {
        throw new SchedulerRestException(e);
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:35,代码来源:SchedulerStateRest.java

示例12: send

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@POST
@Path("send")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response send(@MultipartForm FormFileUpload fileUpload) {
	try {
		FileReader fileReader = new FileReader(fileUpload.getFile());
		Email email = new Email(fileUpload.getSubject(),
				fileUpload.getText(), "[email protected]");
		event.fire(email);
		return null;
	} catch (FileNotFoundException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:danielsoro,项目名称:send-mail-server,代码行数:15,代码来源:MailMB.java

示例13: upload

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@POST
@Path(PATH_UPLOAD)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject upload(
        @HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization,
        @MultipartForm UploadForm form) {

    Identity githubIdentity = identities.getGitHubIdentity(authorization);
    Identity openShiftIdentity = identities.getOpenShiftIdentity(authorization, form.getOpenShiftCluster());
    try {
        final java.nio.file.Path tempDir = Files.createTempDirectory("tmpUpload");
        try (InputStream inputStream = form.getFile()) {
            FileUploadHelper.unzip(inputStream, tempDir);
            try (DirectoryStream<java.nio.file.Path> projects = Files.newDirectoryStream(tempDir)) {
                java.nio.file.Path project = projects.iterator().next();
                CreateProjectile projectile = ProjectileBuilder.newInstance()
                        .gitHubIdentity(githubIdentity)
                        .openShiftIdentity(openShiftIdentity)
                        .openShiftProjectName(form.getOpenShiftProjectName())
                        .openShiftClusterName(form.getOpenShiftCluster())
                        .startOfStep(form.getStartOfStep())
                        .createType()
                        .mission(form.getMission())
                        .runtime(form.getRuntime())
                        .gitHubRepositoryName(form.getGitHubRepositoryName())
                        .gitHubRepositoryDescription(form.getGitHubRepositoryDescription())
                        .projectLocation(project)
                        .build();
                // Fling it
                CompletableFuture.supplyAsync(() -> missionControl.launch(projectile), executorService)
                        .whenComplete((boom, ex) -> {
                            if (ex != null) {
                                event.fire(new StatusMessageEvent(projectile.getId(), ex));
                                log.log(Level.SEVERE, "Error while launching project", ex);
                            }

                            FileUploadHelper.deleteDirectory(tempDir);
                        });
                return Json.createObjectBuilder()
                        .add("uuid", projectile.getId().toString())
                        .add("uuid_link", PATH_STATUS + "/" + projectile.getId().toString())
                        .build();
            }
        }
    } catch (final IOException e) {
        throw new WebApplicationException("could not unpack zip file into temp folder", e);
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:50,代码来源:MissionControlResource.java

示例14: create

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@POST
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@ApiOperation("Creates a new Connector based on the ConnectorTemplate identified by the provided `id` and the data given in `connectorSettings` multipart part, plus optional `icon` file")
@ApiResponses(@ApiResponse(code = 200, response = Connector.class, message = "Newly created Connector"))
public Connector create(@MultipartForm CustomConnectorFormData customConnectorFormData) throws IOException {
    final ConnectorSettings connectorSettings = customConnectorFormData.getConnectorSettings();
    if (connectorSettings == null) {
        throw new IllegalArgumentException("Missing connectorSettings parameter");
    }

    final ConnectorSettings connectorSettingsToUse;
    if (connectorSettings.getConfiguredProperties().containsKey("specification")) {
        connectorSettingsToUse = connectorSettings;
    } else {
        final String specification;
        try (BufferedSource source = Okio.buffer(Okio.source(customConnectorFormData.getSpecification()))) {
            specification = source.readUtf8();
        }

        connectorSettingsToUse = new ConnectorSettings.Builder().createFrom(connectorSettings).putConfiguredProperty("specification", specification).build();
    }

    Connector generatedConnector = withGeneratorAndTemplate(connectorSettingsToUse.getConnectorTemplateId(),
        (generator, template) -> generator.generate(template, connectorSettingsToUse));

    if (customConnectorFormData.getIconInputStream() != null) {
        // URLConnection.guessContentTypeFromStream resets the stream after inspecting the media type so
        // can continue to be used, rather than being consumed.
        try(BufferedInputStream iconStream = new BufferedInputStream(customConnectorFormData.getIconInputStream())) {
            String guessedMediaType = URLConnection.guessContentTypeFromStream(iconStream);
            if (!guessedMediaType.startsWith("image/")) {
                throw new IllegalArgumentException("Invalid file contents for an image");
            }
            MediaType mediaType = MediaType.valueOf(guessedMediaType);
            Icon.Builder iconBuilder = new Icon.Builder()
                .mediaType(mediaType.toString());

            Icon icon = getDataManager().create(iconBuilder.build());
            iconDao.write(icon.getId().get(), iconStream);

            generatedConnector = new Connector.Builder().createFrom(generatedConnector).icon("db:" + icon.getId().get()).build();
        } catch (IOException e) {
            throw new IllegalArgumentException("Error while reading multipart request", e);
        }
    }

    return getDataManager().create(generatedConnector);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:51,代码来源:CustomConnectorHandler.java

示例15: upload

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; //导入依赖的package包/类
@POST
@Path(PATH_UPLOAD)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject upload(
        @HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization,
        @MultipartForm UploadForm form) {

    Identity githubIdentity = getGitHubIdentity(authorization);
    Identity openShiftIdentity = getOpenShiftIdentity(authorization, form.getOpenShiftCluster());
    try {
        final java.nio.file.Path tempDir = Files.createTempDirectory("tmpUpload");
        try (InputStream inputStream = form.getFile()) {
            FileUploadHelper.unzip(inputStream, tempDir);
            try (DirectoryStream<java.nio.file.Path> projects = Files.newDirectoryStream(tempDir)) {
                java.nio.file.Path project = projects.iterator().next();
                CreateProjectile projectile = ProjectileBuilder.newInstance()
                        .gitHubIdentity(githubIdentity)
                        .openShiftIdentity(openShiftIdentity)
                        .openShiftProjectName(form.getOpenShiftProjectName())
                        .openShiftClusterName(form.getOpenShiftCluster())
                        .createType()
                        .mission(form.getMission())
                        .runtime(form.getRuntime())
                        .gitHubRepositoryName(form.getGitHubRepositoryName())
                        .gitHubRepositoryDescription(form.getGitHubRepositoryDescription())
                        .projectLocation(project)
                        .build();
                // Fling it
                CompletableFuture.supplyAsync(() -> missionControl.launch(projectile), executorService)
                        .whenComplete((boom, ex) -> {
                            if (ex != null) {
                                event.fire(new StatusMessageEvent(projectile.getId(), ex));
                                log.log(Level.SEVERE, "Error while launching project", ex);
                            }

                            FileUploadHelper.deleteDirectory(tempDir);
                        });
                return Json.createObjectBuilder()
                        .add("uuid", projectile.getId().toString())
                        .add("uuid_link", PATH_STATUS + "/" + projectile.getId().toString())
                        .build();
            }
        }
    } catch (final IOException e) {
        throw new WebApplicationException("could not unpack zip file into temp folder", e);
    }
}
 
开发者ID:fabric8-launcher,项目名称:launchpad-missioncontrol,代码行数:49,代码来源:MissionControlResource.java


注:本文中的org.jboss.resteasy.annotations.providers.multipart.MultipartForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。