Skip to content

Commit

Permalink
refactor: remove v1 code and unused constants
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Hung <chris@iotechsys.com>
  • Loading branch information
Chris Hung committed Mar 17, 2021
1 parent 269686d commit 3a954db
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 146 deletions.
8 changes: 4 additions & 4 deletions internal/application/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (c *CommandProcessor) ReadDeviceResource() (res *dtos.Event, e edgexErr.Edg
lc.Debugf("Application - readDeviceResource: reading deviceResource: %s; %s: %s", c.deviceResource.Name, common.CorrelationHeader, c.correlationID)

// check provided deviceResource is not write-only
if c.deviceResource.Properties.ReadWrite == common.DeviceResourceWriteOnly {
if c.deviceResource.Properties.ReadWrite == v2.ReadWrite_W {
errMsg := fmt.Sprintf("deviceResource %s is marked as write-only", c.deviceResource.Name)
return res, edgexErr.NewCommonEdgeX(edgexErr.KindNotAllowed, errMsg, nil)
}
Expand Down Expand Up @@ -201,7 +201,7 @@ func (c *CommandProcessor) ReadCommand() (res *dtos.Event, e edgexErr.EdgeX) {
}

// check the deviceResource isn't write-only
if dr.Properties.ReadWrite == common.DeviceResourceWriteOnly {
if dr.Properties.ReadWrite == v2.ReadWrite_W {
errMsg := fmt.Sprintf("deviceResource %s in GET command %s is marked as write-only", drName, c.cmd)
return res, edgexErr.NewCommonEdgeX(edgexErr.KindNotAllowed, errMsg, nil)
}
Expand Down Expand Up @@ -239,7 +239,7 @@ func (c *CommandProcessor) WriteDeviceResource() edgexErr.EdgeX {
lc.Debugf("Application - writeDeviceResource: writing deviceResource: %s; %s: %s", c.deviceResource.Name, common.CorrelationHeader, c.correlationID)

// check provided deviceResource is not read-only
if c.deviceResource.Properties.ReadWrite == common.DeviceResourceReadOnly {
if c.deviceResource.Properties.ReadWrite == v2.ReadWrite_R {
errMsg := fmt.Sprintf("deviceResource %s is marked as read-only", c.deviceResource.Name)
return edgexErr.NewCommonEdgeX(edgexErr.KindNotAllowed, errMsg, nil)
}
Expand Down Expand Up @@ -335,7 +335,7 @@ func (c *CommandProcessor) WriteCommand() edgexErr.EdgeX {
}

// check the deviceResource isn't read-only
if dr.Properties.ReadWrite == common.DeviceResourceReadOnly {
if dr.Properties.ReadWrite == v2.ReadWrite_R {
errMsg := fmt.Sprintf("deviceResource %s in SET command %s is marked as read-only", drName, c.cmd)
return edgexErr.NewCommonEdgeX(edgexErr.KindNotAllowed, errMsg, nil)
}
Expand Down
49 changes: 0 additions & 49 deletions internal/common/apperror.go

This file was deleted.

28 changes: 3 additions & 25 deletions internal/common/consts.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -*- mode: Go; indent-tabs-mode: t -*-
//
// Copyright (C) 2017-2018 Canonical Ltd
// Copyright (C) 2018-2020 IOTech Ltd
// Copyright (C) 2018-2021 IOTech Ltd
// Copyright (c) 2019 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
Expand All @@ -16,35 +16,13 @@ import (
const (
EnvInstanceName = "EDGEX_INSTANCE_NAME"

Colon = ":"
HttpScheme = "http://"
HttpProto = "HTTP"

ConfigStemDevice = "edgex/devices/"
ConfigMajorVersion = "1.0/"

APICallbackRoute = clients.ApiCallbackRoute
APIValueDescriptorRoute = clients.ApiValueDescriptorRoute
APIPingRoute = clients.ApiPingRoute
APIVersionRoute = clients.ApiVersionRoute
APIMetricsRoute = clients.ApiMetricsRoute
APIConfigRoute = clients.ApiConfigRoute
APIAllCommandRoute = clients.ApiDeviceRoute + "/all/{command}"
APIIdCommandRoute = clients.ApiDeviceRoute + "/{id}/{command}"
APINameCommandRoute = clients.ApiDeviceRoute + "/name/{name}/{command}"
APIDiscoveryRoute = clients.ApiBase + "/discovery"
APITransformRoute = clients.ApiBase + "/debug/transformData/{transformData}"

APIV2SecretRoute = v2.ApiBase + "/secret"

IdVar string = "id"
NameVar string = "name"
CommandVar string = "command"
GetCmdMethod string = "get"
SetCmdMethod string = "set"

DeviceResourceReadOnly string = "R"
DeviceResourceWriteOnly string = "W"
GetCmdMethod = "get"
SetCmdMethod = "set"

CorrelationHeader = clients.CorrelationHeader
URLRawQuery = "urlRawQuery"
Expand Down
17 changes: 0 additions & 17 deletions internal/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package common

import (
"context"
"sync"
"time"

"github.com/edgexfoundry/go-mod-core-contracts/v2/clients"
Expand All @@ -19,22 +18,6 @@ import (
"github.com/edgexfoundry/go-mod-core-contracts/v2/v2/dtos/requests"
)

var (
previousOrigin int64
originMutex sync.Mutex
)

func GetUniqueOrigin() int64 {
originMutex.Lock()
defer originMutex.Unlock()
now := time.Now().UnixNano()
if now <= previousOrigin {
now = previousOrigin + 1
}
previousOrigin = now
return now
}

func UpdateLastConnected(name string, lc logger.LoggingClient, dc interfaces.DeviceClient) {
t := time.Now().UnixNano() / int64(time.Millisecond)
device := dtos.UpdateDevice{
Expand Down
21 changes: 0 additions & 21 deletions internal/common/utils_test.go

This file was deleted.

30 changes: 0 additions & 30 deletions pkg/models/event.go

This file was deleted.

0 comments on commit 3a954db

Please sign in to comment.