-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
986 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package group | ||
|
||
import ( | ||
"encoding/json" | ||
"log" | ||
"net/http" | ||
|
||
"github.com/aborroy/alfresco-cli/cmd" | ||
"github.com/aborroy/alfresco-cli/httpclient" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const AddGroupCmdId string = "[GROUP ADD]" | ||
|
||
var authorityId string | ||
var authorityType string | ||
var groupAddCmd = &cobra.Command{ | ||
Use: "add", | ||
Short: "Add an authority (person or group) to a Group in repository", | ||
Long: `The authority is added as children of the Group.`, | ||
Run: func(command *cobra.Command, args []string) { | ||
|
||
var groupAdd GroupAdd | ||
groupAdd.ID = authorityId | ||
groupAdd.MemberType = authorityType | ||
jsonGroupAdd, _ := json.Marshal(groupAdd) | ||
|
||
execution := &httpclient.HttpExecution{ | ||
Method: http.MethodPost, | ||
Data: string(jsonGroupAdd), | ||
Format: httpclient.Json, | ||
Url: groupsUrlPath + groupId + "/members", | ||
ResponseBodyOutput: &responseBody, | ||
} | ||
|
||
_error := httpclient.Execute(execution) | ||
if _error != nil { | ||
cmd.ExitWithError(AddGroupCmdId, _error) | ||
} | ||
}, | ||
PostRun: func(command *cobra.Command, args []string) { | ||
log.Println(AddGroupCmdId, "Authority "+authorityId+" ("+authorityType+") has been added to group "+groupId) | ||
}, | ||
} | ||
|
||
func init() { | ||
groupCmd.AddCommand(groupAddCmd) | ||
groupAddCmd.Flags().StringVarP(&groupId, "groupId", "i", "", "ID of the group in Alfresco Repository.") | ||
groupAddCmd.Flags().StringVarP(&authorityId, "authorityId", "a", "", "ID of the authority (group or person) in Alfresco Repository to be added.") | ||
groupAddCmd.Flags().StringVarP(&authorityType, "authorityType", "t", "", "Type of the authority: GROUP or PERSON.") | ||
groupAddCmd.Flags().SortFlags = false | ||
groupAddCmd.MarkFlagRequired("groupId") | ||
groupAddCmd.MarkFlagRequired("authorityId") | ||
groupAddCmd.MarkFlagRequired("authorityType") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package group | ||
|
||
import ( | ||
"encoding/json" | ||
"log" | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/aborroy/alfresco-cli/cmd" | ||
"github.com/aborroy/alfresco-cli/httpclient" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const CreateGroupCmdId string = "[GROUP CREATE]" | ||
|
||
var displayName string | ||
var parentIds []string | ||
var groupCreateCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "Create new Group in ACS Repository", | ||
Long: `Creates a new group in the repository. | ||
The group can be created setting only required properties. | ||
When specifying parentIds, the group is created associated to those parentIds, not as a children of them.`, | ||
Run: func(command *cobra.Command, args []string) { | ||
|
||
var groupCreate GroupUpdate | ||
groupCreate.ID = groupId | ||
groupCreate.DisplayName = displayName | ||
if parentIds != nil { | ||
groupCreate.ParentIds = parentIds | ||
} | ||
jsonGroupCreate, _ := json.Marshal(groupCreate) | ||
|
||
execution := &httpclient.HttpExecution{ | ||
Method: http.MethodPost, | ||
Data: string(jsonGroupCreate), | ||
Format: httpclient.Json, | ||
Url: strings.TrimSuffix(groupsUrlPath, "/"), | ||
ResponseBodyOutput: &responseBody, | ||
} | ||
|
||
_error := httpclient.Execute(execution) | ||
if _error != nil { | ||
cmd.ExitWithError(CreateGroupCmdId, _error) | ||
} | ||
}, | ||
PostRun: func(command *cobra.Command, args []string) { | ||
log.Println(CreateGroupCmdId, "Group "+groupId+" has been created") | ||
}, | ||
} | ||
|
||
func init() { | ||
groupCmd.AddCommand(groupCreateCmd) | ||
groupCreateCmd.Flags().StringVarP(&groupId, "groupId", "i", "", "ID of the group in Alfresco Repository.") | ||
groupCreateCmd.Flags().StringVarP(&displayName, "displayName", "d", "", "Display name of the group in Alfresco Repository.") | ||
groupCreateCmd.Flags().StringArrayVarP(&parentIds, "parentIds", "p", nil, "List containing the IDs of parent groups.") | ||
groupCreateCmd.Flags().SortFlags = false | ||
groupCreateCmd.MarkFlagRequired("groupId") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package group | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
|
||
"github.com/aborroy/alfresco-cli/cmd" | ||
"github.com/aborroy/alfresco-cli/httpclient" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const DeleteGroupCmdId string = "[GROUP DELETE]" | ||
|
||
var groupDeleteCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete a Group existing in the repository", | ||
Long: `Removes an existing group from the repository.`, | ||
Run: func(command *cobra.Command, args []string) { | ||
execution := &httpclient.HttpExecution{ | ||
Method: http.MethodDelete, | ||
Format: httpclient.None, | ||
Url: groupsUrlPath + groupId, | ||
ResponseBodyOutput: &responseBody, | ||
} | ||
_error := httpclient.Execute(execution) | ||
if _error != nil { | ||
cmd.ExitWithError(DeleteGroupCmdId, _error) | ||
} | ||
}, | ||
PostRun: func(command *cobra.Command, args []string) { | ||
log.Println(DeleteGroupCmdId, "Group "+groupId+" has been deleted") | ||
}, | ||
} | ||
|
||
func init() { | ||
groupCmd.AddCommand(groupDeleteCmd) | ||
groupDeleteCmd.Flags().StringVarP(&groupId, "groupId", "i", "", "ID of the group in Alfresco Repository.") | ||
groupDeleteCmd.MarkFlagRequired("groupId") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package group | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
|
||
"github.com/aborroy/alfresco-cli/cmd" | ||
"github.com/aborroy/alfresco-cli/httpclient" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const GetGroupCmdId string = "[GROUP GET]" | ||
|
||
var groupGetCmd = &cobra.Command{ | ||
Use: "get", | ||
Short: "Get Group information from repository", | ||
Long: `Properties of the Group are retrieved. | ||
Properties are provided as output of the command.`, | ||
Run: func(command *cobra.Command, args []string) { | ||
execution := &httpclient.HttpExecution{ | ||
Method: http.MethodGet, | ||
Format: httpclient.None, | ||
Url: groupsUrlPath + groupId, | ||
ResponseBodyOutput: &responseBody, | ||
} | ||
_error := httpclient.Execute(execution) | ||
if _error != nil { | ||
cmd.ExitWithError(GetGroupCmdId, _error) | ||
} | ||
}, | ||
PostRun: func(command *cobra.Command, args []string) { | ||
log.Println(GetGroupCmdId, "Details for group "+groupId+" have been retrieved") | ||
}, | ||
} | ||
|
||
func init() { | ||
groupCmd.AddCommand(groupGetCmd) | ||
groupGetCmd.Flags().StringVarP(&groupId, "groupId", "i", "", "ID of the group in Alfresco Repository.") | ||
groupGetCmd.MarkFlagRequired("groupId") | ||
} |
Oops, something went wrong.