Skip to content
This repository was archived by the owner on Feb 3, 2026. It is now read-only.

Commit 028a544

Browse files
author
Mikhail Yakushin
committed
#58 - Completed.
1 parent 19932bd commit 028a544

28 files changed

+241
-73
lines changed

src/main/java/com/driver733/vkmusicuploader/post/UploadServers.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public final class UploadServers {
4646
/**
4747
* Group ID.
4848
*/
49-
private static final int GROUP_ID = 161929264;
49+
private final int group;
5050

5151
/**
5252
* VKAPIClient that is used for all VK API requests.
@@ -62,10 +62,16 @@ public final class UploadServers {
6262
* Ctor.
6363
* @param client VKAPIClient that is used for all VK API requests.
6464
* @param actor UserActor on behalf of which all requests will be sent.
65+
* @param group Group ID.
6566
*/
66-
public UploadServers(final VkApiClient client, final UserActor actor) {
67+
public UploadServers(
68+
final VkApiClient client,
69+
final UserActor actor,
70+
final int group
71+
) {
6772
this.client = client;
6873
this.actor = actor;
74+
this.group = group;
6975
}
7076

7177
/**
@@ -148,7 +154,7 @@ private String audioUploadUrl() throws ClientException, ApiException {
148154
private String wallDocUploadUrl() throws ClientException, ApiException {
149155
return this.client.docs()
150156
.getWallUploadServer(this.actor)
151-
.groupId(UploadServers.GROUP_ID)
157+
.groupId(this.group)
152158
.execute()
153159
.getUploadUrl();
154160
}
@@ -164,7 +170,7 @@ private String wallDocUploadUrl() throws ClientException, ApiException {
164170
private String wallPhotoUploadUrl() throws ClientException, ApiException {
165171
return this.client.photos()
166172
.getWallUploadServer(this.actor)
167-
.groupId(UploadServers.GROUP_ID)
173+
.groupId(this.group)
168174
.execute()
169175
.getUploadUrl();
170176
}

src/main/java/com/driver733/vkmusicuploader/post/post/PostRootDir.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
@Immutable
4747
public final class PostRootDir implements Post {
4848

49+
/**
50+
* Group ID.
51+
*/
52+
private final int group;
53+
4954
/**
5055
* Root directory that contains directories with albums.
5156
*/
@@ -73,18 +78,21 @@ public final class PostRootDir implements Post {
7378
* @param dir Root directory that contains directories with albums.
7479
* @param servers Upload servers
7580
* that provide upload URLs for attachmentsFields.
81+
* @param group Group ID.
7682
* @checkstyle ParameterNumberCheck (10 lines)
7783
*/
7884
public PostRootDir(
7985
final VkApiClient client,
8086
final UserActor actor,
8187
final File dir,
82-
final UploadServers servers
88+
final UploadServers servers,
89+
final int group
8390
) {
8491
this.client = client;
8592
this.directory = dir;
8693
this.actor = actor;
8794
this.servers = servers;
95+
this.group = group;
8896
}
8997

9098
@Override
@@ -122,7 +130,8 @@ public void post() throws IOException {
122130
this.actor,
123131
dir,
124132
this.servers,
125-
props
133+
props,
134+
this.group
126135
)
127136
).execute();
128137
}

src/main/java/com/driver733/vkmusicuploader/post/posts/PostsBasic.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
@Immutable
4444
public final class PostsBasic implements Posts {
4545

46+
/**
47+
* Group ID.
48+
*/
49+
private final int group;
50+
4651
/**
4752
* {@link VkApiClient} for all requests.
4853
*/
@@ -64,15 +69,19 @@ public final class PostsBasic implements Posts {
6469
* @param actor UserActor on behalf of which all requests will be sent.
6570
* @param servers Upload servers that
6671
* provide upload URLs for attachmentsFields.
72+
* @param group Group ID.
73+
* @checkstyle ParameterNumberCheck (10 lines)
6774
*/
6875
public PostsBasic(
6976
final VkApiClient client,
7077
final UserActor actor,
71-
final UploadServers servers
78+
final UploadServers servers,
79+
final int group
7280
) {
7381
this.client = client;
7482
this.actor = actor;
7583
this.servers = servers;
84+
this.group = group;
7685
}
7786

7887
@Override
@@ -81,7 +90,8 @@ public Post postFromDir(final File dir) {
8190
this.client,
8291
this.actor,
8392
dir,
84-
this.servers
93+
this.servers,
94+
this.group
8595
);
8696
}
8797

src/main/java/com/driver733/vkmusicuploader/wallpost/attachment/AttachmentAddAudio.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import com.vk.api.sdk.client.AbstractQueryBuilder;
2828
import com.vk.api.sdk.client.VkApiClient;
2929
import com.vk.api.sdk.client.actors.UserActor;
30-
import com.vk.api.sdk.exceptions.ApiException;
31-
import com.vk.api.sdk.exceptions.ClientException;
3230
import java.util.Collections;
3331
import java.util.List;
3432

@@ -49,7 +47,7 @@ public final class AttachmentAddAudio implements Attachment {
4947
/**
5048
* Group ID.
5149
*/
52-
private static final int GROUP_ID = 161929264;
50+
private final int group;
5351

5452
/**
5553
* VKAPIClient that is used for all VK API requests.
@@ -79,31 +77,33 @@ public final class AttachmentAddAudio implements Attachment {
7977
* @param ownerId Audio`s owner ID.
8078
* @param mediaId Audio`s media ID.
8179
* @param client VKAPIClient that is used for all VK API requests.
80+
* @param group Group ID.
8281
* @checkstyle ParameterNumberCheck (10 lines)
8382
*/
8483
public AttachmentAddAudio(
8584
final VkApiClient client,
8685
final UserActor actor,
8786
final int ownerId,
88-
final int mediaId
87+
final int mediaId,
88+
final int group
8989
) {
9090
this.actor = actor;
9191
this.ownerId = ownerId;
9292
this.mediaId = mediaId;
9393
this.client = client;
94+
this.group = group;
9495
}
9596

9697
@Override
97-
public List<AbstractQueryBuilder> upload()
98-
throws ClientException, ApiException {
98+
public List<AbstractQueryBuilder> upload() {
9999
return Collections.singletonList(
100100
this.client.audio()
101101
.add(
102102
this.actor,
103103
this.mediaId,
104104
this.ownerId
105105
)
106-
.groupId(AttachmentAddAudio.GROUP_ID)
106+
.groupId(this.group)
107107
);
108108
}
109109

src/main/java/com/driver733/vkmusicuploader/wallpost/attachment/AttachmentAudio.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public final class AttachmentAudio implements Attachment {
5858
/**
5959
* Group ID.
6060
*/
61-
private static final int GROUP_ID = 161929264;
61+
private final int group;
6262

6363
/**
6464
* {@link VkApiClient} that is used for all VK API requests.
@@ -86,6 +86,7 @@ public final class AttachmentAudio implements Attachment {
8686
* that is used for all VK API requests.
8787
* @param actor UserActor on behalf of which all requests will be sent.
8888
* @param audios Audios files.
89+
* @param group Group ID.
8990
* @param properties Properties that contain the
9091
* {@link AudioStatus} of audio files.
9192
* @checkstyle ParameterNumberCheck (10 lines)
@@ -94,11 +95,13 @@ public AttachmentAudio(
9495
final VkApiClient client,
9596
final UserActor actor,
9697
final ImmutableProperties properties,
98+
final int group,
9799
final UploadAudio... audios
98100
) {
99101
this.client = client;
100102
this.actor = actor;
101103
this.properties = properties;
104+
this.group = group;
102105
this.audios = new Array<>(audios);
103106
}
104107

@@ -149,7 +152,7 @@ private List<AbstractQueryBuilder> upload(
149152
this.actor,
150153
audio.getId(),
151154
audio.getOwnerId()
152-
).groupId(AttachmentAudio.GROUP_ID)
155+
).groupId(this.group)
153156
);
154157
}
155158

src/main/java/com/driver733/vkmusicuploader/wallpost/attachment/AttachmentCachedAudio.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
@Immutable
5757
public final class AttachmentCachedAudio implements Attachment {
5858

59+
/**
60+
* Group ID.
61+
*/
62+
private final int group;
63+
5964
/**
6065
* {@link VkApiClient} for all requests.
6166
*/
@@ -88,21 +93,24 @@ public final class AttachmentCachedAudio implements Attachment {
8893
* @param url Audio upload URL for the audio files.
8994
* @param properties Properties that contain the
9095
* {@link AudioStatus} of audio files.
91-
* @param audios Audios files.*
96+
* @param audios Audios files.
97+
* @param group Group ID.
9298
* @checkstyle ParameterNumberCheck (2 lines)
9399
*/
94100
public AttachmentCachedAudio(
95101
final VkApiClient client,
96102
final UserActor actor,
97103
final String url,
98104
final ImmutableProperties properties,
99-
final List<File> audios
105+
final List<File> audios,
106+
final int group
100107
) {
101108
this.client = client;
102109
this.audios = new Array<>(audios);
103110
this.actor = actor;
104111
this.url = url;
105112
this.properties = properties;
113+
this.group = group;
106114
}
107115

108116
@Override
@@ -146,6 +154,7 @@ private List<AbstractQueryBuilder> upload(final File audio)
146154
this.client,
147155
this.actor,
148156
this.properties,
157+
this.group,
149158
new UploadAudio(
150159
this.client, this.url, audio
151160
)
@@ -174,7 +183,8 @@ private List<AbstractQueryBuilder> upload(final File audio)
174183
this.client,
175184
this.actor,
176185
ownerId,
177-
mediaId
186+
mediaId,
187+
this.group
178188
).upload();
179189
} else if (status == 1) {
180190
final String mediaId = value.substring(

src/main/java/com/driver733/vkmusicuploader/wallpost/attachment/AttachmentWallPhoto.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public final class AttachmentWallPhoto implements Attachment {
5353
/**
5454
* Group ID.
5555
*/
56-
private static final int GROUP_ID = 161929264;
56+
private final int group;
5757

5858
/**
5959
* VKAPIClient that is used for all VK API requests.
@@ -75,15 +75,19 @@ public final class AttachmentWallPhoto implements Attachment {
7575
* @param client VKAPIClient that is used for all VK API requests.
7676
* @param actor UserActor on behalf of which all requests will be sent.
7777
* @param photo File that contains a photo. Typically an album toByteArray.
78+
* @param group Group ID.
79+
* @checkstyle ParameterNumberCheck (10 lines)
7880
*/
7981
public AttachmentWallPhoto(
8082
final VkApiClient client,
8183
final UserActor actor,
82-
final UploadWallPhoto photo
84+
final UploadWallPhoto photo,
85+
final int group
8386
) {
8487
this.client = client;
8588
this.actor = actor;
8689
this.photo = photo;
90+
this.group = group;
8791
}
8892

8993
@Override
@@ -96,7 +100,7 @@ public List<AbstractQueryBuilder> upload()
96100
.saveWallPhoto(this.actor, response.getPhoto())
97101
.server(response.getServer())
98102
.hash(response.getHash())
99-
.groupId(AttachmentWallPhoto.GROUP_ID)
103+
.groupId(this.group)
100104
);
101105
return result;
102106
}

src/main/java/com/driver733/vkmusicuploader/wallpost/attachment/support/attachment/fields/AttachmentArrays.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,16 @@
5454
* @version $Id$
5555
* @since 0.1
5656
* @checkstyle ClassDataAbstractionCouplingCheck (20 lines)
57+
* @checkstyle ParameterNumberCheck (10 lines)
5758
*/
5859
@Immutable
5960
public final class AttachmentArrays implements AttachmentsFields {
6061

62+
/**
63+
* Group ID.
64+
*/
65+
private final int group;
66+
6167
/**
6268
* Array of attachmentsFields.
6369
*/
@@ -78,16 +84,20 @@ public final class AttachmentArrays implements AttachmentsFields {
7884
* @param actor UserActor on behalf of which all requests will be sent.
7985
* @param properties Properties that contain the
8086
* {@link AudioStatus} of audio files.
87+
* @param group Group ID.
8188
* @param attachments Attachments.
89+
* @checkstyle ParameterNumberCheck (10 lines)
8290
*/
8391
public AttachmentArrays(
8492
final UserActor actor,
8593
final ImmutableProperties properties,
94+
final int group,
8695
final Attachment... attachments
8796
) {
8897
this.attachments = new Array<>(attachments);
8998
this.actor = actor;
9099
this.properties = properties;
100+
this.group = group;
91101
}
92102

93103
@Override
@@ -118,7 +128,8 @@ public List<String> attachmentsFields()
118128
).save();
119129
try {
120130
return new AttachmentsFromResults(
121-
root.getAsJsonArray()
131+
root.getAsJsonArray(),
132+
this.group
122133
).attachmentStrings();
123134
} catch (final IOException ex) {
124135
throw new IOException(

0 commit comments

Comments
 (0)