Package org.jbpm.designer.repository.impl

Examples of org.jbpm.designer.repository.impl.AssetBuilder


            return getAssetBuilder(Asset.AssetType.Text).type(extension).name(nameOnly);
        }
    }

    public static AssetBuilder getAssetBuilder(Asset asset) {
        AssetBuilder builder = null;
        if(binaryFormats.contains(asset.getAssetType())) {
            builder = getAssetBuilder(Asset.AssetType.Byte);


        } else {
            builder = getAssetBuilder(Asset.AssetType.Text);
        }
        builder.type(asset.getAssetType())
                .name(asset.getName())
                .version(asset.getVersion())
                .location(asset.getAssetLocation())
                .uniqueId(asset.getUniqueId())
                .creationDate(asset.getCreationDate())
View Full Code Here


    protected Asset buildAsset(Path file, boolean loadContent) {
        String name = file.getFileName().toString();
        String location = trimLocation(file);

        AssetBuilder assetBuilder = AssetBuilderFactory.getAssetBuilder(name);
        BasicFileAttributes attrs = getFileSystem(file.toUri().toString()).provider().readAttributes(file, BasicFileAttributes.class);
        assetBuilder.uniqueId(encodeUniqueId(file.toUri().toString()))
                    .location(location)
                    .creationDate(attrs.creationTime() == null ? "" : new Date(attrs.creationTime().toMillis()).toString())
                    .lastModificationDate(attrs.lastModifiedTime() == null ? "" : new Date(attrs.lastModifiedTime().toMillis()).toString())
                    // TODO some provider specific details
                    .description("")
                    .owner("");

        if (loadContent) {
            if (((AbstractAsset)assetBuilder.getAsset()).acceptBytes()) {
                assetBuilder.content(ioService.readAllBytes(file));
            } else {
                assetBuilder.content(ioService.readAllString(file, Charset.forName("UTF-8")));
            }
        }

        return assetBuilder.getAsset();
    }
View Full Code Here

                profile = _profileService.findProfile(req, profileName);
            }
            Repository repository = profile.getRepository();
            if(action != null && action.equals(ACTION_CREATE_ASSET)) {
                try {
                    AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text);
                    builder.content("")
                            .type(assetType)
                            .name(assetName)
                            .location(assetLocation);

                    String id = repository.createAsset(builder.getAsset());
                    if(id == null) {
                        _logger.error("Unable to create asset: " + assetLocation);
                        addError(errorsArray, "Unable to create asset: " + assetLocation);
                    }
                    returnObj.put("assetId", id);
                } catch (Exception e) {
                    _logger.error("Error creating asset: " + e.getMessage());
                    addError(errorsArray, "Error creating asset: " + e.getMessage());
                }
                jsonResponse(returnObj, errorsArray, resp);
            } else if(action != null && action.equals(ACTION_UPDATE_ASSET)) {
                try {
                    if(assetContentTransform != null && assetContentTransform.equals(TRANSFORMATION_JSON_TO_BPMN2)) {
                            assetContent = profile.createMarshaller().parseModel(assetContent, preprocessingData);
                    }

                    Asset<String> currentAsset = repository.loadAsset(assetId);
                    AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(currentAsset);
                    builder.content(assetContent);
                    String id = repository.updateAsset(builder.getAsset(), commitMessage);

                    if(id == null) {
                        _logger.error("Unable to store asset: " + assetLocation);
                        addError(errorsArray, "Unable to store asset: " + assetLocation);
                    }
View Full Code Here

TOP

Related Classes of org.jbpm.designer.repository.impl.AssetBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.