|
@@ -128,6 +128,34 @@ public class GTMService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public GTMContainerDTO getContainer(String containerResourceName) throws DataException {
|
|
|
+ try {
|
|
|
+ Container container =
|
|
|
+ tagManager.accounts().containers().get(containerResourceName).execute();
|
|
|
+
|
|
|
+ // Converts and returns.
|
|
|
+ GTMContainerDTO gtmContainer =
|
|
|
+ GTMContainerDTO.builder()
|
|
|
+ .id(container.getContainerId())
|
|
|
+ .resourceName(container.getPath())
|
|
|
+ .displayName(container.getName())
|
|
|
+ .accountId(container.getAccountId())
|
|
|
+ .domainNames(container.getDomainName())
|
|
|
+ .publicId(container.getPublicId())
|
|
|
+ .tagIds(container.getTagIds())
|
|
|
+ .notes(container.getNotes())
|
|
|
+ .usageContext(container.getUsageContext())
|
|
|
+ .fingerprint(container.getFingerprint())
|
|
|
+ .build();
|
|
|
+
|
|
|
+ log.info("getContainer : {}", JsonUtils.toJson(gtmContainer));
|
|
|
+ return gtmContainer;
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ throw new DataException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public GTMContainerDTO createContainer(
|
|
|
String accountResourceName, String displayName, String googleTagId)
|
|
|
throws DataException {
|
|
@@ -142,7 +170,6 @@ public class GTMService {
|
|
|
.containers()
|
|
|
.create(GTMAccountDTO.toResourceName(accountResourceName), container)
|
|
|
.execute();
|
|
|
- log.info("Created container {}", JsonUtils.toJson(createdContainer));
|
|
|
|
|
|
// Converts.
|
|
|
GTMContainerDTO gtmContainer =
|
|
@@ -163,6 +190,10 @@ public class GTMService {
|
|
|
this.initContainerAccess(accountResourceName, gtmContainer.getId());
|
|
|
this.initContainerSetups(gtmContainer.getResourceName(), googleTagId);
|
|
|
|
|
|
+ log.info(
|
|
|
+ "createContainer for {} : {}",
|
|
|
+ accountResourceName,
|
|
|
+ JsonUtils.toJson(gtmContainer));
|
|
|
return gtmContainer;
|
|
|
} catch (IOException e) {
|
|
|
log.error(e.getMessage());
|
|
@@ -170,16 +201,6 @@ public class GTMService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void deleteContainer(String containerResourceName) throws DataException {
|
|
|
- try {
|
|
|
- tagManager.accounts().containers().delete(containerResourceName).execute();
|
|
|
- log.info("Deleted container {}", containerResourceName);
|
|
|
- } catch (IOException e) {
|
|
|
- log.error(e.getMessage());
|
|
|
- throw new DataException(e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void initContainerAccess(String accountResourceName, String containerId)
|
|
|
throws DataException {
|
|
|
try {
|
|
@@ -242,21 +263,24 @@ public class GTMService {
|
|
|
.filter(w -> w.getName().equalsIgnoreCase("Default Workspace"))
|
|
|
.findFirst()
|
|
|
.get();
|
|
|
- log.info(
|
|
|
- "Default workspace for {} : {}",
|
|
|
- containerResourceName,
|
|
|
- JsonUtils.toJson(workspace));
|
|
|
|
|
|
// Converts and returns.
|
|
|
- return GTMWorkspaceDTO.builder()
|
|
|
- .id(workspace.getWorkspaceId())
|
|
|
- .resourceName(workspace.getPath())
|
|
|
- .displayName(workspace.getName())
|
|
|
- .accountId(workspace.getAccountId())
|
|
|
- .containerId(workspace.getContainerId())
|
|
|
- .description(workspace.getDescription())
|
|
|
- .fingerprint(workspace.getFingerprint())
|
|
|
- .build();
|
|
|
+ GTMWorkspaceDTO gtmWorkspace =
|
|
|
+ GTMWorkspaceDTO.builder()
|
|
|
+ .id(workspace.getWorkspaceId())
|
|
|
+ .resourceName(workspace.getPath())
|
|
|
+ .displayName(workspace.getName())
|
|
|
+ .accountId(workspace.getAccountId())
|
|
|
+ .containerId(workspace.getContainerId())
|
|
|
+ .description(workspace.getDescription())
|
|
|
+ .fingerprint(workspace.getFingerprint())
|
|
|
+ .build();
|
|
|
+
|
|
|
+ log.info(
|
|
|
+ "getDefaultWorkspace for {} : {}",
|
|
|
+ containerResourceName,
|
|
|
+ JsonUtils.toJson(gtmWorkspace));
|
|
|
+ return gtmWorkspace;
|
|
|
} catch (IOException e) {
|
|
|
log.error(e.getMessage());
|
|
|
throw new DataException(e);
|
|
@@ -279,20 +303,26 @@ public class GTMService {
|
|
|
.triggers()
|
|
|
.create(workspaceResourceName, trigger)
|
|
|
.execute();
|
|
|
- log.info("Created trigger {}", JsonUtils.toJson(createdTrigger));
|
|
|
|
|
|
// Converts and returns.
|
|
|
- return GTMTriggerDTO.builder()
|
|
|
- .id(createdTrigger.getTriggerId())
|
|
|
- .resourceName(createdTrigger.getPath())
|
|
|
- .displayName(createdTrigger.getName())
|
|
|
- .accountId(createdTrigger.getAccountId())
|
|
|
- .containerId(createdTrigger.getContainerId())
|
|
|
- .workspaceId(createdTrigger.getWorkspaceId())
|
|
|
- .type(createdTrigger.getType())
|
|
|
- .notes(createdTrigger.getNotes())
|
|
|
- .fingerprint(createdTrigger.getFingerprint())
|
|
|
- .build();
|
|
|
+ GTMTriggerDTO gtmTrigger =
|
|
|
+ GTMTriggerDTO.builder()
|
|
|
+ .id(createdTrigger.getTriggerId())
|
|
|
+ .resourceName(createdTrigger.getPath())
|
|
|
+ .displayName(createdTrigger.getName())
|
|
|
+ .accountId(createdTrigger.getAccountId())
|
|
|
+ .containerId(createdTrigger.getContainerId())
|
|
|
+ .workspaceId(createdTrigger.getWorkspaceId())
|
|
|
+ .type(createdTrigger.getType())
|
|
|
+ .notes(createdTrigger.getNotes())
|
|
|
+ .fingerprint(createdTrigger.getFingerprint())
|
|
|
+ .build();
|
|
|
+
|
|
|
+ log.info(
|
|
|
+ "createTrigger for {} : {}",
|
|
|
+ workspaceResourceName,
|
|
|
+ JsonUtils.toJson(gtmTrigger));
|
|
|
+ return gtmTrigger;
|
|
|
} catch (IOException e) {
|
|
|
log.error(e.getMessage());
|
|
|
throw new DataException(e);
|
|
@@ -323,7 +353,7 @@ public class GTMService {
|
|
|
.tags()
|
|
|
.create(workspaceResourceName, tag)
|
|
|
.execute();
|
|
|
- log.info("Created tag {}", JsonUtils.toJson(createdTag));
|
|
|
+ log.info("createGoogleTag {}", JsonUtils.toJson(createdTag));
|
|
|
} catch (IOException e) {
|
|
|
log.error(e.getMessage());
|
|
|
throw new DataException(e);
|
|
@@ -348,19 +378,25 @@ public class GTMService {
|
|
|
.createVersion(workspaceResourceName, versionOptions)
|
|
|
.execute()
|
|
|
.getContainerVersion();
|
|
|
- log.info("Created container version {}", JsonUtils.toJson(createdContainerVersion));
|
|
|
|
|
|
// Converts and returns.
|
|
|
- return GTMVersionDTO.builder()
|
|
|
- .id(createdContainerVersion.getContainerVersionId())
|
|
|
- .resourceName(createdContainerVersion.getPath())
|
|
|
- .displayName(createdContainerVersion.getName())
|
|
|
- .accountId(createdContainerVersion.getAccountId())
|
|
|
- .containerId(createdContainerVersion.getContainerId())
|
|
|
- .deleted(BooleanUtils.isTrue(createdContainerVersion.getDeleted()))
|
|
|
- .description(createdContainerVersion.getDescription())
|
|
|
- .fingerprint(createdContainerVersion.getFingerprint())
|
|
|
- .build();
|
|
|
+ GTMVersionDTO gtmVersion =
|
|
|
+ GTMVersionDTO.builder()
|
|
|
+ .id(createdContainerVersion.getContainerVersionId())
|
|
|
+ .resourceName(createdContainerVersion.getPath())
|
|
|
+ .displayName(createdContainerVersion.getName())
|
|
|
+ .accountId(createdContainerVersion.getAccountId())
|
|
|
+ .containerId(createdContainerVersion.getContainerId())
|
|
|
+ .deleted(BooleanUtils.isTrue(createdContainerVersion.getDeleted()))
|
|
|
+ .description(createdContainerVersion.getDescription())
|
|
|
+ .fingerprint(createdContainerVersion.getFingerprint())
|
|
|
+ .build();
|
|
|
+
|
|
|
+ log.info(
|
|
|
+ "createContainerVersion for {} : {}",
|
|
|
+ workspaceResourceName,
|
|
|
+ JsonUtils.toJson(gtmVersion));
|
|
|
+ return gtmVersion;
|
|
|
} catch (IOException e) {
|
|
|
log.error(e.getMessage());
|
|
|
throw new DataException(e);
|
|
@@ -370,7 +406,17 @@ public class GTMService {
|
|
|
private void publishContainerVersion(String versionResourceName) throws DataException {
|
|
|
try {
|
|
|
tagManager.accounts().containers().versions().publish(versionResourceName).execute();
|
|
|
- log.info("Published container version {}", versionResourceName);
|
|
|
+ log.info("publishContainerVersion {}", versionResourceName);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ throw new DataException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void deleteContainer(String containerResourceName) throws DataException {
|
|
|
+ try {
|
|
|
+ tagManager.accounts().containers().delete(containerResourceName).execute();
|
|
|
+ log.info("deleteContainer {}", containerResourceName);
|
|
|
} catch (IOException e) {
|
|
|
log.error(e.getMessage());
|
|
|
throw new DataException(e);
|