Search in sources :

Example 1 with Action

use of com.google.privacy.dlp.v2.Action in project atlasmap by atlasmap.

the class DefaultAtlasFieldActionService method internalProcessActions.

protected Field internalProcessActions(Actions actions, Object sourceObject, FieldType targetType) throws AtlasException {
    Field processedField = new SimpleField();
    processedField.setValue(sourceObject);
    processedField.setFieldType(targetType);
    if (FieldType.COMPLEX.equals(targetType)) {
        return processedField;
    }
    Object tmpSourceObject = sourceObject;
    FieldType sourceType = (sourceObject != null ? getConversionService().fieldTypeFromClass(sourceObject.getClass()) : FieldType.NONE);
    if (actions == null || actions.getActions() == null || actions.getActions().isEmpty()) {
        if (sourceObject == null) {
            return processedField;
        }
        processedField.setValue(getConversionService().convertType(sourceObject, sourceType, targetType));
        processedField.setFieldType(targetType);
        return processedField;
    }
    FieldType currentType = sourceType;
    for (Action action : actions.getActions()) {
        ActionDetail detail = findActionDetail(action.getDisplayName(), currentType);
        if (!detail.getSourceType().equals(currentType) && !FieldType.ANY.equals(detail.getSourceType())) {
            tmpSourceObject = getConversionService().convertType(sourceObject, currentType, detail.getSourceType());
        }
        processedField.setValue(processAction(action, detail, tmpSourceObject));
        processedField.setFieldType(detail.getTargetType());
        currentType = detail.getTargetType();
    }
    return processedField;
}
Also used : Field(io.atlasmap.v2.Field) SimpleField(io.atlasmap.v2.SimpleField) AtlasFieldAction(io.atlasmap.api.AtlasFieldAction) Action(io.atlasmap.v2.Action) ActionDetail(io.atlasmap.v2.ActionDetail) SimpleField(io.atlasmap.v2.SimpleField) FieldType(io.atlasmap.v2.FieldType)

Example 2 with Action

use of com.google.privacy.dlp.v2.Action in project atlasmap by atlasmap.

the class DefaultAtlasFieldActionsServiceTest method testProcessActionWithActionActionDetailObject.

@Test
public void testProcessActionWithActionActionDetailObject() throws AtlasException {
    ActionDetail actionDetail = null;
    Object sourceObject = "String";
    Action action = new Trim();
    assertEquals(sourceObject, fieldActionsService.processAction(action, actionDetail, sourceObject));
    action = new GenerateUUID();
    actionDetail = new ActionDetail();
    actionDetail.setClassName("io.atlasmap.actions.StringComplexFieldActions");
    actionDetail.setSourceType(FieldType.ANY);
    actionDetail.setMethod("genareteUUID");
    assertNotNull(fieldActionsService.processAction(action, actionDetail, sourceObject));
}
Also used : Action(io.atlasmap.v2.Action) ActionDetail(io.atlasmap.v2.ActionDetail) Trim(io.atlasmap.v2.Trim) GenerateUUID(io.atlasmap.v2.GenerateUUID) Test(org.junit.Test)

Example 3 with Action

use of com.google.privacy.dlp.v2.Action in project weicoder by wdcode.

the class StrutsAction method getAction.

/**
 * 获得当前Action
 * @param <E> 泛型
 * @return Action
 */
@SuppressWarnings("unchecked")
public <E extends Action> E getAction() {
    // 获得值栈里的对象
    Object action = ActionContext.getContext().getValueStack().peek();
    // 判断对象是Action类型的
    if (action instanceof Action) {
        // 返回Action
        return (E) action;
    }
    // 获得Action拦截器
    ActionInvocation ai = ActionContext.getContext().getActionInvocation();
    // 如果拦截器不为空
    if (ai != null) {
        return (E) ai.getAction();
    }
    // 如果都不符合返回null
    return null;
}
Also used : Action(com.opensymphony.xwork2.Action) ActionInvocation(com.opensymphony.xwork2.ActionInvocation)

Example 4 with Action

use of com.google.privacy.dlp.v2.Action in project powerbot by powerbot.

the class DrawAbilities method repaint.

@Override
public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    render.setFont(new Font("Arial", 0, 10));
    render.setColor(Color.green);
    for (final Action action : ctx.combatBar.actions()) {
        final Component c = action.component();
        final Point p = c.screenPoint();
        render.drawString(action.id() + " (" + action.bind() + ")", p.x, p.y);
    }
}
Also used : Action(org.powerbot.script.rt6.Action) Point(java.awt.Point) Component(org.powerbot.script.rt6.Component) Font(java.awt.Font)

Example 5 with Action

use of com.google.privacy.dlp.v2.Action in project java-docs-samples by GoogleCloudPlatform.

the class Inspect method inspectDatastore.

// [END dlp_inspect_gcs]
// [START dlp_inspect_datastore]
/**
 * Inspect a Datastore kind
 *
 * @param projectId The project ID containing the target Datastore
 * @param namespaceId The ID namespace of the Datastore document to inspect
 * @param kind The kind of the Datastore entity to inspect
 * @param minLikelihood The minimum likelihood required before returning a match
 * @param infoTypes The infoTypes of information to match
 * @param maxFindings max number of findings
 * @param topicId Google Cloud Pub/Sub topic to notify job status updates
 * @param subscriptionId Google Cloud Pub/Sub subscription to above topic to receive status
 *     updates
 */
private static void inspectDatastore(String projectId, String namespaceId, String kind, Likelihood minLikelihood, List<InfoType> infoTypes, int maxFindings, String topicId, String subscriptionId) {
    // Instantiates a client
    try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
        // Reference to the Datastore namespace
        PartitionId partitionId = PartitionId.newBuilder().setProjectId(projectId).setNamespaceId(namespaceId).build();
        // Reference to the Datastore kind
        KindExpression kindExpression = KindExpression.newBuilder().setName(kind).build();
        DatastoreOptions datastoreOptions = DatastoreOptions.newBuilder().setKind(kindExpression).setPartitionId(partitionId).build();
        // Construct Datastore configuration to be inspected
        StorageConfig storageConfig = StorageConfig.newBuilder().setDatastoreOptions(datastoreOptions).build();
        FindingLimits findingLimits = FindingLimits.newBuilder().setMaxFindingsPerRequest(maxFindings).build();
        InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).setMinLikelihood(minLikelihood).setLimits(findingLimits).build();
        String pubSubTopic = String.format("projects/%s/topics/%s", projectId, topicId);
        Action.PublishToPubSub publishToPubSub = Action.PublishToPubSub.newBuilder().setTopic(pubSubTopic).build();
        Action action = Action.newBuilder().setPubSub(publishToPubSub).build();
        InspectJobConfig inspectJobConfig = InspectJobConfig.newBuilder().setStorageConfig(storageConfig).setInspectConfig(inspectConfig).addActions(action).build();
        // Asynchronously submit an inspect job, and wait on results
        CreateDlpJobRequest createDlpJobRequest = CreateDlpJobRequest.newBuilder().setParent(ProjectName.of(projectId).toString()).setInspectJob(inspectJobConfig).build();
        DlpJob dlpJob = dlpServiceClient.createDlpJob(createDlpJobRequest);
        System.out.println("Job created with ID:" + dlpJob.getName());
        final SettableApiFuture<Boolean> done = SettableApiFuture.create();
        // Set up a Pub/Sub subscriber to listen on the job completion status
        Subscriber subscriber = Subscriber.newBuilder(ProjectSubscriptionName.of(projectId, subscriptionId), (pubsubMessage, ackReplyConsumer) -> {
            if (pubsubMessage.getAttributesCount() > 0 && pubsubMessage.getAttributesMap().get("DlpJobName").equals(dlpJob.getName())) {
                // notify job completion
                done.set(true);
                ackReplyConsumer.ack();
            }
        }).build();
        subscriber.startAsync();
        // For long jobs, consider using a truly asynchronous execution model such as Cloud Functions
        try {
            done.get(1, TimeUnit.MINUTES);
            // Wait for the job to become available
            Thread.sleep(500);
        } catch (Exception e) {
            System.out.println("Unable to verify job completion.");
        }
        DlpJob completedJob = dlpServiceClient.getDlpJob(GetDlpJobRequest.newBuilder().setName(dlpJob.getName()).build());
        System.out.println("Job status: " + completedJob.getState());
        InspectDataSourceDetails inspectDataSourceDetails = completedJob.getInspectDetails();
        InspectDataSourceDetails.Result result = inspectDataSourceDetails.getResult();
        if (result.getInfoTypeStatsCount() > 0) {
            System.out.println("Findings: ");
            for (InfoTypeStats infoTypeStat : result.getInfoTypeStatsList()) {
                System.out.print("\tInfo type: " + infoTypeStat.getInfoType().getName());
                System.out.println("\tCount: " + infoTypeStat.getCount());
            }
        } else {
            System.out.println("No findings.");
        }
    } catch (Exception e) {
        System.out.println("inspectDatastore Problems: " + e.getMessage());
    }
}
Also used : ByteContentItem(com.google.privacy.dlp.v2.ByteContentItem) InspectResult(com.google.privacy.dlp.v2.InspectResult) KindExpression(com.google.privacy.dlp.v2.KindExpression) Options(org.apache.commons.cli.Options) Likelihood(com.google.privacy.dlp.v2.Likelihood) Subscriber(com.google.cloud.pubsub.v1.Subscriber) BigQueryOptions(com.google.privacy.dlp.v2.BigQueryOptions) HelpFormatter(org.apache.commons.cli.HelpFormatter) MimetypesFileTypeMap(javax.activation.MimetypesFileTypeMap) CloudStorageOptions(com.google.privacy.dlp.v2.CloudStorageOptions) ArrayList(java.util.ArrayList) DefaultParser(org.apache.commons.cli.DefaultParser) InspectDataSourceDetails(com.google.privacy.dlp.v2.InspectDataSourceDetails) FindingLimits(com.google.privacy.dlp.v2.InspectConfig.FindingLimits) InspectContentResponse(com.google.privacy.dlp.v2.InspectContentResponse) ServiceOptions(com.google.cloud.ServiceOptions) URLConnection(java.net.URLConnection) StorageConfig(com.google.privacy.dlp.v2.StorageConfig) CommandLine(org.apache.commons.cli.CommandLine) PartitionId(com.google.privacy.dlp.v2.PartitionId) Action(com.google.privacy.dlp.v2.Action) DatastoreOptions(com.google.privacy.dlp.v2.DatastoreOptions) ProjectTopicName(com.google.pubsub.v1.ProjectTopicName) Option(org.apache.commons.cli.Option) InspectJobConfig(com.google.privacy.dlp.v2.InspectJobConfig) DlpServiceClient(com.google.cloud.dlp.v2.DlpServiceClient) Finding(com.google.privacy.dlp.v2.Finding) CreateDlpJobRequest(com.google.privacy.dlp.v2.CreateDlpJobRequest) Files(java.nio.file.Files) CommandLineParser(org.apache.commons.cli.CommandLineParser) ContentItem(com.google.privacy.dlp.v2.ContentItem) InfoType(com.google.privacy.dlp.v2.InfoType) InfoTypeStats(com.google.privacy.dlp.v2.InfoTypeStats) SettableApiFuture(com.google.api.core.SettableApiFuture) ByteString(com.google.protobuf.ByteString) TimeUnit(java.util.concurrent.TimeUnit) InspectConfig(com.google.privacy.dlp.v2.InspectConfig) List(java.util.List) ProjectName(com.google.privacy.dlp.v2.ProjectName) GetDlpJobRequest(com.google.privacy.dlp.v2.GetDlpJobRequest) Paths(java.nio.file.Paths) ParseException(org.apache.commons.cli.ParseException) BigQueryTable(com.google.privacy.dlp.v2.BigQueryTable) ProjectSubscriptionName(com.google.pubsub.v1.ProjectSubscriptionName) OptionGroup(org.apache.commons.cli.OptionGroup) DlpJob(com.google.privacy.dlp.v2.DlpJob) InspectContentRequest(com.google.privacy.dlp.v2.InspectContentRequest) Collections(java.util.Collections) Action(com.google.privacy.dlp.v2.Action) FindingLimits(com.google.privacy.dlp.v2.InspectConfig.FindingLimits) StorageConfig(com.google.privacy.dlp.v2.StorageConfig) InspectDataSourceDetails(com.google.privacy.dlp.v2.InspectDataSourceDetails) ByteString(com.google.protobuf.ByteString) PartitionId(com.google.privacy.dlp.v2.PartitionId) InspectConfig(com.google.privacy.dlp.v2.InspectConfig) CreateDlpJobRequest(com.google.privacy.dlp.v2.CreateDlpJobRequest) ParseException(org.apache.commons.cli.ParseException) InfoTypeStats(com.google.privacy.dlp.v2.InfoTypeStats) Subscriber(com.google.cloud.pubsub.v1.Subscriber) DlpServiceClient(com.google.cloud.dlp.v2.DlpServiceClient) DlpJob(com.google.privacy.dlp.v2.DlpJob) DatastoreOptions(com.google.privacy.dlp.v2.DatastoreOptions) KindExpression(com.google.privacy.dlp.v2.KindExpression) InspectJobConfig(com.google.privacy.dlp.v2.InspectJobConfig)

Aggregations

ArrayList (java.util.ArrayList)9 Collections (java.util.Collections)9 List (java.util.List)9 SettableApiFuture (com.google.api.core.SettableApiFuture)8 ServiceOptions (com.google.cloud.ServiceOptions)8 DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)8 Subscriber (com.google.cloud.pubsub.v1.Subscriber)8 Action (com.google.privacy.dlp.v2.Action)8 BigQueryTable (com.google.privacy.dlp.v2.BigQueryTable)8 CreateDlpJobRequest (com.google.privacy.dlp.v2.CreateDlpJobRequest)8 DlpJob (com.google.privacy.dlp.v2.DlpJob)8 GetDlpJobRequest (com.google.privacy.dlp.v2.GetDlpJobRequest)8 InfoType (com.google.privacy.dlp.v2.InfoType)8 ProjectName (com.google.privacy.dlp.v2.ProjectName)8 ProjectSubscriptionName (com.google.pubsub.v1.ProjectSubscriptionName)8 ProjectTopicName (com.google.pubsub.v1.ProjectTopicName)8 TimeUnit (java.util.concurrent.TimeUnit)8 CommandLine (org.apache.commons.cli.CommandLine)8 CommandLineParser (org.apache.commons.cli.CommandLineParser)8 DefaultParser (org.apache.commons.cli.DefaultParser)8